:root {
  --bg: #070b14;
  --bg2: #0b1220;
  --panel: #0e1626;
  --panel2: #131d31;
  --line: #1e2a41;
  --line2: #2a3852;
  --txt: #dbe4f3;
  --muted: #7b8aa5;
  --accent: #22d3ee;
  --accent2: #0891b2;
  --red: #ef4444;
  --red-bg: #3a1218;
  --orange: #f97316;
  --yellow: #eab308;
  --green: #22c55e;
  --blue: #3b82f6;
  --purple: #a855f7;
  --radius: 8px;
  --mono: ui-monospace, 'JetBrains Mono', 'Cascadia Mono', Consolas, monospace;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--txt);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body { overflow: hidden; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 15px; }
h3 { font-size: 14px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--panel2); padding: 1px 5px; border-radius: 4px; }
pre { background: var(--bg2); padding: 10px; border-radius: 6px; overflow: auto; max-height: 240px; font-size: 12px; margin: 6px 0 0; }
[hidden] { display: none !important; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
.muted { color: var(--muted); }
.xs { font-size: 11.5px; }
.block { display: block; }
.txt-red { color: var(--red); font-weight: 600; }
.txt-green { color: var(--green); }
.danger-txt { color: var(--red) !important; }
.pad { padding: 0 12px; }

/* ---------- Form controls ---------- */
input, select, textarea {
  font: inherit; color: var(--txt); background: var(--bg2); border: 1px solid var(--line2);
  border-radius: 6px; padding: 7px 10px; outline: none; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent2); box-shadow: 0 0 0 3px rgb(34 211 238 / 0.12); }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
textarea { resize: vertical; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 500; }
label.chk { flex-direction: row; align-items: center; gap: 6px; color: var(--txt); font-size: 13px; cursor: pointer; white-space: nowrap; }
.btn {
  font: inherit; font-weight: 600; font-size: 13px; color: var(--txt); background: var(--panel2);
  border: 1px solid var(--line2); border-radius: 6px; padding: 7px 14px; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #1a2640; border-color: #3a4a68; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.btn.primary:hover { background: #0aa3c7; }
.btn.danger { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn.danger:hover { background: #dc2626; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--panel2); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.xs { padding: 2px 8px; font-size: 11.5px; font-weight: 600; }
.btn.block { width: 100%; }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 14px; padding: 4px 6px; border-radius: 5px; line-height: 1; }
.icon-btn:hover { color: var(--txt); background: var(--panel2); }
.row { display: flex; align-items: center; flex-wrap: wrap; }
.gap { gap: 8px; margin: 10px 0; }
.end { justify-content: flex-end; }
.grid2, .grid3, .grid4 { display: grid; gap: 10px 12px; margin-bottom: 10px; }
.grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 10px; max-width: 420px; margin-top: 18px; }
.stack .btn { align-self: flex-start; }
.filter { margin: 8px 0; }

/* ---------- Login ---------- */
.login { display: grid; place-items: center; height: 100vh; background: radial-gradient(1200px 600px at 50% -10%, #0f2236 0%, var(--bg) 60%); padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 30px 80px rgb(0 0 0 / .5); }
.login-card h1 { font-size: 20px; }
.login-card p { margin: -8px 0 4px; }
.err { background: var(--red-bg); color: #fca5a5; border-radius: 6px; padding: 8px 10px; font-size: 13px; }
.brand-mark { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; background: linear-gradient(135deg, #0891b2, #1e3a8a); font-weight: 800; letter-spacing: .04em; font-size: 13px; color: #fff; }
.brand-mark.sm { width: 30px; height: 30px; font-size: 10px; border-radius: 7px; }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: 64px 1fr; grid-template-rows: 52px 1fr; height: 100vh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; padding: 0 14px; background: var(--bg2); border-bottom: 1px solid var(--line); min-width: 0; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand-name { white-space: nowrap; }
.spacer { flex: 1; }
.srv { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.srv b { color: var(--txt); }
.srv .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.srv.ok .dot { background: var(--green); box-shadow: 0 0 0 3px rgb(34 197 94 / .2); }
.srv.bad .dot { background: var(--red); }
.srv.idle .dot { background: var(--yellow); }
.me { display: flex; align-items: center; gap: 8px; }
.me-name { color: var(--muted); font-size: 13px; }
.duty { display: flex; align-items: center; gap: 8px; }
.duty-cs { font-family: var(--mono); font-weight: 700; color: var(--accent); background: rgb(34 211 238 / .08); border: 1px solid rgb(34 211 238 / .25); padding: 3px 9px; border-radius: 6px; }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 7px; overflow: hidden; }
.seg button { font: inherit; font-size: 12px; font-weight: 600; background: var(--panel); color: var(--muted); border: 0; border-right: 1px solid var(--line2); padding: 5px 9px; cursor: pointer; white-space: nowrap; }
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--txt); }
.seg button.on { color: #fff; background: var(--panel2); }

.sidenav { background: var(--bg2); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 8px 0; gap: 2px; }
.sidenav a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 2px; color: var(--muted); font-size: 10.5px; font-weight: 600; text-decoration: none; border-left: 2px solid transparent; }
.sidenav a svg { width: 21px; height: 21px; fill: currentColor; }
.sidenav a:hover { color: var(--txt); }
.sidenav a.active { color: var(--accent); border-left-color: var(--accent); background: rgb(34 211 238 / .06); }
main { overflow: hidden; min-width: 0; min-height: 0; padding: 10px; display: grid; gap: 10px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); min-height: 0; min-width: 0; overflow: auto; }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 5; }
.panel-head h2 { flex: 1; display: flex; align-items: center; gap: 8px; }
.count { font-size: 11px; background: var(--panel2); color: var(--muted); border-radius: 999px; padding: 1px 7px; font-weight: 600; }
.count:empty { display: none; }
.sub-head { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 14px 0 6px; padding: 0 12px; }
.drawer-body .sub-head { padding: 0; }
.empty { color: var(--muted); padding: 24px 12px; text-align: center; font-size: 13px; }
.empty.sm { padding: 10px 12px; text-align: left; }
.tabs { display: flex; gap: 2px; padding: 8px 10px 0; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 6; overflow-x: auto; }
.tabs button { font: inherit; font-weight: 600; font-size: 13px; background: none; border: 0; color: var(--muted); padding: 8px 14px; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button:hover { color: var(--txt); }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Tables / chips / tags ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; background: var(--panel); }
.tbl td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:hover td { background: rgb(255 255 255 / .015); }
.tbl td.actions { white-space: nowrap; text-align: right; }
.tbl select { padding: 3px 6px; font-size: 12.5px; width: auto; }
.row-hit td { background: rgb(239 68 68 / .09); }
.row-warn td { background: rgb(234 179 8 / .06); }
.row-panic td { background: rgb(239 68 68 / .15); animation: pulse-bg 1s infinite alternate; }
.row-new td { animation: flash-in 1.2s ease-out; }
@keyframes flash-in { from { background: rgb(34 211 238 / .25); } }
@keyframes pulse-bg { to { background: rgb(239 68 68 / .3); } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; background: var(--panel2); border: 1px solid var(--line2); padding: 2px 8px; border-radius: 999px; }
.chip-x { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0 0 0 2px; font-size: 14px; line-height: 1; }
.chip-x:hover { color: var(--red); }
.tag { display: inline-block; font-size: 10.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; padding: 2px 6px; border-radius: 4px; background: var(--panel2); color: var(--muted); border: 1px solid var(--line2); }
.tag-red { background: var(--red-bg); color: #fca5a5; border-color: #7f1d1d; }
.tag-green { background: #0b2a1a; color: #86efac; border-color: #14532d; }
.tag-911 { background: #3b0d0d; color: #fecaca; border-color: #991b1b; }
.badge { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 7px; border-radius: 4px; background: var(--panel2); }
.badge.ok { color: #86efac; background: #0b2a1a; }
.badge.bad { color: #fca5a5; background: var(--red-bg); }
.plate { font-family: var(--mono); font-weight: 700; background: #e8edf5; color: #0b1220; padding: 1px 6px; border-radius: 3px; border: 1px solid #94a3b8; letter-spacing: .05em; font-size: 12px; }
a.plate:hover { text-decoration: none; background: #fff; }
.swatch { display: inline-block; width: 11px; height: 11px; border-radius: 3px; vertical-align: -1px; margin-right: 5px; border: 1px solid rgb(255 255 255 / .2); }
.swatch.lg { width: 26px; height: 26px; border-radius: 6px; }
.team-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); margin-right: 6px; }

/* status colors */
.st-avail { --sc: var(--green); }
.st-busy { --sc: var(--yellow); }
.st-off { --sc: var(--muted); }
.st-enroute { --sc: var(--blue); }
.st-scene { --sc: var(--purple); }
.st-panic { --sc: var(--red); }
.chip[class*=st-], .badge[class*=st-] { color: var(--sc); border-color: color-mix(in srgb, var(--sc) 40%, transparent); background: color-mix(in srgb, var(--sc) 12%, transparent); }
.seg button.on[class*=st-] { color: var(--sc); background: color-mix(in srgb, var(--sc) 15%, var(--panel)); }
select.st-sel[class*=st-] { color: var(--sc); font-weight: 700; }

/* ---------- Dispatch ---------- */
main.view-dispatch { grid-template-columns: minmax(0, 1fr) 460px; }
.disp-map { position: relative; overflow: hidden; }
.map-host { position: absolute; inset: 0; }
.disp-side { display: grid; grid-template-rows: minmax(200px, 1.3fr) minmax(150px, 1fr) auto; gap: 10px; min-height: 0; }
.calls-panel { position: relative; display: flex; flex-direction: column; }
.call-list { padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.call {
  text-align: left; font: inherit; color: inherit; background: var(--bg2); border: 1px solid var(--line); border-left: 4px solid var(--pc, var(--line2));
  border-radius: 6px; padding: 8px 10px; cursor: pointer; display: flex; flex-direction: column; gap: 3px;
}
.call:hover { border-color: var(--line2); border-left-color: var(--pc); }
.call.sel { background: var(--panel2); outline: 1px solid var(--accent2); }
.call.closed { opacity: .55; }
.call.p0 { --pc: var(--red); } .call.p1 { --pc: var(--orange); } .call.p2 { --pc: var(--yellow); } .call.p3 { --pc: var(--blue); }
.call-panic { animation: pulse-bg2 .8s infinite alternate; }
@keyframes pulse-bg2 { to { background: #3a1218; } }
.call-top { display: flex; align-items: center; gap: 7px; }
.call-id { font-family: var(--mono); color: var(--muted); font-size: 12px; }
.call-nature { font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-time { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.call-loc { font-size: 12.5px; color: #b6c2d8; }
.call-desc { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-units { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.pri { font-family: var(--mono); font-size: 11px; font-weight: 800; color: var(--pc); }
.st { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.st-pending { color: var(--orange); } .st-active { color: var(--green); } .st-closed { color: var(--muted); }
.call-drawer { position: absolute; inset: 0; background: var(--panel); z-index: 10; display: flex; flex-direction: column; overflow: auto; }
.drawer-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.drawer-head h3 { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-body { padding: 12px; }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; margin-bottom: 10px; }
.kv > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kv span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.kv b { font-weight: 600; overflow-wrap: anywhere; }
.kv select { padding: 4px 6px; }
.kv.inline { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.desc-box { background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 9px 11px; white-space: pre-wrap; margin-bottom: 8px; }
.notes { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow: auto; font-size: 13px; }
.note { padding: 4px 0; border-bottom: 1px dashed var(--line); }
.note-t { font-family: var(--mono); color: var(--muted); font-size: 11.5px; margin-right: 6px; }
.note-form { display: flex; gap: 6px; margin-top: 8px; }
.units-panel .tbl td, .units-panel .tbl th { padding: 6px 8px; }
.bolo-panel { max-height: 200px; }
.bolo { display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.bolo > span:nth-child(3), .bolo > span:nth-child(2):not(.tag) { flex: 1; }
.ig-list { display: flex; flex-direction: column; }
.ig { display: flex; align-items: center; gap: 8px; text-align: left; font: inherit; color: inherit; font-size: 13px; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 7px 12px; cursor: pointer; }
.ig:hover { background: var(--panel2); }
.ig-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 25%, transparent); }
.ig-main { display: flex; flex-direction: column; min-width: 0; }
.ig-sub { font-size: 11.5px; color: var(--muted); }

/* ---------- Map ---------- */
#livemap { position: absolute; inset: 0; background: #2c4f5f; }
/* SVG focus outlines form a rectangle around the entire jurisdiction on click. */
#livemap .jurisdiction-boundary:focus:not(:focus-visible) { outline: none; }
#livemap .jurisdiction-boundary:focus-visible { outline: none; stroke-width: 4; }
#livemap.picking { cursor: crosshair !important; }
#livemap.picking::after { content: attr(data-hint); position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: var(--accent2); color: #fff; padding: 6px 14px; border-radius: 999px; font-weight: 600; z-index: 1000; pointer-events: none; }
#livemap.picking .leaflet-interactive, #livemap.picking .leaflet-marker-icon { cursor: crosshair !important; }
#livemap:is(.picking,.drawing,.placing) .leaflet-interactive,
#livemap:is(.picking,.drawing,.placing) .leaflet-marker-pane,
#livemap:is(.picking,.drawing,.placing) .leaflet-tooltip-pane,
#livemap:is(.picking,.drawing,.placing) .leaflet-popup-pane { pointer-events:none !important; }
#livemap.placing .placement-preview { pointer-events:auto !important; }
.leaflet-container { font-family: inherit; }
.leaflet-control-zoom a { background: var(--panel) !important; color: var(--txt) !important; border-color: var(--line) !important; }
.pm-wrap { background: none; border: 0; }
.map-tools .toggles { flex-wrap: wrap; gap: 8px 12px; }
.map-options > summary { cursor:pointer; font-weight:700; font-size:12px; }
.map-options[open] > summary { margin-bottom:6px; }
.map-full:has(#livemap.drawing) .map-tools { display:none; }
.map-full:has(#livemap.placing) .map-tools { display:none; }
.camera-placement { position:absolute; top:10px; right:10px; z-index:1100; width:min(264px,calc(100% - 64px)); max-height:calc(100% - 20px); overflow:auto; background:rgb(14 22 38 / .97); border:1px solid var(--accent); border-radius:8px; padding:12px; box-shadow:0 4px 16px #0005; }
.camera-placement label { font-size:10px; margin:7px 0; }
.camera-placement input,.camera-placement select { padding:6px 8px; font-size:11px; }
.camera-placement p { margin:7px 0; line-height:1.4; }
.camera-placement .grid2 { gap:8px; grid-template-columns:1fr 1fr; }
.placement-heading { display:flex; align-items:end; gap:8px; }
.placement-heading label { flex:1; min-width:0; }
.placement-heading button { margin-bottom:7px; white-space:nowrap; }
.placement-preview { display:grid; place-items:center; background:#0b1220; border:3px solid var(--preview-color,#22d3ee); border-radius:50%; color:var(--preview-color,#22d3ee); box-shadow:0 0 0 5px #ffffff55; cursor:grab; }
#livemap.placing { cursor:crosshair; }
.map-tools { max-height:calc(100% - 20px); overflow:auto; }
.map-select { display: flex; align-items: center; gap: 8px; font-size: 11px; }
.map-select select { min-width: 0; flex: 1; }
.wrap { flex-wrap: wrap; }
.drawing-tools { position:absolute; left:10px; bottom:10px; right:10px; z-index:1100; display:flex; align-items:center; flex-wrap:wrap; gap:8px; padding:12px; background:var(--panel); border:1px solid var(--accent); border-radius:8px; }
#livemap.drawing { cursor:crosshair; }
.zone-manage { display:flex; width:100%; margin-bottom:8px; gap:8px; text-align:left; }
.camera-group > summary { padding:10px 12px; font-weight:700; cursor:pointer; background:var(--panel); border-bottom:1px solid var(--line); }
.cam-row input[type=checkbox] { width:16px; flex:0 0 16px; }
.leaflet-marker-icon.pm-wrap { transition: transform 1.2s linear; }
#livemap.zooming .leaflet-marker-icon.pm-wrap { transition: none; }
.pm { position: absolute; transform: translate(-7px, -7px); display: flex; align-items: center; gap: 5px; white-space: nowrap; pointer-events: auto; }
.pm-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--c); border: 2px solid #fff; box-shadow: 0 0 0 2px rgb(0 0 0 / .45), 0 2px 6px rgb(0 0 0 / .5); }
.pm-civ .pm-dot { width: 9px; height: 9px; border-width: 1.5px; opacity: .8; }
.pm-civ { transform: translate(-4.5px, -4.5px); }
.pm-label { font-size: 11px; font-weight: 800; font-family: var(--mono); background: rgb(7 11 20 / .85); color: #fff; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--c); }
.pm-cad.st-panic .pm-dot { animation: ping 0.8s infinite; background: var(--red); }
.pm-cad[class*=st-] .pm-label { box-shadow: inset 3px 0 0 var(--sc); }
.pm-wanted .pm-dot { outline: 2px solid var(--red); outline-offset: 2px; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgb(239 68 68 / .7); } 100% { box-shadow: 0 0 0 16px rgb(239 68 68 / 0); } }
.cm-wrap { background: none; border: 0; }
.cm { position: absolute; transform: translate(-50%, -100%); }
.cm-pin { display: grid; place-items: center; min-width: 28px; height: 22px; padding: 0 6px; border-radius: 6px; font-size: 11px; font-weight: 800; color: #fff; background: var(--pc, #ca8a04); border: 2px solid #fff; box-shadow: 0 2px 8px rgb(0 0 0 / .5); position: relative; }
.cm-pin::after { content: ''; position: absolute; bottom: -7px; left: 50%; transform: translateX(-50%); border: 5px solid transparent; border-top-color: #fff; }
.cm.p0 { --pc: #dc2626; } .cm.p1 { --pc: #ea580c; } .cm.p2 { --pc: #ca8a04; } .cm.p3 { --pc: #2563eb; }
.cm-911 .cm-pin { animation: bob 1.4s ease-in-out infinite; }
.cm-panic .cm-pin { animation: ping 0.8s infinite; }
@keyframes bob { 50% { transform: translateY(-3px); } }
.cam-wrap { background: none; border: 0; }
.cam { position: absolute; transform: translate(-50%, -50%); width: 22px; height: 22px; display: grid; place-items: center; border-radius: 6px; background: #083344; color: var(--accent); border: 1.5px solid var(--accent); box-shadow: 0 2px 6px rgb(0 0 0 / .5); }
.cam-off { color: var(--muted); border-color: var(--muted); background: var(--panel); }
.cam.flash { animation: camflash 1s ease-out; }
.cam.flash-hit { animation: camhit 1.5s ease-out 2; }
@keyframes camflash { 0% { background: var(--accent); color: #000; transform: translate(-50%, -50%) scale(1.4); } }
@keyframes camhit { 0% { background: var(--red); color: #fff; border-color: #fff; transform: translate(-50%, -50%) scale(1.6); } }
.dark-pop .leaflet-popup-content-wrapper, .dark-pop .leaflet-popup-tip { background: var(--panel); color: var(--txt); border: 1px solid var(--line2); box-shadow: 0 10px 30px rgb(0 0 0 / .5); }
.dark-pop .leaflet-popup-content { margin: 10px 12px; font-size: 13px; line-height: 1.5; }
.pop-title { font-weight: 800; font-size: 14px; margin-bottom: 2px; }
.pop-desc { color: var(--muted); max-width: 240px; }
.pop-veh { display: flex; align-items: center; gap: 4px; }

main.view-map { grid-template-columns: minmax(0, 1fr) 320px; }
.map-full { position: relative; overflow: hidden; }
.map-tools { position: absolute; top: 10px; right: 10px; z-index: 1000; background: rgb(14 22 38 / .94); border: 1px solid var(--line2); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 8px; backdrop-filter: blur(6px); max-width: calc(100% - 70px); }
.toggles { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.postal-go { display: flex; gap: 6px; }
.postal-go input { width: 110px; }
.map-tools .row.gap { margin: 0; }
.map-full .map-tools { padding:0; border:0; background:none; backdrop-filter:none; overflow:visible; width:min(264px,calc(100% - 64px)); pointer-events:none; }
.map-options { width:100%; pointer-events:auto; }
.map-options > summary { list-style:none; margin-left:auto; width:max-content; display:flex; align-items:center; gap:7px; padding:8px 11px; border:1px solid var(--line2); border-radius:7px; background:rgb(14 22 38 / .96); box-shadow:0 2px 8px #0004; }
.map-options > summary::-webkit-details-marker { display:none; }
.map-options-body { padding:12px; background:rgb(14 22 38 / .97); border:1px solid var(--line2); border-radius:8px; max-height:min(52vh,330px); overflow:auto; box-shadow:0 4px 16px #0005; }
.map-options-heading { display:flex; align-items:center; justify-content:space-between; font-size:12px; font-weight:700; margin-bottom:9px; }
.map-control-label { color:var(--muted); text-transform:uppercase; letter-spacing:.08em; font-size:9px; font-weight:700; margin:13px 0 7px; }
.map-tools .toggles { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.map-tools .chk { font-size:11px; margin:0; white-space:nowrap; }
.map-tools .map-select { display:block; margin-top:8px; color:var(--muted); }
.map-tools .map-select select { width:100%; margin-top:4px; font-size:11px; padding:6px; }
.map-tools .postal-go input { width:0; flex:1; padding:6px 8px; font-size:11px; }
.map-manage { display:grid; grid-template-columns:1fr 1fr; gap:6px; }
.map-manage .btn { padding:6px; font-size:10px; }
.map-manage .btn:last-child { grid-column:1 / -1; }
.cam.cam-cctv { background:#3b1b54; color:#c084fc; border-color:#c084fc; border-radius:50%; }
.cam.cam-cctv.cam-off { color:var(--muted); border-color:var(--muted); background:var(--panel); }
main.view-cctv { grid-template-columns:minmax(0,1fr); }
.cctv-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(240px,1fr)); gap:12px; padding:14px; }
.cctv-card { border:1px solid var(--line); border-radius:8px; padding:14px; }
.cctv-card h3 { margin:0 0 8px; font-size:14px; }
.cctv-card .row { margin-top:12px; flex-wrap:wrap; }
.cctv-note { margin:0; padding:0 14px 12px; line-height:1.5; }
.cctv-card.off { opacity:.6; }
.cctv-search { display:grid; grid-template-columns:repeat(auto-fit,minmax(170px,1fr)); gap:10px; padding:14px; align-items:end; }
.cctv-search label { display:flex; flex-direction:column; gap:4px; font-size:11px; color:var(--muted); }
.cctv-quick { display:flex; flex-wrap:wrap; gap:6px; }
#cctv-results { padding:0 14px 14px; overflow:auto; }
.cctv-summary { margin:4px 0 10px; font-size:13px; }
.cctv-scene { display:block; width:100%; max-width:560px; aspect-ratio:1; margin:0 auto 10px; border:1px solid var(--line2); border-radius:8px; background:var(--bg2); }
.cctv-cone { fill:rgb(192 132 252 / .16); stroke:#c084fc; }
.cctv-cam-dot { fill:#c084fc; }
.cctv-trail { fill:none; stroke:#fbbf24; stroke-linejoin:round; stroke-linecap:round; opacity:.85; }
.cctv-subject { fill:#ef4444; stroke:#fff; }
.cctv-label { fill:#fff; text-anchor:middle; font-weight:700; paint-order:stroke; stroke:#000; stroke-width:.6px; }
.cctv-controls { display:flex; align-items:center; gap:10px; max-width:560px; margin:0 auto 8px; }
.cctv-controls input[type=range] { flex:1; }
.cctv-time { font-family:var(--mono); font-size:12px; min-width:110px; text-align:right; }
#cctv-log summary { cursor:pointer; list-style:none; }
.plate-art { position:relative; display:inline-block; width:110px; height:56px; vertical-align:middle; background-color:#fff; background-size:100% 100%; background-repeat:no-repeat; border-radius:4px; color:#102339; overflow:hidden; }
.plate-art b { position:absolute; left:6%; right:6%; top:39%; bottom:12%; display:grid; place-items:center; font-family:Impact,'Arial Narrow',monospace; font-size:18px; letter-spacing:1px; font-weight:700; white-space:nowrap; text-shadow:0 1px 1px #ffffffaa; }
.plate-art-large { width:240px; height:123px; margin:8px 0 12px; }
.plate-art-large b { font-size:38px; }
.plate-art-government { border:2px solid #8ba1b8; background:#e5edf4; }
.plate-art-government small { position:absolute; top:7%; width:100%; text-align:center; font-size:9px; font-weight:800; color:#213c54; }
.plate-exempt { display:flex; flex-direction:column; gap:2px; font-size:10px; color:#87d9ba; margin:5px 0; }
[data-plate-design] { display:block; max-width:170px; font-size:10px; margin-top:5px; }
@media (max-width: 700px) {
  .map-options-body { max-height:calc(60vh - 86px); }
}

/* ---------- Search / results / profiles ---------- */
main.view-mdt, main.view-admin, main.view-account { grid-template-columns: minmax(0, 1fr); }
.mdt-body, .admin-body { padding: 14px; }
.search { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.search input { flex: 1; min-width: 120px; }
.search select { width: auto; }
.result-list { display: flex; flex-direction: column; gap: 6px; }
.result { display: flex; align-items: center; gap: 10px; text-align: left; font: inherit; color: inherit; background: var(--bg2); border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; cursor: pointer; }
.result > span:nth-child(2) { flex: 1; min-width: 0; }
.result:hover, .result.sel { border-color: var(--accent2); background: var(--panel2); }
.avatar { width: 36px; height: 36px; border-radius: 8px; background: linear-gradient(135deg, #1e3a8a, #0e7490); display: inline-grid; place-items: center; font-weight: 800; font-size: 13px; flex: none; object-fit: cover; color: #fff; }
.avatar.lg { width: 96px; height: 96px; font-size: 28px; border-radius: 12px; }
.profile { display: flex; flex-direction: column; gap: 4px; max-width: 1100px; }
.profile-head { display: flex; gap: 18px; align-items: flex-start; margin-bottom: 8px; }
.profile-id { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.profile-id h2 { font-size: 20px; display: flex; gap: 8px; align-items: center; }
.profile-id .row.gap { margin: 0; }
h3.sec { font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 18px 0 8px; display: flex; align-items: center; gap: 8px; font-weight: 700; }
.alert-box { padding: 9px 12px; border-radius: 6px; font-weight: 700; font-size: 13px; margin: 4px 0; border: 1px solid; }
.alert-box.high { background: var(--red-bg); border-color: #7f1d1d; color: #fecaca; }
.alert-box.med { background: #3a2a0a; border-color: #854d0e; color: #fde68a; }
.alert-box.low { background: var(--panel2); border-color: var(--line2); color: #cbd5e1; }
.alert-chip { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 4px; margin: 1px 3px 1px 0; }
.alert-chip.high { background: var(--red-bg); color: #fecaca; }
.alert-chip.med { background: #3a2a0a; color: #fde68a; }
.alert-chip.low { background: var(--panel2); color: #cbd5e1; }
.lic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px; }
.lic { background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; display: flex; flex-direction: column; }
.lic span { font-size: 11px; color: var(--muted); text-transform: capitalize; }
.lic-valid b { color: var(--green); } .lic-suspended b, .lic-revoked b { color: var(--red); } .lic-expired b { color: var(--yellow); } .lic-none b { color: var(--muted); font-weight: 500; }
.record { background: var(--bg2); border: 1px solid var(--line); border-left: 3px solid var(--line2); border-radius: 6px; padding: 8px 11px; margin-bottom: 6px; display: flex; flex-direction: column; gap: 5px; }
.rec-arrest { border-left-color: var(--red); } .rec-citation { border-left-color: var(--yellow); } .rec-warning { border-left-color: var(--blue); }
.record-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.record-head .icon-btn { margin-left: auto; }
.narr { color: #b6c2d8; white-space: pre-wrap; font-size: 13px; }
.charge { display: inline-block; font-size: 12px; padding: 2px 7px; border-radius: 4px; margin: 2px 4px 2px 0; background: var(--panel2); border-left: 3px solid var(--muted); }
.charge.felony { border-left-color: var(--red); } .charge.misdemeanor { border-left-color: var(--orange); } .charge.infraction { border-left-color: var(--yellow); }
.charge-pick { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 8px; }
.charge-opt { flex-direction: row; align-items: center; gap: 8px; color: var(--txt); font-size: 13px; padding: 6px 10px; border-bottom: 1px solid var(--line); cursor: pointer; border-left: 3px solid transparent; }
.charge-opt.felony { border-left-color: var(--red); } .charge-opt.misdemeanor { border-left-color: var(--orange); } .charge-opt.infraction { border-left-color: var(--yellow); }
.charge-opt:has(input:checked) { background: rgb(34 211 238 / .08); }
.totals { font-size: 13px; padding: 6px 0 10px; }
.chk-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.plate-result { max-width: 1100px; }
.plate-big { display: inline-block; font-family: var(--mono); font-size: 28px; font-weight: 800; letter-spacing: .1em; background: #e8edf5; color: #0b1220; padding: 6px 18px; border-radius: 6px; border: 3px solid #94a3b8; margin-bottom: 10px; }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }

/* ---------- Civilian ---------- */
main.view-civ { grid-template-columns: 280px minmax(0, 1fr); }
.civ-list { display: flex; flex-direction: column; }
.civ-list #chars { padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.civ-list > .btn.block { margin: 10px 12px 6px; width: auto; }
.civ-main { padding: 16px; }

/* ---------- ALPR ---------- */
main.view-alpr { grid-template-columns: minmax(0, 1fr) 320px; }
.alpr-main { display: flex; flex-direction: column; }
.alpr-main .search { padding: 10px 12px 0; }
.stats { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); }
.stats b { color: var(--txt); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.feed { flex: 1; }
.cam-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.cam-row.off { opacity: .5; }
.cam-ico { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); flex: none; }
.cam-name { flex: 1; min-width: 0; font-size: 13px; }

/* ---------- Admin ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.card span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.card b { font-size: 17px; }
.card small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.card.bad { border-color: #7f1d1d; }
.inline-input { padding: 3px 7px; width: 150px; }
.settings { max-width: 900px; }
.steps { line-height: 1.8; padding-left: 20px; }
.admin-body .seg { margin-bottom: 12px; }
.account { padding: 18px; max-width: 640px; width: 100%; }
.account > h2 { font-size: 20px; margin-bottom: 8px; }

/* ---------- Modal / toast ---------- */
.modal-wrap { position: fixed; inset: 0; background: rgb(2 6 14 / .7); display: grid; place-items: center; z-index: 5000; padding: 16px; backdrop-filter: blur(2px); }
.modal { background: var(--panel); border: 1px solid var(--line2); border-radius: 12px; width: 100%; max-width: 480px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 30px 80px rgb(0 0 0 / .6); }
.modal.wide { max-width: 760px; }
.modal header { display: flex; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal header h3 { flex: 1; font-size: 15px; }
.modal-body { padding: 16px; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.modal-body p { margin: 0; }
.modal-body h4 { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.warn { color: #fde68a; background: #3a2a0a; padding: 8px 10px; border-radius: 6px; font-size: 13px; }
#toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 6000; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--panel2); border: 1px solid var(--line2); border-left: 4px solid var(--accent); border-radius: 8px; padding: 10px 14px; font-size: 13px; box-shadow: 0 10px 30px rgb(0 0 0 / .5); cursor: pointer; animation: tin .2s ease-out; transition: opacity .4s, transform .4s; }
.toast.out { opacity: 0; transform: translateX(20px); }
.toast-error { border-left-color: var(--red); }
.toast-call { border-left-color: var(--orange); }
.toast-hit { border-left-color: var(--red); background: #2a0f14; }
.toast-panic { border-left-color: var(--red); background: #7f1d1d; color: #fff; animation: tin .2s ease-out, shake .5s 2; }
@keyframes tin { from { opacity: 0; transform: translateY(10px); } }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  main.view-dispatch { grid-template-columns: minmax(0, 1fr) 380px; }
  .seg button { padding: 5px 6px; font-size: 11px; }
  .brand-name { display: none; }
}
@media (max-width: 900px) {
  body { overflow: auto; }
  .app { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; height: auto; min-height: 100vh; }
  .topbar { flex-wrap: wrap; padding: 8px 12px; height: auto; gap: 8px; }
  .srv { order: 5; flex-basis: 100%; }
  .duty { flex-wrap: wrap; }
  .sidenav { flex-direction: row; overflow-x: auto; padding: 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidenav a { flex: 1; min-width: 64px; border-left: 0; border-bottom: 2px solid transparent; }
  .sidenav a.active { border-bottom-color: var(--accent); }
  main { overflow: visible; padding: 8px; }
  main.view-dispatch, main.view-map, main.view-civ, main.view-alpr { grid-template-columns: 1fr; }
  .disp-map, .map-full { height: 60vh; }
  .disp-side { grid-template-rows: auto; }
  .calls-panel { min-height: 320px; }
  .grid3, .grid4, .cols2 { grid-template-columns: 1fr 1fr; }
  .profile-head { flex-direction: column; }
  .tbl { display: block; overflow-x: auto; }
}
@media (max-width: 520px) {
  .grid2, .grid3, .grid4, .cols2, .kv { grid-template-columns: 1fr; }
}

/* control sizing inside inline rows */
.row select, .search input[type=checkbox] { width: auto; flex: none; }
.search label.chk { flex: none; }

/* directional ALPR cameras */
.cam-dir { position: absolute; inset: -14px; pointer-events: none; filter: drop-shadow(0 0 1px #000) drop-shadow(0 0 1px #000); }
.cam-dir::before { content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%); border: 6px solid transparent; border-bottom: 9px solid #fff; border-top: 0; }
.cam-off .cam-dir::before { border-bottom-color: var(--muted); }
.pop-links { display: flex; gap: 12px; margin-top: 4px; }
.dir { font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--accent); }

/* Server switcher (multi-server) */
.server-switch { position: relative; min-width: 0; }
.server-switch-btn { display: flex; align-items: center; gap: 6px; max-width: 260px; min-width: 0; padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--txt); font: inherit; font-weight: 700; cursor: pointer; }
.server-switch-btn:hover { border-color: var(--line2); }
.server-switch .brand-name { display: inline; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.server-switch .caret { color: var(--muted); font-size: 11px; }
.server-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 3000; width: max-content; min-width: 220px; max-width: min(320px, calc(100vw - 24px)); max-height: 60vh; overflow: auto; padding: 6px; background: var(--panel); border: 1px solid var(--line2); border-radius: 9px; box-shadow: 0 16px 40px rgb(0 0 0 / .5); }
.server-menu-head { padding: 4px 8px 6px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.server-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 8px; border: 0; border-radius: 6px; background: none; color: var(--txt); font: inherit; text-align: left; cursor: pointer; }
.server-item:hover, .server-item.on { background: var(--panel2); }
.server-item.on .server-item-name { color: var(--accent); }
.server-item.add { color: var(--accent); border-top: 1px solid var(--line); border-radius: 0 0 6px 6px; margin-top: 4px; }
.server-item-name { min-width: 0; overflow-wrap: anywhere; }
.srv-badge { flex: none; padding: 1px 6px; border-radius: 9px; font-size: 10px; font-weight: 700; background: var(--panel2); color: var(--muted); border: 1px solid var(--line2); }
.srv-badge-trialing, .srv-badge-comped { color: var(--accent); border-color: var(--accent2); }
.srv-badge-past_due { color: var(--yellow); border-color: var(--yellow); }
.srv-badge-canceled, .srv-badge-suspended { color: var(--red); border-color: var(--red); }
@media (max-width: 520px) {
  .server-switch-btn { max-width: 150px; }
}
/* Discord / Roblox sign-in and linked accounts */
.discord-btn { display:flex; align-items:center; justify-content:center; gap:8px; background:#5865F2; border-color:#5865F2; color:#fff; text-decoration:none; }
.discord-btn:hover { background:#4752c4; border-color:#4752c4; color:#fff; }
.btn.sm.discord-btn { display:inline-flex; }
.login-or { display:flex; align-items:center; gap:10px; color:var(--muted); font-size:11px; margin:4px 0; }
.login-or::before, .login-or::after { content:''; flex:1; border-top:1px solid var(--line2); }
.login-password summary { cursor:pointer; color:var(--muted); font-size:12px; margin-bottom:10px; }
.login-password[open] { display:flex; flex-direction:column; gap:12px; }
.linked { display:flex; flex-direction:column; gap:8px; margin-bottom:12px; }
.linked-row { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:10px 12px; border:1px solid var(--line); border-radius:8px; }
.linked-name { min-width:0; }
.verified { color:var(--green); font-weight:700; }
/* Invites + Discord role sync */
.invite-banner { margin:0 0 12px; padding:10px 12px; border:1px solid #5865f2; border-radius:8px; background:rgb(88 101 242 / .14); font-size:13px; line-height:1.45; }
.invite-form { flex-wrap:wrap; align-items:end; }
.invite-form label { display:flex; flex-direction:column; gap:4px; font-size:11px; color:var(--muted); }
#invites { margin-bottom:8px; overflow:auto; }
.discord-chip { display:inline-block; margin-left:6px; padding:1px 7px; border-radius:999px; background:rgb(88 101 242 / .18); color:#c7ccff; font-size:10px; font-weight:600; vertical-align:middle; }
.discord-sync .search { max-width:520px; }
.dc-roles { margin:8px 0 12px; }
.role-dot { display:inline-block; width:10px; height:10px; border-radius:50%; margin-right:7px; vertical-align:middle; }
.discord-sync .chk { margin:6px 0 12px; }

.shot { display: block; width: 100%; aspect-ratio: 600 / 315; border-radius: 6px; background: var(--bg2); margin: 6px 0; }

.rch { border: 1px solid var(--line2); border-radius: 8px; padding: 10px 12px; margin: 0 0 10px; }
.rch-wrap { flex-wrap: wrap; margin-top: 6px; }
.pref-wrap { flex-wrap: wrap; margin-bottom: 10px; }
.station-pin { transform: translate(-50%, -50%); width: 22px; height: 22px; display: grid; place-items: center; border-radius: 5px; background: #b91c1c; border: 2px solid #fff; color: #fff; font: 700 11px var(--mono); }

/* ---------- Radio (overlay widget and Radio tab) ---------- */
.rstat { font-family: var(--mono); font-size: 12px; min-height: 18px; color: var(--muted); }
.rstat.tx { color: var(--red); }
.rstat.rx { color: var(--green); }
.ptt { width: 100%; touch-action: none; }
.ptt.on { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.radio-view { max-width: 720px; }
.radio-panel { display: grid; gap: 8px; max-width: 360px; padding: 4px 0 10px; }
.radio-panel .row { display: flex; gap: 8px; align-items: center; }
.radio-panel .grow { flex: 1; }
.radio-panel select { width: 100%; }
