/* ═══════════════════════════════════════════════════════
   ASTraM Command Center — Bengaluru Traffic Police
   Design System & Tactical Themes
   ═══════════════════════════════════════════════════════ */

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

/* Colour, type, space and layout tokens live in tokens.css. */
html {
    scroll-behavior: smooth;
    height: 100%;
}

body {
    font-family: var(--font-sans);
    background: var(--ground);
    color: var(--text-hi);
    line-height: 1.5;
    overflow: hidden;
    height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* ── Noise Overlay ── */
.noise-overlay {
    position: fixed;
    inset: 0;
    z-index: 9998;
    pointer-events: none;
    opacity: 0.03;
    filter: url(#noiseFilter);
    width: 100%;
    height: 100%;
}

/* ══════════════════════════════════════
   TOP NAV BAR
   ══════════════════════════════════════ */
.top-nav {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: var(--nav-h);
    background: var(--surface-1);
    border-bottom: 1px solid var(--border);
    transition: background-color 0.2s ease;
}

.nav-left, .nav-center, .nav-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-logo { display: flex; align-items: center; gap: 8px; }

.logo-mark {
    width: 32px; height: 28px;
    background: var(--accent);
    border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px;
    font-weight: 800;
    color: var(--ground);
    font-family: var(--font-mono);
    letter-spacing: 0.5px;
}

.logo-text { display: flex; flex-direction: column; }

.logo-title {
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 1.2px;
    color: var(--text-hi);
}

.logo-subtitle {
    font-size: 9px;
    color: var(--text-mid);
    letter-spacing: 0.5px;
    font-family: var(--font-mono);
    text-transform: uppercase;
}

/* ── Theme Switcher Toggle Button ── */
.theme-toggle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-lo);
    font-size: 10px;
    font-weight: 600;
    font-family: var(--font-mono);
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
    border-color: var(--accent-dim);
    color: var(--accent);
    transform: translateY(-1px);
}

.theme-icon { font-size: 12px; }

/* ── Alert Level Indicator ── */
.alert-level {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    font-family: var(--font-mono);
    letter-spacing: 0.5px;
    background: color-mix(in srgb, var(--sev-low) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--sev-low) 20%, transparent);
    color: var(--sev-low);
    transition: all 0.4s ease;
}

.alert-level.red {
    background: color-mix(in srgb, var(--sev-critical) 12%, transparent);
    border-color: color-mix(in srgb, var(--sev-critical) 30%, transparent);
    color: var(--sev-critical);
    animation: alertPulse 2s ease-in-out infinite;
}

.alert-level.amber {
    background: color-mix(in srgb, var(--sev-high) 12%, transparent);
    border-color: color-mix(in srgb, var(--sev-high) 30%, transparent);
    color: var(--sev-high);
}

.alert-level.green {
    background: color-mix(in srgb, var(--sev-low) 12%, transparent);
    border-color: color-mix(in srgb, var(--sev-low) 20%, transparent);
    color: var(--sev-low);
}

@keyframes alertPulse {
    0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--sev-critical) 30%, transparent); }
    50% { box-shadow: 0 0 12px 2px color-mix(in srgb, var(--sev-critical) 20%, transparent); }
}

.alert-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    animation: blink 2s infinite;
}

.alert-dot.green { background: var(--sev-low); }
.alert-dot.amber { background: var(--sev-high); }
.alert-dot.red { background: var(--sev-critical); }

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.alert-text {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* ── Clock ── */
.nav-clock {
    display: flex; align-items: center; gap: 5px;
    padding: 3px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 3px;
}

.clock-time {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
}

.clock-label {
    font-size: 8px;
    color: var(--text-mid);
    font-weight: 600;
    font-family: var(--font-mono);
}

.nav-countdown {
    display: flex; align-items: center; gap: 5px;
    padding: 3px 10px;
    background: color-mix(in srgb, var(--sev-high) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--sev-high) 20%, transparent);
    border-radius: 3px;
}

.countdown-text {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    color: var(--sev-high);
}

.nav-icon-btn {
    position: relative;
    display: flex; align-items: center; justify-content: center;
    width: 30px; height: 30px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-lo);
    cursor: pointer;
    transition: all 0.15s ease;
}

.nav-icon-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.history-count {
    position: absolute;
    top: -4px; right: -4px;
    min-width: 14px; height: 14px;
    background: var(--accent);
    border-radius: 7px;
    font-size: 8px;
    font-weight: 700;
    color: var(--ground);
    display: flex; align-items: center; justify-content: center;
    padding: 0 3px;
    font-family: var(--font-mono);
}

.nav-shortcuts { display: flex; gap: 3px; }

.nav-shortcuts kbd {
    display: flex; align-items: center; justify-content: center;
    width: 20px; height: 20px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 3px;
    font-size: 9px;
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-mid);
}

/* ══════════════════════════════════════
   COMMAND CENTER
   ══════════════════════════════════════ */
.command-center {
    display: grid;
    grid-template-columns: var(--left-w) 1fr;
    height: calc(100vh - var(--nav-h) - var(--ticker-h));
    margin-top: var(--nav-h);
    overflow: hidden;
}

/* ══════════════════════════════════════
   LEFT PANEL
   ══════════════════════════════════════ */
.left-panel {
    background: var(--surface-1);
    border-right: 1px solid var(--border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.left-panel-inner {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.left-panel-inner::-webkit-scrollbar { width: 4px; }
.left-panel-inner::-webkit-scrollbar-track { background: transparent; }
.left-panel-inner::-webkit-scrollbar-thumb {
    background: var(--surface-2);
    border-radius: 2px;
}

.panel-section {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.panel-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 6px;
}

.panel-section-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-lo);
}

.panel-section-title svg { color: var(--accent); flex-shrink: 0; }

.config-form { display: flex; flex-direction: column; gap: 10px; }
.config-field { display: flex; flex-direction: column; gap: 4px; }
.config-field.half { flex: 1; }
.config-row { display: flex; gap: 8px; }

.config-field label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-mid);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-family: var(--font-mono);
}

.config-field .optional {
    text-transform: none; font-weight: 400; color: var(--text-mid); opacity: 0.7;
}

.config-field select,
.config-field input {
    padding: 8px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-hi);
    font-size: 12px;
    font-family: var(--font-sans);
    transition: border-color 0.15s ease;
    outline: none;
    width: 100%;
}

.config-field select:focus,
.config-field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
}

.predict-btn {
    position: relative;
    width: 100%;
    padding: 10px 16px;
    background: var(--accent);
    color: var(--ground);
    border: none;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 700;
    font-family: var(--font-sans);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    letter-spacing: 0.3px;
    text-transform: uppercase;
    overflow: hidden;
    margin-top: 4px;
}

.predict-btn:hover {
    background: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(196, 162, 101, 0.25);
}

.stats-section { animation: slideDown 0.4s ease-out; }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); max-height: 0; }
    to { opacity: 1; transform: translateY(0); max-height: 500px; }
}

.event-badge {
    padding: 2px 8px;
    background: var(--accent-dim);
    border: 1px solid var(--accent-dim);
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

.stats-grid { display: flex; flex-direction: column; gap: 6px; }

.stat-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px;
    background: var(--surface-2);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    transition: border-color 0.2s ease;
}

.stat-item.alert-stat { border-left: 2px solid var(--sev-low); }
.stat-item.savings-stat { border-left: 2px solid var(--accent); }
.stat-icon { font-size: 16px; flex-shrink: 0; }
.stat-data { display: flex; flex-direction: column; }

.stat-value {
    font-family: var(--font-mono);
    font-size: 16px; font-weight: 700;
    color: var(--text-hi); line-height: 1.2;
}

.stat-label {
    font-size: 9px; color: var(--text-mid);
    text-transform: uppercase; letter-spacing: 0.3px;
    font-family: var(--font-mono);
}

.zone-section { animation: slideDown 0.4s ease-out 0.2s both; }
.zone-list { display: flex; flex-direction: column; gap: 4px; }

.zone-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 10px;
    background: var(--surface-2);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.15s ease;
}

.zone-item:hover {
    border-color: var(--accent-dim);
    background: var(--surface-2);
}

.zone-name {
    font-family: var(--font-sans);
    font-size: 11px; font-weight: 600; color: var(--text-hi);
}

.zone-badges { display: flex; gap: 4px; }

.zone-badge {
    padding: 1px 6px; border-radius: 3px;
    font-size: 9px; font-weight: 700; font-family: var(--font-mono);
}

.zone-badge.critical { background: color-mix(in srgb, var(--sev-critical) 12%, transparent); color: var(--sev-critical); }
.zone-badge.high { background: color-mix(in srgb, var(--sev-high) 12%, transparent); color: var(--sev-high); }
.zone-badge.moderate { background: var(--accent-dim); color: var(--accent); }
.zone-badge.low { background: color-mix(in srgb, var(--sev-low) 12%, transparent); color: var(--sev-low); }

.panel-footer {
    margin-top: auto; padding: 10px 16px;
    border-top: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 4px;
}

.panel-footer-row { display: flex; align-items: center; justify-content: space-between; }
.footer-label { font-size: 9px; color: var(--text-mid); font-family: var(--font-mono); }

.system-status {
    display: flex; align-items: center; gap: 5px;
    font-size: 9px; color: var(--sev-low);
    font-family: var(--font-mono); font-weight: 600;
}

.status-dot {
    width: 5px; height: 5px; background: var(--sev-low);
    border-radius: 50%; animation: blink 2.5s infinite;
}

/* ══════════════════════════════════════
   MAIN VIEWPORT & SCROLLING FIX
   ══════════════════════════════════════ */
.main-viewport {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    position: relative;
    background: var(--ground);
}

.view-switcher {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: var(--surface-1);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    height: 40px;
    z-index: 10;
}

.view-btn {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 14px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-mid);
    font-size: 11px; font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer; transition: all 0.2s ease;
    text-transform: uppercase; letter-spacing: 0.4px;
}

.view-btn:hover { color: var(--text-lo); background: var(--surface-2); }

.view-btn.active {
    color: var(--accent);
    background: var(--accent-dim);
    border-color: var(--accent-dim);
}

.view-btn-3d.active {
    color: var(--sev-low);
    background: color-mix(in srgb, var(--sev-low) 15%, transparent);
    border-color: color-mix(in srgb, var(--sev-low) 35%, transparent);
}

.btn-beta-tag {
    font-size: 8px;
    font-weight: 800;
    padding: 1px 5px;
    background: color-mix(in srgb, var(--sev-high) 20%, transparent);
    border: 1px solid color-mix(in srgb, var(--sev-high) 40%, transparent);
    color: var(--sev-high);
    border-radius: 3px;
    letter-spacing: 0.5px;
    font-family: var(--font-mono);
}

.view-btn kbd {
    display: inline-flex; align-items: center; justify-content: center;
    width: 16px; height: 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 3px; font-size: 8px;
    font-family: var(--font-mono); font-weight: 600;
    color: var(--text-mid);
}

.view-container {
    flex: 1;
    overflow: hidden;
    position: relative;
    height: calc(100% - 40px);
}

/* ── VIEW PANELS ── */
.view-panel {
    display: none;
    position: absolute;
    top: 0; bottom: 0; left: 0; right: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    overflow: hidden;
}

.view-panel.active {
    display: block;
    opacity: 1;
    animation: viewFade 0.2s ease-out;
}

@keyframes viewFade { from { opacity: 0; } to { opacity: 1; } }

.view-scroll-body {
    position: absolute;
    top: 0; bottom: 0; left: 0; right: 0;
    width: 100%;
    height: 100%;
    overflow-y: scroll !important;
    overflow-x: hidden;
    padding: 16px;
    padding-bottom: 50px;
    -webkit-overflow-scrolling: touch;
}

.view-scroll-body::-webkit-scrollbar { width: 6px; }
.view-scroll-body::-webkit-scrollbar-track { background: transparent; }
.view-scroll-body::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 3px; }

/* ══════════════════════════════════════
   MAP VIEW (2D Leaflet)
   ══════════════════════════════════════ */
#mapView {
    display: none;
}
#mapView.active {
    display: flex;
    flex-direction: column;
}

.map-welcome {
    flex: 1; display: flex; align-items: center; justify-content: center;
    padding: 40px;
}

.welcome-content { text-align: center; max-width: 480px; }

.welcome-icon {
    display: flex; align-items: center; justify-content: center;
    width: 80px; height: 80px; margin: 0 auto 24px;
    background: var(--surface-2); border-radius: 50%;
    border: 1px solid var(--border); color: var(--accent);
    animation: floatIcon 4s ease-in-out infinite;
}

@keyframes floatIcon {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.welcome-content h2 {
    font-family: var(--font-sans); font-size: 22px; font-weight: 800;
    color: var(--text-hi); margin-bottom: 8px; letter-spacing: -0.02em;
}

.welcome-content p { font-size: 13px; color: var(--text-lo); line-height: 1.7; margin-bottom: 28px; }

.welcome-stats {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 1px; background: var(--border);
    border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden;
}

.ws-item { padding: 14px 8px; background: var(--surface-2); text-align: center; }
.ws-val { display: block; font-size: 20px; font-weight: 700; color: var(--accent); font-family: var(--font-mono); }
.ws-lab { display: block; font-size: 9px; color: var(--text-mid); text-transform: uppercase; font-family: var(--font-mono); margin-top: 2px; }

.map-wrapper { position: relative; flex: 1; display: flex; width: 100%; height: 100%; }
.map-container { flex: 1; width: 100%; height: 100%; min-height: 300px; }

.map-overlay {
    position: absolute; z-index: 800;
    background: color-mix(in srgb, var(--surface-1) 88%, transparent);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 10px 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

.map-legend-overlay { bottom: 16px; left: 16px; }
.overlay-title { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-mid); margin-bottom: 8px; font-family: var(--font-mono); }
.legend-items { display: flex; flex-direction: column; gap: 5px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 10px; color: var(--text-lo); font-family: var(--font-mono); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.legend-dot.critical { background: var(--sev-critical); animation: criticalBlink 1.5s infinite; }
.legend-dot.high { background: var(--sev-high); animation: highPulse 2s infinite; }
.legend-dot.moderate { background: var(--sev-moderate); }
.legend-dot.low { background: var(--sev-low); }
.legend-dot.venue { background: var(--accent); border: 2px solid var(--text-hi); }

@keyframes criticalBlink {
    0%, 100% { opacity: 1; box-shadow: 0 0 6px color-mix(in srgb, var(--sev-critical) 35%, transparent); }
    50% { opacity: 0.3; box-shadow: 0 0 0 transparent; }
}

@keyframes highPulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 4px color-mix(in srgb, var(--sev-high) 25%, transparent); }
    50% { opacity: 0.6; box-shadow: 0 0 8px color-mix(in srgb, var(--sev-high) 25%, transparent); }
}

.map-filters-overlay { top: 16px; left: 16px; display: flex; gap: 4px; padding: 6px 8px; }

.filter-chip {
    padding: 4px 10px; background: var(--surface-2);
    border: 1px solid var(--border); border-radius: 20px;
    font-size: 10px; font-weight: 600; font-family: var(--font-mono);
    color: var(--text-lo); cursor: pointer; transition: all 0.15s ease;
}

.filter-chip.active { background: var(--accent-dim); border-color: var(--accent-dim); color: var(--accent); }

.spotlight-panel {
    top: 16px; right: 16px; width: 260px; padding: 14px;
    animation: spotlightIn 0.3s ease-out;
}

@keyframes spotlightIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

.spotlight-close {
    position: absolute; top: 8px; right: 8px;
    width: 22px; height: 22px; background: var(--surface-2);
    border: 1px solid var(--border); border-radius: 4px;
    color: var(--text-lo); cursor: pointer; font-size: 10px;
    display: flex; align-items: center; justify-content: center;
}

.spotlight-name { font-family: var(--font-sans); font-size: 14px; font-weight: 700; color: var(--text-hi); margin-bottom: 4px; }
.spotlight-zone { font-size: 10px; color: var(--text-mid); font-family: var(--font-mono); margin-bottom: 10px; }
.spotlight-severity { display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: 10px; font-weight: 700; font-family: var(--font-mono); margin-bottom: 10px; }

.custom-div-icon { background: transparent !important; border: none !important; box-shadow: none !important; }

/* ══════════════════════════════════════
   ANALYTICS VIEW
   ══════════════════════════════════════ */
.analytics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-content: start;
}

.analytics-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.analytics-card.full-width { grid-column: 1 / -1; }

.acard-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; border-bottom: 1px solid var(--border);
    flex-wrap: wrap; gap: 8px;
}

.acard-header h3 { font-family: var(--font-sans); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-lo); }
.acard-sub { font-size: 10px; color: var(--text-mid); font-family: var(--font-mono); }

/* ── JUNCTION STATUS MATRIX ── */
.junction-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px;
}

.junction-cell {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    flex-shrink: 0;
}

.junction-cell:hover {
    transform: scale(1.4);
    box-shadow: 0 4px 12px rgba(0,0,0,0.6);
}

.junction-cell.sev-critical { background: var(--sev-critical); animation: criticalBlink 1.5s infinite; }
.junction-cell.sev-high { background: var(--sev-high); animation: highPulse 2.5s infinite; }
.junction-cell.sev-moderate { background: var(--sev-moderate); }
.junction-cell.sev-low { background: var(--sev-low); }

.seasonality-banner {
    margin-bottom: 12px;
    padding: 10px 14px;
    background: color-mix(in srgb, var(--sev-high) 8%, transparent);
    border: 1px dashed color-mix(in srgb, var(--sev-high) 40%, transparent);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.seasonality-note {
    font-size: 11px;
    font-weight: 500;
    color: var(--sev-high);
    line-height: 1.4;
    font-family: var(--font-mono, monospace);
}

.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--border); }
.summary-card { padding: 14px 16px; background: var(--surface-1); display: flex; flex-direction: column; gap: 2px; position: relative; }
.summary-card .card-accent { position: absolute; top: 0; left: 0; width: 3px; height: 100%; }
.summary-card.blue .card-accent { background: var(--accent); }
.summary-card.red .card-accent { background: var(--sev-critical); }
.summary-card.green .card-accent { background: var(--sev-low); }
.summary-card.yellow .card-accent { background: var(--sev-high); }
.summary-card.purple .card-accent { background: var(--sev-moderate); }
.summary-card.cyan .card-accent { background: var(--sev-low); }

.summary-card .card-value { font-size: 20px; font-weight: 700; font-family: var(--font-mono); color: var(--text-hi); }
.summary-card .card-label { font-size: 9px; color: var(--text-mid); text-transform: uppercase; font-family: var(--font-mono); }
.summary-card .card-sub { font-size: 10px; color: var(--text-lo); }

.timeline-chart { display: flex; align-items: flex-end; gap: 3px; padding: 20px 16px; min-height: 200px; overflow-x: auto; }
.timeline-bar-group { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; min-width: 32px; }
.timeline-bar { width: 100%; max-width: 24px; border-radius: 3px 3px 1px 1px; min-height: 3px; cursor: pointer; transition: opacity 0.15s ease, transform 0.15s ease; }
.timeline-bar-label { font-size: 9px; color: var(--text-mid); font-family: var(--font-mono); font-weight: 500; }
.timeline-bar-phase { font-size: 7px; color: var(--text-mid); text-align: center; max-width: 44px; font-family: var(--font-mono); }

.table-controls { display: flex; align-items: center; gap: 10px; }
.filter-group { display: flex; align-items: center; gap: 5px; }
.filter-group label { font-size: 10px; font-weight: 600; color: var(--text-mid); text-transform: uppercase; font-family: var(--font-mono); }
.filter-group select { padding: 4px 8px; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-md); color: var(--text-hi); font-size: 10px; font-family: var(--font-mono); outline: none; cursor: pointer; }

.table-wrapper { overflow-x: auto; }
.impact-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.impact-table thead th { padding: 10px 12px; background: var(--surface-1); color: var(--text-mid); font-weight: 600; text-transform: uppercase; font-size: 9px; font-family: var(--font-mono); text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; }
.impact-table thead th.sortable { cursor: pointer; user-select: none; }
.impact-table tbody td { padding: 8px 12px; border-bottom: 1px solid var(--border); color: var(--text-hi); white-space: nowrap; font-family: var(--font-sans); font-size: 11px; }

.severity-badge { display: inline-block; padding: 2px 7px; border-radius: 3px; font-size: 9px; font-weight: 700; font-family: var(--font-mono); }
.severity-badge.CRITICAL { background: var(--sev-critical); color: white; animation: criticalBlink 1.5s infinite; }
.severity-badge.HIGH { background: var(--sev-high); color: var(--ground); }
.severity-badge.MODERATE { background: var(--sev-moderate); color: var(--ground); }
.severity-badge.LOW { background: var(--sev-low); color: white; }

.table-footer { padding: 8px 12px; font-size: 10px; color: var(--text-mid); font-family: var(--font-mono); text-align: center; }

.economics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 16px; }
.economics-card { padding: 16px; border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface-1); }
.economics-card.without { border-left: 3px solid var(--sev-critical); }
.economics-card.with { border-left: 3px solid var(--sev-low); }
.economics-card h3 { font-family: var(--font-sans); font-size: 12px; font-weight: 700; margin-bottom: 12px; }
.economics-card.without h3 { color: var(--sev-critical); }
.economics-card.with h3 { color: var(--sev-low); }
.econ-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); }
.econ-label { font-size: 11px; color: var(--text-lo); }
.econ-value { font-size: 12px; font-weight: 600; font-family: var(--font-mono); color: var(--text-hi); }
.econ-total { font-size: 16px; font-weight: 700; }

.savings-banner { grid-column: 1 / -1; padding: 20px; background: var(--accent-dim); border: 1px solid var(--accent-dim); border-radius: var(--radius-lg); text-align: center; }
.savings-title { font-size: 10px; color: var(--text-lo); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 6px; font-family: var(--font-mono); }
.savings-value { font-size: 32px; font-weight: 800; font-family: var(--font-mono); color: var(--accent); }
.savings-sub { font-size: 11px; color: var(--text-mid); margin-top: 4px; font-family: var(--font-mono); }
.savings-details { display: flex; justify-content: center; gap: 24px; margin-top: 14px; flex-wrap: wrap; }
.savings-detail-item { text-align: center; }
.savings-detail-value { font-size: 16px; font-weight: 700; font-family: var(--font-mono); color: var(--sev-low); }
.savings-detail-label { font-size: 9px; color: var(--text-mid); text-transform: uppercase; font-family: var(--font-mono); }

/* ══════════════════════════════════════
   OPERATIONS VIEW
   ══════════════════════════════════════ */
.operations-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ops-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.ops-card-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; gap: 8px; }
.ops-card-header h3 { font-family: var(--font-sans); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-lo); }

.export-btn {
    display: flex; align-items: center; gap: 5px; padding: 5px 12px;
    background: var(--surface-1); border: 1px solid var(--border);
    border-radius: var(--radius-md); color: var(--text-lo);
    font-size: 10px; font-weight: 600; font-family: var(--font-sans);
    cursor: pointer; transition: all 0.15s ease; text-transform: uppercase;
}
.export-btn:hover { border-color: var(--accent); color: var(--accent); }

.dispatch-trigger-btn {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 14px;
    background: var(--wa-brand);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all 0.2s ease;
}

.dispatch-trigger-btn:hover {
    background: var(--wa-accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 168, 132, 0.3);
}

.bandobast-header { padding: 20px; background: var(--accent-dim); border-bottom: 1px solid var(--accent-dim); text-align: center; }
.bandobast-header h3 { font-family: var(--font-sans); font-size: 14px; font-weight: 800; letter-spacing: 2px; text-transform: uppercase; color: var(--accent); }
.bandobast-ref { font-size: 10px; color: var(--text-mid); font-family: var(--font-mono); margin-top: 4px; }
.bandobast-meta { padding: 14px 16px; display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; border-bottom: 1px solid var(--border); }
.bandobast-meta-item { display: flex; flex-direction: column; gap: 2px; }
.bandobast-meta-item .meta-label { font-size: 9px; color: var(--text-mid); text-transform: uppercase; font-family: var(--font-mono); }
.bandobast-meta-item .meta-value { font-size: 12px; font-weight: 600; color: var(--text-hi); font-family: var(--font-sans); }

.bandobast-assignments { padding: 16px; }
.bandobast-assignments h4 { font-family: var(--font-sans); font-size: 11px; font-weight: 700; color: var(--text-lo); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 10px; }

.assignment-card { padding: 10px 12px; background: var(--surface-1); border-radius: var(--radius-md); border-left: 3px solid var(--accent); margin-bottom: 8px; display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: start; }
.assignment-card.severity-CRITICAL { border-left-color: var(--sev-critical); }
.assignment-card.severity-HIGH { border-left-color: var(--sev-high); }
.assignment-card.severity-MODERATE { border-left-color: var(--sev-moderate); }
.assignment-card.severity-LOW { border-left-color: var(--sev-low); }

.assignment-name { font-family: var(--font-sans); font-weight: 700; font-size: 12px; color: var(--text-hi); }
.assignment-zone { font-size: 10px; color: var(--text-mid); font-family: var(--font-mono); }
.assignment-instructions { list-style: none; margin-top: 4px; }
.assignment-instructions li { font-size: 10px; color: var(--text-lo); padding: 1px 0; }
.assignment-instructions li::before { content: '→ '; color: var(--accent); }
.assignment-constables { text-align: right; }
.constable-count { font-size: 20px; font-weight: 700; font-family: var(--font-mono); color: var(--accent); }
.constable-label { font-size: 8px; color: var(--text-mid); text-transform: uppercase; font-family: var(--font-mono); }

.flipkart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1px; background: var(--border); overflow: hidden; }
.flipkart-card { padding: 14px 16px; background: var(--surface-1); display: flex; flex-direction: column; gap: 4px; }
.flipkart-card .fk-icon { font-size: 18px; }
.flipkart-card .fk-value { font-size: 18px; font-weight: 700; font-family: var(--font-mono); }
.flipkart-card .fk-label { font-size: 9px; color: var(--text-mid); text-transform: uppercase; font-family: var(--font-mono); }
.flipkart-card .fk-compare { font-size: 10px; padding: 2px 6px; border-radius: 3px; font-weight: 600; display: inline-block; width: fit-content; font-family: var(--font-mono); }
.fk-compare.bad { background: color-mix(in srgb, var(--sev-critical) 12%, transparent); color: var(--sev-critical); }
.fk-compare.good { background: color-mix(in srgb, var(--sev-low) 12%, transparent); color: var(--sev-low); }

.whatsapp-container { display: flex; justify-content: center; padding: 16px; }
.whatsapp-phone { width: 340px; background: var(--wa-body); border-radius: 14px; overflow: hidden; border: 1px solid color-mix(in srgb, var(--wa-text) 6%, transparent); }
.phone-header { padding: 8px 12px; background: var(--wa-header); display: flex; align-items: center; gap: 8px; }
.phone-back { color: var(--wa-accent); font-size: 14px; }
.phone-contact { display: flex; align-items: center; gap: 6px; }
.contact-avatar { font-size: 20px; }
.contact-name { display: block; font-size: 12px; font-weight: 600; color: var(--wa-text); }
.contact-status { font-size: 9px; color: var(--wa-text-dim); }
.phone-body { padding: 12px; min-height: 200px; background: var(--wa-body); }
.wa-message { background: var(--wa-bubble); padding: 8px 10px; border-radius: 0 8px 8px 8px; font-size: 11px; line-height: 1.6; color: var(--wa-text); white-space: pre-wrap; word-wrap: break-word; font-family: var(--font-sans); max-width: 95%; position: relative; }
.wa-message::before { content: ''; position: absolute; top: 0; left: -7px; border-bottom: 8px solid transparent; border-right: 8px solid var(--wa-bubble); }
.wa-time { text-align: right; font-size: 8px; color: color-mix(in srgb, var(--wa-text) 45%, transparent); margin-top: 2px; }

/* ══════════════════════════════════════
   🧊 3D TACTICAL VIEW STYLING
   ══════════════════════════════════════ */
.tactical-3d-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    background: var(--ground);
    overflow: hidden;
}

/* Dev Phase Ribbon Banner */
.dev-phase-banner {
    position: absolute;
    top: 16px; left: 16px;
    z-index: 850;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: color-mix(in srgb, var(--surface-1) 88%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid color-mix(in srgb, var(--sev-high) 35%, transparent);
    border-radius: var(--radius-lg);
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-hi);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.dev-phase-icon { font-size: 14px; }
.dev-phase-text { letter-spacing: 0.5px; }
.dev-phase-text strong { color: var(--sev-high); }

.tactical-3d-canvas {
    width: 100%;
    height: 100%;
}

.hud-3d-controls {
    position: absolute;
    top: 16px; right: 16px;
    background: color-mix(in srgb, var(--surface-1) 88%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    width: 280px;
    z-index: 850;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.hud-title {
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--sev-low);
    margin-bottom: 2px;
}

.hud-sub {
    font-size: 10px;
    color: var(--text-lo);
    font-family: var(--font-mono);
    margin-bottom: 12px;
}

.hud-btn-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.hud-btn {
    padding: 6px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-hi);
    font-size: 10px;
    font-weight: 600;
    font-family: var(--font-mono);
    cursor: pointer;
    text-align: left;
    transition: all 0.15s ease;
}

.hud-btn:hover {
    border-color: var(--accent-dim);
    color: var(--accent);
    background: var(--surface-2);
}

.hud-legend {
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-top: 1px solid var(--border);
    padding-top: 8px;
    font-size: 9px;
    font-family: var(--font-mono);
    color: var(--text-mid);
}

.hud-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 4px;
}

.hud-dot.stadium { background: var(--accent); }
.hud-dot.bus { background: var(--legend-bus); }
.hud-dot.crowd { background: var(--legend-crowd); }
.hud-dot.police { background: var(--legend-police); }
.hud-dot.traffic { background: var(--legend-traffic); }
.hud-dot.trees { background: var(--legend-trees); }
.hud-dot.critical { background: var(--sev-critical); }

/* ══════════════════════════════════════
   BOTTOM TICKER — (ULTRA SLOW: 140s)
   ══════════════════════════════════════ */
.bottom-ticker {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--ticker-h);
    background: var(--surface-1);
    border-top: 1px solid var(--border);
    display: flex; align-items: center;
    z-index: 900; overflow: hidden;
}

.ticker-label {
    display: flex; align-items: center; gap: 5px;
    padding: 0 12px; font-size: 9px; font-weight: 700;
    color: var(--accent); font-family: var(--font-mono);
    text-transform: uppercase; letter-spacing: 0.5px;
    white-space: nowrap; border-right: 1px solid var(--border);
    height: 100%; flex-shrink: 0;
}

.ticker-dot {
    width: 5px; height: 5px; background: var(--sev-critical);
    border-radius: 50%; animation: blink 1.5s infinite;
}

.ticker-track { flex: 1; overflow: hidden; height: 100%; display: flex; align-items: center; }

.ticker-content {
    display: flex; align-items: center; gap: 24px;
    white-space: nowrap;
    animation: tickerScroll 140s linear infinite !important;
    padding-left: 100%;
}

.ticker-content.paused { animation-play-state: paused; }

@keyframes tickerScroll {
    from { transform: translateX(0); }
    to { transform: translateX(-100%); }
}

.ticker-item { display: flex; align-items: center; gap: 6px; font-size: 10px; font-family: var(--font-mono); font-weight: 500; color: var(--text-lo); }
.ticker-item.standby { color: var(--text-mid); font-style: italic; }
.ticker-sev { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.ticker-sev.critical { background: var(--sev-critical); animation: criticalBlink 1.5s infinite; }
.ticker-sev.high { background: var(--sev-high); animation: highPulse 2s infinite; }
.ticker-sev.moderate { background: var(--sev-moderate); }
.ticker-sev.low { background: var(--sev-low); }

.ticker-name { color: var(--text-hi); font-weight: 600; }
.ticker-detail { color: var(--text-mid); }
.ticker-sep { color: var(--surface-2); font-size: 8px; }

/* ══════════════════════════════════════
   HISTORY SIDEBAR & OVERLAY
   ══════════════════════════════════════ */
.history-sidebar {
    position: fixed; top: 0; right: -380px;
    width: 340px; height: 100vh; z-index: 1100;
    background: var(--surface-1); border-left: 1px solid var(--border);
    display: flex; flex-direction: column; transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.history-sidebar.open { right: 0; }
.history-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.history-header h3 { font-family: var(--font-sans); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.history-close-btn { width: 24px; height: 24px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; color: var(--text-lo); cursor: pointer; font-size: 10px; display: flex; align-items: center; justify-content: center; }
.history-list { flex: 1; overflow-y: auto; padding: 10px; }
.history-empty { text-align: center; padding: 32px 14px; color: var(--text-mid); }
.history-empty-icon { font-size: 28px; display: block; margin-bottom: 8px; }
.history-item { padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 6px; cursor: pointer; transition: all 0.15s ease; }
.history-item.active { border-color: var(--accent); border-left: 3px solid var(--accent); }
.history-item-header { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.history-item-title { font-family: var(--font-sans); font-size: 11px; font-weight: 700; color: var(--text-hi); flex: 1; }
.history-item-time { font-size: 9px; color: var(--text-mid); font-family: var(--font-mono); }
.history-item-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.history-meta-tag { font-size: 9px; color: var(--text-lo); font-family: var(--font-mono); }
.history-footer { padding: 10px 16px; border-top: 1px solid var(--border); }
.history-clear-btn { width: 100%; padding: 6px; background: color-mix(in srgb, var(--sev-critical) 12%, transparent); border: 1px solid color-mix(in srgb, var(--sev-critical) 15%, transparent); border-radius: var(--radius-md); color: var(--sev-critical); font-size: 10px; font-weight: 600; cursor: pointer; }

.history-overlay { position: fixed; inset: 0; z-index: 1050; background: color-mix(in srgb, var(--ground) 55%, transparent); opacity: 0; pointer-events: none; transition: opacity 0.3s ease; }
.history-overlay.active { opacity: 1; pointer-events: all; }

.loading-overlay { display: none; position: fixed; inset: 0; z-index: 9999; background: color-mix(in srgb, var(--surface-1) 95%, transparent); backdrop-filter: blur(8px); justify-content: center; align-items: center; }
.loading-overlay.active { display: flex; }
.loader-content { text-align: center; }
.loader-ring { width: 48px; height: 48px; position: relative; margin: 0 auto 20px; }
.ring-segment { position: absolute; width: 100%; height: 100%; border: 3px solid transparent; border-radius: 50%; }
.ring-segment:nth-child(1) { border-top-color: var(--accent); animation: spin 1s linear infinite; }
.ring-segment:nth-child(2) { border-right-color: var(--sev-high); animation: spin 1.5s linear infinite reverse; }
.ring-segment:nth-child(3) { border-bottom-color: var(--sev-critical); animation: spin 2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text { font-family: var(--font-sans); font-size: 14px; font-weight: 700; color: var(--text-hi); margin-bottom: 12px; }
.loader-steps { display: flex; gap: 16px; justify-content: center; }
.loader-step { font-size: 11px; color: var(--text-mid); font-family: var(--font-mono); position: relative; padding-left: 14px; }
.loader-step::before { content: ''; position: absolute; left: 0; top: 50%; width: 6px; height: 6px; margin-top: -3px; background: var(--surface-2); border-radius: 50%; animation: loaderDot 1.5s ease-in-out infinite; }
@keyframes loaderDot { 0%, 100% { background: var(--surface-2); } 50% { background: var(--accent); } }

/* ══════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ══════════════════════════════════════ */
@media (max-width: 1024px) {
    :root { --left-w: 260px; }
    .analytics-grid { grid-template-columns: 1fr; }
    .economics-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    :root { --left-w: 100%; --ticker-h: 28px; }
    .command-center { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
    .left-panel { border-right: none; border-bottom: 1px solid var(--border); max-height: 50vh; overflow-y: auto; }
    .nav-shortcuts { display: none; }
    .nav-countdown { display: none !important; }
    .view-btn span { display: none; }
    .view-btn kbd { display: none; }
    .welcome-stats { grid-template-columns: repeat(2, 1fr); }
    .summary-grid { grid-template-columns: repeat(2, 1fr); }
    .spotlight-panel { top: auto; bottom: 16px; right: 16px; left: 16px; width: auto; }
    .whatsapp-phone { width: 100%; }
}

/* ══════════════════════════════════════
   INLINE ERROR SURFACE
   Replaces alert(), which blocks the page and reads as a crash.
   ══════════════════════════════════════ */
.error-surface {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    margin-top: var(--space-3);
    padding: var(--space-3);
    background: color-mix(in srgb, var(--sev-critical) 12%, var(--surface-1));
    border: 1px solid var(--sev-critical);
    border-radius: var(--radius-md);
}

.error-surface[data-kind="server"] {
    background: color-mix(in srgb, var(--sev-high) 12%, var(--surface-1));
    border-color: var(--sev-high);
}

.error-text {
    flex: 1;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-hi);
}

.error-dismiss {
    background: none;
    border: 0;
    color: var(--text-mid);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 0 var(--space-1);
}

.error-dismiss:hover { color: var(--text-hi); }

/* ══════════════════════════════════════
   EMPTY STATE HINTS
   ══════════════════════════════════════ */
.welcome-hints {
    list-style: none;
    margin: var(--space-6) auto 0;
    display: grid;
    gap: var(--space-2);
    text-align: left;
    max-width: 46ch;
}

.welcome-hints li {
    font-size: 12px;
    color: var(--text-lo);
    padding-left: var(--space-4);
    border-left: 2px solid var(--accent-dim);
    line-height: 1.5;
}

.welcome-hints strong { color: var(--text-mid); font-weight: 600; }

/* ══════════════════════════════════════
   SKELETON LOADING
   Marks the panels being filled instead of blanking the page.
   ══════════════════════════════════════ */
.skeleton {
    position: relative;
    background: linear-gradient(90deg,
        var(--surface-1) 0%, var(--surface-2) 50%, var(--surface-1) 100%);
    background-size: 200% 100%;
    animation: skeleton-sweep 1.2s var(--ease) infinite;
    border-radius: var(--radius-sm);
    color: transparent;
    pointer-events: none;
}

@keyframes skeleton-sweep {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}


/* ══════════════════════════════════════
   BASEMAP THEMING
   The dark map is the light OSM tileset inverted in CSS. The filter is scoped
   to the tile pane so markers, radius circles and the legend keep their true
   severity colours — inverting the whole map would invert those too.
   ══════════════════════════════════════ */
[data-theme="dark"] .leaflet-tile-pane {
    filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(1.15) saturate(0.5);
}

/*
 * Light mode needs its own treatment for the same reason. Full-colour OSM puts
 * tan arterials behind --sev-high and green parks behind --sev-low, so the
 * severity markers stop being the loudest thing on the map. Desaturating the
 * tiles restores that hierarchy without hiding the labels.
 */
[data-theme="light"] .leaflet-tile-pane {
    filter: saturate(0.45) brightness(1.03) contrast(0.96);
}

/* ══════════════════════════════════════
   MOTION
   Entrances are staggered so a panel resolves as a sequence rather than a
   single pop. --i is set on list children after each render (see stagger()
   in app.js); everything else keys off nth-child or its own state.
   Every rule here is disabled under prefers-reduced-motion at the bottom.
   ══════════════════════════════════════ */

@keyframes rise-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

@keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes grow-up {
    from { transform: scaleY(0.02); opacity: 0; }
    to   { transform: scaleY(1); opacity: 1; }
}

/* ── View panels ── */
.view-panel.active {
    animation: rise-in var(--dur-slow) var(--ease-out) both;
}

/* ── Staggered lists ── */
.stats-grid > *,
.zone-list > *,
.junction-grid > *,
.assignment-card,
.impact-table tbody tr {
    animation: rise-in 380ms var(--ease-out) both;
    animation-delay: calc(var(--i, 0) * var(--stagger));
}

/* ── Timeline bars grow from the axis, in time order ── */
.timeline-bar {
    transform-origin: bottom center;
    animation: grow-up 520ms var(--ease-out) both;
    animation-delay: calc(var(--bar-index, 0) * 26ms);
    transition: filter var(--dur-fast) var(--ease);
}

.timeline-bar:hover { filter: brightness(1.25); }

/*
 * Phase, not severity. The engine scores severity per junction from capacity
 * and delay — never per hour — so colouring these by magnitude asserted
 * something the data does not support.
 */
.timeline-bar.phase-normal     { background: var(--border-strong); }
.timeline-bar.phase-surge      { background: color-mix(in srgb, var(--accent) 55%, transparent); }
.timeline-bar.phase-active     { background: var(--accent); }
.timeline-bar.phase-dispersal  { background: color-mix(in srgb, var(--accent) 35%, transparent); }

/* ── Controls respond to press ── */
.predict-btn,
.view-tab,
.hud-btn,
.filter-chip {
    transition: transform var(--dur-fast) var(--ease-spring),
                background-color var(--dur-fast) var(--ease),
                border-color var(--dur-fast) var(--ease);
}

.predict-btn:active,
.view-tab:active,
.hud-btn:active,
.filter-chip:active { transform: scale(0.97); }

.predict-btn:not(:disabled):hover { transform: translateY(-1px); }

/* ── Cards lift on hover ── */
.analytics-card,
.assignment-card {
    transition: transform var(--dur-base) var(--ease-out),
                border-color var(--dur-base) var(--ease);
}

.analytics-card:hover,
.assignment-card:hover { transform: translateY(-2px); }

/* ── Error surface arrives rather than appearing ── */
.error-surface:not([hidden]) {
    animation: rise-in var(--dur-base) var(--ease-out) both;
}

/* ── Map overlays ── */
.map-legend-overlay,
.map-filters-overlay,
.spotlight-panel {
    animation: fade-in var(--dur-slow) var(--ease-out) both;
}

/* ── Focus is always visible, and never animated away ── */
.predict-btn:focus-visible,
.view-tab:focus-visible,
.filter-chip:focus-visible,
.hud-btn:focus-visible,
.nav-icon-btn:focus-visible,
select:focus-visible,
input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ── Tap targets ──
   The severity filter chips were 23px tall, a pixel under the 24px minimum. */
.filter-chip { min-height: 24px; }

/* ══════════════════════════════════════
   REDUCED MOTION
   The dashboard had no guard at all. Vestibular triggers are not a preference
   to style around — when the OS asks for stillness, everything above stops.
   ══════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
