/* Statewide CAD - console styling (Night / Day modes, like a real dispatch floor) */
:root, [data-theme="night"] {
  --bg: #15181d;
  --bg2: #1b1f25;
  --panel: #20242b;
  --panel2: #272c34;
  --panel3: #30363f;
  --hdr: #2b313a;
  --hdr2: #343b46;
  --line: #3a414c;
  --line2: #4a5260;
  --text: #dfe4ec;
  --muted: #9aa4b2;
  --dim: #6f7987;
  --sel: #1f4f99;
  --sel2: #173a70;
  --accent: #3d82f0;
  --gold: #e8b34a;
  --red: #e0453f;
  --green: #3fae5a;
  --amber: #e3a21a;
  --blue: #3d82f0;
  --tty-bg: #07090c;
  --tty: #c8f5c8;
  --input: #111418;
  --p1: #d32f2f;
  --p2: #e6a100;
  --p3: #5c6b7f;
  --shadow: 0 8px 24px rgba(0, 0, 0, .5);
  --row-alt: rgba(255, 255, 255, .025);
}
[data-theme="day"] {
  --bg: #c8ccd2;
  --bg2: #d6d9de;
  --panel: #eceef1;
  --panel2: #e1e4e8;
  --panel3: #d3d7dd;
  --hdr: #c3c9d2;
  --hdr2: #b4bbc6;
  --line: #a3abb7;
  --line2: #8a93a1;
  --text: #11151b;
  --muted: #444d5a;
  --dim: #66707e;
  --sel: #9fc3f5;
  --sel2: #c2d9fa;
  --accent: #1d5fd1;
  --gold: #a46b00;
  --red: #c62828;
  --green: #2e7d32;
  --amber: #b77700;
  --blue: #1d5fd1;
  --tty-bg: #fbfbf2;
  --tty: #111;
  --input: #ffffff;
  --row-alt: rgba(0, 0, 0, .03);
  --shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
:root {
  --sans: 'Segoe UI', 'IBM Plex Sans', Tahoma, Arial, sans-serif;
  --mono: Consolas, 'IBM Plex Mono', 'Cascadia Mono', 'Courier New', monospace;
  --radius: 2px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 12.5px/1.35 var(--sans); overflow: hidden; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--sel); color: #fff; }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-thumb { background: var(--line2); border: 3px solid var(--panel); border-radius: 0; }
::-webkit-scrollbar-track { background: var(--panel); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 11.5px; }
.tiny { font-size: 10.5px; }
.right { text-align: right; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 6px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row > input, .row > select:not([style*=width]) { flex: 1; width: auto; min-width: 0; }
.col { display: flex; flex-direction: column; gap: 6px; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upper { text-transform: uppercase; }

/* ------------------------------------------------------------ shell */
#app { display: grid; grid-template-rows: 30px 1fr auto 24px 20px; grid-template-columns: minmax(0, 1fr); height: 100vh; }
#app > * { min-width: 0; }
#top { display: flex; align-items: stretch; background: var(--hdr); border-bottom: 1px solid var(--line); position: relative; z-index: 20; user-select: none; }
#top .brand { display: flex; align-items: center; gap: 7px; padding: 0 10px; border-right: 1px solid var(--line); flex: none; }
#top .brand img { height: 22px; }
#top .brand b { font-size: 11.5px; letter-spacing: .06em; }
#top .brand span { font-size: 10.5px; color: var(--muted); margin-left: 2px; }
#modes { display: flex; align-items: center; gap: 2px; padding: 0 6px; border-right: 1px solid var(--line); background: var(--bg2); flex: none; }
#modes button { height: 20px; border: 1px solid var(--line2); background: var(--panel2); color: var(--muted); font: 700 10.5px var(--sans); text-transform: uppercase; padding: 0 8px; cursor: pointer; letter-spacing: .04em; }
#modes button.on { color: #fff; border-color: transparent; }
body[data-mode="dispatch"] #modes button.on { background: #6b3fb5; }
body[data-mode="law"] #modes button.on { background: #1d5fd1; }
body[data-mode="fire"] #modes button.on { background: #c62828; }
body[data-mode="ems"] #modes button.on { background: #d96a00; }
body[data-mode="civ"] #modes button.on { background: #2e7d32; }
body[data-mode="admin"] #modes button.on { background: #5c636e; }
body[data-mode="fire"] #nav a.active { box-shadow: inset 0 2px 0 #e0453f; }
body[data-mode="ems"] #nav a.active { box-shadow: inset 0 2px 0 #f08c1a; }
body[data-mode="civ"] #nav a.active { box-shadow: inset 0 2px 0 #3fae5a; }
#nav { display: flex; align-items: stretch; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
#nav::-webkit-scrollbar { display: none; }
#nav a { display: flex; align-items: center; gap: 5px; padding: 0 11px; color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; border-right: 1px solid var(--line); white-space: nowrap; text-decoration: none; }
#nav a:hover { background: var(--hdr2); color: var(--text); }
#nav a.active { background: var(--panel); color: var(--text); box-shadow: inset 0 2px 0 var(--accent); }
#nav a .badge { margin-left: 2px; }
#mystatus { display: flex; align-items: center; gap: 5px; margin-left: auto; padding: 0 8px; border-left: 1px solid var(--line); flex: none; white-space: nowrap; }
#signal-banner { position: absolute; left: 50%; top: 3px; transform: translateX(-50%); padding: 3px 14px; background: var(--red); color: #fff; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; font-size: 12px; animation: flash 1s steps(2, start) infinite; z-index: 5; white-space: nowrap; }
@keyframes flash { 50% { background: #6d0f0c; } }
#main { overflow: auto; position: relative; background: var(--bg); }

/* command line */
#cmdbar { display: flex; align-items: stretch; background: var(--hdr); border-top: 1px solid var(--line); min-height: 28px; }
#cmdbar label { display: flex; align-items: center; padding: 0 8px; font: 700 12px var(--mono); color: var(--gold); background: var(--hdr2); border-right: 1px solid var(--line); }
#cmdbar.hidden { display: flex !important; height: 0; min-height: 0; overflow: hidden; border: 0; }
#cmd { flex: 1; border: 0; background: var(--input); padding: 0 8px; font: 13px var(--mono); text-transform: uppercase; outline: none; color: var(--text); }
#cmd:focus { box-shadow: inset 0 0 0 1px var(--accent); }
#cmdmsg { display: flex; align-items: center; padding: 0 10px; font: 12px var(--mono); max-width: 46%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; border-left: 1px solid var(--line); }
#cmdmsg.ok { color: var(--green); }
#cmdmsg.err { color: var(--red); }
#fkeys { display: flex; background: var(--hdr); border-top: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
#fkeys button { flex: 1; min-width: 86px; border: 0; border-right: 1px solid var(--line); background: transparent; padding: 0 6px; cursor: pointer; font-size: 11px; text-transform: uppercase; color: var(--text); white-space: nowrap; }
#fkeys button b { color: var(--gold); margin-right: 4px; font-family: var(--mono); }
#fkeys button:hover { background: var(--hdr2); }
#fkeys button.alarm { background: var(--red); color: #fff; font-weight: 800; }
#fkeys button.alarm b { color: #fff; }
#statusbar { display: flex; align-items: center; background: var(--bg2); border-top: 1px solid var(--line); font: 11px var(--mono); color: var(--muted); overflow: hidden; white-space: nowrap; }
#statusbar > span { padding: 0 10px; border-right: 1px solid var(--line); height: 100%; display: flex; align-items: center; gap: 5px; }
#statusbar > span.grow { border-right: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); display: inline-block; flex: none; }
.dot.on { background: var(--green); }
.dot.off { background: var(--red); }

/* ------------------------------------------------------------ panes (window-style) */
.pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--panel); border: 1px solid var(--line); }
.pane > .ph { display: flex; align-items: center; gap: 6px; height: 24px; padding: 0 6px 0 8px; background: var(--hdr); border-bottom: 1px solid var(--line); flex: none; }
.pane > .ph .t { font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.pane > .ph .c { font: 11px var(--mono); color: var(--muted); }
.pane > .pb { flex: 1; min-height: 0; overflow: auto; }
.page { padding: 10px 12px 30px; max-width: 1500px; }
.page.full { max-width: none; padding: 0; height: 100%; }
.page h1 { font-size: 15px; margin: 2px 0 2px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.page .sub { color: var(--muted); margin: 0 0 10px; }
.toolbar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.panel { background: var(--panel); border: 1px solid var(--line); }
.panel > .hd { display: flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px; background: var(--hdr); border-bottom: 1px solid var(--line); font-weight: 700; font-size: 11px; }
.panel > .hd .title { text-transform: uppercase; letter-spacing: .06em; font-size: 11px; color: var(--text); }
.panel > .bd { padding: 8px; }
.grid { display: grid; gap: 8px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }
.stat { padding: 8px 10px; }
.stat .n { font: 700 22px var(--mono); }
.stat .l { color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; }

/* ------------------------------------------------------------ controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 5px; height: 24px; padding: 0 10px; border: 1px solid var(--line2); background: linear-gradient(var(--panel2), var(--panel3)); color: var(--text); cursor: pointer; font-size: 11.5px; font-weight: 600; white-space: nowrap; border-radius: var(--radius); text-transform: uppercase; letter-spacing: .02em; }
.btn:hover { border-color: var(--accent); }
.btn:active { background: var(--panel3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.good { background: var(--green); border-color: var(--green); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); border-color: var(--line2); }
.btn.sm { height: 22px; padding: 0 8px; font-size: 11px; }
.btn.xs { height: 18px; padding: 0 5px; font-size: 10.5px; }
.btn.big { height: 34px; padding: 0 14px; font-size: 13px; }
.btn.discord { background: #5865f2; border-color: #5865f2; color: #fff; height: 34px; padding: 0 18px; font-size: 13px; }
input[type=text], input[type=number], input[type=date], input[type=search], input[type=url], input:not([type]), select, textarea {
  background: var(--input); border: 1px solid var(--line2); border-radius: var(--radius); padding: 3px 6px; width: 100%; outline: none; min-height: 24px; color: var(--text);
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
textarea { resize: vertical; min-height: 60px; font-family: var(--mono); font-size: 12px; }
select { cursor: pointer; }
label.f { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--muted); }
label.f > span { text-transform: uppercase; letter-spacing: .04em; font-size: 10px; font-weight: 700; }
label.chk { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; color: var(--text); }
.form { display: grid; gap: 6px 8px; }
.form.cols2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form.cols3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form .span2 { grid-column: span 2; }
.form .spanall { grid-column: 1 / -1; }
@media (max-width: 760px) { .form.cols2, .form.cols3 { grid-template-columns: 1fr; } .form .span2 { grid-column: auto; } }
.search-big { position: relative; }
.search-big input { padding: 6px 10px 6px 30px; font: 14px var(--mono); text-transform: uppercase; min-height: 32px; }
.search-big .ico { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--muted); font: 700 12px var(--mono); }

/* ------------------------------------------------------------ tags */
.tag { display: inline-flex; align-items: center; padding: 0 5px; height: 17px; font-size: 10.5px; font-weight: 700; letter-spacing: .03em; white-space: nowrap; background: var(--panel3); color: var(--text); border: 1px solid var(--line2); text-transform: uppercase; }
.tag.danger { background: var(--red); color: #fff; border-color: var(--red); }
.tag.warn { background: var(--amber); color: #111; border-color: var(--amber); }
.tag.ok { background: transparent; color: var(--green); border-color: var(--green); }
.tag.info { background: transparent; color: var(--accent); border-color: var(--accent); }
.tag.p1 { background: var(--p1); color: #fff; border-color: var(--p1); }
.tag.p2 { background: var(--p2); color: #111; border-color: var(--p2); }
.tag.p3 { background: var(--p3); color: #fff; border-color: var(--p3); }
.badge { min-width: 16px; height: 15px; padding: 0 4px; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.status-chip { display: inline-flex; align-items: center; height: 17px; padding: 0 5px; font: 700 10.5px var(--mono); white-space: nowrap; }
.dept-chip { font: 700 10.5px var(--mono); padding: 0 4px; border: 1px solid; height: 16px; display: inline-flex; align-items: center; }
.flags { display: flex; gap: 4px; flex-wrap: wrap; }

/* ------------------------------------------------------------ grids (tables) */
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 10.5px; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: 3px 6px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); background: var(--hdr); position: sticky; top: 0; z-index: 1; white-space: nowrap; }
table.t td { padding: 3px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:nth-child(even) td { background: var(--row-alt); }
table.t tr.click { cursor: default; }
table.t tr.click:hover td { background: var(--panel3); }
table.t tr.sel td { background: var(--sel) !important; color: #fff; }
table.t.dense td { padding: 2px 6px; }
table.t td.m, table.t th.m { font-family: var(--mono); }
.empty { padding: 14px; text-align: center; color: var(--dim); font-style: italic; }
.grid-table td.st { font: 700 11px var(--mono); text-align: center; }
.pend-warn td { background: rgba(230, 161, 0, .18) !important; }
.pend-late td { animation: lateflash 1s steps(2, start) infinite; }
@keyframes lateflash { 50% { background: rgba(211, 47, 47, .35); } }
tr.check-due td { animation: checkflash 1s steps(2, start) infinite; }
@keyframes checkflash { 50% { background: rgba(230, 161, 0, .35); } }
tr.panic td { background: var(--red) !important; color: #fff; animation: flash2 .7s steps(2, start) infinite; }
@keyframes flash2 { 50% { background: #6d0f0c !important; } }

/* ------------------------------------------------------------ dispatch console */
.console { display: grid; height: 100%; padding: 4px; gap: 4px; grid-template-columns: var(--c1, 50%) 5px 1fr; }
.console .stack { display: grid; gap: 4px; min-height: 0; }
.console .colL { grid-template-rows: var(--r1, 24%) 5px var(--r2, 32%) 5px 1fr; }
.console .colR { grid-template-rows: var(--r3, 46%) 5px 1fr; }
.splitter { background: transparent; }
.splitter.v { cursor: col-resize; }
.splitter.h { cursor: row-resize; }
.splitter:hover, .splitter.drag { background: var(--accent); }
.mapwrap { position: relative; flex: 1; min-height: 0; }
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); background: var(--hdr); overflow-x: auto; scrollbar-width: none; }
.tabs button { background: none; border: 0; border-right: 1px solid var(--line); padding: 0 11px; height: 24px; color: var(--muted); cursor: pointer; font-weight: 700; font-size: 11px; text-transform: uppercase; white-space: nowrap; }
.tabs button.on { color: var(--text); background: var(--panel); box-shadow: inset 0 2px 0 var(--accent); }
.page > .tabs { margin: 8px 0; border: 1px solid var(--line); }

/* event detail */
.ev { display: flex; flex-direction: column; min-height: 100%; }
.ev-head { display: flex; align-items: center; gap: 6px; padding: 5px 8px; background: var(--panel2); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ev-head .num { font: 700 14px var(--mono); }
.ev-head .ttl { font-weight: 700; font-size: 13px; text-transform: uppercase; }
.ev-body { padding: 6px 8px; display: flex; flex-direction: column; gap: 6px; }
.kv { display: grid; grid-template-columns: 82px 1fr 82px 1fr; gap: 2px 8px; font-size: 12px; }
.kv > .k { color: var(--muted); font-size: 10px; text-transform: uppercase; font-weight: 700; padding-top: 2px; }
.kv > .v { font-family: var(--mono); min-width: 0; overflow-wrap: anywhere; }
.times { display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid var(--line); }
.times > div { padding: 3px 6px; border-right: 1px solid var(--line); }
.times > div:last-child { border-right: 0; }
.times b { display: block; font-size: 9.5px; color: var(--muted); text-transform: uppercase; }
.times span { font: 12px var(--mono); }
.alert-bar { padding: 4px 8px; font-weight: 700; font-size: 12px; text-transform: uppercase; }
.alert-bar.danger { background: var(--red); color: #fff; }
.alert-bar.warn { background: var(--amber); color: #111; }
.alert-bar.info { background: var(--sel2); color: var(--text); }
.ali { border: 1px solid var(--red); background: rgba(224, 69, 63, .08); font: 12px var(--mono); padding: 4px 8px; }
.ali b { color: var(--red); }
.chrono { font: 12px/1.45 var(--mono); background: var(--tty-bg); color: var(--tty); border: 1px solid var(--line); padding: 4px 6px; max-height: 240px; overflow-y: auto; white-space: pre-wrap; }
.chrono .s { opacity: .7; }
.chrono .t { color: var(--gold); }
.section-t { font-size: 10px; text-transform: uppercase; font-weight: 700; color: var(--muted); letter-spacing: .06em; margin-top: 2px; }
.tty { font: 12.5px/1.4 var(--mono); background: var(--tty-bg); color: var(--tty); padding: 8px 10px; white-space: pre; overflow: auto; margin: 0; border: 1px solid var(--line); }
.tty .hit { color: #ff5a52; font-weight: 700; }
[data-theme="day"] .tty .hit { color: #c00; }
.tty .warn { color: #ffbf3c; }
[data-theme="day"] .tty .warn { color: #9a5b00; }
.tty .sep { opacity: .45; }

/* ------------------------------------------------------------ map */
.leaflet-container { font-family: var(--sans); }
.leaflet-container img.leaflet-tile { outline: 1px solid transparent; }
[data-theme="night"] .leaflet-tile-pane { filter: brightness(.82) saturate(.75); }
.map-unit { display: flex; align-items: center; gap: 3px; transform: translate(-8px, -8px); }
.map-unit .arrow { width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; border: 2px solid #000; }
.map-unit .arrow svg { width: 11px; height: 11px; }
.map-unit .lbl { background: #000; color: #fff; font: 700 10.5px var(--mono); padding: 0 3px; white-space: nowrap; border: 1px solid; }
.map-unit.panic .arrow { animation: pulse .9s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(224, 69, 63, .9); } 100% { box-shadow: 0 0 0 16px rgba(224, 69, 63, 0); } }
.map-call { transform: translate(-9px, -9px); }
.map-call .pin { width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; border: 2px solid #000; transform: rotate(45deg); }
.map-call .pin span { transform: rotate(-45deg); font: 800 10px var(--mono); }
.map-postal { font: 700 10px var(--mono); color: #000; background: rgba(255, 255, 255, .8); padding: 0 2px; transform: translate(-50%, -50%); white-space: nowrap; pointer-events: none; }
.map-station { font: 800 10px var(--mono); background: #000; color: #fff; padding: 0 3px; border: 1px solid #fff; transform: translate(-10px, -8px); white-space: nowrap; }
.map-civ { width: 7px; height: 7px; border-radius: 50%; background: #cbd5e1; border: 1px solid #000; transform: translate(-3px, -3px); }
.map-alpr { width: 12px; height: 12px; background: var(--red); border: 2px solid #fff; transform: translate(-6px, -6px) rotate(45deg); }
.map-hazard { width: 14px; height: 14px; background: var(--amber); border: 2px solid #000; transform: translate(-7px, -7px); font: 900 10px var(--mono); color: #000; display: flex; align-items: center; justify-content: center; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel) !important; color: var(--text) !important; border-radius: 0 !important; }
.leaflet-tooltip { background: var(--panel); color: var(--text); border: 1px solid var(--line2); border-radius: 0; font: 11.5px var(--sans); box-shadow: var(--shadow); }
.leaflet-control-layers, .leaflet-bar a { background: var(--panel) !important; color: var(--text) !important; border-color: var(--line2) !important; border-radius: 0 !important; }
.leaflet-bar { border-radius: 0 !important; }
.leaflet-control-layers label { color: var(--text); }
.ctxmenu { position: fixed; z-index: 3000; background: var(--panel); border: 1px solid var(--line2); box-shadow: var(--shadow); padding: 2px; min-width: 200px; }
.ctxmenu .h { padding: 3px 8px; font: 700 11px var(--mono); color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 2px; }
.ctxmenu button { display: block; width: 100%; text-align: left; padding: 4px 10px; background: none; border: 0; cursor: pointer; font-size: 12px; }
.ctxmenu button:hover { background: var(--sel); color: #fff; }
.ctxmenu hr { border: 0; border-top: 1px solid var(--line); margin: 2px 0; }

/* ------------------------------------------------------------ person / records */
.profile-head { display: grid; grid-template-columns: 96px 1fr auto; gap: 12px; align-items: start; }
.mugshot { width: 96px; height: 120px; background: var(--panel3) center / cover no-repeat; border: 1px solid var(--line2); display: flex; align-items: center; justify-content: center; font: 700 30px var(--mono); color: var(--dim); }
.big-name { font-size: 17px; font-weight: 800; margin: 0; text-transform: uppercase; }
.charges { display: flex; flex-direction: column; max-height: 300px; overflow-y: auto; border: 1px solid var(--line); background: var(--input); }
.charge { display: grid; grid-template-columns: 1fr 70px 50px 60px; gap: 6px; align-items: center; padding: 2px 6px; border-bottom: 1px solid var(--line); font-size: 12px; }
.charge:hover { background: var(--panel3); }
.charge.on { background: var(--sel2); }
.charge .cat { font-size: 10px; color: var(--muted); text-transform: uppercase; font-weight: 700; }
.totals { display: flex; gap: 18px; font: 700 12px var(--mono); padding: 4px 2px; }
.plate-box { display: inline-block; font: 800 18px var(--mono); letter-spacing: .1em; padding: 3px 12px; background: #f3f4f6; color: #0b2a6b; border: 2px solid #0b2a6b; }

/* ------------------------------------------------------------ dialogs / toasts */
.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 1000; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; overflow-y: auto; }
.modal { background: var(--panel); border: 1px solid var(--line2); width: 100%; max-width: 620px; box-shadow: var(--shadow); }
.modal.wide { max-width: 900px; }
.modal .mh { height: 26px; padding: 0 4px 0 10px; background: var(--hdr); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.modal .mh h2 { margin: 0; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; }
.modal .mb { padding: 10px; }
.modal .mf { padding: 6px 10px; border-top: 1px solid var(--line); display: flex; gap: 6px; justify-content: flex-end; background: var(--panel2); }
#toasts > .toast:nth-last-child(n+5) { display: none; }
#toasts { position: fixed; right: 10px; bottom: 76px; z-index: 2000; display: flex; flex-direction: column; gap: 6px; max-width: 380px; }
.toast { background: var(--panel); border: 1px solid var(--line2); border-left: 4px solid var(--accent); padding: 6px 10px; box-shadow: var(--shadow); animation: tin .15s ease-out; font-size: 12px; }
.toast.err { border-left-color: var(--red); }
.toast.ok { border-left-color: var(--green); }
.toast.alert { border-left-color: var(--red); background: var(--red); color: #fff; }
.toast b { display: block; text-transform: uppercase; font-size: 11px; letter-spacing: .04em; }
@keyframes tin { from { transform: translateX(10px); opacity: 0; } }
.panic-overlay { position: fixed; inset: 0; pointer-events: none; z-index: 900; box-shadow: inset 0 0 0 5px var(--red); animation: pflash .8s steps(2, start) infinite; }
@keyframes pflash { 50% { box-shadow: inset 0 0 0 5px transparent; } }
.panic-bar { position: fixed; top: 34px; left: 50%; transform: translateX(-50%); z-index: 950; display: flex; flex-direction: column; gap: 4px; }
.panic-bar .p { background: var(--red); color: #fff; padding: 6px 10px; box-shadow: var(--shadow); display: flex; gap: 10px; align-items: center; font: 700 12.5px var(--mono); }

/* ------------------------------------------------------------ sign-in page */
.login { height: 100vh; display: flex; align-items: center; justify-content: center; background: #0f1216; overflow: auto; color: #dfe4ec; }
.login .box { width: 560px; max-width: 94vw; background: #1b1f25; border: 1px solid #3a414c; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.login .bh { background: #2b313a; padding: 6px 10px; font: 700 11px var(--sans); text-transform: uppercase; letter-spacing: .08em; border-bottom: 1px solid #3a414c; }
.login .bb { padding: 18px 22px; text-align: center; }
.login img { width: 150px; }
.login h1 { font-size: 15px; letter-spacing: .1em; text-transform: uppercase; margin: 10px 0 2px; }
.login .warn { text-align: left; font: 11.5px/1.45 var(--mono); background: #07090c; color: #c8d0dc; border: 1px solid #3a414c; padding: 10px 12px; margin: 14px 0; }
.login .warn b { color: #e8b34a; }
.login .err { background: #c62828; color: #fff; padding: 6px 10px; margin: 10px 0; font-weight: 700; }

/* ------------------------------------------------------------ MDT (in-car tablet) */
.mdt { display: grid; grid-template-rows: auto 1fr; height: 100%; }
.mdt-status { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 4px; padding: 6px; background: var(--hdr); border-bottom: 1px solid var(--line); }
.mdt-status button { height: 46px; border: 2px solid #000; font: 800 13px var(--mono); cursor: pointer; text-transform: uppercase; line-height: 1.1; }
.mdt-status button small { display: block; font: 700 10px var(--sans); }
.mdt-status button.cur { outline: 3px solid var(--text); outline-offset: -6px; }
.mdt-body { display: grid; grid-template-columns: 1.1fr 1fr; gap: 6px; padding: 6px; min-height: 0; }

/* tablet (inside the game) */
body.tablet #top .brand span, body.tablet #top .brand b { display: none; }
body.tablet #modes button { padding: 0 5px; }
@media (max-width: 1400px) { #top .brand span { display: none; } }
@media (max-width: 1000px) { #top .brand { min-width: 0; } #top .brand b, #top .brand span { display: none; } #fkeys button { min-width: 70px; } }
@media print {
  #top, #cmdbar, #fkeys, #statusbar, .btn, .tabs { display: none !important; }
  body, #main { overflow: visible; background: #fff; color: #000; }
  #app { display: block; }
}

/* ------------------------------------------------------------ action buttons (Simple mode friendly) */
.btn .ico { flex: none; margin-left: -2px; }
.btn { transition: border-color .12s, background .12s, transform .05s; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.actbar { display: flex; align-items: center; gap: 4px; padding: 4px; background: var(--hdr); border: 1px solid var(--line); flex-wrap: wrap; }
.actbar .sep { width: 1px; height: 18px; background: var(--line2); margin: 0 3px; }
.actbar .btn { height: 26px; }
.actgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px; padding: 6px; background: var(--panel2); border-bottom: 1px solid var(--line); }
.actgrid .btn { height: 34px; justify-content: flex-start; padding: 0 10px; font-size: 12px; }
.actgrid .btn .ico { width: 16px; height: 16px; }
.unit-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 4px; max-height: 340px; overflow-y: auto; }
.unit-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 6px 8px; border: 1px solid var(--line2); background: var(--panel2); cursor: pointer; text-align: left; color: var(--text); }
.unit-tile b { font: 700 14px var(--mono); }
.unit-tile span { font-size: 11px; color: var(--muted); }
.unit-tile i { font: 700 10.5px var(--mono); font-style: normal; padding: 0 4px; margin-top: 2px; }
.unit-tile:hover { border-color: var(--accent); }
.unit-tile.on { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); background: var(--sel2); }
.status-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 4px; }
.status-btn { height: 46px; border: 2px solid #000; cursor: pointer; font-size: 12px; font-weight: 700; text-transform: uppercase; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.status-btn b { font: 800 14px var(--mono); }
.status-btn.cur { outline: 3px solid var(--text); outline-offset: -6px; }
.hint { padding: 4px 8px; font-size: 11.5px; color: var(--muted); background: var(--panel2); border-bottom: 1px solid var(--line); }
.hint b { color: var(--text); }
body[data-level="advanced"] .hint { display: none; }
.dispatch-wrap { display: flex; flex-direction: column; height: 100%; }
.dispatch-wrap > .actbar { margin: 4px 4px 0; }
.dispatch-wrap > .console { flex: 1; min-height: 0; height: auto; }
#mystatus .lvl { border: 1px solid var(--line2); }
