/* ============================================================
   Pretoria 911 Dispatch — polished command-center theme
   ============================================================ */
:root {
    --bg-900: #0b1220;
    --bg-800: #0f172a;
    --bg-700: #1b2638;
    --bg-600: #243246;
    --line: #2d3c54;
    --text: #e6edf6;
    --text-muted: #94a3b8;
    --ems: #ef4444;
    --police: #3b82f6;
    --fire: #f97316;
    --accent: #22c55e;
    --primary: #38bdf8;
    --warn: #f59e0b;
    --danger: #ef4444;
    --radius: 12px;
    --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-900);
    color: var(--text);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

h2 { margin: 0; }

/* ---------------- Header ---------------- */
#app-header {
    flex: 0 0 70px;
    height: 70px;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 0 20px;
    background: linear-gradient(90deg, #0a101d 0%, #111f38 100%);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 4px 24px rgba(0, 0, 0, .45);
    z-index: 1200;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 230px; }
.brand-badge {
    width: 44px; height: 44px;
    border-radius: 13px;
    display: grid; place-items: center;
    font-size: 20px; color: #fff;
    background: linear-gradient(135deg, #ef4444, #b91c1c);
    box-shadow: 0 8px 20px rgba(239, 68, 68, .45);
    animation: badgeGlow 2.6s ease-in-out infinite;
}
@keyframes badgeGlow {
    0%, 100% { box-shadow: 0 8px 20px rgba(239, 68, 68, .35); }
    50% { box-shadow: 0 8px 26px rgba(239, 68, 68, .7); }
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title { font-weight: 800; font-size: 18px; letter-spacing: .2px; }
.brand-sub { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 2px; }

/* ---------------- HUD stat chips ---------------- */
.hud-stats {
    display: flex; gap: 10px;
    flex: 1; justify-content: center; flex-wrap: wrap;
}
.stat-chip {
    display: flex; align-items: center; gap: 11px;
    background: var(--bg-700);
    border: 1px solid var(--line);
    padding: 8px 16px;
    border-radius: 12px;
    min-width: 132px;
    transition: transform .15s ease, border-color .15s ease;
}
.stat-chip:hover { transform: translateY(-2px); border-color: #3a4d6b; }
.stat-chip i { font-size: 19px; }
.stat-money i { color: var(--accent); }
.stat-score i { color: #facc15; }
.stat-rep i { color: var(--ems); }
.stat-wave i { color: var(--primary); }
.stat-label { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); }
.stat-value { display: block; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------------- Buttons ---------------- */
.hud-actions { display: flex; align-items: center; gap: 8px; }

.btn-action {
    display: inline-flex; align-items: center; gap: 8px;
    border: none; cursor: pointer;
    padding: 10px 18px; border-radius: 11px;
    font-weight: 700; font-size: 14px; color: #fff;
    transition: transform .12s ease, filter .12s ease, box-shadow .12s ease;
}
.btn-action:active { transform: translateY(1px); }
.btn-action-primary {
    background: linear-gradient(135deg, #22c55e, #15803d);
    box-shadow: 0 8px 20px rgba(34, 197, 94, .35);
}
.btn-action-primary:hover { filter: brightness(1.08); box-shadow: 0 10px 26px rgba(34, 197, 94, .5); }

.btn-icon {
    width: 40px; height: 40px;
    display: grid; place-items: center;
    border: 1px solid var(--line);
    background: var(--bg-700);
    color: var(--text);
    border-radius: 11px; cursor: pointer;
    font-size: 15px; transition: all .14s ease;
}
.btn-icon:hover { background: var(--bg-600); color: #fff; transform: translateY(-2px); }
.btn-icon-danger:hover { background: rgba(239, 68, 68, .18); border-color: var(--danger); color: #fca5a5; }

.btn-block-action {
    width: 100%;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: none; cursor: pointer;
    padding: 11px 14px; border-radius: 11px;
    font-weight: 700; font-size: 14px; color: #fff;
    background: linear-gradient(135deg, #0ea5e9, #2563eb);
    box-shadow: 0 8px 20px rgba(37, 99, 235, .35);
    transition: transform .12s ease, filter .12s ease;
}
.btn-block-action:hover { filter: brightness(1.08); transform: translateY(-2px); }
.btn-block-action:active { transform: translateY(0); }

.btn-shop {
    display: inline-flex; align-items: center; gap: 7px;
    border: none; cursor: pointer;
    padding: 7px 14px; border-radius: 10px;
    font-weight: 700; font-size: 13px; color: #0b1220;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    box-shadow: 0 6px 16px rgba(245, 158, 11, .35);
    transition: transform .12s ease, filter .12s ease;
}
.btn-shop:hover { filter: brightness(1.06); transform: translateY(-2px); }

/* ---------------- Layout / panels ---------------- */
#app-body {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: 330px 1fr 330px;
    min-height: 0;
}

.panel {
    background: var(--bg-800);
    border-right: 1px solid var(--line);
    padding: 16px;
    overflow-y: auto;
    display: flex; flex-direction: column; gap: 12px;
}
#units { border-right: none; border-left: 1px solid var(--line); }

#map-wrap { position: relative; min-height: 0; }
#map { height: 100%; width: 100%; background: var(--bg-900); }

.panel-head {
    display: flex; align-items: center; justify-content: space-between;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}
.panel-head h2 {
    font-size: 14px; text-transform: uppercase; letter-spacing: 1.2px;
    font-weight: 700; color: var(--text);
    display: flex; align-items: center; gap: 9px;
}
.panel-head h2 i { color: var(--primary); }

.count-pill {
    background: var(--ems); color: #fff;
    border-radius: 999px; padding: 2px 11px;
    font-size: 12px; font-weight: 800; min-width: 26px; text-align: center;
}

.empty-hint {
    color: var(--text-muted); font-size: 13px;
    text-align: center; padding: 18px 10px;
    border: 1px dashed var(--line); border-radius: 12px;
    background: rgba(255, 255, 255, .015);
}

/* ---------------- Incident feed ---------------- */
.incident-feed { display: flex; flex-direction: column; gap: 9px; padding: 0; margin: 0; }
.incident-item {
    list-style: none;
    background: var(--bg-700) !important;
    border: 1px solid var(--line) !important;
    border-left: 4px solid var(--warn) !important;
    border-radius: 11px !important;
    color: var(--text) !important;
    cursor: pointer;
    padding: 11px 13px !important;
    transition: transform .14s ease, border-color .14s ease, background .14s ease;
}
.incident-item:hover {
    transform: translateX(3px);
    border-color: var(--primary) !important;
    background: var(--bg-600) !important;
}
.incident-item strong { font-weight: 700; }
.incident-item .text-muted, .incident-item small { color: var(--text-muted) !important; }
.incident-item .badge { font-weight: 600; }

/* ---------------- Units ---------------- */
.unit-group { margin-bottom: 4px; }
.unit-group h5 {
    margin: 6px 0; font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-muted);
    display: flex; align-items: center; gap: 8px;
}
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-ems { background: var(--ems); box-shadow: 0 0 8px var(--ems); }
.dot-police { background: var(--police); box-shadow: 0 0 8px var(--police); }
.dot-fire { background: var(--fire); box-shadow: 0 0 8px var(--fire); }

.list-group { padding: 0; margin: 0; }
.unit {
    list-style: none;
    background: var(--bg-700) !important;
    border: 1px solid var(--line) !important;
    color: var(--text) !important;
    border-radius: 10px !important;
    margin-bottom: 7px !important;
    cursor: pointer;
    display: flex; align-items: center; justify-content: space-between;
    padding: 9px 12px !important;
    transition: transform .14s ease, border-color .14s ease, background .14s ease;
}
.unit:hover { border-color: var(--primary) !important; background: var(--bg-600) !important; transform: translateX(3px); }
.unit-name { font-size: 13px; font-weight: 600; }
.selected-unit {
    background: linear-gradient(135deg, #0ea5e9, #2563eb) !important;
    color: #fff !important;
    border-color: #38bdf8 !important;
    box-shadow: 0 0 0 2px rgba(56, 189, 248, .35), 0 6px 16px rgba(37, 99, 235, .35);
}

.badge-status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px; font-weight: 700;
    margin-left: 8px;
}
.badge-available { background: rgba(34, 197, 94, .16); color: #4ade80; border: 1px solid rgba(34, 197, 94, .4); }
.badge-busy { background: rgba(239, 68, 68, .16); color: #f87171; border: 1px solid rgba(239, 68, 68, .4); }

/* ---------------- Map markers ---------------- */
.veh-divicon, .incident-divicon, .station-divicon { background: transparent; border: none; }

.veh-marker {
    width: 34px; height: 34px; border-radius: 50%;
    display: grid; place-items: center; color: #fff;
    border: 2px solid #fff; font-size: 15px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, .5);
}
.veh-ems { background: linear-gradient(135deg, #f87171, #dc2626); }
.veh-police { background: linear-gradient(135deg, #60a5fa, #2563eb); }
.veh-fire { background: linear-gradient(135deg, #fb923c, #ea580c); }

.station-marker {
    width: 32px; height: 32px; border-radius: 9px;
    display: grid; place-items: center; color: #fff;
    border: 2px solid #fff; font-size: 14px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, .5);
}
.station-hospital { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.station-police { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.station-fire { background: linear-gradient(135deg, #f97316, #c2410c); }

.incident-marker {
    position: relative;
    width: 40px; height: 40px; border-radius: 50%;
    display: grid; place-items: center; color: #fff;
    border: 2px solid #fff; font-size: 17px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .5);
    --glow: rgba(234, 88, 12, .6);
    background: radial-gradient(circle at 32% 28%, #fb923c, #ea580c);
}
.incident-marker i { position: relative; z-index: 2; }
.incident-marker.sev-low { --glow: rgba(37, 99, 235, .55); background: radial-gradient(circle at 32% 28%, #60a5fa, #2563eb); }
.incident-marker.sev-medium { --glow: rgba(217, 119, 6, .55); background: radial-gradient(circle at 32% 28%, #fbbf24, #d97706); }
.incident-marker.sev-high { --glow: rgba(220, 38, 38, .65); background: radial-gradient(circle at 32% 28%, #f87171, #dc2626); }
.incident-pulse {
    position: absolute; inset: 0; border-radius: 50%; z-index: 1;
    animation: incPulse 1.8s ease-out infinite;
}
@keyframes incPulse {
    0% { box-shadow: 0 0 0 0 var(--glow); }
    70% { box-shadow: 0 0 0 16px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}

/* ---------------- Map legend ---------------- */
.map-legend {
    background: rgba(15, 23, 42, .92);
    backdrop-filter: blur(6px);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 10px 12px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    font-size: 13px;
}
.legend-title {
    font-size: 10px; text-transform: uppercase; letter-spacing: 1.4px;
    color: var(--text-muted); margin-bottom: 7px;
}
.legend-item { display: flex; align-items: center; gap: 9px; margin-bottom: 6px; }
.legend-item:last-child { margin-bottom: 0; }
.lg-dot {
    width: 22px; height: 22px; border-radius: 7px;
    display: grid; place-items: center; color: #fff; font-size: 11px;
}
.lg-ems { background: linear-gradient(135deg, #f87171, #dc2626); }
.lg-police { background: linear-gradient(135deg, #60a5fa, #2563eb); }
.lg-fire { background: linear-gradient(135deg, #fb923c, #ea580c); }
.lg-station { background: linear-gradient(135deg, #64748b, #334155); }

/* ---------------- Leaflet control tweaks ---------------- */
.leaflet-routing-container { display: none !important; }
.leaflet-bar a, .leaflet-bar a:hover {
    background: var(--bg-700); color: var(--text);
    border-bottom: 1px solid var(--line);
}
.leaflet-bar a:hover { background: var(--bg-600); }
.leaflet-control-layers {
    background: var(--bg-700); color: var(--text);
    border: 1px solid var(--line) !important; border-radius: 10px;
    box-shadow: var(--shadow);
}
.leaflet-control-layers-expanded { padding: 10px 12px; }
.leaflet-control-layers label { margin-bottom: 4px; font-size: 13px; }
.leaflet-control-scale-line { background: rgba(15, 23, 42, .7); color: var(--text); border-color: var(--line); }
.leaflet-popup-content-wrapper { border-radius: 12px; box-shadow: var(--shadow); }
.leaflet-popup-content { font-family: 'Inter', sans-serif; }
.leaflet-container { font-family: 'Inter', sans-serif; }

/* ---------------- Notification toast ---------------- */
.notification-popup {
    position: fixed;
    top: 86px; left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    padding: 13px 22px;
    border-radius: 12px;
    font-size: 15px; font-weight: 600;
    text-align: center;
    display: none;
    z-index: 1500;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .45);
    border: 1px solid rgba(255, 255, 255, .12);
}
.notification-popup.toast-arrival { background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; }
.notification-popup.toast-resolved { background: linear-gradient(135deg, #22c55e, #16a34a); color: #fff; }
.notification-popup.toast-start { background: linear-gradient(135deg, #0ea5e9, #2563eb); color: #fff; }

/* ---------------- Incident progress ---------------- */
.incident-progress .progress { height: 14px; margin-top: 6px; border-radius: 7px; }
.incident-progress .progress-bar { transition: width .25s linear; }
.req-row { margin-bottom: 4px; }

/* ---------------- Shop / SweetAlert dark theme ---------------- */
.swal2-popup {
    background: var(--bg-800) !important;
    color: var(--text) !important;
    border: 1px solid var(--line);
    border-radius: 18px !important;
}
.swal2-title, .swal2-html-container { color: var(--text) !important; }
.swal2-close { color: var(--text-muted) !important; }
.swal2-close:hover { color: #fff !important; }

.tab-container { display: flex; flex-direction: column; }
.tab-buttons { display: flex; gap: 8px; justify-content: center; margin-bottom: 14px; flex-wrap: wrap; }
.tab-button {
    background: var(--bg-700);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 9px 20px; border-radius: 10px;
    cursor: pointer; font-weight: 600;
    transition: all .15s ease;
}
.tab-button:hover { background: var(--bg-600); }
.tab-button.active {
    background: linear-gradient(135deg, #0ea5e9, #2563eb);
    color: #fff; border-color: #38bdf8;
}

#filterInput.form-control,
.swal2-html-container select.form-control {
    background: var(--bg-700) !important;
    border: 1px solid var(--line) !important;
    color: var(--text) !important;
    border-radius: 10px;
}
#filterInput.form-control::placeholder { color: var(--text-muted); }

.tab-content { display: none; }
.tab-content.active { display: block; }

.shop-card {
    background: var(--bg-700);
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
    color: var(--text);
}
.shop-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 26px rgba(0, 0, 0, .5);
    border-color: var(--primary);
}
.card { margin: 10px; }
.card-image { border-bottom: 1px solid var(--line); }
.shop-card .card-title { font-size: 15px; font-weight: 700; color: #fff; }
.shop-card .card-text, .shop-card ul { font-size: 12px; color: var(--text-muted); }
.shop-card .card-price { color: #4ade80 !important; }
.card-image-placeholder {
    height: 150px;
    display: grid; place-items: center;
    font-size: 50px; color: rgba(255, 255, 255, .9);
}
.card-image-placeholder.type-ambulance { background: linear-gradient(135deg, #7f1d1d, #ef4444); }
.card-image-placeholder.type-fire { background: linear-gradient(135deg, #7c2d12, #f97316); }
.card-image-placeholder.type-police { background: linear-gradient(135deg, #1e3a8a, #3b82f6); }
.custom-row-spacing > .col { margin-bottom: 20px; }

.swal-html-container .card { border: none; }
.swal-html-container .card .card-body { padding: 12px; }
.btn-buy-now {
    background: linear-gradient(135deg, #22c55e, #15803d) !important;
    border: none !important; font-weight: 700;
    border-radius: 9px;
}

/* ---------------- Scrollbars ---------------- */
.panel::-webkit-scrollbar, .swal2-html-container::-webkit-scrollbar { width: 9px; }
.panel::-webkit-scrollbar-track, .swal2-html-container::-webkit-scrollbar-track { background: transparent; }
.panel::-webkit-scrollbar-thumb, .swal2-html-container::-webkit-scrollbar-thumb {
    background: var(--bg-600); border-radius: 8px; border: 2px solid var(--bg-800);
}
.panel::-webkit-scrollbar-thumb:hover { background: #33475f; }

/* ---------------- Responsive ---------------- */
button, .btn-icon, .btn-action, .pop-btn, .spd-btn, .u-patrol, .audio-toggle, .assign-go { touch-action: manipulation; }

@media (max-width: 1200px) {
    #app-body { grid-template-columns: 270px 1fr 270px; }
    .stat-chip { min-width: 108px; padding: 7px 12px; }
    .brand-sub { display: none; }
}
@media (max-width: 992px) {
    #app-header { flex-wrap: wrap; height: auto; padding: 10px 12px; gap: 8px; }
    .brand { min-width: auto; }
    .hud-stats { order: 3; flex-basis: 100%; justify-content: flex-start; gap: 8px; }
    .hud-actions { flex-wrap: wrap; }
    #app-body { grid-template-columns: 220px 1fr 220px; }
}

/* Tablet / phone: stack into a single scrollable column, map first */
@media (max-width: 760px) {
    html, body { height: auto; }
    body { overflow-y: auto; -webkit-overflow-scrolling: touch; }
    #app-header { position: sticky; top: 0; z-index: 1200; }
    #app-body { display: flex; flex-direction: column; min-height: 0; }
    #map-wrap { order: -1; height: 52vh; min-height: 300px; flex: none; }
    .panel { border: none; border-bottom: 1px solid var(--line); overflow: visible; max-height: none; }
    .brand-title { font-size: 16px; }
    .brand-badge { width: 40px; height: 40px; }
    .stat-chip { min-width: 0; flex: 1 1 calc(33.333% - 8px); padding: 6px 10px; }
    .stat-value { font-size: 16px; }
    .speed-control { order: 2; }
    /* bigger touch targets */
    .unit { padding: 12px !important; }
    .unit-name { font-size: 14px; }
    .u-patrol { width: 32px; height: 32px; font-size: 13px; }
    .badge-status { padding: 4px 11px; }
    .btn-icon { width: 42px; height: 42px; font-size: 16px; }
    .btn-action { padding: 11px 16px; }
    .incident-item { padding: 13px 14px !important; }
    .pop-btn { padding: 12px 12px; font-size: 13.5px; }
    .assign-row { padding: 12px; }
    .assign-go { padding: 10px 14px; }
    .leaflet-popup-content { min-width: 210px; }
    /* SweetAlert (shop / dialogs) fit small screens */
    .swal2-popup { width: 96% !important; padding: 14px !important; }
    .tab-buttons { flex-wrap: wrap; gap: 6px; }
    .tab-button { padding: 8px 14px; }
    .diff-grid { grid-template-columns: 1fr; }
    .audio-panel { width: 210px; }
}

@media (max-width: 480px) {
    #app-header { gap: 6px; padding: 8px 10px; }
    .brand-badge { width: 36px; height: 36px; font-size: 17px; }
    .brand-title { font-size: 15px; }
    .stat-chip { flex: 1 1 calc(50% - 6px); }
    .stat-chip i { font-size: 16px; }
    .hud-actions { gap: 6px; width: 100%; justify-content: space-between; }
    .btn-action-primary { flex: 1; justify-content: center; }
    #map-wrap { height: 46vh; min-height: 260px; }
    .panel-head h2 { font-size: 13px; }
    .shop-card .card-title { font-size: 14px; }
}

/* ============================================================
   v2 additions: time controls, patrol, route, popups, toasts
   ============================================================ */

/* Difficulty chip accent */
.stat-diff i { color: #a78bfa; }

/* Speed / time controls */
.speed-control {
    display: inline-flex; align-items: center; gap: 2px;
    background: var(--bg-700); border: 1px solid var(--line);
    border-radius: 11px; padding: 3px;
}
.spd-btn {
    border: none; background: transparent; color: var(--text-muted);
    font-weight: 700; font-size: 12px; cursor: pointer;
    padding: 6px 9px; border-radius: 8px; line-height: 1;
    transition: background .12s ease, color .12s ease;
}
.spd-btn:hover { color: #fff; background: var(--bg-600); }
.spd-btn.active { background: linear-gradient(135deg, #0ea5e9, #2563eb); color: #fff; }
.spd-pause { color: var(--accent); font-size: 13px; }
.spd-pause.paused { background: rgba(245, 158, 11, .2); color: var(--warn); }

/* Marker stability: never transition map markers (kills the zoom "swim") */
.veh-divicon, .incident-divicon, .station-divicon,
.veh-marker, .incident-marker, .station-marker { transition: none !important; }
.leaflet-marker-icon { will-change: transform; }
.leaflet-zoom-anim .veh-marker, .leaflet-zoom-anim .incident-marker { transition: none !important; }

/* Route line drawn by the engine */
.route-line { filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }

/* Patrolling vehicle marker ring */
.veh-marker.patrolling { box-shadow: 0 0 0 3px rgba(56,189,248,.55), 0 3px 8px rgba(0,0,0,.45); }

/* Unit list item: actions + patrol button */
.unit { gap: 6px; }
.unit-actions { display: inline-flex; align-items: center; gap: 6px; }
.u-patrol {
    width: 26px; height: 26px; border-radius: 8px;
    border: 1px solid var(--line); background: var(--bg-800);
    color: var(--text-muted); cursor: pointer; font-size: 12px;
    display: grid; place-items: center; transition: all .12s ease;
}
.u-patrol:hover { color: #fff; border-color: var(--primary); }
.u-patrol.active { background: linear-gradient(135deg, #0ea5e9, #2563eb); color: #fff; border-color: #38bdf8; }
.badge-patrol { background: rgba(56,189,248,.16); color: #7dd3fc; border: 1px solid rgba(56,189,248,.4); }

/* Smaller, less intrusive toast */
.notification-popup {
    top: auto; bottom: 18px; left: 50%;
    transform: translateX(-50%) translateY(10px);
    padding: 8px 14px; font-size: 12.5px; font-weight: 600;
    border-radius: 9px; opacity: 0; pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
    max-width: 320px; box-shadow: 0 8px 20px rgba(0,0,0,.4);
}
.notification-popup.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Incident marker selected/targeted halo */
.incident-marker.targeted { outline: 3px solid rgba(56,189,248,.7); outline-offset: 2px; }

/* ---- Dark themed Leaflet popups (cleaner dispatch) ---- */
.leaflet-popup-content-wrapper {
    background: var(--bg-800); color: var(--text);
    border: 1px solid var(--line); border-radius: 14px;
    box-shadow: 0 16px 40px rgba(0,0,0,.55);
}
.leaflet-popup-tip { background: var(--bg-800); border: 1px solid var(--line); }
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; min-width: 230px; }
.leaflet-popup-close-button { color: var(--text-muted) !important; }
.leaflet-container a.leaflet-popup-close-button:hover { color: #fff !important; }

.pop { display: flex; flex-direction: column; gap: 9px; }
.pop-head { display: flex; align-items: center; gap: 9px; }
.pop-ic { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-size: 15px; flex: 0 0 auto; }
.pop-ic.sev-low { background: linear-gradient(135deg,#60a5fa,#2563eb); }
.pop-ic.sev-medium { background: linear-gradient(135deg,#fbbf24,#d97706); }
.pop-ic.sev-high { background: linear-gradient(135deg,#f87171,#dc2626); }
.pop-title { font-weight: 700; font-size: 14px; line-height: 1.1; }
.pop-sub { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .6px; }
.pop-reqs { display: flex; flex-direction: column; gap: 6px; }
.req-chip { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.req-chip .ric { width: 20px; text-align: center; }
.req-bar { flex: 1; height: 7px; background: rgba(255,255,255,.08); border-radius: 5px; overflow: hidden; }
.req-bar > span { display: block; height: 100%; border-radius: 5px; transition: width .3s ease; }
.req-val { font-variant-numeric: tabular-nums; font-size: 11px; color: var(--text-muted); min-width: 64px; text-align: right; }
.pop-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.pop-btn {
    flex: 1; min-width: 96px; border: none; cursor: pointer;
    padding: 8px 10px; border-radius: 9px; font-weight: 700; font-size: 12.5px;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    transition: filter .12s ease, transform .12s ease;
}
.pop-btn:hover { filter: brightness(1.08); }
.pop-btn:active { transform: translateY(1px); }
.pop-btn-primary { background: linear-gradient(135deg,#22c55e,#16a34a); color: #fff; }
.pop-btn-ghost { background: var(--bg-700); color: var(--text); border: 1px solid var(--line); }
.pop-note { font-size: 11px; color: var(--text-muted); }
.pop-resolving { font-size: 12px; color: #4ade80; font-weight: 700; display: flex; align-items: center; gap: 7px; }

/* Assign-from-list (revamped) */
.assign-list { display: flex; flex-direction: column; gap: 8px; max-height: 360px; overflow-y: auto; text-align: left; }
.assign-row {
    display: flex; align-items: center; gap: 10px; cursor: pointer;
    background: var(--bg-700); border: 1px solid var(--line); border-radius: 11px;
    padding: 9px 12px; transition: border-color .12s ease, transform .12s ease, background .12s ease;
}
.assign-row:hover { border-color: var(--primary); transform: translateX(2px); background: var(--bg-600); }
.assign-ic { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-size: 14px; flex: 0 0 auto; }
.assign-ic.t-ambulance { background: linear-gradient(135deg,#f87171,#dc2626); }
.assign-ic.t-police { background: linear-gradient(135deg,#60a5fa,#2563eb); }
.assign-ic.t-fire { background: linear-gradient(135deg,#fb923c,#ea580c); }
.assign-meta { flex: 1; min-width: 0; }

/* ============================================================
   HUD polish: streak, reputation warnings, cash pulse, wave button
   ============================================================ */
.stat-chip[hidden] { display: none !important; }

.stat-streak i { color: #fb923c; }
.stat-streak {
    border-color: rgba(251, 146, 60, .5);
    background: linear-gradient(135deg, rgba(251, 146, 60, .16), var(--bg-700));
}
.stat-streak.streak-hot {
    border-color: #fb923c;
    animation: streakGlow 1s ease-in-out infinite;
}
@keyframes streakGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(251, 146, 60, 0); }
    50% { box-shadow: 0 0 16px 2px rgba(251, 146, 60, .55); }
}

@keyframes cashPop {
    0% { transform: scale(1); }
    35% { transform: scale(1.11); border-color: var(--accent); box-shadow: 0 0 18px 2px rgba(34, 197, 94, .55); }
    100% { transform: scale(1); }
}
.stat-money.cash-pop { animation: cashPop .5s ease; }

.stat-rep.rep-warn {
    border-color: var(--warn);
    background: linear-gradient(135deg, rgba(245, 158, 11, .16), var(--bg-700));
}
.stat-rep.rep-critical {
    border-color: var(--danger);
    background: linear-gradient(135deg, rgba(239, 68, 68, .2), var(--bg-700));
    animation: repPulse 1s ease-in-out infinite;
}
@keyframes repPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
    50% { box-shadow: 0 0 16px 2px rgba(239, 68, 68, .6); }
}

/* Start Wave button — intermission / live states */
.btn-action-primary.is-intermission {
    background: linear-gradient(135deg, #0ea5e9, #2563eb);
    box-shadow: 0 8px 20px rgba(37, 99, 235, .35);
}
.btn-action-primary.is-intermission:hover { box-shadow: 0 10px 26px rgba(37, 99, 235, .5); }
.btn-action-primary.is-live {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    box-shadow: 0 8px 20px rgba(245, 158, 11, .35);
    cursor: default;
}

/* Subtle map attribution (kept for Esri terms, restyled to match the theme) */
.leaflet-control-attribution {
    background: rgba(15, 23, 42, .72) !important;
    color: var(--text-muted) !important;
    font-size: 10px !important;
    padding: 2px 8px !important;
    border-top-left-radius: 8px;
    backdrop-filter: blur(4px);
}
.leaflet-control-attribution a { color: var(--primary) !important; }
.assign-name { font-weight: 700; font-size: 13px; }
.assign-sub { font-size: 11px; color: var(--text-muted); }
.assign-go { background: linear-gradient(135deg,#22c55e,#16a34a); color: #fff; border: none; border-radius: 8px; padding: 7px 12px; font-weight: 700; font-size: 12px; cursor: pointer; }
.assign-empty { color: var(--text-muted); padding: 18px; text-align: center; }

/* Difficulty selector cards */
.diff-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-top: 6px; }
.diff-card {
    background: var(--bg-700); border: 2px solid var(--line); border-radius: 14px;
    padding: 16px 12px; cursor: pointer; text-align: center; transition: all .15s ease;
}
.diff-card:hover { transform: translateY(-4px); border-color: var(--primary); }
.diff-card i { font-size: 26px; margin-bottom: 8px; }
.diff-card.easy i { color: #4ade80; }
.diff-card.normal i { color: #38bdf8; }
.diff-card.hard i { color: #f87171; }
.diff-card h4 { margin: 0 0 4px; font-size: 16px; font-weight: 800; color: #fff; }
.diff-card p { margin: 0; font-size: 11.5px; color: var(--text-muted); }
@media (max-width: 560px) { .diff-grid { grid-template-columns: 1fr; } }

/* Hide the leaflet bottom-right corner if it lingers */
.leaflet-bottom.leaflet-right { display: none !important; }

/* Audio settings popover */
.audio-wrap { position: relative; display: inline-flex; }
.btn-icon.audio-off { color: #f87171; }
.audio-panel {
    position: absolute; top: calc(100% + 8px); right: 0;
    background: var(--bg-800); border: 1px solid var(--line);
    border-radius: 12px; box-shadow: var(--shadow);
    padding: 12px; width: 230px; z-index: 1400;
    display: flex; flex-direction: column; gap: 10px;
}
.audio-panel[hidden] { display: none; }
.audio-title { font-size: 10px; text-transform: uppercase; letter-spacing: 1.4px; color: var(--text-muted); }
.audio-row { display: flex; align-items: center; gap: 10px; }
.audio-toggle {
    width: 34px; height: 34px; flex: 0 0 auto; border-radius: 9px;
    border: 1px solid var(--line); background: var(--bg-700); color: var(--text);
    cursor: pointer; display: grid; place-items: center; font-size: 14px; transition: all .12s ease;
}
.audio-toggle:hover { background: var(--bg-600); color: #fff; }
.audio-toggle.off { color: var(--text-muted); opacity: .6; }
.audio-slider {
    -webkit-appearance: none; appearance: none; flex: 1; height: 6px;
    border-radius: 5px; background: var(--bg-600); outline: none; cursor: pointer;
}
.audio-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none; width: 15px; height: 15px;
    border-radius: 50%; background: linear-gradient(135deg,#38bdf8,#2563eb);
    cursor: pointer; border: 2px solid #fff;
}
.audio-slider::-moz-range-thumb {
    width: 15px; height: 15px; border-radius: 50%;
    background: #2563eb; cursor: pointer; border: 2px solid #fff;
}




