:root {
  --bg: #0f1113;
  --surface: #17191c;
  --surface-2: #1f2226;
  --border: #2c3036;
  --text: #ecebe7;
  --text-2: #b9b8b0;
  --muted: #8a8984;
  --accent: #3987e5;
  --accent-2: #1baf7a;
  --free: #0ca30c;
  --moderate: #fab219;
  --heavy: #ec835a;
  --severe: #d03b3b;
  --info: #3987e5;
  --radius: 8px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 13px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.row { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 16px; padding: 8px 14px; background: var(--surface);
  border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { color: var(--accent); display: grid; place-items: center; }
.title { font-weight: 700; font-size: 16px; letter-spacing: .3px; }
.subtitle { color: var(--muted); font-size: 11.5px; }
.poc-badge { border: 1px solid var(--moderate); color: var(--moderate); border-radius: 999px; padding: 2px 10px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.replay { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 320px; }
.replay input[type=range] { flex: 1; accent-color: var(--accent); min-width: 120px; }
.clock { text-align: right; min-width: 92px; }
#clockTime { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
#clockDate { font-size: 11px; }
.who { display: flex; align-items: center; gap: 6px; }

.btn { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px;
  padding: 5px 10px; cursor: pointer; font: inherit; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.icon { width: 32px; padding: 5px 0; }
.btn.primary { background: #1c5cab; border-color: #256abf; }
.btn.danger { background: #7a2323; border-color: var(--severe); }
.btn.ok { border-color: var(--free); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 2px 8px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.sel { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 6px; font: inherit; max-width: 100%; }

/* KPI strip */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; padding: 8px 14px;
  background: var(--bg); border-bottom: 1px solid var(--border); }
.kpis.mini { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 8px 0; border: 0; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 10px; min-width: 0; }
.kpi-l { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-v { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-v.small { font-size: 13px; padding-top: 4px; }

/* layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 470px; height: calc(100vh - 118px); min-height: 520px; }
.mapwrap { position: relative; min-height: 400px; }
#map { position: absolute; inset: 0; background: #0b0c0d; }
.legend { position: absolute; left: 10px; bottom: 22px; z-index: 500; background: rgba(23,25,28,.92);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; font-size: 11.5px; line-height: 1.7; }
.legend-title { font-weight: 600; margin-bottom: 2px; }
.sw { display: inline-block; width: 18px; height: 4px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }

.panel { background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.tabs { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px 6px 0; border-bottom: 1px solid var(--border); }
.tab { background: transparent; color: var(--text-2); border: 0; border-bottom: 2px solid transparent; padding: 6px 8px;
  cursor: pointer; font: inherit; font-size: 12.5px; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.pill { background: var(--surface-2); border-radius: 999px; padding: 0 6px; font-size: 11px; margin-left: 2px; }
.pill.live { color: var(--moderate); }
.tabpane { display: none; overflow-y: auto; padding: 10px 12px 18px; flex: 1; min-height: 0; }
.tabpane.active { display: block; }

.card { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; margin: 8px 0; }
.card-h { font-weight: 600; margin-bottom: 6px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.chartbox { position: relative; height: 220px; }
.chartbox.short { height: 150px; }
.segmeta { margin-bottom: 6px; font-size: 12px; }
.fcpoints { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.fcp { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; }
.fcp b { font-size: 15px; }

.list { display: flex; flex-direction: column; gap: 6px; }
.item { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: 6px; padding: 8px 10px; }
.item.sev-high { border-left-color: var(--severe); }
.item.sev-medium { border-left-color: var(--heavy); }
.item.sev-low { border-left-color: var(--moderate); }
.item.sev-info { border-left-color: var(--info); }
.item.done { opacity: .6; }
.item-h { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.item-b { color: var(--text-2); margin-top: 3px; font-size: 12px; }
.item-a { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 0 7px; font-size: 11px;
  border: 1px solid var(--border); white-space: nowrap; font-weight: 600; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; }
.chip.high, .chip.severe, .chip.Critical { color: #ff8f8f; border-color: var(--severe); }
.chip.medium, .chip.heavy, .chip.Dense { color: var(--heavy); border-color: var(--heavy); }
.chip.low, .chip.moderate { color: var(--moderate); border-color: var(--moderate); }
.chip.free, .chip.Normal, .chip.acknowledged { color: #4fd14f; border-color: var(--free); }
.chip.info, .chip.open { color: #8fbff5; border-color: var(--info); }
.chip.dismissed { color: var(--muted); }
.chip.overridden { color: #c9a7ff; border-color: #9085e9; }

.tablewrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--border); padding: 4px 5px; position: sticky; top: 0; background: var(--surface); }
.tbl td { border-bottom: 1px solid #24272b; padding: 4px 5px; vertical-align: top; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: #22262b; }
.tbl tr.sel td { background: #1c2a3d; }

.form { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin-bottom: 8px; }
.form label { display: flex; flex-direction: column; gap: 2px; color: var(--muted); font-size: 11.5px; }
.out { margin-top: 8px; font-size: 12.5px; }
.out .big { font-size: 20px; font-weight: 700; }
.compare { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 6px 0; }
.compare > div { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; }
.bar { height: 8px; background: #2a2e33; border-radius: 4px; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 4px; }
.phasebar { display: flex; height: 26px; border-radius: 6px; overflow: hidden; margin: 6px 0; border: 1px solid var(--border); }
.phasebar > div { display: grid; place-items: center; font-size: 11px; color: #0b0b0b; font-weight: 600; border-right: 2px solid var(--surface-2); }

.cvframe { position: relative; margin-top: 8px; }
.cvframe img { width: 100%; border-radius: var(--radius); border: 1px solid var(--border); display: block; background: #000; min-height: 120px; }
.cvcap { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.65); padding: 2px 8px; border-radius: 4px; font-size: 11px; }
.thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 6px; }
.thumbs img { width: 100%; border-radius: 4px; cursor: pointer; border: 1px solid var(--border); }
.thumbs img.on { border-color: var(--accent); }

.live-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); margin-right: 6px; }
.live-dot.on { background: var(--free); box-shadow: 0 0 0 0 rgba(12,163,12,.6); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(12,163,12,.6); } 70% { box-shadow: 0 0 0 8px rgba(12,163,12,0); } 100% { box-shadow: 0 0 0 0 rgba(12,163,12,0); } }

.advisory { background: #f6f5f1; color: #141414; border-radius: var(--radius); padding: 12px; }
.adv-h { font-weight: 700; font-size: 15px; margin-bottom: 8px; }
.adv { border-bottom: 1px solid #dddad2; padding: 8px 0; display: flex; gap: 10px; }
.adv .tag { font-size: 11px; font-weight: 700; text-transform: uppercase; min-width: 74px; }
.adv .tag.high { color: #b02a2a; } .adv .tag.medium { color: #a6531d; } .adv .tag.low { color: #8a6500; }
.advisory .muted { color: #5f5e59; }

/* map markers */
.inc-marker { width: 18px; height: 18px; border-radius: 50%; background: var(--severe); border: 2px solid #fff;
  box-shadow: 0 0 0 0 rgba(208,59,59,.7); animation: pulsered 1.4s infinite; }
@keyframes pulsered { 0% { box-shadow: 0 0 0 0 rgba(208,59,59,.7); } 70% { box-shadow: 0 0 0 12px rgba(208,59,59,0); } 100% { box-shadow: 0 0 0 0 rgba(208,59,59,0); } }
.vtag { font: 700 10px/1 system-ui, sans-serif; padding: 3px 5px; border-radius: 4px; color: #fff; border: 1px solid #fff; white-space: nowrap; text-align: center; }
.vtag.ambulance { background: #d03b3b; } .vtag.fire { background: #c25a00; } .vtag.police { background: #256abf; }
.vtag.vip { background: #6250d6; } .vtag.drone { background: #111; border-color: #3ad0ff; color: #3ad0ff; }
.vtag.obj { background: #444; } .vtag.alert { background: #d03b3b; }
.leaflet-tooltip.seg-tip { background: #17191c; color: var(--text); border: 1px solid var(--border); }
.leaflet-container { font: inherit; }
/* control-room dark rendering of standard OSM tiles */
.osm-dark { filter: invert(1) hue-rotate(180deg) brightness(.78) contrast(.92) saturate(.35); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); }
.leaflet-control-layers { background: var(--surface) !important; color: var(--text); border: 1px solid var(--border) !important; }

.toast { position: fixed; right: 16px; bottom: 16px; background: var(--surface-2); border: 1px solid var(--accent);
  border-radius: var(--radius); padding: 8px 12px; opacity: 0; transition: opacity .25s; z-index: 2000; pointer-events: none; }
.toast.show { opacity: 1; }

@media (max-width: 1280px) {
  .layout { grid-template-columns: minmax(0, 1fr) 420px; }
  .subtitle { display: none; }
}
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .mapwrap { height: 55vh; }
  .panel { border-left: 0; border-top: 1px solid var(--border); }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tabpane { max-height: none; }
}
