/* Look follows Markus's rooftop-monitoring mockups (2026-10): deep teal brand, soft grey page,
   white cards, amber = attention, red = offline, green-grey = ok. */
:root {
  --bg: #f3f5f6;
  --surface: #ffffff;
  --surface-2: #f2f5f5;
  --border: #e1e6e8;
  --text: #17262b;
  --muted: #6b7a80;
  --brand: #12363b;
  --brand-2: #1d6f66;
  --accent: #17796c;
  --accent-text: #ffffff;
  --good: #2d7a57;
  --warn: #b36b00;
  --bad: #c62828;
  --good-bg: #e3f3eb;
  --warn-bg: #fbecd2;
  --bad-bg: #fbe4e2;
  --heat-ok: #bfe6d8;
  --heat-attention: #eab062;
  --heat-offline: #e57f7f;
  --heat-nodata: #eceff0;
  --near: #1f6feb;
  --far: #d9480f;
  --near-2: #9dbff5;
  --far-2: #f2b08f;
  --board: #6f42c1;
  --grid: #e7eaee;
  --radius: 12px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1416; --surface: #151d20; --surface-2: #1b2529; --border: #26333a;
    --text: #e2eaec; --muted: #8a9aa0; --brand: #0d2a2e; --brand-2: #3fae9f; --accent: #3fae9f; --accent-text: #08201d;
    --good: #5cc38f; --warn: #f0a63a; --bad: #ff6b6b;
    --good-bg: #133026; --warn-bg: #3a2a10; --bad-bg: #3d1717;
    --heat-ok: #1f4a3e; --heat-attention: #a8701f; --heat-offline: #9e3b3b; --heat-nodata: #1f292d;
    --near: #5b9bff; --far: #ff8a4c; --near-2: #2b4f8a; --far-2: #8a4a2a; --board: #b18cff; --grid: #24303a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1416; --surface: #151d20; --surface-2: #1b2529; --border: #26333a;
  --text: #e2eaec; --muted: #8a9aa0; --brand: #0d2a2e; --brand-2: #3fae9f; --accent: #3fae9f; --accent-text: #08201d;
  --good: #5cc38f; --warn: #f0a63a; --bad: #ff6b6b;
  --good-bg: #133026; --warn-bg: #3a2a10; --bad-bg: #3d1717;
  --heat-ok: #1f4a3e; --heat-attention: #a8701f; --heat-offline: #9e3b3b; --heat-nodata: #1f292d;
  --near: #5b9bff; --far: #ff8a4c; --near-2: #2b4f8a; --far-2: #8a4a2a; --board: #b18cff; --grid: #24303a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
h1 { font-size: 28px; line-height: 1.2; margin: 4px 0 6px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0; font-weight: 650; }
h3 { font-size: 12.5px; margin: 0 0 6px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
button, select, input { font: inherit; color: inherit; }
button { background: var(--accent); color: var(--accent-text); border: 0; border-radius: 8px; padding: 7px 13px; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
button.ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
button.ghost.accent { color: var(--accent); }
button.small { padding: 4px 10px; font-size: 12.5px; }
button.link { background: none; color: var(--accent); padding: 0; font-size: 12.5px; font-weight: 600; }
select, input[type=time], input[type=date], input[type=search] { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 12px; }
.num { font-variant-numeric: tabular-nums; }
.spacer { flex: 1; }

/* header */
.top { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 28px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 40px; height: 40px; border-radius: 9px; background: var(--brand); color: #67d3bf; display: grid; place-items: center; font-weight: 700; font-size: 20px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text b { font-size: 20px; letter-spacing: -.01em; }
.brand-text small { font-size: 10.5px; font-weight: 700; letter-spacing: .18em; color: var(--muted); }
.brand-sep { width: 1px; height: 26px; background: var(--border); margin: 0 6px; }
.brand-sub { color: var(--muted); }
.status { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; }
.pill { border-radius: 999px; padding: 4px 12px; font-size: 12.5px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.pill.good { background: var(--good-bg); color: var(--good); border-color: transparent; }
.pill.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.pill.quiet { font-weight: 500; }
.pill.outline { background: var(--good-bg); color: var(--good); border-color: transparent; font-weight: 500; }

main { padding: 8px 28px 24px; max-width: 1440px; margin: 0 auto; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; margin: 18px 0 22px; }
.tabs button { white-space: nowrap; background: none; color: var(--muted); border-radius: 0; padding: 10px 16px; border-bottom: 2px solid transparent; }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 650; }

.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; }
.eyebrow { font-size: 11.5px; font-weight: 700; letter-spacing: .14em; color: var(--muted); }
.page-sub { color: var(--muted); }
.page-tools { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; justify-content: flex-end; }
.tz { flex-basis: 100%; text-align: right; color: var(--muted); font-size: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.field.grow { flex: 1; min-width: 220px; }
.field input, .field select { color: var(--text); }

.banner { background: var(--bad-bg); color: var(--bad); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; font-size: 13px; }
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid.sites, .grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; min-width: 0; margin-bottom: 16px; }
.grid > .card { margin-bottom: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.badge { background: var(--surface-2); border: 1px solid var(--border); border-radius: 7px; padding: 1px 8px; font-size: 12px; color: var(--muted); }

/* KPI strip */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 20px; }
.kpi { padding: 18px 22px; border-right: 1px solid var(--border); min-width: 0; }
.kpi:last-child { border-right: 0; }
.kpi .k { color: var(--muted); font-size: 13px; }
.kpi .v { font-size: 22px; font-weight: 700; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.kpi .v.warn { color: var(--warn); }
.kpi .v.bad { color: var(--bad); }
.kpi .v.good { color: var(--good); }
.kpi .s { color: var(--muted); font-size: 12px; }
.kpi select { margin-top: 4px; }

/* dark status banner */
.banner-dark { background: var(--brand); color: #e6f2f0; border-radius: var(--radius); padding: 20px 24px; display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 16px; margin-bottom: 20px; align-items: center; }
.banner-dark .k { color: #9fc4bd; font-size: 12.5px; }
.banner-dark .v { font-size: 17px; font-weight: 700; margin: 3px 0; }
.banner-dark .s { color: #9fc4bd; font-size: 12px; }
.banner-dark .live { color: #67d3bf; font-size: 12.5px; font-weight: 600; }
.banner-dark .live.off { color: #ff9b9b; }

/* time-lapse */
.tl-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.tl-main { padding: 0; overflow: hidden; }
.tl-main > .card-head { padding: 18px 20px 6px; }
.viewers { display: grid; grid-template-columns: 1fr; gap: 3px; background: #0b1214; }
.viewers.two { grid-template-columns: 1fr 1fr; }
.viewers.two .vtag { font-size: 10.5px; padding: 4px 7px; }
.viewers.two .voverlay .motion { bottom: 30px; font-size: 11px; }
.viewers.two .vempty { font-size: 12px; padding: 16px; }
.viewer { position: relative; background: #0b1214; aspect-ratio: 16 / 9; overflow: hidden; }
.viewer img { width: 100%; height: 100%; object-fit: contain; display: block; }
.vtags { position: absolute; top: 12px; right: 14px; display: flex; gap: 6px; }
.vtag { background: rgba(10, 18, 20, .82); color: #fff; font: 600 11.5px var(--mono); padding: 6px 10px; border-radius: 6px; }
.vtag .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #3ddc97; margin: 0 6px; vertical-align: middle; }
.vfoot { position: absolute; bottom: 10px; color: rgba(255,255,255,.88); font: 600 11px var(--mono); text-shadow: 0 1px 2px rgba(0,0,0,.8); letter-spacing: .04em; }
.vfoot.bl { left: 16px; }
.voverlay { position: absolute; inset: 0; pointer-events: none; }
.voverlay .box { position: absolute; border: 2px solid #f0a63a; }
.voverlay .box span { position: absolute; left: -2px; top: -22px; background: #f0a63a; color: #2a1a00; font-size: 11.5px; font-weight: 600; padding: 2px 7px; white-space: nowrap; }
.voverlay .motion { position: absolute; left: 50%; bottom: 40px; transform: translateX(-50%); background: rgba(240, 166, 58, .95); color: #2a1a00; font-size: 12px; font-weight: 650; padding: 4px 10px; border-radius: 6px; }
.voverlay.frame-edge { box-shadow: inset 0 0 0 3px rgba(240, 166, 58, .9); }
.vempty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: #cfdcdf; padding: 30px; font-size: 13.5px; line-height: 1.6; background: #0b1214; }
.vempty b { color: #fff; font-size: 15px; }
[hidden] { display: none !important; }
.controls { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.controls label { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; }
button.round { width: 40px; height: 40px; border-radius: 50%; background: var(--brand); color: #fff; padding: 0; font-size: 14px; }
button.icon { background: none; color: var(--text); padding: 4px 6px; font-size: 16px; }
.tl-time { font-variant-numeric: tabular-nums; }
.daily { padding: 16px 20px 18px; }
.daily-head { display: flex; justify-content: space-between; margin-bottom: 18px; }
.tline { position: relative; height: 34px; cursor: pointer; margin: 0 6px; }
.tline .track { position: absolute; left: 0; right: 0; top: 9px; height: 5px; border-radius: 3px; background: var(--grid); }
.tline .frames { position: absolute; top: 9px; height: 5px; background: #9fc9c0; border-radius: 3px; }
.tline .progress { position: absolute; left: 0; top: 9px; height: 5px; border-radius: 3px; background: var(--brand-2); }
.tline .gap { position: absolute; top: 4px; height: 15px; background: repeating-linear-gradient(135deg, rgba(229,127,127,.55) 0 3px, transparent 3px 6px); }
.tline .knob { position: absolute; top: 3px; width: 17px; height: 17px; border-radius: 50%; background: #5b6b70; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border); transform: translateX(-50%); }
.tline .mk { position: absolute; top: 24px; transform: translateX(-50%); }
.tline .mk.tick { width: 2px; height: 8px; background: var(--brand-2); opacity: .55; }
.tline .mk.obj { width: 8px; height: 8px; border-radius: 50%; background: #2b5d8a; top: 23px; }
.tline .mk.diamond { width: 9px; height: 9px; background: #e09100; transform: translateX(-50%) rotate(45deg); top: 23px; }
.tline .mk.sel { outline: 2px solid var(--text); }
.tline-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin: 4px 0 10px; font-variant-numeric: tabular-nums; }
.tline-legend { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; color: var(--muted); font-size: 12px; margin-bottom: 14px; }
.tline-legend i { display: inline-block; vertical-align: middle; margin-right: 6px; }
.lg-diamond { width: 8px; height: 8px; background: #e09100; transform: rotate(45deg); }
.lg-tick { width: 2px; height: 10px; background: var(--brand-2); }
.lg-obj { width: 8px; height: 8px; border-radius: 50%; background: #2b5d8a; }
.lg-gap { width: 14px; height: 10px; background: repeating-linear-gradient(135deg, rgba(229,127,127,.7) 0 3px, transparent 3px 6px); }
.lg-frames { width: 14px; height: 5px; background: #9fc9c0; border-radius: 3px; }
.thumbs { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.thumbs.two { gap: 8px; }
.tline .mk.tick.cam1 { top: 30px; }  /* both cameras: near ticks above, far ticks below */
.thumb { position: relative; border-radius: 8px; overflow: hidden; border: 2px solid transparent; background: #0b1214; aspect-ratio: 16 / 9; cursor: pointer; padding: 0; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb span { position: absolute; left: 6px; bottom: 4px; color: #fff; font: 600 11px var(--mono); text-shadow: 0 1px 2px #000; }
.thumb.on { border-color: var(--brand-2); }
.thumb.none { display: grid; place-items: center; color: #7f9196; font-size: 11px; }
.tl-side .card { padding: 16px; }
.evcards { list-style: none; margin: 10px 0 0; padding: 0; max-height: 640px; overflow-y: auto; }
.evcard { border: 1px solid transparent; border-bottom-color: var(--border); padding: 12px 12px; cursor: pointer; border-radius: 0; }
.evcard:hover { background: var(--surface-2); }
.evcard.on { border: 1px solid #9fd2c6; background: #eef8f5; border-radius: 10px; }
:root[data-theme="dark"] .evcard.on { background: #15302b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .evcard.on { background: #15302b; } }
.evcard .row1 { display: flex; justify-content: space-between; align-items: center; }
.evcard .title { font-weight: 650; margin: 6px 0 2px; }
.evcard .detail { color: var(--muted); font-size: 12.5px; }
.evcard .row3 { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.evcard .row3 .act { color: var(--accent); font-weight: 600; }
.sev { display: inline-block; border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 600; }
.sev.observation { background: var(--good-bg); color: var(--good); }
.sev.attention { background: var(--warn-bg); color: var(--warn); }
.sev.critical { background: var(--bad-bg); color: var(--bad); }
.sev.connection { background: var(--surface-2); color: var(--muted); }
.sev.object { background: #e3eef8; color: #2b5d8a; }
:root[data-theme="dark"] .sev.object { background: #17293a; color: #8cbbe6; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sev.object { background: #17293a; color: #8cbbe6; } }
.rev { display: inline-block; border-radius: 6px; padding: 2px 8px; font-size: 12px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.rev.open { color: var(--warn); }
.selected-event .eyebrow { margin-bottom: 4px; }
.selected-event h2 { font-size: 17px; margin-bottom: 12px; }
.dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; font-size: 13px; margin-bottom: 12px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; text-align: right; font-weight: 500; }
.selected-event .actions { display: grid; gap: 8px; margin-top: 12px; }
.selected-event .actions .row { display: flex; gap: 8px; }
.selected-event .actions .row > * { flex: 1; }
.side-note { color: var(--muted); font-size: 12.5px; padding: 4px 4px; }
.side-note b { color: var(--text); }

/* site map */
.map-tools { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.map-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.map-main { padding-bottom: 12px; }
.mapview { position: relative; background: #0b1214; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; margin: 0 -4px; }
.mapview img { width: 100%; height: 100%; object-fit: contain; display: block; }
.mapview.adding { cursor: crosshair; outline: 3px solid var(--accent); }
.map-layer { position: absolute; inset: 0; }
.map-layer .area { position: absolute; border: 2px dashed rgba(240, 166, 58, .9); pointer-events: none; }
.map-layer .area.observation { border-color: rgba(102, 205, 170, .9); }
.map-layer .pin { position: absolute; transform: translate(-50%, -50%); width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; color: #fff; font-weight: 700; font-size: 13px; padding: 0; display: grid; place-items: center; box-shadow: 0 2px 6px rgba(0,0,0,.45); }
.map-layer .pin.attention { background: #c2541d; }
.map-layer .pin.critical { background: #b3261e; }
.map-layer .pin.observation { background: #1d6f66; }
.map-layer .pin.on { box-shadow: 0 0 0 4px rgba(103, 211, 191, .85), 0 2px 6px rgba(0,0,0,.45); }
.map-layer .pin.pending { background: var(--accent); }
.map-layer .plabel { position: absolute; transform: translate(-50%, calc(-100% - 22px)); background: rgba(18, 54, 59, .92); color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 5px; white-space: nowrap; pointer-events: none; }
.dot-sev { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.dot-sev.attention { background: #c2541d; } .dot-sev.critical { background: #b3261e; } .dot-sev.observation { background: #1d6f66; }
.map-add { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-top: 12px; display: grid; gap: 10px; grid-template-columns: 2fr 1fr 1fr; align-items: end; }
.map-add textarea { grid-column: 1 / -1; min-height: 56px; border: 1px solid var(--border); border-radius: 8px; padding: 8px; font: inherit; background: var(--surface); color: var(--text); }
.map-add .row { grid-column: 1 / -1; }
.map-add input[type=text] { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; color: var(--text); }
.maplist { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.mapcard { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; cursor: pointer; background: var(--surface); text-align: left; color: var(--text); }
.mapcard.on { border-color: #9fd2c6; background: #eef8f5; }
:root[data-theme="dark"] .mapcard.on { background: #15302b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .mapcard.on { background: #15302b; } }
.mapcard .n { width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.mapcard b { display: block; }
.ai-runs { list-style: none; padding: 0; margin: 8px 0 0; font-size: 12.5px; }
.ai-runs li { padding: 4px 0; border-top: 1px solid var(--border); color: var(--muted); }

/* heat map */
.heat { overflow-x: auto; }
.heat table { border-collapse: separate; border-spacing: 4px; width: 100%; min-width: 760px; }
.heat th { font-size: 11.5px; color: var(--muted); font-weight: 500; text-align: center; }
.heat th.day { text-align: left; white-space: nowrap; padding-right: 8px; font-variant-numeric: tabular-nums; }
.heat td { height: 30px; border-radius: 4px; text-align: center; font-size: 11px; color: rgba(0,0,0,.55); cursor: pointer; font-variant-numeric: tabular-nums; }
.heat td.ok { background: var(--heat-ok); }
.heat td.attention { background: var(--heat-attention); }
.heat td.offline { background: var(--heat-offline); color: rgba(0,0,0,.6); }
.heat td.nodata, .heat td.future { background: var(--heat-nodata); cursor: default; }
.heat td.future { opacity: .5; }
.heat td.sel { outline: 2px solid var(--text); }
.heat-legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12.5px; color: var(--muted); margin-top: 12px; }
.heat-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.h-ok { background: var(--heat-ok); } .h-attention { background: var(--heat-attention); } .h-offline { background: var(--heat-offline); } .h-nodata { background: var(--heat-nodata); border: 1px solid var(--border); }

/* events table */
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; padding-bottom: 16px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.table-head h2 { display: inline; margin-right: 10px; }
.table-wrap { overflow-x: auto; margin: 0 -20px; }
.evtable { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.evtable th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; background: var(--surface-2); padding: 10px 20px; }
.evtable td { padding: 13px 20px; border-top: 1px solid var(--border); vertical-align: middle; }
.evtable .t1 { font-weight: 650; color: var(--brand-2); }
.evtable .t2 { color: var(--muted); font-size: 12px; }
.evtable tr.detail td { background: var(--surface-2); }
.evtable .detail-grid { display: grid; grid-template-columns: minmax(0, 340px) 1fr; gap: 18px; align-items: start; }
.evtable .detail-grid img { width: 100%; border-radius: 8px; display: block; background: #0b1214; }
.evtable .detail-grid .acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.more { text-align: center; margin-top: 12px; }

/* live, history, video, data (earlier pages) */
.alerts { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.alert { border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.alert.bad { background: var(--bad-bg); color: var(--bad); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.good { background: var(--good-bg); color: var(--good); }
.site { display: flex; flex-direction: column; }
.site-events { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 12px; }
.site-events .card-head { margin-bottom: 4px; }
.site-events h3 { margin: 0; }
.board-wide .kv { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.kv-group { padding: 10px 0 4px; border-top: 1px solid var(--border); }
.kv-group:first-of-type { border-top: 0; padding-top: 0; }
.kv-group h3 { margin-bottom: 2px; }
.jlist { list-style: none; margin: 8px 0 0; padding: 0; font-size: 12.5px; }
.jlist li { padding: 4px 0; border-top: 1px solid var(--border); }
.jtable { margin-top: 10px; }
.meter { display: inline-block; width: 90px; height: 8px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; vertical-align: middle; }
.meter i { display: block; height: 100%; background: var(--accent); }
.meter.good i { background: var(--good); } .meter.warn i { background: var(--warn); } .meter.bad i { background: var(--bad); }
.infer td, .infer th { white-space: nowrap; }
.jtable td, .jtable th { text-align: left !important; }
.jtable td:last-child { white-space: normal; }
.site .title { display: flex; align-items: baseline; gap: 8px; }
.big { font-size: 34px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.big small { font-size: 15px; font-weight: 500; color: var(--muted); }
.gauge { position: relative; height: 12px; border-radius: 6px; margin: 8px 0 18px; background: linear-gradient(to right, var(--bad) 0 var(--r), var(--warn) var(--r) var(--a), var(--good) var(--a) 100%); opacity: .9; }
.gauge .needle { position: absolute; top: -4px; width: 3px; height: 20px; background: var(--text); border-radius: 2px; transform: translateX(-1px); }
.gauge .cut { position: absolute; top: 13px; font-size: 10.5px; color: var(--muted); transform: translateX(-50%); white-space: nowrap; }
.gauge .cut::before { content: ""; position: absolute; left: 50%; top: -14px; height: 12px; border-left: 2px dashed var(--text); opacity: .6; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px 14px; margin: 8px 0; }
.kv div { min-width: 0; }
.kv .k { font-size: 11.5px; color: var(--muted); }
.kv .v { font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sep { border-top: 1px solid var(--border); margin: 12px 0; }
.chip { display: inline-block; border-radius: 6px; padding: 1px 7px; font-size: 12px; font-weight: 600; background: var(--surface-2); }
.chip.good { background: var(--good-bg); color: var(--good); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.snap { margin-top: 10px; }
.snap img { width: 100%; border-radius: 8px; display: block; background: var(--surface-2); }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 10px; }
.toolbar label:not(.field) { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: var(--surface); }
.seg button { background: var(--surface); color: var(--text); border-radius: 0; padding: 7px 13px; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.seg.small button { padding: 4px 10px; font-size: 12.5px; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(520px, 1fr)); gap: 16px; }
#charts { display: block; }
.hist-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 18px; position: sticky; top: 64px; z-index: 3; background: var(--bg); padding: 8px 0; }
.hist-nav a { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 4px 12px; font-size: 13px; text-decoration: none; color: var(--text); }
.hist-nav a:hover { border-color: var(--accent); color: var(--accent); }
.hist-section { margin-bottom: 26px; scroll-margin-top: 120px; }
.hist-title { font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 10px; min-width: 0; }
.chart-card .legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.chart-card .legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 4px; }
.chart-card canvas { width: 100%; height: 220px; display: block; }
.events { list-style: none; margin: 0; padding: 0; }
.events li { display: grid; grid-template-columns: 92px 1fr auto; gap: 10px; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--border); }
.events li:last-child { border-bottom: 0; }
.events .when { font-variant-numeric: tabular-nums; font-weight: 600; }
.events .what { min-width: 0; }
.events .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.events .thumb { grid-column: 1 / -1; aspect-ratio: auto; background: none; border: 0; cursor: default; }
.events .thumb img { max-width: min(640px, 100%); border-radius: 8px; display: block; }
.events .thumb:empty, .events .plan:empty { display: none; }
.events.compact li { grid-template-columns: 76px 1fr auto; padding: 6px 2px; }
.camtag { font-size: 11.5px; font-weight: 600; border-radius: 5px; padding: 0 6px; margin-right: 6px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); }
.plan { font-size: 13px; }
.timeline-wrap { width: 100%; }
#timeline { width: 100%; height: 70px; display: block; cursor: crosshair; }
.clips { list-style: none; margin: 0; padding: 0; }
.clips li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: center; padding: 8px 2px; border-bottom: 1px solid var(--border); }
.progress { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; width: 160px; display: inline-block; vertical-align: middle; }
.progress i { display: block; height: 100%; background: var(--accent); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { text-align: right; padding: 5px 8px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th { color: var(--muted); font-weight: 500; }
ul.plain { padding-left: 18px; margin: 8px 0 0; }
ul.plain li { margin-bottom: 6px; }
.foot { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; padding: 24px 0 8px; }

dialog#player { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 12px; width: min(1200px, 96vw); }
dialog#player::backdrop { background: rgba(0,0,0,.6); }
#player-video { width: 100%; max-height: 75vh; background: #000; border-radius: 6px; }
.player-head, .player-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 4px 0 8px; font-size: 13px; }

@media (max-width: 1100px) {
  .tl-grid, .map-grid { grid-template-columns: 1fr; }
  .banner-dark { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  main { padding: 8px 16px 24px; }
  .top { padding: 10px 16px; }
  .brand-sep, .brand-sub { display: none; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi { padding: 14px 16px; }
  .kpi .v { font-size: 18px; }
  h1 { font-size: 24px; }
  .kpi:nth-child(2) { border-right: 0; }
  .kpi:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .charts { grid-template-columns: 1fr; }
  .grid.sites, .grid.two { grid-template-columns: 1fr; }
  .thumbs { grid-template-columns: repeat(3, 1fr); }
  .viewers.two { grid-template-columns: 1fr; }
  .events li { grid-template-columns: 70px 1fr; }
  .events .acts { grid-column: 1 / -1; justify-content: flex-start; }
  .evtable .detail-grid { grid-template-columns: 1fr; }
  .map-add { grid-template-columns: 1fr; }
  .tz { text-align: left; }
}

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(100%, 400px); padding: 32px; }
.login-card h1 { margin: 12px 0; }
.login-card form { display: grid; gap: 20px; margin-top: 24px; }
.login-card .field { display: grid; gap: 8px; }
.login-card input { width: 100%; }
#login-error { color: var(--bad); margin: 0; }
