/* ============================================
   112 Dashboard v3 — CSS
   ============================================ */

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

/* ── Variables (light default) ── */
:root {
    --c-grip3: #922b21; --c-grip3-bg: #f9d4d0; --c-grip3-tx: #641e16;
    --c-grip2: #e74c3c; --c-grip2-bg: #fde8e6; --c-grip2-tx: #922b21;
    --c-grip1: #e74c3c; --c-grip1-bg: #fde8e6; --c-grip1-tx: #922b21;
    --c-esc-m: #888; --c-esc-m-bg: #f0f0f0; --c-esc-m-tx: #555;
    --c-esc-g: #c0700a; --c-esc-g-bg: #fef5e7; --c-esc-g-tx: #7a4d0f;
    --c-esc-zg: #b33025; --c-esc-zg-bg: #fde8e6; --c-esc-zg-tx: #7b2020;
    --c-esc: #b33025; --c-esc-bg: #fde8e6; --c-esc-tx: #7b2020;
    --c-bw: #e74c3c; --c-bw-bg: #fde8e6; --c-bw-tx: #922b21;
    --c-amb: #f39c12; --c-amb-bg: #fef5e7; --c-amb-tx: #935f06;
    --c-pol: #3498db; --c-pol-bg: #e8f4fd; --c-pol-tx: #1a5276;
    --c-life: #9b59b6; --c-life-bg: #f0e6f6; --c-life-tx: #6c3483;
    --c-knrm: #1abc9c; --c-knrm-bg: #e8f8f5; --c-knrm-tx: #0e6655;
    --c-vr: #27ae60; --c-vr-bg: #e9f7ef; --c-vr-tx: #1e8449;

    --bg: #fff; --bg2: #f8f7f4; --bg3: #f1efe8;
    --tx: #1a1a1a; --tx2: #6b6b6b; --tx3: #9b9b9b;
    --border: rgba(0,0,0,.1); --border2: rgba(0,0,0,.2);
    --r: 8px; --rlg: 12px;
    --sb-w: 370px; --fp-w: 300px; --dp-w: 380px;
    --tb-h: 52px;

    --marker-border: rgba(0,0,0,.3);
    --popup-bg: #fff; --popup-text: #1a1a1a; --popup-muted: #6b6b6b;
}

/* ── Dark mode ── */
[data-theme="dark"] {
    --bg: #1c1c1e; --bg2: #2c2c2e; --bg3: #111113;
    --tx: #f0f0f0; --tx2: #aaa; --tx3: #555;
    --border: rgba(255,255,255,.1); --border2: rgba(255,255,255,.22);
    --marker-border: rgba(255,255,255,.7);
    --popup-bg: #2c2c2e; --popup-text: #f0f0f0; --popup-muted: #aaa;
}

html, body {
    height: 100%;
    font-family: system-ui, 'Segoe UI', -apple-system, sans-serif;
    background: var(--bg3);
    color: var(--tx);
    overflow: hidden;
}

a { color: inherit; text-decoration: none; }

/* ============================================
   Layout — CSS grid: topbar + sidebar + map
   ============================================ */
.dash {
    display: grid;
    grid-template-columns: var(--sb-w) 1fr;
    grid-template-rows: var(--tb-h) 1fr;
    height: 100vh;
}

/* ============================================
   Topbar
   ============================================ */
.tb {
    grid-column: 1 / -1;
    background: var(--bg);
    border-bottom: .5px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 8px;
    z-index: 20;
}
.tb-brand {
    font-size: 14px; font-weight: 600; color: var(--tx);
    letter-spacing: -.015em; white-space: nowrap;
}
.tb-112 { color: var(--c-grip2); }
.tb-home {
    font-size: 11px; color: var(--tx2); white-space: nowrap;
    padding: 2px 8px; border-radius: 4px; border: .5px solid var(--border);
}
.tb-home:hover { color: var(--tx); border-color: var(--border2); }
.tb-counts { display: flex; gap: 4px; flex-shrink: 0; overflow-x: auto; }
.tbc {
    font-size: 10px; padding: 2px 7px; border-radius: 20px;
    font-weight: 500; white-space: nowrap;
}
.tbc[data-disc], .tbc[data-esc], .tbc-sub { cursor: pointer; transition: box-shadow .15s, opacity .15s; }
.tbc[data-disc]:hover, .tbc[data-esc]:hover, .tbc-sub:hover { opacity: .8; }
.tbc-active { box-shadow: inset 0 0 0 1.5px var(--tx); }
.tbc-sub { font-size: 9px; padding: 1px 5px; }
.tbc-sub.tbc-active { opacity: 1 !important; }
.bounds-btn {
    font-size: 10px; padding: 2px 8px; border-radius: 20px;
    font-weight: 500; white-space: nowrap; cursor: pointer;
    background: var(--bg2); color: var(--tx2); border: 1px solid var(--border);
    transition: background .15s, color .15s, border-color .15s;
}
.bounds-btn:hover { color: var(--tx); border-color: var(--border2); }
.bounds-btn.active { background: var(--tx); color: var(--bg); border-color: var(--tx); }
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }

/* Topbar search */
.tb-search {
    display: flex; align-items: center; gap: 4px; margin: 0;
}
.tb-search-input {
    padding: 5px 10px; font-size: 13px; border: 1px solid var(--border);
    border-radius: 6px; background: var(--bg2); color: var(--tx);
    outline: none; width: 260px; max-width: 40vw; font-family: inherit;
}
.tb-search-input:focus { border-color: var(--border2); }
.tb-search-input::placeholder { color: var(--tx3); }
.tb-search-close {
    background: none; border: none; color: var(--tx2); font-size: 18px;
    cursor: pointer; padding: 2px 4px; line-height: 1;
}
.tb-search-close:hover { color: var(--tx); }

/* WS status pill */
.ws-pill {
    font-size: 11px; padding: 3px 9px; border-radius: 20px;
    display: flex; align-items: center; gap: 4px; white-space: nowrap;
}
.ws-live { background: #dcfce7; color: #166534; }
.ws-disc { background: #fee2e2; color: #991b1b; }
.ws-conn { background: var(--c-grip1-bg); color: var(--c-grip1-tx); }
.ws-reload { background: #e0f2fe; color: #0c4a6e; }
.wsd {
    width: 6px; height: 6px; border-radius: 50%;
    background: currentColor; animation: bl 1.4s infinite;
}
@keyframes bl { 0%,100% { opacity: 1; } 50% { opacity: .2; } }

/* Icon buttons */
.icon-btn {
    background: none; border: .5px solid var(--border); border-radius: var(--r);
    padding: 4px 9px; font-size: 12px; color: var(--tx2); cursor: pointer;
    display: flex; align-items: center; gap: 4px; transition: all .15s; white-space: nowrap;
    font-family: inherit;
}
.icon-btn:hover { border-color: var(--border2); color: var(--tx); }
.icon-btn.on { background: var(--c-bw-bg); border-color: var(--c-bw); color: var(--c-bw-tx); }

/* Pro button (logged out / free plan) */
.pro-btn {
    font-size: 11px; padding: 4px 11px; border-radius: 20px;
    background: #185FA5; color: #E6F1FB; font-weight: 500;
    cursor: pointer; border: none; display: inline-block;
}
.pro-active { background: #0F6E56; }

/* User dropdown (logged in) */
.tb-user { position: relative; }
.tb-user-btn {
    display: flex; align-items: center; gap: 5px; padding: 2px 8px 2px 2px;
    border-radius: 16px; border: 1px solid var(--border); background: var(--bg2);
    color: var(--tx); font-size: 11px; font-weight: 500; cursor: pointer;
    font-family: inherit; transition: border-color .15s;
}
.tb-user-btn:hover { border-color: var(--border2); }
.tb-user-btn svg { color: var(--tx2); }
.tb-user-avatar {
    width: 20px; height: 20px; border-radius: 50%; background: var(--accent, #3498db);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 9px; font-weight: 700; flex-shrink: 0;
}
.tb-user-name { max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-dropdown {
    display: none; position: absolute; right: 0; top: calc(100% + 6px);
    background: var(--bg); border: 1px solid var(--br); border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.18); min-width: 180px; z-index: 9999;
    padding: 4px 0; animation: nvSlideIn .15s ease-out;
}
.tb-dropdown.open { display: block; }
.tb-dd-plan {
    padding: 8px 14px 6px; font-size: 10px; font-weight: 700; color: var(--tx2);
    text-transform: uppercase; letter-spacing: .05em;
}
.tb-dd-item {
    display: block; padding: 7px 14px; font-size: 12px; color: var(--tx);
    text-decoration: none; transition: background .08s; cursor: pointer;
    border: none; background: none; width: 100%; text-align: left; font-family: inherit;
}
.tb-dd-item:hover { background: var(--bg2); }
.tb-dd-div { height: 1px; background: var(--br); margin: 4px 0; }
.tb-dd-logout { color: var(--c-bw, #e74c3c); }

/* ============================================
   Sidebar
   ============================================ */
.sb {
    background: var(--bg);
    border-right: .5px solid var(--border);
    display: flex; flex-direction: column;
    overflow: hidden; min-height: 0;
}
.sb-hd {
    padding: 10px 12px 8px;
    border-bottom: .5px solid var(--border);
    display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.sb-hd-lbl { font-size: 13px; font-weight: 500; color: var(--tx); }
.sb-tot {
    font-size: 11px; padding: 1px 7px; border-radius: 20px;
    background: var(--bg2); color: var(--tx2);
}

/* Active filter chips bar */
.active-filters {
    padding: 6px 10px; background: var(--c-bw-bg);
    border-bottom: .5px solid var(--border);
    font-size: 11px; color: var(--c-bw-tx);
    display: none; align-items: center; gap: 6px; flex-wrap: wrap;
}
.active-filters.show { display: flex; }
.af-chip {
    background: rgba(255,255,255,.5); border-radius: 20px;
    padding: 1px 7px; display: flex; align-items: center; gap: 4px; cursor: pointer;
}
.af-chip:hover { background: rgba(255,255,255,.8); }

/* Alert list */
.al {
    flex: 1; overflow-y: auto; padding: 6px;
    display: flex; flex-direction: column; gap: 4px;
}
.al::-webkit-scrollbar { width: 3px; }
.al::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ============================================
   Alert Card
   ============================================ */
.ac {
    border-radius: var(--r); border: .5px solid var(--border);
    padding: 8px 10px 7px; cursor: pointer; background: var(--bg);
    transition: border-color .15s; position: relative;
}
.ac:hover { border-color: var(--border2); }
.ac.sel { border-color: #185FA5; border-width: 1.5px; }
.ac.grip2 { border-left: 3px solid var(--c-grip2); }
.ac.grip1 { border-left: 3px solid var(--c-grip1); }
.ac.esc   { border-left: 3px solid var(--c-esc); }
.ac.bw    { border-left: 3px solid var(--c-bw); }
.ac.amb   { border-left: 3px solid var(--c-amb); }
.ac.pol   { border-left: 3px solid var(--c-pol); }
.ac.life  { border-left: 3px solid var(--c-life); }
.ac.knrm  { border-left: 3px solid var(--c-knrm); }
.ac.vr    { border-left: 3px solid var(--c-vr); }
.ac.closed { opacity: .4; }
.ac.test  { opacity: .5; }
.ac.administrative { opacity: .5; border-left-style: dashed; }

@keyframes cardIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }
.ac.new-in { animation: cardIn .3s ease; }
@keyframes cardFlash { 0% { background: var(--c-grip1-bg); } 100% { background: var(--bg); } }
.ac.flash { animation: cardFlash .7s ease; }

/* Merge mode (admin) */
.merge-btn {
    margin-left: auto; font-size: 11px; padding: 2px 8px;
    border-radius: 4px; border: 1px solid var(--border);
    background: var(--bg2); color: var(--tx2); cursor: pointer;
    transition: all .15s;
}
.merge-btn:hover { border-color: var(--border2); color: var(--tx); }
.merge-btn.active { background: #185FA5; color: #fff; border-color: #185FA5; }
.merge-bar {
    display: none; padding: 8px 12px; gap: 8px; align-items: center;
    border-bottom: .5px solid var(--border); background: var(--bg2);
    flex-shrink: 0;
}
.merge-bar.active { display: flex; }
.merge-count { font-size: 12px; color: var(--tx2); flex: 1; }
.merge-confirm {
    font-size: 11px; padding: 3px 10px; border-radius: 4px; border: none;
    background: #185FA5; color: #fff; cursor: pointer; font-weight: 500;
}
.merge-confirm:disabled { opacity: .4; cursor: default; }
.merge-confirm:not(:disabled):hover { background: #1a6fc2; }
.merge-cancel {
    font-size: 11px; padding: 3px 10px; border-radius: 4px; border: 1px solid var(--border);
    background: var(--bg); color: var(--tx2); cursor: pointer;
}
.merge-cancel:hover { border-color: var(--border2); color: var(--tx); }
.sb.merge-mode .ac { cursor: crosshair; }
.sb.merge-mode .ac:hover { border-color: #185FA5; }
.ac.merge-sel {
    border-color: #185FA5 !important; border-width: 1.5px;
    background: rgba(24, 95, 165, .08);
}

/* ===== Timeline ===== */
.tl-bar {
    position: absolute; bottom: 36px; left: 50%; transform: translateX(-50%);
    z-index: 800; display: flex; align-items: center; gap: 8px;
    padding: 6px 12px; border-radius: 8px;
    background: var(--bg); border: .5px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,.2); min-width: 300px; max-width: 500px;
}
.tl-toggle {
    background: none; border: none; color: var(--tx); cursor: pointer;
    font-size: 14px; padding: 2px 6px; border-radius: 4px; line-height: 1;
}
.tl-toggle:hover { background: var(--bg2); }
.tl-slider { flex: 1; accent-color: #185FA5; cursor: pointer; }
.tl-label { font-size: 11px; color: var(--tx2); white-space: nowrap; min-width: 40px; text-align: center; }
.ac.tl-dimmed { opacity: .25; }
#tlToggle.active { background: #185FA5; color: #fff; }

/* Generic badge (used in detail panel) */
.badge {
    font-size: 10px; font-weight: 500; padding: 1px 5px;
    border-radius: 3px; white-space: nowrap; display: inline-block;
}
.b-grip2 { background: var(--c-grip2-bg); color: var(--c-grip2-tx); }
.b-grip1 { background: var(--c-grip1-bg); color: var(--c-grip1-tx); }
.b-over  { background: var(--c-vr-bg); color: var(--c-vr-tx); }

.ac-top { display: flex; align-items: flex-start; gap: 6px; }
.badges { display: flex; gap: 0; flex-shrink: 0; margin-top: 1px; }

/* Discipline letter badge */
.disc-letter {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 0;
    font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.badges > :first-child { border-radius: 5px 0 0 5px; }
.badges > :last-child { border-radius: 0 5px 5px 0; }
.badges > :only-child { border-radius: 5px; }
.badges > :first-child:last-child { border-radius: 5px; }
.disc-letter.b-bw   { background: var(--c-bw); }
.disc-letter.b-amb  { background: var(--c-amb); }
.disc-letter.b-pol  { background: var(--c-pol); }
.disc-letter.b-life { background: var(--c-life); }
.disc-letter.b-knrm { background: var(--c-knrm); }
.disc-letter.b-vr   { background: var(--c-vr); }
.disc-letter.b-over { background: #888; }

/* Priority code badge (A1, P2, etc.) — same size as disc-letter */
.prio-badge {
    display: inline-flex; align-items: center; justify-content: center;
    height: 22px; padding: 0 5px; border-radius: 0;
    font-size: 10px; font-weight: 700; flex-shrink: 0; white-space: nowrap;
}
.prio-badge.b-bw    { background: var(--c-bw-bg); color: var(--c-bw-tx); }
.prio-badge.b-amb   { background: var(--c-amb-bg); color: var(--c-amb-tx); }
.prio-badge.b-pol   { background: var(--c-pol-bg); color: var(--c-pol-tx); }
.prio-badge.b-grip2 { background: var(--c-grip2-bg); color: var(--c-grip2-tx); }
.prio-badge.b-over  { background: var(--c-vr-bg); color: var(--c-vr-tx); }

/* Card text area */
.ac-text { min-width: 0; flex: 1; }
.ac-body {
    font-size: 12px; font-weight: 500; color: var(--tx);
    line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ac-type {
    font-size: 11px; color: var(--tx2); margin-top: 1px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ac-time { font-size: 11px; color: var(--tx3); flex-shrink: 0; margin-left: 4px; white-space: nowrap; align-self: flex-start; text-align: right; line-height: 1.4; }
.ac-updated { display: block; color: var(--tx2); font-weight: 500; }
.ac-meta {
    display: flex; align-items: center; gap: 5px;
    font-size: 11px; color: var(--tx2); margin-top: 3px; flex-wrap: wrap;
}
.ac-city { margin-left: auto; }
.ac-media-icon {
    display: inline-flex; align-items: center; color: #185FA5; opacity: .7;
}

/* Hover / selected state: show full body text */
.ac.hover, .ac.sel { border-color: var(--border2); background: var(--bg2); }
.ac.hover .ac-body, .ac.sel .ac-body { white-space: normal; overflow: visible; }
.ac.hover .ac-type, .ac.sel .ac-type { white-space: normal; overflow: visible; }

/* Marker highlight ring (pulse) */
@keyframes highlightPulse { 0% { box-shadow: 0 0 0 4px currentColor; } 50% { box-shadow: 0 0 0 7px currentColor; } 100% { box-shadow: 0 0 0 4px currentColor; } }
.pin-highlight { animation: highlightPulse 1.2s ease infinite; opacity: 1 !important; }

/* ============================================
   Map wrapper
   ============================================ */
.mw { position: relative; overflow: hidden; background: #d4dde6; }
#map { width: 100%; height: 100%; z-index: 1; }
.leaflet-container { background: var(--bg3) !important; }

/* Map controls — top-left (timeline only) */
#mapControls {
    position: absolute; top: 10px; left: 10px; z-index: 5;
    display: flex; gap: 6px; align-items: center;
}
.mc-btn {
    background: var(--bg); border: .5px solid var(--border); color: var(--tx2);
    padding: 5px 10px; font-size: 11px; cursor: pointer; transition: all .15s;
    font-family: inherit; white-space: nowrap; border-radius: 6px;
}
.mc-btn:hover { color: var(--tx); border-color: var(--border2); }
.mc-btn.active { background: var(--bg2); color: var(--tx); border-color: var(--border2); }

/* Right-side controls: location + zoom (Google Maps style) */
.mc-right {
    position: absolute; bottom: 80px; right: 10px; z-index: 5;
    display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.mw.dp-open .mc-right { right: calc(var(--dp-w) + 10px); transition: right .22s ease; }

/* Bottom bar: tile thumbnails + NL zoom */
.mc-bottom {
    position: absolute; bottom: 10px; right: 10px; z-index: 5;
    display: flex; align-items: flex-end; gap: 8px;
}
.mw.dp-open .mc-bottom { right: calc(var(--dp-w) + 10px); transition: right .22s ease; }

/* Tile thumbnail strip — collapsed by default, expands on hover/click */
.mc-tile-strip {
    display: flex; gap: 4px; background: var(--bg); border-radius: 8px;
    padding: 4px; box-shadow: 0 1px 4px rgba(0,0,0,.15);
    border: .5px solid var(--border);
}
.mc-tile-thumb {
    width: 52px; display: flex; flex-direction: column; align-items: center; gap: 2px;
    background: none; border: 2px solid transparent; border-radius: 6px;
    cursor: pointer; padding: 2px; transition: border-color .15s; font-family: inherit;
}
.mc-tile-thumb:hover { border-color: var(--border2); }
.mc-tile-thumb.active { border-color: #185FA5; }
.mc-tile-img {
    width: 44px; height: 32px; border-radius: 4px;
    background-size: cover; background-position: center;
    display: block;
}
.mc-tile-lbl { font-size: 9px; color: var(--tx2); font-weight: 500; }
.mc-tile-thumb.active .mc-tile-lbl { color: #185FA5; font-weight: 600; }
/* Collapsed state: hide inactive thumbs */
.mc-tile-strip:not(.expanded) .mc-tile-thumb:not(.active) {
    display: none;
}
.mc-tile-strip.expanded .mc-tile-thumb { display: flex; }

/* Zoom buttons */
.mc-zoom {
    display: flex; flex-direction: column; border-radius: 8px; overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.mc-zbtn {
    width: 36px; height: 36px; background: var(--bg); border: .5px solid var(--border);
    color: var(--tx); font-size: 18px; cursor: pointer; transition: background .15s;
    display: flex; align-items: center; justify-content: center; font-family: inherit;
    line-height: 1;
}
.mc-zbtn:first-child { border-bottom: none; }
.mc-zbtn:hover { background: var(--bg2); }

/* Round buttons (location, zoom NL) */
.mc-round {
    width: 36px; height: 36px; border-radius: 50%; background: var(--bg);
    border: .5px solid var(--border); color: var(--tx2); cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    box-shadow: 0 1px 4px rgba(0,0,0,.15); transition: all .15s; flex-shrink: 0;
}
.mc-round:hover { color: var(--tx); background: var(--bg2); }
.mc-round.active { color: #185FA5; }
.mc-zbtn-nl {
    border-radius: 8px; border: .5px solid var(--border);
    box-shadow: 0 1px 4px rgba(0,0,0,.15); margin-top: 8px;
}

/* Bottom-left layers button */
.mc-layers {
    position: absolute; bottom: 10px; left: 128px; z-index: 4;
}
.mc-layer-btn {
    background: var(--bg); border: .5px solid var(--border); color: var(--tx2);
    padding: 5px 10px; font-size: 11px; cursor: pointer; border-radius: 6px;
    display: flex; align-items: center; gap: 4px; font-family: inherit;
    box-shadow: 0 1px 4px rgba(0,0,0,.1); transition: all .15s;
}
.mc-layer-btn:hover { color: var(--tx); border-color: var(--border2); }
.mc-layer-menu {
    display: none; position: absolute; bottom: 32px; left: 0;
    background: var(--bg); border: .5px solid var(--border);
    border-radius: 8px; padding: 6px 8px; box-shadow: 0 2px 12px rgba(0,0,0,.2);
    white-space: nowrap; min-width: 160px;
}
.mc-layer-menu.open { display: flex; flex-direction: column; gap: 4px; }
.mc-layer-item {
    display: flex; align-items: center; gap: 6px; font-size: 11px;
    color: var(--tx2); cursor: pointer; padding: 3px 4px; border-radius: 4px;
}
.mc-layer-item:hover { background: var(--bg2); color: var(--tx); }
.mc-layer-item input { accent-color: #185FA5; }
.mc-layer-disabled { opacity: .5; cursor: default; }
.mc-layer-disabled:hover { background: none; color: var(--tx2); }
.mc-soon { font-size: 9px; color: var(--tx3); font-style: italic; }
.mc-layer-group-label {
    font-size: 9px; font-weight: 600; color: var(--tx3); text-transform: uppercase;
    letter-spacing: .04em; padding: 4px 4px 0; margin-top: 2px;
}
.mc-layer-group-label:first-child { margin-top: 0; }
.mc-layer-item img { border-radius: 3px; vertical-align: middle; }

/* Map legend */
.map-legend {
    position: absolute; bottom: 10px; left: 10px;
    background: var(--bg); border: .5px solid var(--border);
    border-radius: var(--r); padding: 8px 11px;
    display: flex; flex-direction: column; gap: 4px; z-index: 5;
    max-height: calc(100% - 60px); overflow-y: auto;
}
.leg-toggle {
    display: flex; align-items: center; gap: 4px; cursor: pointer;
    font-size: 11px; font-weight: 600; color: var(--tx2); user-select: none;
    padding: 2px 0;
}
.leg-toggle:hover { color: var(--tx); }
.leg-chevron { transition: transform .2s; flex-shrink: 0; }
.map-legend.collapsed .leg-chevron { transform: rotate(-90deg); }
.map-legend.collapsed .leg-content { display: none; }
.map-legend.collapsed { padding: 6px 11px; }
.leg-section { font-size: 9px; font-weight: 600; color: var(--tx3); text-transform: uppercase; letter-spacing: .04em; margin-top: 4px; }
.leg-section:first-child { margin-top: 0; }
.li { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--tx2); }
.ld { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; background: var(--tx3); position: relative; display: flex; align-items: center; justify-content: center; }
.ld-emoji { display: none; font-size: 7px; line-height: 1; }
.legend-icons .ld-disc { width: 16px; height: 16px; border: 1.5px solid rgba(255,255,255,.9); }
.legend-icons .ld-emoji { display: block; }
.ld-sm { width: 7px; height: 7px; }
.ld-md { width: 9px; height: 9px; background: var(--c-esc-m); }
.ld-lg { width: 11px; height: 11px; background: var(--c-esc-g); }
.ld-xl { width: 13px; height: 13px; background: var(--c-esc-zg); }
.ld-grip1 { width: 15px; height: 15px; background: var(--c-grip1); }
.ld-grip2 { width: 17px; height: 17px; background: var(--c-grip2); }
.ld-grip3 { width: 19px; height: 19px; background: var(--c-grip3); }

/* Timestamp box (inline in mapControls) */
.ts-box {
    background: var(--bg); border: .5px solid var(--border);
    border-radius: var(--r); padding: 4px 9px;
    font-size: 11px; color: var(--tx2);
}

/* VR tooltip */
.vr-tooltip { background: var(--bg); color: var(--tx); border: .5px solid var(--border); font-size: 11px; padding: 3px 7px; border-radius: 4px; box-shadow: 0 2px 6px rgba(0,0,0,.2); }

/* Dark popup (Leaflet) */
.dark-popup .leaflet-popup-content-wrapper { background: var(--popup-bg); color: var(--popup-text); border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,.3); }
.dark-popup .leaflet-popup-tip { background: var(--popup-bg); }

/* Marker pulse */
@keyframes markerPulse { 0% { transform: scale(1); opacity: .8; } 100% { transform: scale(3); opacity: 0; } }
.marker-pulse {
    position: absolute; width: 12px; height: 12px; border-radius: 50%;
    top: 50%; left: 50%; transform: translate(-50%, -50%);
}
.marker-pulse::after {
    content: ''; position: absolute; width: 100%; height: 100%;
    border-radius: 50%; border: 2px solid currentColor;
    animation: markerPulse 1.5s ease-out infinite;
}
.pin-dot { position: relative; display: flex; align-items: center; justify-content: center; }
.station-icon { background: none; border: none; filter: drop-shadow(0 1px 2px rgba(0,0,0,.25)); }
/* NL-Alert */
.nlalert-pin {
    width: 44px; height: 44px; border-radius: 50%;
    background: #fff; border: 3px solid #dc2626;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 0 20px rgba(220,38,38,.5), 0 4px 12px rgba(0,0,0,.3);
    animation: nlalertPulse 2s ease-in-out infinite;
}
.nlalert-pin img { border-radius: 50%; }
@keyframes nlalertPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(220,38,38,.5), 0 4px 12px rgba(0,0,0,.3); transform: scale(1); }
    50% { box-shadow: 0 0 32px rgba(220,38,38,.8), 0 4px 16px rgba(0,0,0,.4); transform: scale(1.06); }
}
.nlalert-area { animation: nlalertAreaPulse 3s ease-in-out infinite; }
@keyframes nlalertAreaPulse { 0%, 100% { fill-opacity: 0.12; } 50% { fill-opacity: 0.22; } }
.mc-nl-count {
    background: #dc2626; color: #fff; font-size: 10px; font-weight: 700;
    padding: 1px 5px; border-radius: 8px; margin-left: 4px;
}

.inc-station-pin {
    width: 28px; height: 28px; border-radius: 50%; background: var(--bg2, #fff);
    border: 2px solid var(--br2, rgba(0,0,0,.15)); display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,.25); animation: stationFadeIn .3s ease-out;
}
@keyframes stationFadeIn { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.pin-grip {
    animation: gripPulse 2s ease-in-out infinite;
    box-shadow: 0 0 10px currentColor, 0 0 3px rgba(0,0,0,.5);
}
@keyframes gripPulse {
    0%, 100% { box-shadow: 0 0 10px currentColor, 0 0 3px rgba(0,0,0,.5); }
    50% { box-shadow: 0 0 20px currentColor, 0 0 35px currentColor, 0 0 3px rgba(0,0,0,.5); }
}

/* ============================================
   Event Log Toasts (overlay on map)
   ============================================ */
.ev-log {
    position: absolute; top: 10px; right: 10px; max-width: 230px;
    display: flex; flex-direction: column; gap: 3px;
    pointer-events: none; z-index: 5;
    transition: right .22s ease;
}
.mw.dp-open .ev-log { right: calc(var(--dp-w) + 10px); }
.ev-item {
    background: var(--bg); border: .5px solid var(--border);
    border-radius: var(--r); padding: 5px 10px;
    font-size: 11px; color: var(--tx2);
    animation: evIn .25s ease, evOut .3s 2.8s ease forwards;
}
@keyframes evIn { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: translateX(0); } }
@keyframes evOut { to { opacity: 0; transform: translateX(6px); } }

/* ============================================
   Filter Panel (slides from left inside map)
   ============================================ */
.fp {
    position: absolute; top: 0; left: 0;
    width: var(--fp-w); height: 100%;
    background: var(--bg); border-right: .5px solid var(--border);
    display: flex; flex-direction: column;
    z-index: 30; transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,.08);
}
.fp.open { transform: translateX(0); }
.fp-hd {
    padding: 14px 14px 12px; border-bottom: .5px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.fp-title { font-size: 13px; font-weight: 500; color: var(--tx); }
.fp-close {
    background: none; border: none; cursor: pointer; color: var(--tx2);
    font-size: 16px; padding: 0 2px;
}
.fp-body { flex: 1; overflow-y: auto; padding: 12px 14px; }
.fp-body::-webkit-scrollbar { width: 3px; }
.fp-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.fp-footer {
    padding: 10px 14px; border-top: .5px solid var(--border);
    display: flex; gap: 8px; flex-shrink: 0;
}
.fp-apply {
    flex: 1; padding: 8px; background: #185FA5; color: #E6F1FB;
    border: none; border-radius: var(--r); font-size: 12px; font-weight: 500;
    cursor: pointer; font-family: inherit;
}
.fp-reset {
    padding: 8px 12px; background: none; border: .5px solid var(--border);
    border-radius: var(--r); font-size: 12px; color: var(--tx2);
    cursor: pointer; font-family: inherit;
}

.fg { margin-bottom: 16px; }
.fg-label {
    font-size: 10px; font-weight: 500; color: var(--tx2);
    text-transform: uppercase; letter-spacing: .05em; margin-bottom: 7px; display: block;
}

/* Chips */
.chip-grid { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
    font-size: 11px; padding: 3px 10px; border-radius: 20px;
    border: .5px solid var(--border); background: var(--bg2); color: var(--tx2);
    cursor: pointer; transition: all .15s; user-select: none;
}
.chip.on { border-color: currentColor; font-weight: 500; }
.chip.bw.on     { background: var(--c-bw-bg);    color: var(--c-bw-tx); }
.chip.amb.on    { background: var(--c-amb-bg);   color: var(--c-amb-tx); }
.chip.pol.on    { background: var(--c-pol-bg);   color: var(--c-pol-tx); }
.chip.life.on   { background: var(--c-life-bg);  color: var(--c-life-tx); }
.chip.knrm.on   { background: var(--c-knrm-bg);  color: var(--c-knrm-tx); }
.chip.vr.on     { background: var(--c-vr-bg);    color: var(--c-vr-tx); }
.chip.esc.on    { background: var(--c-esc-bg);   color: var(--c-esc-tx); }
.chip.grip1.on  { background: var(--c-grip1-bg); color: var(--c-grip1-tx); }
.chip.grip2.on  { background: var(--c-grip2-bg); color: var(--c-grip2-tx); }
.chip.neutral.on { background: #1a1a1a; color: #fff; }

.fp-select {
    width: 100%; padding: 7px 10px; border: .5px solid var(--border);
    border-radius: var(--r); background: var(--bg); color: var(--tx);
    font-size: 12px; outline: none; cursor: pointer; font-family: inherit;
}
.fp-input {
    width: 100%; padding: 6px 8px; border: .5px solid var(--border);
    border-radius: var(--r); background: var(--bg); color: var(--tx);
    font-size: 12px; font-family: inherit;
}
.fp-range { width: 100%; accent-color: #185FA5; }
.fp-toggle {
    display: flex; align-items: center; gap: 6px;
    font-size: 11px; color: var(--tx2); cursor: pointer;
    margin-top: 6px;
}
.fp-toggle input[type="checkbox"] { accent-color: #185FA5; }

.loc-row { display: flex; gap: 6px; margin-top: 6px; }
.loc-btn {
    flex: 1; padding: 7px; border: .5px solid var(--border);
    border-radius: var(--r); font-size: 11px; color: var(--tx2);
    background: var(--bg2); cursor: pointer; text-align: center;
    transition: all .15s; font-family: inherit;
}
.loc-btn:hover { border-color: var(--border2); color: var(--tx); }
.loc-btn.on { background: var(--c-bw-bg); border-color: var(--c-bw); color: var(--c-bw-tx); }
.loc-coords {
    font-size: 11px; color: var(--tx2); margin-top: 5px;
    font-family: monospace; background: var(--bg2); padding: 4px 8px; border-radius: var(--r);
}

/* ============================================
   Detail Panel (slides from right inside map)
   ============================================ */
.dp {
    position: absolute; top: 0; right: 0;
    width: var(--dp-w); height: 100%;
    background: var(--bg); border-left: .5px solid var(--border);
    display: flex; flex-direction: column; overflow: hidden;
    transform: translateX(100%); transition: transform .22s ease; z-index: 10;
}
.dp.open { transform: translateX(0); }

/* Shift map overlays left when detail panel is open */
.mw.dp-open .leaflet-top.leaflet-right { right: var(--dp-w); transition: right .22s ease; }
.dp-hd {
    padding: 11px 13px; border-bottom: .5px solid var(--border);
    display: flex; align-items: flex-start; gap: 8px; flex-shrink: 0;
}
.dp-info { flex: 1; min-width: 0; }
.dp-title-row { display: flex; align-items: center; gap: 6px; }
.dp-title { font-size: 13px; font-weight: 500; color: var(--tx); }
.dp-sub { font-size: 11px; color: var(--tx2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.dp-link { color: var(--tx2); opacity: .5; transition: opacity .15s; flex-shrink: 0; line-height: 1; }
.dp-link:hover { opacity: 1; color: var(--accent, #4a9eff); }
.dp-close {
    background: none; border: none; cursor: pointer; color: var(--tx2);
    font-size: 14px; padding: 1px 4px; flex-shrink: 0;
}

/* Tabs */
.dp-tabs {
    display: flex; border-bottom: .5px solid var(--border); flex-shrink: 0;
}
.dp-tab {
    flex: 1; padding: 8px 4px; font-size: 11px; font-weight: 500;
    color: var(--tx2); cursor: pointer; text-align: center;
    border-bottom: 2px solid transparent; transition: all .15s;
}
.dp-tab.on { color: #185FA5; border-bottom-color: #185FA5; }
.tab-badge {
    display: inline-block; min-width: 15px; height: 15px; line-height: 15px;
    border-radius: 8px; background: #185FA5; color: #fff;
    font-size: 9px; font-weight: 600; text-align: center;
    padding: 0 4px; margin-left: 3px; vertical-align: middle;
}

.dp-body {
    flex: 1; overflow-y: auto; padding: 12px 13px; min-height: 0;
}
.dp-body::-webkit-scrollbar { width: 3px; }
.dp-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Detail shared elements */
.sl {
    font-size: 10px; font-weight: 500; color: var(--tx2);
    text-transform: uppercase; letter-spacing: .05em;
    margin-top: 14px; margin-bottom: 7px;
}
.sl:first-child { margin-top: 0; }
.sl-sub { font-weight: 400; opacity: .6; text-transform: none; letter-spacing: 0; margin-left: 4px; }
.sl-badge {
    display: inline-block; font-size: 10px; font-weight: 600; color: var(--tx2);
    background: var(--bg-alt, var(--border)); padding: 1px 5px; border-radius: 8px;
    margin-left: 4px; text-transform: none; letter-spacing: 0; vertical-align: middle;
}

/* Escalation bar */
.esc-bar { display: flex; gap: 2px; align-items: center; margin-bottom: 12px; }
.es { flex: 1; height: 5px; border-radius: 2px; background: var(--bg2); transition: background .4s; }
.es.l1 { background: #63913a; }
.es.l2 { background: #BA7517; }
.es.l3 { background: #A32D2D; }
.esc-lbl { font-size: 11px; color: var(--tx2); margin-left: 6px; white-space: nowrap; }

/* Timeline */
.tl { position: relative; padding-left: 0; }
.tl-ln { position: absolute; left: 3px; top: 6px; bottom: 6px; width: 1px; background: var(--border); }
.te { position: relative; margin-bottom: 10px; display: flex; gap: 10px; }
.td {
    position: relative; left: auto; top: auto; flex-shrink: 0; margin-top: 4px;
    width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid;
}
.td.r { background: var(--c-grip2-bg); border-color: var(--c-grip2); }
.td.o { background: var(--c-grip1-bg); border-color: var(--c-grip1); }
.td.b { background: var(--c-bw-bg); border-color: var(--c-bw); }
.td.g { background: #D3D1C7; border-color: #888780; }
.tc { flex: 1; min-width: 0; }
.tt { font-size: 13px; font-weight: 500; color: var(--tx); }
.tl-vlink { color: inherit; text-decoration: underline; text-decoration-color: var(--br2, rgba(0,0,0,.2)); text-underline-offset: 2px; font-weight: 600; transition: text-decoration-color .15s; }
.tl-vlink:hover { text-decoration-color: var(--c-bw); color: var(--c-bw); }
.ts2 { font-size: 11px; color: var(--tx2); margin-bottom: 2px; }
.tl-units { font-size: 12px; color: var(--tx2); margin-top: 4px; line-height: 1.4; display: none; }
.show-capcodes .tl-units { display: block; }
.tl-cc-toggle { background: var(--bg2, #f0f0f0); border: 1px solid var(--bd, #ddd); border-radius: 6px; padding: 2px 8px; font-size: 11px; color: var(--tx2, #666); cursor: pointer; line-height: 1.4; }
.tl-cc-toggle.on { background: #3182ce; color: #fff; border-color: #3182ce; }
.tl-esc {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 12px; border-radius: 6px; font-size: 12px; font-weight: 600;
    margin: 4px 0 6px 0; letter-spacing: .02em;
}
.tl-esc-up { background: rgba(231,76,60,.1); color: #e74c3c; border: 1px solid rgba(231,76,60,.25); }
.tl-esc-grip { background: rgba(142,68,173,.1); color: #8e44ad; border: 1px solid rgba(142,68,173,.25); }
.tl-esc-down { background: rgba(39,174,96,.1); color: #27ae60; border: 1px solid rgba(39,174,96,.25); }

/* Info rows */
.info-row {
    background: var(--bg2); border-radius: var(--r); padding: 6px 10px;
    font-size: 12px; color: var(--tx2); display: flex; gap: 8px;
    align-items: flex-start; margin-bottom: 5px;
}
.info-row b { color: var(--tx); font-weight: 500; min-width: 90px; flex-shrink: 0; }

/* Vehicle list */
.vl { display: flex; flex-direction: column; gap: 4px; }
.vi {
    background: var(--bg2); border-radius: var(--r); padding: 6px 10px;
    display: flex; align-items: flex-start; gap: 8px;
}
.vi-main { flex: 1; min-width: 0; }
.vi-hd {
    display: flex; align-items: center; justify-content: space-between; gap: 6px; cursor: pointer;
}
.vi-id { font-size: 11px; color: var(--tx2); margin-right: 4px; }
.vi-cam { color: var(--tx2); margin-right: 3px; vertical-align: -1px; opacity: .6; }
.vi-station .vi-hd { cursor: default; }
.vi-station .sl-badge { font-size: 9px; background: var(--bg-alt, var(--border)); color: var(--tx2); }
.vi-chev {
    width: 12px; height: 12px; flex-shrink: 0; color: var(--tx2);
    transition: transform .15s;
}
.vi.expanded .vi-chev { transform: rotate(180deg); }
.vc { font-size: 12px; font-weight: 500; color: var(--tx); }
.vt2 { font-size: 11px; color: var(--tx2); }
.vi-details {
    display: none; margin-top: 6px; padding-top: 6px;
    border-top: 1px solid var(--br);
}
.vi.expanded .vi-details { display: block; }
.vi-dr { display: flex; justify-content: space-between; font-size: 11px; padding: 2px 0; }
.vi-dl { color: var(--tx2); }
.vi-link { font-size: 11px; color: var(--accent); text-decoration: none; }
.vi-link:hover { text-decoration: underline; }
.vs {
    font-size: 10px; padding: 1px 6px; border-radius: 3px;
    flex-shrink: 0; margin-top: 2px;
}
.vs-bw   { background: var(--c-bw-bg); color: var(--c-bw-tx); }
.vs-amb  { background: var(--c-amb-bg); color: var(--c-amb-tx); }
.vs-pol  { background: var(--c-pol-bg); color: var(--c-pol-tx); }
.vs-life { background: var(--c-life-bg); color: var(--c-life-tx); }
.vs-knrm { background: var(--c-knrm-bg); color: var(--c-knrm-tx); }
.vs-vr   { background: var(--c-vr-bg); color: var(--c-vr-tx); }

/* Nearest vehicles button + overlay */
.nv-btn {
    display: flex; align-items: center; justify-content: center; gap: 7px; width: 100%;
    margin-top: 16px; padding: 10px 14px; border-radius: 8px;
    background: var(--accent, #3498db); border: none;
    color: #fff; font-size: 12px; font-weight: 600; cursor: pointer;
    transition: opacity .15s;
}
.nv-btn:hover { opacity: .85; }
.nv-btn svg { color: #fff; flex-shrink: 0; }
.nv-overlay {
    display: none; position: fixed; inset: 0; z-index: 9999;
    background: rgba(0,0,0,.45); backdrop-filter: blur(3px);
    align-items: center; justify-content: center;
}
.nv-overlay.open { display: flex; }
.nv-panel {
    background: var(--bg); border-radius: 14px; width: 480px; max-width: 94vw;
    max-height: 85vh; display: flex; flex-direction: column;
    box-shadow: 0 12px 48px rgba(0,0,0,.25); animation: nvSlideIn .2s ease-out;
}
@keyframes nvSlideIn { from { transform: translateY(16px); opacity: 0; } }
.nv-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px 12px;
}
.nv-header h3 { font-size: 15px; font-weight: 700; margin: 0; }
.nv-close {
    background: none; border: none; font-size: 22px; color: var(--tx2);
    cursor: pointer; line-height: 1; padding: 2px 4px; border-radius: 6px;
}
.nv-close:hover { background: var(--bg2); color: var(--tx); }
.nv-filters {
    display: flex; gap: 6px; padding: 0 20px 12px; flex-wrap: wrap;
    border-bottom: 1px solid var(--br);
}
.nv-pill {
    padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 500;
    background: var(--bg2); border: 1px solid var(--br); color: var(--tx2);
    cursor: pointer; white-space: nowrap; transition: all .12s;
}
.nv-pill:hover { border-color: var(--tx2); }
.nv-pill.on { background: var(--tx); color: var(--bg); border-color: var(--tx); }
.nv-body { overflow-y: auto; padding: 4px 0; }
.nv-loading { padding: 40px 16px; text-align: center; color: var(--tx2); font-size: 12px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.nv-spinner { width: 24px; height: 24px; border: 2.5px solid var(--br); border-top-color: var(--tx2); border-radius: 50%; animation: nvSpin .6s linear infinite; }
@keyframes nvSpin { to { transform: rotate(360deg); } }
.nv-empty { padding: 32px 16px; text-align: center; color: var(--tx2); font-size: 12px; }
.nv-row {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 20px; transition: background .08s;
}
.nv-row:hover { background: var(--bg2); }
.nv-row .vs { width: 22px; height: 22px; font-size: 10px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border-radius: 4px; }
.nv-info { flex: 1; min-width: 0; }
.nv-type { display: block; font-size: 12px; font-weight: 600; color: var(--tx); line-height: 1.3; }
.nv-desc { display: block; font-size: 11px; color: var(--tx2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nv-dist { text-align: right; flex-shrink: 0; min-width: 50px; }
.nv-km { font-size: 13px; font-weight: 700; color: var(--tx); line-height: 1.3; }
.nv-min { font-size: 10px; color: var(--tx2); }
.nv-row-first { background: var(--bg2); }

/* Weather bar */
.wx-bar {
    display: flex; flex-wrap: wrap; gap: 4px 12px;
    padding: 6px 0; font-size: 12px; color: var(--tx);
}
.wx-item { white-space: nowrap; }
.wx-warn {
    font-size: 11px; font-weight: 600; color: #e67e22;
    padding: 4px 0;
}

/* Kladblok notes */
.kb-list { display: flex; flex-direction: column; }
.kb-note {
    display: flex; gap: 8px; padding: 8px 0;
    border-bottom: 1px solid var(--border2, rgba(0,0,0,.1)); font-size: 12px;
}
.kb-note:last-child { border-bottom: none; padding-bottom: 0; }
.kb-time { color: var(--tx2); font-size: 11px; flex-shrink: 0; font-variant-numeric: tabular-nums; min-width: 52px; }
.kb-body { color: var(--tx); line-height: 1.4; }

/* Lock screen (Pro gating) */
.lock {
    background: var(--bg2); border-radius: var(--r);
    border: .5px dashed var(--border2); padding: 18px 14px;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    text-align: center; margin-top: 8px;
}
.lock-t { font-size: 13px; font-weight: 500; color: var(--tx); }
.lock-s { font-size: 12px; color: var(--tx2); line-height: 1.5; max-width: 200px; }
.upg {
    font-size: 12px; padding: 7px 18px; border-radius: var(--r);
    background: #185FA5; color: #E6F1FB; border: none; cursor: pointer;
    font-weight: 500; margin-top: 4px; text-decoration: none; display: inline-block;
}

.empty-state { padding: 24px 14px; text-align: center; font-size: 13px; color: var(--tx2); }

/* Media tab */
.media-photos {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 6px; margin-bottom: 10px;
}
.media-photo-thumb {
    position: relative; border-radius: var(--r); overflow: hidden;
    aspect-ratio: 1; cursor: pointer; background: var(--bg2);
    border: .5px solid var(--border);
}
.media-photo-thumb img {
    width: 100%; height: 100%; object-fit: cover;
    transition: transform .2s;
}
.media-photo-thumb:hover img { transform: scale(1.05); }
.media-photo-cap {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: rgba(0,0,0,.6); color: #fff; font-size: 10px;
    padding: 2px 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.media-link-item {
    display: flex; align-items: center; gap: 6px;
    background: var(--bg2); border-radius: var(--r); padding: 7px 10px;
    font-size: 12px; color: var(--tx); text-decoration: none;
    border: .5px solid var(--border); margin-bottom: 4px;
    transition: border-color .15s;
}
.media-link-item:hover { border-color: #185FA5; color: #185FA5; }
.media-link-item svg { flex-shrink: 0; opacity: .5; }
.media-link-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Media submit form */
.media-submit-form {
    background: var(--bg2); border-radius: var(--r); padding: 10px;
    border: .5px solid var(--border);
}
.media-submit-tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.media-submit-tab {
    flex: 1; padding: 5px 8px; font-size: 11px; font-weight: 500;
    border: .5px solid var(--border); border-radius: var(--r);
    background: var(--bg); color: var(--tx2); cursor: pointer;
    text-align: center; font-family: inherit; transition: all .15s;
}
.media-submit-tab.on { background: #185FA5; color: #fff; border-color: #185FA5; }
.media-input {
    width: 100%; padding: 6px 8px; font-size: 12px;
    border: .5px solid var(--border); border-radius: var(--r);
    background: var(--bg); color: var(--tx); font-family: inherit;
    margin-bottom: 6px; box-sizing: border-box;
}
.media-input:focus { outline: none; border-color: #185FA5; }
.media-file-label {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 10px; font-size: 12px; color: var(--tx2);
    border: .5px dashed var(--border2); border-radius: var(--r);
    cursor: pointer; margin-bottom: 6px; transition: all .15s;
}
.media-file-label:hover { border-color: #185FA5; color: var(--tx); }
.media-submit-btn {
    width: 100%; padding: 7px; font-size: 12px; font-weight: 500;
    border: none; border-radius: var(--r); cursor: pointer;
    background: #185FA5; color: #E6F1FB; font-family: inherit;
    transition: opacity .15s;
}
.media-submit-btn:disabled { opacity: .4; cursor: not-allowed; }
.media-submit-btn:hover:not(:disabled) { opacity: .85; }
.media-submit-status {
    font-size: 11px; padding: 6px 8px; border-radius: var(--r);
    margin-top: 6px; text-align: center;
}
.media-submit-status.success { background: #d4edda; color: #155724; }
.media-submit-status.error { background: #f8d7da; color: #721c24; }
[data-theme="dark"] .media-submit-status.success { background: #1a3a1a; color: #75b798; }
[data-theme="dark"] .media-submit-status.error { background: #3a1a1a; color: #ea868f; }

/* Lightbox */
.lb-overlay {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(0,0,0,.92); display: none;
    justify-content: center; align-items: center;
}
.lb-overlay.open { display: flex; }
.lb-close {
    position: absolute; top: 12px; right: 16px;
    font-size: 32px; color: #fff; cursor: pointer;
    opacity: .7; transition: opacity .15s; z-index: 2;
    line-height: 1;
}
.lb-close:hover { opacity: 1; }
.lb-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    font-size: 42px; color: #fff; cursor: pointer;
    opacity: .6; transition: opacity .15s; z-index: 2;
    padding: 10px; user-select: none; line-height: 1;
}
.lb-nav:hover { opacity: 1; }
.lb-prev { left: 10px; }
.lb-next { right: 10px; }
.lb-content {
    display: flex; flex-direction: column; align-items: center;
    max-width: 90vw; max-height: 90vh;
}
.lb-img {
    max-width: 90vw; max-height: 80vh; object-fit: contain;
    border-radius: 4px;
}
.lb-caption {
    color: #fff; font-size: 13px; margin-top: 8px;
    text-align: center; max-width: 600px;
}
.lb-counter {
    color: rgba(255,255,255,.5); font-size: 12px; margin-top: 4px;
}

/* ============================================
   Feed Switcher (sidebar header)
   ============================================ */
.feed-switch { position: relative; flex: 1; min-width: 0; }
.feed-current {
    display: flex; align-items: center; gap: 6px;
    background: var(--bg); border: 1px solid var(--border); cursor: pointer;
    font-family: inherit; font-size: 13px; font-weight: 600;
    color: var(--tx); padding: 5px 10px; border-radius: 8px;
    transition: background .15s, border-color .15s, box-shadow .15s; max-width: 100%;
}
.feed-current:hover { background: var(--bg2); border-color: var(--tx2); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.feed-current-lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-arrow { flex-shrink: 0; margin-left: 2px; color: var(--tx2); transition: transform .2s; }

.feed-menu {
    display: none; position: absolute; top: calc(100% + 6px); left: 0;
    min-width: 240px; max-width: 300px;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.12);
    z-index: 40; padding: 6px 0; max-height: 320px; overflow-y: auto;
}
.feed-menu.open { display: block; }
.feed-menu-item {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 14px; font-size: 13px; color: var(--tx);
    cursor: pointer; transition: background .1s;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.feed-menu-item:hover { background: var(--bg2); }
.feed-menu-item.active { color: #185FA5; font-weight: 600; }
.feed-menu-item.active::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #185FA5; flex-shrink: 0; }
.feed-menu-sep { height: 1px; background: var(--border); margin: 4px 8px; }
.feed-menu-add {
    padding: 9px 14px; font-size: 13px; color: #185FA5;
    cursor: pointer; font-weight: 500; transition: background .1s;
}
.feed-menu-add:hover { background: var(--bg2); }

/* Feed active indicator on sidebar header */
.sb-hd .feed-badge {
    font-size: 10px; padding: 1px 6px; border-radius: 10px;
    background: #185FA5; color: #E6F1FB; font-weight: 500; margin-left: 4px;
}

/* Feed settings button */
.feed-settings-btn {
    background: none; border: .5px solid var(--border);
    border-radius: 4px; padding: 2px 6px; font-size: 13px;
    color: var(--tx2); cursor: pointer; transition: all .15s;
    flex-shrink: 0;
}
.feed-settings-btn:hover { border-color: var(--border2); color: var(--tx); }

/* Feed detail bar (shows follows for active feed) */
.feed-detail-bar {
    padding: 8px 12px; border-bottom: .5px solid var(--border);
    background: var(--bg2); font-size: 11px;
}
.feed-follows-list { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.feed-follow-chip {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 2px 8px; border-radius: 12px;
    background: var(--bg); border: .5px solid var(--border);
    font-size: 10px; color: var(--tx2);
}
.feed-follow-chip b { color: var(--tx); font-weight: 600; }
.feed-follow-rm {
    background: none; border: none; color: var(--tx3);
    cursor: pointer; font-size: 12px; padding: 0 2px; line-height: 1;
}
.feed-follow-rm:hover { color: var(--c-bw); }
.feed-actions { display: flex; gap: 6px; }
.feed-add-follow {
    font-size: 10px; padding: 2px 8px; border-radius: 4px;
    background: none; border: .5px solid #185FA5; color: #185FA5;
    cursor: pointer; font-family: inherit; transition: all .15s;
}
.feed-add-follow:hover { background: rgba(24,95,165,.06); }
.feed-delete {
    font-size: 10px; padding: 2px 8px; border-radius: 4px;
    background: none; border: .5px solid var(--c-bw); color: var(--c-bw);
    cursor: pointer; font-family: inherit; transition: all .15s;
}
.feed-delete:hover { background: rgba(231,76,60,.06); }

/* ============================================
   Feed Wizard Modal
   ============================================ */
.wiz-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.5); z-index: 1000;
    align-items: center; justify-content: center;
    backdrop-filter: blur(2px);
}
.wiz-overlay.open { display: flex; }

.wiz {
    background: var(--bg); border-radius: 12px;
    width: 460px; max-width: calc(100vw - 32px);
    max-height: calc(100vh - 64px);
    display: flex; flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,.25);
    animation: wizIn .2s ease;
}
@keyframes wizIn { from { opacity: 0; transform: scale(.96) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }

.wiz-hd {
    padding: 16px 20px 12px; display: flex;
    align-items: center; justify-content: space-between;
    border-bottom: .5px solid var(--border); flex-shrink: 0;
}
.wiz-title { font-size: 15px; font-weight: 600; color: var(--tx); }
.wiz-close {
    background: none; border: none; color: var(--tx2);
    font-size: 18px; cursor: pointer; padding: 2px 4px;
}

.wiz-progress { padding: 12px 20px 0; flex-shrink: 0; }
.wiz-dots { display: flex; gap: 6px; }
.wiz-dot {
    flex: 1; height: 3px; border-radius: 2px;
    background: var(--bg3); transition: background .2s;
}
.wiz-dot.on { background: #185FA5; }
.wiz-dot.done { background: #2ecc71; }

.wiz-body {
    flex: 1; overflow-y: auto; padding: 16px 20px; min-height: 0;
}
.wiz-body::-webkit-scrollbar { width: 3px; }
.wiz-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.wiz-step { display: none; }
.wiz-step.on { display: block; }

.wiz-step-title { font-size: 14px; font-weight: 600; color: var(--tx); margin-bottom: 4px; }
.wiz-step-desc { font-size: 12px; color: var(--tx2); margin-bottom: 16px; line-height: 1.5; }

.wiz-field { margin-bottom: 12px; }
.wiz-input {
    width: 100%; padding: 10px 12px; font-size: 14px; font-family: inherit;
    background: var(--bg2); color: var(--tx); border: .5px solid var(--border);
    border-radius: var(--r); outline: none; transition: border-color .15s;
}
.wiz-input:focus { border-color: #185FA5; box-shadow: 0 0 0 3px rgba(24,95,165,.12); }
.wiz-input::placeholder { color: var(--tx3); }

.wiz-label { display: block; font-size: 11px; font-weight: 500; color: var(--tx2); margin-bottom: 5px; }

/* Follow type cards */
.wiz-types { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.wiz-type {
    padding: 10px 12px; border: .5px solid var(--border);
    border-radius: var(--r); cursor: pointer; transition: all .15s;
    display: flex; flex-direction: column; gap: 2px;
}
.wiz-type:hover { border-color: var(--border2); background: var(--bg2); }
.wiz-type.sel { border-color: #185FA5; background: rgba(24,95,165,.06); }
.wiz-type-icon { font-size: 18px; }
.wiz-type-name { font-size: 12px; font-weight: 600; color: var(--tx); }
.wiz-type-desc { font-size: 10px; color: var(--tx2); line-height: 1.3; }

/* Autocomplete in wizard */
.wiz-ac-wrap { position: relative; }
.wiz-ac-list {
    display: none; position: fixed;
    background: var(--bg); border: .5px solid var(--border);
    border-radius: var(--r); box-shadow: 0 4px 12px rgba(0,0,0,.15);
    z-index: 1010; max-height: 200px; overflow-y: auto;
}
.wiz-ac-list.open { display: block; }
.wiz-ac-item {
    padding: 8px 12px; font-size: 12px; cursor: pointer;
    color: var(--tx); transition: background .1s;
    display: flex; justify-content: space-between; gap: 8px;
}
.wiz-ac-item:hover { background: var(--bg2); }
.wiz-ac-item-sub { font-size: 10px; color: var(--tx2); flex-shrink: 0; }

/* Discipline selection in wizard */
.wiz-disc-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.wiz-disc {
    padding: 8px 14px; border: .5px solid var(--border);
    border-radius: 20px; cursor: pointer; font-size: 12px;
    color: var(--tx2); transition: all .15s;
}
.wiz-disc:hover { border-color: var(--border2); }
.wiz-disc.sel { font-weight: 600; border-color: currentColor; }
.wiz-disc.bw.sel { background: var(--c-bw-bg); color: var(--c-bw-tx); }
.wiz-disc.amb.sel { background: var(--c-amb-bg); color: var(--c-amb-tx); }
.wiz-disc.pol.sel { background: var(--c-pol-bg); color: var(--c-pol-tx); }

/* Escalation select in wizard */
.wiz-esc-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.wiz-esc {
    padding: 8px 14px; border: .5px solid var(--border);
    border-radius: 20px; cursor: pointer; font-size: 12px;
    color: var(--tx2); transition: all .15s;
}
.wiz-esc:hover { border-color: var(--border2); }
.wiz-esc.sel { font-weight: 600; background: var(--c-esc-bg); color: var(--c-esc-tx); border-color: var(--c-esc); }

/* Geo config in wizard */
.wiz-geo-row { display: flex; gap: 8px; margin-bottom: 8px; }
.wiz-geo-row .wiz-input { flex: 1; }
.wiz-radius-row { display: flex; align-items: center; gap: 8px; }
.wiz-radius-row input[type="range"] { flex: 1; accent-color: #185FA5; }
.wiz-radius-val { font-size: 12px; color: var(--tx2); min-width: 45px; text-align: right; }

/* Filter chips in step 3 */
.wiz-filter-group { margin-bottom: 14px; }
.wiz-filter-lbl { display: block; font-size: 10px; font-weight: 500; color: var(--tx2); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.wiz-chips { display: flex; flex-wrap: wrap; gap: 4px; }

/* Summary */
.wiz-summary {
    margin-top: 16px; padding: 12px; background: var(--bg2);
    border-radius: var(--r); font-size: 12px; color: var(--tx2);
    line-height: 1.6;
}
.wiz-summary b { color: var(--tx); font-weight: 600; }

/* Footer */
.wiz-footer {
    padding: 12px 20px; border-top: .5px solid var(--border);
    display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.wiz-btn-back {
    padding: 8px 16px; font-size: 12px; font-weight: 500;
    background: none; border: .5px solid var(--border);
    border-radius: var(--r); color: var(--tx2);
    cursor: pointer; font-family: inherit; transition: all .15s;
}
.wiz-btn-back:hover { border-color: var(--border2); color: var(--tx); }
.wiz-btn-next {
    padding: 8px 20px; font-size: 12px; font-weight: 600;
    background: #185FA5; color: #E6F1FB; border: none;
    border-radius: var(--r); cursor: pointer;
    font-family: inherit; transition: all .15s;
}
.wiz-btn-next:hover { background: #1a6fc2; }
.wiz-btn-next:disabled { opacity: .4; cursor: not-allowed; }

/* ============================================
   Mobile
   ============================================ */
#mobileTabs { display: none; }

@media (max-width: 768px) {
    .dash {
        grid-template-columns: 1fr;
        grid-template-rows: var(--tb-h) 1fr;
    }

    .sb {
        position: absolute; top: var(--tb-h); left: 0; right: 0;
        bottom: 48px; z-index: 15; display: none;
    }
    .sb.mobile-visible { display: flex; }

    .mw { height: calc(100vh - var(--tb-h) - 48px); }

    #mobileTabs {
        display: flex; height: 48px; background: var(--bg);
        border-top: .5px solid var(--border); z-index: 20;
        position: fixed; bottom: 0; left: 0; right: 0;
    }
    .mobile-tab {
        flex: 1; background: none; border: none; color: var(--tx2);
        font-size: 14px; font-weight: 600; cursor: pointer;
        padding: 8px; transition: all .15s;
        border-top: 2px solid transparent; font-family: inherit;
    }
    .mobile-tab.active { color: var(--tx); border-top-color: #185FA5; }

    /* Topbar compact */
    .tb-counts { display: none; }
    .tb { padding: 0 8px; gap: 6px; }

    /* Filter & detail panels full width */
    .fp { width: 100%; }
    .dp { width: 100%; }
    .mw.dp-open .ev-log { right: 10px; }
    .mw.dp-open .mc-right,
    .mw.dp-open .mc-bottom { right: 10px; }

    /* Larger touch targets */
    .ac { padding: 10px 12px; }
    .chip { padding: 5px 12px; font-size: 12px; }

    /* Map controls */
    #mapControls { top: 8px; left: 8px; }
    .mc-btn { padding: 5px 8px; font-size: 10px; }
    .mc-right { right: 8px; bottom: 70px; }
    .mc-bottom { right: 8px; bottom: 8px; }
    .mc-tile-thumb { width: 44px; }
    .mc-tile-img { width: 36px; height: 26px; }
    .mc-layers { left: auto; right: 8px; bottom: auto; top: 8px; }

    /* Wizard mobile */
    .wiz { width: 100%; max-width: 100vw; max-height: 100vh; border-radius: 0; }
    .wiz-types { grid-template-columns: 1fr; }
}

/* Helicopter tracking markers */
.heli-marker { background: none !important; border: none !important; }
.heli-dot { position: relative; width: 24px; height: 24px; border-radius: 50%; border: 2px solid rgba(255,255,255,.9); box-shadow: 0 0 10px currentColor, 0 0 3px rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; margin: 6px auto 0; }
.heli-icon { display: flex; align-items: center; justify-content: center; transition: transform 1s ease; }
.heli-label { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 10px; font-weight: 600; color: #fff; background: rgba(0,0,0,.7); padding: 1px 5px; border-radius: 3px; pointer-events: none; margin-top: 2px; }
[data-theme="light"] .heli-label { color: #333; background: rgba(255,255,255,.85); }
