:root {
  --bg: #F3F6FA;
  --surface: #FFFFFF;
  --raised: #E9EFF6;
  --border: #D6DFEA;
  --text: #12233D;
  --muted: #566880;
  --outline: #A9B7C9;
  --blue: #0048A0;
  --blue-dark: #00306B;
  --green: #32B153;
  --green-bg: #E3F4E7;
  --green-text: #14532D;
  --red: #B3261E;
  --red-tint: #FDECEA;
  --red-text: #7A1712;
  --red-line: #F2B8B2;
  --font: "Nunito Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.45; }
a { color: var(--blue); }
a:hover { color: var(--blue-dark); }
button, input, select { font-family: inherit; }
.live-banner { background: #3D4F66; color: #fff; text-align: center; padding: 10px 16px; font-weight: 600; }
.hdr { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 16px 32px; border-bottom: 1px solid var(--border); background: var(--surface); }
.hdr img.logo { height: 34px; width: auto; display: block; }
.hdr .div { width: 1px; height: 32px; background: var(--border); }
.hdr .title { font-size: 16px; font-weight: 600; }
.hdr .sub { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.hdr nav { display: flex; flex-wrap: wrap; gap: 4px; margin-left: 8px; }
.hdr nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; }
.hdr nav a.on { background: var(--raised); color: var(--text); font-weight: 600; }
.grow { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 14px; border: 1px solid var(--border); border-radius: 999px; font-family: var(--mono); font-size: 12px; background: var(--surface); }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.pill.bad .dot { background: var(--red); }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost-red { background: #fff; border-color: var(--red); color: var(--red-text); }
.btn:disabled { opacity: 0.45; cursor: default; }
.chk { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; }
.chk input { width: 18px; height: 18px; accent-color: var(--blue); }
main { display: flex; flex-direction: column; gap: 24px; padding: 24px 32px; max-width: 1440px; margin: 0 auto; }
h1 { margin: 0; font-size: 28px; font-weight: 700; }
h2 { margin: 0; font-size: 16px; font-weight: 700; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.banner { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; padding: 20px 24px; border-radius: 12px; background: var(--red-tint); border: 1px solid var(--red-line); }
.banner.calm { background: var(--surface); border-color: var(--border); }
.banner .mark { width: 48px; height: 48px; border-radius: 50%; background: var(--red); color: #fff; display: inline-flex; align-items: center; justify-content: center; flex: none; font-weight: 700; }
.banner h2 { font-size: 20px; color: var(--red-text); }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 20px; }
.kpi b { display: block; margin-top: 6px; font-size: 32px; font-weight: 700; }
.kpi b.warn { color: var(--red); }
.kpi .unit { font-size: 18px; font-weight: 500; color: var(--muted); }
.split { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.col-main { flex: 999 1 640px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.col-side { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.row-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12px; color: var(--muted); }
.swatch { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.map { position: relative; height: 380px; background: #E6EEE4; }
.map.tall { height: 520px; }
.map-fallback { position: absolute; left: 12px; top: 12px; z-index: 500; background: rgba(255,255,255,.92); border-radius: 6px; padding: 6px 10px; font-size: 12px; color: var(--muted); }
.cam-icon { background: transparent; border: 0; }
.cam-icon span { display: block; width: 18px; height: 18px; border-radius: 50%; border: 3px solid #fff; box-sizing: border-box; }
.alert-row, .officer-row, .note-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 14px 20px; border-bottom: 1px solid #E9EFF6; color: inherit; text-decoration: none; }
.alert-row.new { background: #FFF8F7; }
.who { flex: 1 1 180px; min-width: 0; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { padding: 2px 8px; border-radius: 4px; background: var(--green-bg); color: var(--green-text); font-size: 12px; font-weight: 600; }
.tag.muted { background: var(--raised); color: var(--muted); }
.tag.bad { background: var(--red-tint); color: var(--red-text); }
.chip { display: inline-flex; align-items: center; justify-content: center; min-width: 88px; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.chip.new { background: var(--red); color: #fff; }
.chip.acknowledged { background: #E8F0FE; color: var(--blue-dark); }
.chip.resolved { background: var(--green-bg); color: var(--green-text); }
.chip.false_alarm { background: var(--raised); color: #3D4F66; }
.chip.test { background: #FFF4E5; color: #7A4E00; }
.shot { position: relative; width: 100%; max-width: 760px; aspect-ratio: 4 / 3; background: #0C100E; border-radius: 8px; overflow: hidden; }
.shot img, .shot video { width: 100%; height: 100%; object-fit: contain; background: #0C100E; display: block; }
.shot .hud { position: absolute; top: 10px; left: 10px; padding: 4px 10px; border-radius: 6px; background: rgba(12,16,14,.82); font-family: var(--mono); font-size: 11px; color: #E8EEE9; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.tl { display: flex; gap: 16px; }
.tl .rail { display: flex; flex-direction: column; align-items: center; }
.tl .rail i { width: 12px; height: 12px; border-radius: 50%; background: var(--blue); flex: none; }
.tl .rail i.wait { background: #fff; border: 2px solid #8A97A8; box-sizing: border-box; }
.tl .rail b { flex: 1; width: 2px; background: var(--border); }
.tl .body { padding-bottom: 16px; }
.crumbs { font-size: 13px; color: var(--muted); }
.crumbs a { text-decoration: none; }
dl.grid { margin: 0; display: grid; grid-template-columns: 140px 1fr; row-gap: 10px; }
dl.grid dt { color: var(--muted); }
dl.grid dd { margin: 0; font-weight: 600; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.channel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.channel.planned { border-style: dashed; border-color: #B8C4D4; }
.dim { color: var(--muted); }
.badge { padding: 2px 10px; border-radius: 4px; font-size: 12px; font-weight: 700; background: var(--green-bg); color: var(--green-text); }
.badge.mock, .badge.preview, .badge.planned, .badge.off { background: var(--raised); color: #3D4F66; }
.wa { background: #EAE6DF; padding: 20px; }
.bubble { max-width: 340px; background: #fff; border-radius: 0 12px 12px 12px; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.help { font-size: 13px; color: var(--muted); background: #FFF8E8; border: 1px solid #F0E0B0; border-radius: 8px; padding: 12px; }
.form { display: flex; flex-wrap: wrap; gap: 16px 24px; }
label.field { flex: 1 1 200px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.picker { position: relative; }
.picker-btn { width: 100%; text-align: left; cursor: pointer; min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--text); background: #fff; }
.picker-btn:disabled { opacity: 0.45; cursor: default; }
.picker-list { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(18,35,61,.16); display: flex; flex-direction: column; padding: 4px; max-height: 320px; overflow: auto; }
.picker-list[hidden] { display: none; }
.picker-list button { text-align: left; min-height: 40px; border: 0; background: #fff; border-radius: 6px; padding: 8px 12px; cursor: pointer; font-weight: 600; color: var(--text); }
.picker-list button.on, .picker-list button:hover { background: var(--raised); }
input[type="text"], input[type="number"], input[type="email"], input[type="password"], select {
  min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; color: var(--text); background: #fff;
}
.modal-back { position: fixed; inset: 0; background: rgba(18,35,61,.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 40; }
.modal { background: #fff; border-radius: 12px; padding: 20px; width: min(520px, 100%); display: flex; flex-direction: column; gap: 12px; }
.keybox { font-family: var(--mono); font-size: 13px; word-break: break-all; background: var(--raised); padding: 12px; border-radius: 8px; }
.state { padding: 28px 20px; color: var(--muted); }
.err { background: var(--red-tint); color: var(--red-text); border: 1px solid var(--red-line); border-radius: 10px; padding: 12px 14px; }
.cam-card { border: 2px solid var(--border); border-radius: 12px; padding: 20px; display: flex; flex-direction: column; gap: 16px; background: #fff; cursor: pointer; text-align: left; }
.cam-card.on { border-color: var(--blue); }
.dashed { border: 2px dashed #B8C4D4; border-radius: 12px; padding: 20px; color: var(--muted); }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login { width: min(420px, 100%); background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.officer { max-width: 480px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.phone { width: min(390px, 100%); min-height: 100vh; margin: 0 auto; background: var(--bg); display: flex; flex-direction: column; }
.pad { padding: 16px 20px; }
.meter { margin-top: 4px; height: 8px; background: var(--raised); border-radius: 4px; }
.meter i { display: block; height: 100%; background: var(--blue); border-radius: 4px; }
.meter.warn i { background: var(--red); }
.stage { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #0C100E; border-radius: 8px; overflow: hidden; }
.stage img, .stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.stage canvas { pointer-events: none; }
.stage .hud { position: absolute; padding: 4px 10px; border-radius: 6px; background: rgba(12,16,14,.82); font-family: var(--mono); font-size: 12px; color: #E8EEE9; }
.stage .hud.tl { top: 12px; left: 12px; }
.stage .hud.tr { top: 12px; right: 12px; display: flex; gap: 8px; }
.stage .hud.bl { left: 12px; bottom: 12px; }
.stage .empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #C9D6CD; padding: 24px; text-align: center; }
.signal { position: relative; height: 72px; margin-top: 8px; background: #303034; border-radius: 8px; overflow: hidden; }
.signal canvas { width: 100%; height: 100%; display: block; }
.signal-lab { position: absolute; left: 10px; bottom: 3px; color: #d5d5da; font-family: var(--mono); font-size: 11px; }
.modes { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.modes button { min-height: 44px; padding: 0 16px; border: 0; background: #fff; color: var(--text); font-weight: 600; cursor: pointer; }
.modes button.on { background: var(--blue); color: #fff; }
.log { background: #0B1210; border-radius: 12px; padding: 16px 20px; color: #C9D6CD; font-family: var(--mono); font-size: 12px; line-height: 1.6; }
.device-off .stage { filter: grayscale(1); }
.thumbs { display: flex; flex-wrap: wrap; gap: 16px; }
.thumb { width: 150px; text-decoration: none; color: inherit; }
.thumb .shot { aspect-ratio: 4 / 3; }
@media (max-width: 800px) {
  .hdr, main { padding-left: 16px; padding-right: 16px; }
  .hdr nav { margin-left: 0; width: 100%; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .map, .map.tall { height: 280px; }
  dl.grid { grid-template-columns: 1fr; }
}
