/* FluidCloud VMS — no build step, no framework.
   Deliberate: the sovereign deployment ships one binary with no node toolchain, and
   these screens do not need a virtual DOM. Revisit when the app outgrows it. */

:root {
  color-scheme: dark;
  --bg: #0e1116;
  --panel: #151a21;
  --panel-2: #1b222b;
  --line: #262e39;
  --text: #e6ecf3;
  --muted: #8b97a6;
  --accent: #4da3ff;
  --accent-dim: #1f4b7a;
  --rec: #2fb47c;
  --gap: #3a4351;
  --warn: #e0a341;
  --bad: #e05c5c;
  --radius: 10px;
  --pad: 14px;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-2: #eef1f5;
  --line: #d9dee6;
  --text: #16202b;
  --muted: #5f6b7a;
  --accent: #1668c9;
  --accent-dim: #bcd6f5;
  --rec: #1d8f61;
  --gap: #c6ccd5;
  --warn: #9a6512;
  --bad: #c0392b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

[hidden] { display: none !important; }
h2, h3 { margin: 0; font-size: 15px; font-weight: 600; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- controls ---------- */
button, select, input {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
}
button { cursor: pointer; }
button:hover { border-color: var(--accent-dim); }
button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.primary-btn { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
:root[data-theme="light"] .primary-btn { color: #fff; }
.ghost-btn { background: transparent; }
.icon-btn { background: transparent; border-color: transparent; font-size: 15px; padding: 6px 9px; }
.icon-btn:hover { background: var(--panel-2); border-color: var(--line); }
label.inline { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); white-space: nowrap; }
label.inline select, label.inline input { color: var(--text); }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 360px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 24px;
  display: flex; flex-direction: column; gap: 14px;
}
.login-card label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.login-card button { padding: 10px; background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.err { color: var(--bad); margin: 0; font-size: 13px; }

.brand { display: flex; align-items: center; gap: 8px; font-size: 15px; letter-spacing: .2px; }
.brand b { font-weight: 700; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--rec); box-shadow: 0 0 0 3px color-mix(in srgb, var(--rec) 25%, transparent); }

/* ---------- layout ---------- */
.app { min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px var(--pad);
  background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  /* Wrap rather than overflow. Without this a fourth tab pushed the nav off the edge
     of a non-maximised window: flex shrank the buttons until they were unreadable and
     then clipped them entirely, so the tab simply was not there. */
  flex-wrap: wrap;
}
/* The nav must never be the thing that gives way when the bar is tight. */
.tabs { flex-shrink: 0; }
.tab { flex-shrink: 0; white-space: nowrap; }
.brand { flex-shrink: 0; }
.who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who { color: var(--muted); font-size: 13px; }
.tabs {
  display: flex; gap: 4px;
  /* On a genuinely narrow screen the tabs scroll sideways instead of disappearing. */
  overflow-x: auto;
  scrollbar-width: none;
  max-width: 100%;
}
.tabs::-webkit-scrollbar { display: none; }
.tab { background: transparent; border-color: transparent; color: var(--muted); padding: 6px 12px; }
.tab.is-active { background: var(--panel-2); border-color: var(--line); color: var(--text); font-weight: 600; }

.body { flex: 1; display: grid; grid-template-columns: 268px 1fr; min-height: 0; }

.sidebar {
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 12px var(--pad); border-bottom: 1px solid var(--line); }
.cams { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }

.cam {
  display: grid; grid-template-columns: 8px 1fr auto; gap: 9px; align-items: center;
  padding: 9px 10px; border-radius: 8px; cursor: pointer; border: 1px solid transparent;
}
.cam:hover { background: var(--panel-2); }
.cam.is-active { background: var(--panel-2); border-color: var(--accent-dim); }
.cam-led { width: 8px; height: 8px; border-radius: 50%; background: var(--rec); }
.cam-led.stale { background: var(--bad); }
.cam-led.pending { background: var(--warn); }
.cam-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cam-sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cam-meta { color: var(--muted); font-size: 11px; text-align: right; font-variant-numeric: tabular-nums; }

.main { min-width: 0; padding: var(--pad); overflow-y: auto; }
.view { display: none; }
.view.is-active { display: block; }

/* ---------- player ---------- */
.player-wrap {
  position: relative; background: #000; border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9;
}
#video { width: 100%; height: 100%; display: block; background: #000; }
.player-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.player-badge {
  position: absolute; top: 10px; left: 10px;
  background: rgba(0,0,0,.66); color: #fff; padding: 4px 9px;
  border-radius: 6px; font-size: 12px; font-variant-numeric: tabular-nums;
}

/* ---------- timeline ---------- */
.timeline-wrap { margin-top: 12px; }
.timeline {
  position: relative; height: 46px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
}
.tl-track { position: absolute; inset: 0 0 16px 0; background: var(--gap); }
.tl-seg { position: absolute; top: 0; bottom: 0; background: var(--rec); }
.tl-gap { position: absolute; top: 0; bottom: 0; background: var(--gap); }
.tl-cursor { position: absolute; top: 0; bottom: 16px; width: 2px; background: var(--accent); pointer-events: none; }
.tl-cursor::after {
  content: ""; position: absolute; top: -1px; left: -4px;
  width: 10px; height: 10px; border-radius: 50%; background: var(--accent);
}
.tl-labels { position: absolute; left: 0; right: 0; bottom: 0; height: 16px; }
.tl-tick { position: absolute; bottom: 1px; transform: translateX(-50%); font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-legend { display: flex; gap: 14px; align-items: center; margin-top: 6px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; }
.sw-rec { background: var(--rec); } .sw-gap { background: var(--gap); }

/* ---------- control bar ---------- */
.controls { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.ctl-group { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tc { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 165px; }

/* ---------- exports ---------- */
.exports { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 14px; }
.exports ul { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.exports li {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
}
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.badge.ready { color: var(--rec); border-color: color-mix(in srgb, var(--rec) 45%, transparent); }
.badge.failed { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.badge.running, .badge.queued { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }

/* ---------- wall ---------- */
.wall-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.cell { background: #000; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; position: relative; aspect-ratio: 16/9; }
.cell video { width: 100%; height: 100%; display: block; }
.cell-label {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,.75));
  color: #fff; font-size: 12px; padding: 14px 8px 6px;
}

/* ---------- fleet ---------- */
.fleet-head { margin-bottom: 12px; }
.table-scroll { overflow-x: auto; }
table.fleet { width: 100%; border-collapse: collapse; min-width: 720px; }
table.fleet th, table.fleet td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; }
table.fleet th { color: var(--muted); font-weight: 600; font-size: 12px; }
table.fleet td.num, table.fleet th.num { text-align: right; font-variant-numeric: tabular-nums; }
.state-ok { color: var(--rec); } .state-bad { color: var(--bad); } .state-pending { color: var(--warn); }
.bar { height: 6px; background: var(--panel-2); border-radius: 999px; overflow: hidden; min-width: 70px; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar > i.hot { background: var(--bad); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 16px; z-index: 50; box-shadow: 0 8px 28px rgba(0,0,0,.35);
}

.only-narrow { display: none; }

/* ---------- narrow screens ---------- */
@media (max-width: 860px) {
  .body { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 30; inset: auto 0 0 0; top: 52px;
    border-right: 0; border-top: 1px solid var(--line);
    transform: translateX(-100%); transition: transform .18s ease;
  }
  .sidebar.is-open { transform: none; }
  .only-narrow { display: inline-block; }
  .tabs .tab { padding: 6px 9px; }
  .who { display: none; }
  .tc { min-width: 0; }
  /* Touch scrubbing needs a bigger target than a mouse does. */
  .timeline { height: 58px; }
  .tl-track, .tl-cursor { bottom: 18px; }
}
@media (max-width: 560px) {
  .brand { font-size: 13px; }
  .controls { gap: 10px; }
}

/* ---------- live ---------- */
#go-live.is-active, #wall-live.is-active, #wall-recorded.is-active {
  border-color: var(--accent); color: var(--accent); font-weight: 600;
}
#go-live.is-active { border-color: var(--bad); color: var(--bad); }
.cell-status {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 12px; background: rgba(0,0,0,.45); text-align: center; padding: 10px;
}
.cell-status:empty { display: none; }
.wall-bar button:disabled { opacity: .4; cursor: not-allowed; }
.only-wide { display: inline; }
@media (max-width: 860px) { .only-wide { display: none; } }

/* ---------- fullscreen ---------- */
.fs-btn {
  position: absolute; top: 8px; right: 8px; z-index: 3;
  background: rgba(0,0,0,.55); border: 1px solid rgba(255,255,255,.18);
  color: #fff; border-radius: 7px; padding: 4px 8px; font-size: 14px; line-height: 1;
  opacity: 0; transition: opacity .12s ease;
}
.cell:hover .fs-btn, .player-wrap:hover .fs-btn, .fs-btn:focus-visible { opacity: 1; }
.fs-btn:hover { background: rgba(0,0,0,.8); border-color: rgba(255,255,255,.4); }
/* Touch devices have no hover, so the control has to be permanently visible. */
@media (hover: none) { .fs-btn { opacity: .85; } }

/* In fullscreen the element is the viewport: letterbox the video and keep overlays. */
.cell:fullscreen, .player-wrap:fullscreen,
.cell:-webkit-full-screen, .player-wrap:-webkit-full-screen {
  width: 100vw; height: 100vh; aspect-ratio: auto;
  border: 0; border-radius: 0; background: #000;
}
.cell:fullscreen video, .player-wrap:fullscreen video,
.cell:-webkit-full-screen video, .player-wrap:-webkit-full-screen video {
  width: 100%; height: 100%; object-fit: contain;
}
.cell:fullscreen .cell-label, .player-wrap:fullscreen .player-badge {
  font-size: 15px; padding-bottom: 14px;
}
.cell:fullscreen .fs-btn, .player-wrap:fullscreen .fs-btn { opacity: 1; }
kbd {
  background: var(--panel-2); border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 4px; padding: 0 4px; font: 11px/1.6 ui-monospace, monospace;
}

/* ---------- alerts ---------- */
.alerts-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.alerts-sub { margin: 20px 0 8px; color: var(--muted); }

.rule-form {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 12px;
}
.field { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.field input { color: var(--text); }

.rules, .alert-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.rule {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px;
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: start;
}
.rule-name { font-weight: 600; }
.rule-interp { color: var(--muted); font-size: 13px; margin-top: 3px; }
.rule-stats { color: var(--muted); font-size: 12px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.rule-off { opacity: .55; }
.rule-err { color: var(--bad); font-size: 12px; margin-top: 6px; }

.alert {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; display: grid; gap: 12px;
  grid-template-columns: 120px 1fr auto; align-items: center;
}
.alert.miss { opacity: .6; }
.alert img {
  width: 120px; height: 68px; object-fit: cover; border-radius: 6px;
  background: #000; cursor: zoom-in; display: block;
}
.alert-when { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; }
.alert-why { color: var(--muted); font-size: 13px; margin-top: 2px; }
.fb-btn { padding: 5px 9px; }
.fb-btn.on { border-color: var(--accent); color: var(--accent); }

.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 60;
  display: grid; place-items: center; cursor: zoom-out; padding: 20px;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

@media (max-width: 700px) {
  .alert { grid-template-columns: 96px 1fr; }
  .alert > .alert-actions { grid-column: 1 / -1; }
  .alert img { width: 96px; height: 54px; }
}

/* ---------- editable fleet ---------- */
.cell-input {
  padding: 4px 6px; font-size: 13px; border-radius: 6px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  max-width: 100%;
}
input.cell-input { width: 6.5em; text-align: right; }
select.cell-input { max-width: 15em; }
.cell-input:disabled { opacity: .45; }
table.fleet td { vertical-align: middle; }
table.fleet td .bar { margin-top: 5px; }
table.fleet { min-width: 1020px; }

.ghost-btn.danger { color: var(--bad); border-color: transparent; }
.ghost-btn.danger:hover { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }

/* ---------- stream editor ---------- */
tr.stream-editor > td { background: var(--panel-2); padding: 14px; }
.stream-grid { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.stream-grid .field { min-width: 260px; flex: 1; }
.stream-grid .field em { font-style: normal; opacity: .75; font-size: 12px; }
select.cell-input.wide { width: 100%; max-width: none; }

/* ---------- AI backends ---------- */
.spend-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 14px;
  display: flex; gap: 26px; align-items: center; flex-wrap: wrap;
}
.spend-fig { display: flex; flex-direction: column; gap: 2px; }
.spend-fig b { font-size: 22px; font-variant-numeric: tabular-nums; font-weight: 650; }
.spend-fig span { color: var(--muted); font-size: 12px; }
.spend-bar { flex: 1; min-width: 180px; }
.spend-bar .bar { height: 10px; }
.spend-capped { color: var(--bad); font-weight: 600; }

.ai-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 14px; margin-bottom: 16px; }
.ai-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; gap: 10px;
}
.ai-card h3 { display: flex; align-items: center; gap: 8px; }
.ai-eff { font-size: 12px; color: var(--muted); }
.ai-eff b { color: var(--text); }
.pill {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted);
}
.pill.on { color: var(--rec); border-color: color-mix(in srgb, var(--rec) 45%, transparent); }
.pill.off { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.ai-card .field { font-size: 12px; }
.ai-card input, .ai-card select { width: 100%; }
.ai-row { display: flex; gap: 10px; flex-wrap: wrap; }
.ai-row > * { flex: 1; min-width: 120px; }

/* --- warning banner ------------------------------------------------------- */
/* A rule that cannot fire is invisible otherwise: silence looks exactly like
   nothing happening, which is the one failure an alerting system must not have. */
.banner {
  margin: 0 0 14px;
  padding: 10px 14px;
  border: 1px solid var(--warn-line, #7a5c12);
  background: var(--warn-bg, rgba(190, 140, 20, .12));
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
}
.banner b { color: var(--warn-fg, #e0b84a); }
.rule-warn {
  margin-top: 4px;
  font-size: 12px;
  color: var(--warn-fg, #e0b84a);
}

/* --- rule preview --------------------------------------------------------- */
.preview {
  margin: 10px 0 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2, rgba(255,255,255,.02));
}
.preview-summary { font-size: 14px; margin-bottom: 8px; }
.preview-summary b { font-size: 18px; }
.preview-foot { margin: 8px 0 0; }
.preview-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.shot {
  flex: 0 0 auto;
  width: 104px;
  font-size: 11px;
  text-align: center;
  opacity: .45;
}
.shot.hit { opacity: 1; }
.shot img, .shot .noimg {
  display: block;
  width: 104px; height: 60px;
  object-fit: cover;
  border-radius: 4px;
  border: 2px solid transparent;
  background: #1a1a1a;
}
.shot.hit img, .shot.hit .noimg { border-color: var(--accent, #4a9eff); }
.shot .cap { margin-top: 3px; color: var(--muted); }

/* --- zone editor ---------------------------------------------------------- */
.modal {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(0,0,0,.68);
}
.modal-card {
  width: min(880px, 100%);
  max-height: 92vh; overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel, #15171b);
}
.modal-head { display: flex; align-items: center; gap: 10px; }
.modal-head h3 { margin: 0; flex: 1; }

/* The stage takes the video's own aspect ratio, so the canvas overlay lines up with
   the picture exactly — which is what makes a click convertible to a fraction of the
   frame without guessing where the letterboxing went. */
.zone-stage {
  position: relative;
  margin: 10px 0;
  background: #000;
  border-radius: 6px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
}
.zone-stage video { display: block; width: 100%; height: 100%; object-fit: contain; }
.zone-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; }
.zone-msg {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 20px;
  color: var(--muted); font-size: 13px;
}
.ghost-btn.danger { color: #e06c6c; border-color: #6b2f2f; }

/* --- bridges strip -------------------------------------------------------- */
.bridges { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0 4px; }
.bridge-card {
  flex: 1 1 260px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2, rgba(255,255,255,.02));
  font-size: 12px;
}
.bridge-card h4 { margin: 0 0 4px; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.bridge-card .meta { color: var(--muted); line-height: 1.6; }
.pip { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.pip-up { background: #4ad07a; }
.pip-down { background: #e06c6c; }
.pip-off { background: #6b7280; }
.bridge-det { margin-top: 4px; }
.bridge-det.bad { color: var(--warn-fg, #e0b84a); }

/* --- object chips --------------------------------------------------------- */
.objects-row { flex-wrap: wrap; }
#rule-objects { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--fg);
  font-size: 12px;
  cursor: pointer;
}
.chip.on { background: var(--accent, #4a9eff); border-color: var(--accent, #4a9eff); color: #04121f; }
.shot .objs { color: var(--accent, #4a9eff); }
.warn-text { color: var(--warn-fg, #e0b84a); }

/* --- what the detector saw ------------------------------------------------ */
.alert-det { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 5px; font-size: 12px; }
.det-chip {
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--accent, #4a9eff);
  color: var(--accent, #4a9eff);
}

/* The wrapper shrink-wraps the image, so a box positioned in percentages lands on the
   picture itself rather than on the letterboxing around it. */
.lb-inner { display: flex; flex-direction: column; gap: 8px; max-width: 100%; max-height: 100%; }
.lb-bar { display: flex; align-items: center; gap: 8px; cursor: default; }
.lb-stage { position: relative; display: inline-block; line-height: 0; }
.lb-stage img { max-width: 100%; max-height: 80vh; border-radius: 8px; }
.lb-overlay { position: absolute; inset: 0; pointer-events: none; }
.lb-box { position: absolute; border: 2px solid; border-radius: 3px; }
.lb-box span {
  position: absolute; top: 0; left: 0; transform: translateY(-100%);
  font-size: 11px; line-height: 1.5; padding: 0 5px; white-space: nowrap;
  border-radius: 3px 3px 0 0;
}
.lb-det { border-color: #4ad07a; }
.lb-det span { background: #4ad07a; color: #05130a; }
.lb-motion { border-color: #e0b84a; border-style: dashed; }
.lb-motion span { background: #e0b84a; color: #1a1405; }
.lightbox { cursor: default; }

/* --- bridge health -------------------------------------------------------- */
.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin: 12px 0;
}
.stat {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2, rgba(255,255,255,.02));
}
.stat .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 20px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.bar { height: 5px; border-radius: 3px; background: rgba(127,127,127,.25); margin-top: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent, #4a9eff); }
.bar.warn > i { background: #e0b84a; }
.bar.bad > i { background: #e06c6c; }
.health-sec { margin: 16px 0 6px; font-size: 13px; color: var(--muted); }
.bridge-card h4 .bhealth { margin-left: auto; font-weight: 400; font-size: 11px; color: var(--muted); }
.bridge-card { cursor: pointer; }
.bridge-card:hover { border-color: var(--accent, #4a9eff); }

/* --- card footage on the timeline ----------------------------------------- */
/* A gap in cloud recording is not necessarily a gap in what happened: the camera may
   still hold it. Its own band, under the main track, so the two are never confused. */
.tl-card {
  position: absolute; left: 0; right: 0; bottom: 16px; height: 7px;
  pointer-events: none;
  border-top: 1px solid rgba(0,0,0,.35);
}
.tl-card-held {
  position: absolute; top: 0; height: 100%;
  background: repeating-linear-gradient(90deg, #6b5cc4 0 6px, transparent 6px 10px);
  border-radius: 2px;
}
.tl-card-pull { position: absolute; top: 0; height: 100%; background: #9b8bff; border-radius: 2px; }
.tl-card-pull.pending { background: #6b5cc4; opacity: .6; }
.tl-card-pull.failed  { background: #e06c6c; opacity: .7; }
.tl-drag {
  position: absolute; top: 0; bottom: 16px;
  background: rgba(155,139,255,.25);
  border-left: 2px solid #9b8bff; border-right: 2px solid #9b8bff;
  pointer-events: none;
}
.sw-card { background: repeating-linear-gradient(90deg, #6b5cc4 0 4px, transparent 4px 7px); }
.sw-pull { background: #9b8bff; }
.player-badge.from-card { background: #6b5cc4; }

/* --- what this camera actually has ---------------------------------------- */
/* The first question anyone has is "is there any footage, and when". Guessing a
   window and seeing whether something plays is not an answer. */
.coverage { margin-top: 10px; font-size: 12px; }
.cov-head { color: var(--muted); margin-bottom: 6px; }
.cov-day { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; flex-wrap: wrap; }
.cov-date { width: 6.5em; color: var(--muted); font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.cov-hours { display: flex; gap: 2px; flex-wrap: wrap; }
.cov-hr {
  width: 22px; height: 18px; border-radius: 3px;
  border: 1px solid var(--line); background: transparent;
  color: var(--muted); font-size: 10px; line-height: 16px; text-align: center;
  padding: 0; cursor: default;
}
.cov-hr.has {
  background: var(--rec); border-color: var(--rec); color: #04121f; cursor: pointer;
}
.cov-hr.has:hover { outline: 2px solid var(--accent); }
.cov-hr.now { outline: 1px dashed var(--accent); }
.cov-empty { color: var(--muted); }
