
:root {
    --bg: #061019;
    --panel: rgba(9, 25, 37, .78);
    --panel-strong: rgba(8, 24, 37, .94);
    --line: rgba(137, 211, 255, .16);
    --line-bright: rgba(115, 221, 255, .42);
    --text: #f0f8ff;
    --muted: #87a4b8;
    --cyan: #55dfff;
    --blue: #3b82f6;
    --green: #49e2a7;
    --orange: #ff9f43;
    --red: #ff4f65;
    --purple: #ad78ff;
    --yellow: #ffd166;
    --shadow: 0 25px 70px rgba(0, 0, 0, .34);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at 55% 5%, rgba(38, 125, 171, .18), transparent 35%),
        linear-gradient(145deg, #030a11 0%, #071521 45%, #04101a 100%);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    overflow-x: hidden;
}

body.storm-mode {
    --cyan: #ff715b;
    --blue: #ff3d4f;
    --line-bright: rgba(255, 92, 76, .48);
    background:
        radial-gradient(circle at 55% 5%, rgba(178, 50, 43, .22), transparent 35%),
        linear-gradient(145deg, #110505 0%, #1b0b0b 45%, #0d0708 100%);
}

button, a { font: inherit; }

button { cursor: pointer; }

.ambient {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    opacity: .18;
    pointer-events: none;
    z-index: 0;
}
.ambient-one { width: 340px; height: 340px; background: #1778ff; top: 12%; left: -130px; }
.ambient-two { width: 460px; height: 460px; background: #02d4ff; bottom: -220px; right: -180px; }

.topbar, .region-nav, .dashboard-shell, footer { position: relative; z-index: 2; }

.topbar {
    height: 82px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 0 28px;
    border-bottom: 1px solid var(--line);
    background: rgba(2, 10, 17, .86);
    backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: white;
    text-decoration: none;
}
.brand-mark {
    width: 50px;
    height: 50px;
    border: 1px solid rgba(98, 224, 255, .48);
    border-radius: 50%;
    position: relative;
    display: grid;
    place-items: center;
    background: radial-gradient(circle, rgba(83, 221, 255, .16), transparent 68%);
    box-shadow: inset 0 0 22px rgba(77, 218, 255, .12);
}
.brand-ring {
    position: absolute;
    width: 38px;
    height: 38px;
    border: 2px solid var(--cyan);
    border-left-color: transparent;
    border-radius: 50%;
    animation: rotate 8s linear infinite;
}
.brand-wave { color: var(--cyan); font-size: 25px; transform: rotate(-10deg); }
.brand-copy { display: flex; flex-direction: column; line-height: .88; letter-spacing: .08em; }
.brand-copy strong { font-size: 21px; }
.brand-copy small { font-size: 11px; color: var(--cyan); margin-top: 8px; letter-spacing: .52em; }

.network-status {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--muted);
    font-size: 11px;
    letter-spacing: .12em;
}
.network-status strong { color: #cde3ef; font-weight: 600; }
.status-dot, .alert-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 0 rgba(73, 226, 167, .5);
    animation: pulse 2s infinite;
}

.header-actions { display: flex; gap: 10px; }
.icon-button, .alert-button {
    border: 1px solid var(--line);
    background: rgba(20, 41, 56, .72);
    color: #d9edf7;
    border-radius: 9px;
    height: 40px;
    padding: 0 14px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .12em;
}
.alert-button { display: flex; align-items: center; gap: 11px; border-color: rgba(255, 79, 101, .35); }
.alert-button strong {
    display: grid;
    place-items: center;
    min-width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--red);
    color: white;
}

.region-nav {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 12px 22px;
    border-bottom: 1px solid var(--line);
    background: rgba(5, 16, 25, .74);
    backdrop-filter: blur(18px);
}
.region-nav a {
    color: #7895a8;
    text-decoration: none;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 750;
}
.region-nav a:hover, .region-nav a.active {
    color: white;
    border-color: var(--line-bright);
    background: rgba(58, 156, 204, .12);
}

.dashboard-shell { max-width: 1840px; margin: 0 auto; padding: 24px; }

.mission-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 30px;
    margin-bottom: 20px;
}
.eyebrow, .panel-kicker, .map-label {
    margin: 0 0 8px;
    color: var(--cyan);
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .2em;
}
.mission-header h1 { margin: 0; font-size: clamp(26px, 3vw, 46px); letter-spacing: -.04em; }
.mission-copy { margin: 8px 0 0; color: var(--muted); max-width: 720px; font-size: 13px; }

.threat-card {
    min-width: 270px;
    border: 1px solid rgba(255, 159, 67, .4);
    background: linear-gradient(135deg, rgba(255, 159, 67, .14), rgba(255, 79, 101, .06));
    box-shadow: var(--shadow);
    border-radius: 13px;
    padding: 15px 18px;
}
.threat-card span, .threat-card small { display: block; color: #aabcc8; font-size: 9px; letter-spacing: .16em; }
.threat-card strong { display: block; color: var(--orange); font-size: 24px; margin: 4px 0; }

.command-grid {
    display: grid;
    grid-template-columns: 300px minmax(500px, 1fr) 320px;
    gap: 16px;
    align-items: start;
}

.left-rail, .right-rail { display: grid; gap: 16px; }

.panel, .map-panel, .metric-card {
    border: 1px solid var(--line);
    background: linear-gradient(145deg, rgba(13, 35, 50, .86), rgba(5, 18, 28, .78));
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow);
    border-radius: 14px;
    overflow: hidden;
}

.panel { padding: 17px; }

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 15px;
}
.panel-heading h2, .broadcast-panel h2, .report-panel h2 { margin: 0; font-size: 17px; }
.panel-kicker { margin-bottom: 5px; }

.text-button {
    border: 0;
    background: transparent;
    color: var(--cyan);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .1em;
}
.live-badge {
    color: var(--red);
    font-size: 9px;
    font-weight: 900;
    letter-spacing: .15em;
}
.live-badge::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--red); margin-right: 6px; }

.hazard-filter-list { display: grid; gap: 8px; }
.hazard-filter {
    width: 100%;
    display: grid;
    grid-template-columns: 34px 1fr auto;
    align-items: center;
    gap: 9px;
    border: 1px solid rgba(125, 189, 220, .12);
    border-radius: 9px;
    padding: 9px;
    background: rgba(9, 24, 35, .58);
    color: #d4e9f3;
    text-align: left;
}
.hazard-filter:hover, .hazard-filter.active { border-color: var(--line-bright); background: rgba(39, 121, 163, .13); }
.hazard-filter .filter-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: rgba(255,255,255,.06); }
.hazard-filter strong { font-size: 12px; }
.hazard-filter b { color: var(--cyan); font-size: 11px; }

.incident-panel { max-height: 535px; }
.incident-list { display: grid; gap: 9px; max-height: 465px; overflow: auto; padding-right: 4px; }
.incident-item {
    border: 1px solid rgba(122, 186, 216, .11);
    background: rgba(3, 15, 23, .54);
    border-radius: 10px;
    padding: 11px;
    cursor: pointer;
}
.incident-item:hover { border-color: var(--line-bright); transform: translateY(-1px); }
.incident-topline { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.incident-type { font-size: 9px; letter-spacing: .12em; color: var(--cyan); font-weight: 900; }
.severity-chip { font-size: 8px; letter-spacing: .08em; padding: 3px 6px; border-radius: 999px; }
.severity-chip.critical { background: rgba(255, 79, 101, .16); color: #ff7f8d; }
.severity-chip.warning { background: rgba(255, 159, 67, .16); color: #ffb36a; }
.severity-chip.advisory { background: rgba(85, 223, 255, .13); color: #79e7ff; }
.incident-item h3 { margin: 8px 0 5px; font-size: 13px; }
.incident-item p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }

.map-column { min-width: 0; }
.map-panel { position: relative; }
.map-toolbar {
    min-height: 62px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
}
.map-toolbar strong { display: block; font-size: 16px; }
.map-meta { display: flex; gap: 16px; color: #97adbb; font-size: 10px; }
.map-meta span { display: flex; align-items: center; gap: 5px; }
.meta-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.meta-dot.fire { background: var(--red); }
.meta-dot.flood { background: var(--cyan); }
.meta-dot.severe { background: var(--yellow); }

#map { height: 610px; background: #06131d; z-index: 1; }
.leaflet-control-zoom a { background: #0a1c28 !important; color: white !important; border-color: rgba(255,255,255,.1) !important; }
.leaflet-control-attribution { background: rgba(2,10,17,.75) !important; color: #7894a5 !important; }
.leaflet-control-attribution a { color: var(--cyan) !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
    background: #071a27;
    color: white;
    border: 1px solid rgba(102, 211, 255, .26);
}
.leaflet-popup-content { margin: 12px 14px; }
.popup-title { font-weight: 800; margin-bottom: 5px; }
.popup-meta { color: #8da7b8; font-size: 11px; }
.hazard-marker {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 50% 50% 50% 12%;
    transform: rotate(-45deg);
    border: 2px solid rgba(255,255,255,.85);
    box-shadow: 0 0 0 5px rgba(255,255,255,.08), 0 0 20px currentColor;
}
.hazard-marker span { transform: rotate(45deg); font-size: 16px; }
.hazard-marker.critical { background: var(--red); color: var(--red); }
.hazard-marker.warning { background: var(--orange); color: var(--orange); }
.hazard-marker.advisory { background: var(--blue); color: var(--blue); }
.hazard-marker.fire { border-radius: 50%; }
.hazard-marker.fire span { font-size: 18px; }

.map-scan-line {
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(89, 231, 255, .72), transparent);
    box-shadow: 0 0 12px rgba(89, 231, 255, .5);
    animation: scan 7s linear infinite;
    pointer-events: none;
    z-index: 500;
}
.map-legend {
    position: absolute;
    left: 14px;
    bottom: 13px;
    z-index: 500;
    display: flex;
    gap: 12px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: rgba(3, 14, 21, .82);
    backdrop-filter: blur(10px);
    color: #c0d1db;
    font-size: 9px;
}
.legend-marker { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.legend-marker.critical { background: var(--red); }
.legend-marker.warning { background: var(--orange); }
.legend-marker.advisory { background: var(--blue); }

.metric-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 12px; }
.metric-card { padding: 15px; }
.metric-card span, .metric-card small { display: block; color: var(--muted); font-size: 9px; letter-spacing: .08em; }
.metric-card strong { display: block; margin: 3px 0; font-size: 25px; color: white; }

.warning-list { display: grid; gap: 9px; }
.warning-item {
    padding: 11px;
    border-left: 3px solid var(--orange);
    border-radius: 8px;
    background: rgba(255, 159, 67, .07);
}
.warning-item.critical { border-color: var(--red); background: rgba(255, 79, 101, .08); }
.warning-item h3 { margin: 0 0 4px; font-size: 12px; }
.warning-item p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.45; }

.condition-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.condition-grid div {
    padding: 12px;
    background: rgba(3, 15, 23, .56);
    border: 1px solid rgba(124, 188, 220, .1);
    border-radius: 9px;
}
.condition-grid span, .condition-grid small { display: block; color: var(--muted); font-size: 9px; }
.condition-grid strong { display: block; font-size: 21px; margin: 3px 0; }

.broadcast-panel p, .report-panel p { color: var(--muted); font-size: 11px; line-height: 1.55; }
.broadcast-actions { display: flex; gap: 8px; margin-top: 15px; }
.primary-action, .secondary-action {
    border: 1px solid var(--line-bright);
    border-radius: 9px;
    padding: 10px 13px;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .06em;
}
.primary-action { color: #001018; background: var(--cyan); }
.secondary-action { color: white; background: rgba(255,255,255,.05); }

.lower-grid { display: grid; grid-template-columns: 1fr 370px; gap: 16px; margin-top: 16px; }
.timeline { display: grid; grid-template-columns: repeat(6, 1fr); position: relative; padding-top: 7px; }
.timeline::before { content: ""; position: absolute; top: 20px; left: 6%; right: 6%; height: 1px; background: linear-gradient(90deg, var(--cyan), var(--orange), var(--red)); }
.timeline-step { position: relative; text-align: center; z-index: 1; }
.timeline-step i { width: 13px; height: 13px; border-radius: 50%; background: #102b3b; border: 2px solid var(--cyan); display: inline-block; box-shadow: 0 0 12px rgba(85, 223, 255, .4); }
.timeline-step.active i { background: var(--orange); border-color: var(--orange); }
.timeline-step strong { display: block; font-size: 10px; margin-top: 8px; }
.timeline-step small { color: var(--muted); font-size: 8px; }

.report-panel { display: flex; align-items: center; justify-content: space-between; gap: 22px; }

.incident-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(470px, 94vw);
    z-index: 2000;
    padding: 28px;
    background: rgba(4, 16, 25, .98);
    border-left: 1px solid var(--line-bright);
    box-shadow: -30px 0 80px rgba(0,0,0,.46);
    transform: translateX(104%);
    transition: transform .28s ease;
    overflow-y: auto;
}
.incident-drawer.open { transform: translateX(0); }
.drawer-backdrop { position: fixed; inset: 0; z-index: 1900; background: rgba(0,0,0,.56); opacity: 0; pointer-events: none; transition: opacity .25s; }
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer-close { position: absolute; top: 16px; right: 18px; border: 0; background: transparent; color: white; font-size: 28px; }
.drawer-hero { margin: 25px 0 20px; padding: 17px; border-radius: 12px; background: linear-gradient(135deg, rgba(255,79,101,.15), rgba(85,223,255,.06)); border: 1px solid var(--line); }
.drawer-hero span { color: var(--cyan); font-size: 10px; font-weight: 900; letter-spacing: .15em; }
.drawer-hero h2 { margin: 7px 0; font-size: 29px; }
.drawer-hero p { color: var(--muted); line-height: 1.55; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.detail-grid div { border: 1px solid var(--line); border-radius: 9px; padding: 12px; background: rgba(255,255,255,.025); }
.detail-grid span, .detail-grid small { display: block; color: var(--muted); font-size: 9px; }
.detail-grid strong { display: block; margin: 4px 0; font-size: 16px; }
.drawer-section { margin-top: 20px; }
.drawer-section h3 { font-size: 14px; }
.drawer-section p { color: var(--muted); font-size: 12px; line-height: 1.6; }

footer {
    max-width: 1840px;
    margin: 15px auto 0;
    padding: 22px 24px 35px;
    display: flex;
    justify-content: space-between;
    gap: 20px;
    color: #638095;
    font-size: 10px;
    letter-spacing: .08em;
}
footer p { margin: 0; }

@keyframes rotate { to { transform: rotate(360deg); } }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes scan { 0% { transform: translateY(0); opacity: 0; } 10% { opacity: 1; } 90% { opacity: 1; } 100% { transform: translateY(600px); opacity: 0; } }

@media (max-width: 1350px) {
    .command-grid { grid-template-columns: 270px 1fr; }
    .right-rail { grid-column: 1 / -1; grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 980px) {
    .topbar { height: auto; min-height: 76px; flex-wrap: wrap; padding: 12px 18px; }
    .network-status { order: 3; width: 100%; justify-content: center; }
    .region-nav { justify-content: flex-start; overflow-x: auto; }
    .mission-header { align-items: stretch; flex-direction: column; }
    .command-grid { grid-template-columns: 1fr; }
    .left-rail { grid-template-columns: 1fr 1fr; }
    .right-rail { grid-column: auto; grid-template-columns: 1fr; }
    .metric-strip { grid-template-columns: 1fr 1fr; }
    .lower-grid { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
    .dashboard-shell { padding: 14px; }
    .header-actions { display: none; }
    .left-rail { grid-template-columns: 1fr; }
    #map { height: 510px; }
    .map-toolbar { align-items: flex-start; flex-direction: column; }
    .map-meta { flex-wrap: wrap; }
    .metric-strip { grid-template-columns: 1fr 1fr; }
    .timeline { grid-template-columns: repeat(3, 1fr); gap: 20px 0; }
    .timeline::before { display: none; }
    .report-panel { flex-direction: column; align-items: flex-start; }
    footer { flex-direction: column; }
}

.source-status-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin: -4px 0 16px;
    padding: 10px 13px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: rgba(5, 18, 28, .72);
    backdrop-filter: blur(16px);
}
.source-status-heading { display: flex; align-items: center; gap: 14px; }
.source-status-heading span { color: var(--muted); font-size: 9px; font-weight: 900; letter-spacing: .15em; }
.source-status-heading a { color: var(--cyan); font-size: 9px; text-decoration: none; }
.source-status-list { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.source-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 9px; border-radius: 999px;
    border: 1px solid var(--line); color: #bdd0dc;
    background: rgba(255,255,255,.03); font-size: 8px; font-weight: 900; letter-spacing: .08em;
}
.source-chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.source-chip.online { border-color: rgba(73,226,167,.35); color: #9cf2cf; }
.source-chip.online::before { background: var(--green); box-shadow: 0 0 10px rgba(73,226,167,.7); }
.source-chip.error { border-color: rgba(255,79,101,.4); color: #ff9aa5; }
.source-chip.error::before { background: var(--red); }
.source-chip.needs_key { border-color: rgba(255,209,102,.4); color: var(--yellow); }
.source-chip.needs_key::before { background: var(--yellow); }
.source-chip.checking::before { background: var(--cyan); animation: pulse 1.5s infinite; }
@media (max-width: 760px) {
    .source-status-panel { align-items: flex-start; flex-direction: column; }
    .source-status-list { justify-content: flex-start; }
}
