* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: flex;
    height: 100vh;
    overflow: hidden;
    background: #f8fafc;
}

/* ── Sidebar ─────────────────────────────────────────── */
#sidebar {
    width: 320px;
    min-width: 320px;
    background: #fff;
    box-shadow: 2px 0 12px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 1000;
}

#map { flex: 1; }

/* ── Header ──────────────────────────────────────────── */
.sidebar-header {
    padding: 18px 20px;
    background: linear-gradient(135deg, #1e40af, #2563eb);
    color: white;
    flex-shrink: 0;
}

.sidebar-header h1 {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.sidebar-header p {
    font-size: 12px;
    opacity: 0.75;
    margin-top: 3px;
}

/* ── Sections ────────────────────────────────────────── */
.section {
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
}

.section-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    margin-bottom: 10px;
}

label {
    display: block;
    font-size: 13px;
    color: #374151;
    margin-bottom: 5px;
    font-weight: 500;
}

input[type="text"],
input[type="number"],
input[type="password"] {
    width: 100%;
    padding: 8px 11px;
    border: 1.5px solid #e2e8f0;
    border-radius: 7px;
    font-size: 13px;
    color: #1f2937;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: #fafafa;
}

input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
    background: #fff;
}

.input-row {
    display: flex;
    gap: 6px;
}

.input-row input { flex: 1; }

/* ── Icon buttons ────────────────────────────────────── */
.btn {
    cursor: pointer;
    border: none;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.btn-ghost {
    background: #f1f5f9;
    color: #64748b;
    padding: 8px 10px;
}

.btn-ghost:hover { background: #e2e8f0; color: #1e40af; }

.btn-primary {
    background: #1e40af;
    color: white;
    padding: 10px 16px;
    width: 100%;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
}

.btn-primary:hover:not(:disabled) { background: #1e3a8a; }

.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Transport mode ──────────────────────────────────── */
.mode-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
}

.mode-btn {
    padding: 9px 4px 7px;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    color: #64748b;
    font-size: 11px;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1.3;
}

.mode-btn:hover { border-color: #3b82f6; color: #1e40af; background: #eff6ff; }

.mode-btn.active {
    border-color: #1e40af;
    background: #eff6ff;
    color: #1e40af;
    box-shadow: 0 0 0 1px #1e40af;
}

.mode-icon { font-size: 18px; display: block; margin-bottom: 2px; }

/* ── Time input ──────────────────────────────────────── */
.time-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.time-row input { width: 80px; flex: none; }

.time-unit { font-size: 13px; color: #64748b; }

/* ── Unit toggle ─────────────────────────────────────── */
.unit-toggle {
    display: flex;
    border: 1.5px solid #e2e8f0;
    border-radius: 7px;
    overflow: hidden;
    flex-shrink: 0;
}

.unit-btn {
    padding: 8px 10px;
    background: #fafafa;
    color: #64748b;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
    line-height: 1;
}

.unit-btn + .unit-btn { border-left: 1.5px solid #e2e8f0; }

.unit-btn:hover  { background: #f1f5f9; color: #1e40af; }
.unit-btn.active { background: #eff6ff; color: #1e40af; }

/* ── Toggle ──────────────────────────────────────────── */
.toggle-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    cursor: pointer;
    user-select: none;
}

.toggle-row span { font-size: 13px; color: #374151; }

.toggle {
    width: 34px;
    height: 18px;
    background: #d1d5db;
    border-radius: 9px;
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}

.toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    transition: left 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle.on { background: #1e40af; }
.toggle.on::after { left: 18px; }

.sub-settings {
    margin-top: 10px;
    padding: 10px 12px;
    background: #f8fafc;
    border-radius: 7px;
    display: none;
}

.sub-settings.visible { display: block; }
.sub-settings label { font-size: 12px; color: #64748b; margin-bottom: 5px; }

/* ── Location indicator ──────────────────────────────── */
.location-badge {
    display: none;
    margin-top: 8px;
    padding: 6px 10px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    font-size: 12px;
    color: #166534;
}

.location-badge.visible { display: block; }

/* ── Search results ──────────────────────────────────── */
.search-dropdown {
    margin-top: 4px;
    background: white;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
    overflow: hidden;
    display: none;
}

.search-dropdown.visible { display: block; }

.search-result {
    padding: 9px 12px;
    font-size: 12px;
    color: #374151;
    cursor: pointer;
    border-bottom: 1px solid #f8fafc;
    line-height: 1.4;
}

.search-result:last-child { border-bottom: none; }
.search-result:hover { background: #f0f9ff; color: #1e40af; }

/* ── Status messages ─────────────────────────────────── */
.status {
    margin-top: 8px;
    padding: 8px 11px;
    border-radius: 7px;
    font-size: 12px;
    display: none;
}

.status.visible { display: block; }
.status.error   { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.status.loading { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.status.success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* ── Legend ──────────────────────────────────────────── */
.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
}

.legend-swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,0.1);
}

.legend-label { font-size: 12.5px; color: #374151; }
.legend-sub   { font-size: 11px; color: #94a3b8; margin-left: 2px; }

/* ── Footer ──────────────────────────────────────────── */
.sidebar-footer {
    padding: 12px 20px;
    text-align: center;
    margin-top: auto;
    border-top: 1px solid #f1f5f9;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.footer-credits {
    font-size: 10.5px;
    color: #cbd5e1;
}

/* ── Donate button ───────────────────────────────────── */
.donate-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 16px;
    background: #003087;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    border-radius: 20px;
    text-decoration: none;
    transition: background 0.15s, transform 0.1s;
    letter-spacing: 0.01em;
}

.donate-btn:hover  { background: #001f5e; transform: translateY(-1px); }
.donate-btn:active { transform: translateY(0); }

.hint {
    font-size: 11.5px;
    color: #94a3b8;
    margin-top: 5px;
    line-height: 1.4;
}

.hint a { color: #3b82f6; text-decoration: none; }
.hint a:hover { text-decoration: underline; }

/* ── Spinner ─────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
    display: inline-block;
    width: 13px;
    height: 13px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 600px) {
    body { flex-direction: column; }
    #sidebar { width: 100%; min-width: 0; height: auto; max-height: 50vh; }
    #map { flex: 1; }
}
