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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    background: #1a1a2e;
    color: #e0e0e0;
}

#app { display: flex; flex-direction: column; height: 100vh; }

/* ── Top bar ── */
#topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: #16213e;
    border-bottom: 1px solid #0f3460;
    height: 52px;
    z-index: 100;
    flex-shrink: 0;
}

#logo { font-weight: 700; font-size: 16px; color: #e94560; min-width: 80px; }

#layer-toggles { display: flex; gap: 8px; flex: 1; }

#search-input {
    max-width: 320px;
    width: 100%;
    padding: 6px 12px;
    background: #0f3460;
    border: 1px solid #e94560;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 13px;
}

#search-input::placeholder { color: #636e72; }

/* ── Main layout ── */
#main { display: flex; flex: 1; overflow: hidden; }

/* ── Filter panel ── */
#filter-panel {
    width: 260px;
    min-width: 260px;
    background: #16213e;
    border-right: 1px solid #0f3460;
    overflow-y: auto;
    padding: 12px;
    flex-shrink: 0;
}

/* ── Map ── */
#map { flex: 1; }

/* ── Detail sidebar ── */
#detail-panel {
    width: 360px;
    min-width: 360px;
    background: #16213e;
    border-left: 1px solid #0f3460;
    overflow-y: auto;
    padding: 16px;
    flex-shrink: 0;
}

/* ── Buttons ── */
button {
    padding: 6px 14px;
    background: #e94560;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
}
button:hover { background: #c73652; }
button.secondary { background: #0f3460; }
button.secondary:hover { background: #1a4a8a; }

/* ── Status badges ── */
.badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    display: inline-block;
}
.badge-announced     { background: #ffd700; color: #000; }
.badge-construction  { background: #ff6b35; color: #fff; }
.badge-operational   { background: #00b894; color: #fff; }
.badge-decommissioned { background: #636e72; color: #fff; }

/* ── Confidence indicator ── */
.confidence-high   { color: #00b894; font-size: 11px; }
.confidence-medium { color: #ffd700; font-size: 11px; }
.confidence-low    { color: #ff6b35; font-size: 11px; }

/* ── Section titles ── */
.section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #636e72;
    margin: 16px 0 6px;
    letter-spacing: 0.5px;
}

/* ── Data rows ── */
.data-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid #0f3460;
    font-size: 13px;
}
.data-row .label { color: #636e72; }
.data-row .value { font-weight: 500; text-align: right; max-width: 55%; }

/* ── Tags ── */
.tag {
    display: inline-block;
    padding: 2px 8px;
    background: #0f3460;
    border-radius: 12px;
    font-size: 11px;
    margin: 2px;
    cursor: default;
}

/* ── Layer toggle chips ── */
.layer-toggle {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    cursor: pointer;
    border: 1px solid #0f3460;
    background: #0f3460;
    color: #e0e0e0;
}
.layer-toggle.active { border-color: #e94560; color: #e94560; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #16213e; }
::-webkit-scrollbar-thumb { background: #0f3460; border-radius: 3px; }

/* ── Responsive / tablet / mobile ── */

/* Tablet portrait: ≤ 1024px
   Strategy: keep everything in the normal flex flow (no absolute overlays)
   so Mapbox's canvas always has correct, stable dimensions.
   Filter panel hides by default; detail/sites panels use narrower widths.
*/
@media (max-width: 1024px) {
    /* Topbar: let it scroll horizontally instead of wrapping / overflowing */
    #topbar {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 8px;
        padding: 8px 10px;
        flex-wrap: nowrap;
    }
    #topbar::-webkit-scrollbar { height: 0; }

    #search-input { max-width: 180px; min-width: 100px; }

    /* Filter panel: hidden by default, re-added to flow via .panel-open */
    #filter-panel {
        display: none;
    }
    #filter-panel.panel-open {
        display: flex;
        flex-direction: column;
        width: 240px;
        min-width: 240px;
    }

    /* Detail sidebar: narrower so the map retains meaningful width */
    #detail-panel {
        width: 300px;
        min-width: 300px;
    }

    /* Sites panel: narrower */
    #sites-panel {
        width: 280px !important;
        min-width: 280px !important;
    }

    /* Chat panel: cap to viewport width */
    #chat-panel {
        width: min(420px, 96vw) !important;
    }
}

/* Mobile: ≤ 640px */
@media (max-width: 640px) {
    #logo { font-size: 14px; min-width: 60px; }
    #search-input { max-width: 130px; font-size: 12px; }

    #filter-panel.panel-open {
        width: 80vw;
        min-width: 0;
    }

    #detail-panel {
        width: 88vw;
        min-width: 0;
    }

    #sites-panel {
        width: 80vw !important;
        min-width: 0 !important;
    }

    #chat-panel {
        width: 100vw !important;
        border-radius: 12px 12px 0 0;
    }
}
