:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #fcfcfb;
  --surface-2: #ecebe7;
  --border: #d9d8d3;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #73726c;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --danger: #c4312f;
  --good: #1a7f37;
  --series-1: #2a78d6;
  --grid: #e3e2de;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 16px rgb(0 0 0 / 6%);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111110;
    --surface: #1a1a19;
    --surface-2: #252523;
    --border: #353532;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #96958d;
    --accent: #3987e5;
    --danger: #e66767;
    --good: #4cb36b;
    --series-1: #3987e5;
    --grid: #2b2b29;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110; --surface: #1a1a19; --surface-2: #252523; --border: #353532;
  --text: #f0efec; --text-2: #c3c2b7; --muted: #96958d; --accent: #3987e5;
  --danger: #e66767; --good: #4cb36b; --series-1: #3987e5; --grid: #2b2b29;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1 { font-size: 1.5rem; margin: 0 0 .5rem; }
h2 { font-size: 1.1rem; margin: 0 0 .5rem; }
a { color: var(--accent); }
code { font-size: .9em; background: var(--surface-2); padding: 0 .3em; border-radius: 4px; }
.muted { color: var(--muted); font-size: .9em; }

/* Controls */
button, .button {
  font: inherit; cursor: pointer; border: 0; border-radius: 10px;
  padding: .6rem 1rem; background: var(--accent); color: var(--accent-ink);
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  text-decoration: none;
}
button.secondary, .button.secondary { background: var(--surface-2); color: var(--text); }
button.icon { background: transparent; color: var(--text); padding: .4rem .6rem; font-size: 1.2rem; }
button:disabled { opacity: .55; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
label { display: grid; gap: .3rem; margin: .8rem 0; font-weight: 500; }
label.check { grid-template-columns: auto 1fr; align-items: start; font-weight: 400; }
input, select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: .55rem .7rem; min-height: 44px; width: 100%;
}
input[type="checkbox"], input[type="radio"] { width: 20px; min-height: 20px; margin-top: .15rem; }
fieldset { border: 1px solid var(--border); border-radius: 10px; margin: 1rem 0; padding: .2rem 1rem; }
legend { padding: 0 .3rem; color: var(--text-2); }
.form-error { color: var(--danger); margin: .6rem 0; }
.info { background: var(--surface-2); border-radius: 10px; padding: .75rem 1rem; margin: .8rem 0; font-size: .92em; }
.info dl { display: grid; grid-template-columns: auto 1fr; gap: .2rem 1rem; margin: 0; }
.info dt { color: var(--text-2); }
.info dd { margin: 0; font-variant-numeric: tabular-nums; }

/* Onboarding & login */
.center-view { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; width: 100%; max-width: 520px; }
.wizard footer, dialog footer { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.2rem; }
.steps { display: flex; gap: .4rem; list-style: none; padding: 0; margin: .5rem 0 1rem; font-size: .8rem; color: var(--muted); }
.steps li { flex: 1; border-top: 3px solid var(--border); padding-top: .3rem; }
.steps li.done, .steps li.active { border-color: var(--accent); color: var(--text); }

/* App shell */
#view-app { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.topbar { display: flex; align-items: center; gap: .6rem; padding: .4rem 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: relative; }
.brand { font-weight: 700; letter-spacing: .02em; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--good); }
.dot.bad { background: var(--danger); }
.tabs { margin-left: auto; display: flex; gap: .2rem; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex-shrink: 0; }
/* Keep the bell and menu on screen however many tabs there are. */
.topbar > .brand, .topbar > .dot, .topbar > button.icon { flex-shrink: 0; }
.tabs button { background: transparent; color: var(--text-2); min-height: 36px; padding: .3rem .8rem; }
.tabs button[aria-current="true"] { background: var(--surface-2); color: var(--text); }
.menu { position: absolute; right: 16px; top: 100%; z-index: 20; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); display: grid; min-width: 220px; padding: .3rem; }
.menu button { background: transparent; color: var(--text); justify-content: flex-start; }
.menu button:hover { background: var(--surface-2); }

.panes { flex: 1; display: flex; width: 300%; transition: transform .28s ease; min-height: 0; touch-action: pan-y; }
.pane { width: calc(100% / 3); min-height: 0; overflow: hidden; }
@media (prefers-reduced-motion: reduce) { .panes { transition: none; } }

/* Live pane: feeds top, assistant bottom */
.live-pane { display: grid; grid-template-rows: minmax(0, auto) minmax(0, 1fr); }
.feeds { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 6px; padding: 6px; max-height: 55dvh; overflow-y: auto; background: #000; }
.feed { position: relative; aspect-ratio: 16 / 9; background: #111; border-radius: 6px; overflow: hidden; cursor: zoom-in; border: 0; padding: 0; min-height: 0; }
.feed img { width: 100%; height: 100%; object-fit: contain; display: block; }
.feed .name { position: absolute; left: 6px; bottom: 6px; background: rgb(0 0 0 / 60%); color: #fff; font-size: .75rem; padding: .1rem .45rem; border-radius: 4px; }
.feed.flash { box-shadow: inset 0 0 0 3px #eda100; }
.feeds .empty { color: #ccc; grid-column: 1 / -1; padding: 1rem; text-align: center; }
@media (max-width: 600px) { .feeds { grid-template-columns: repeat(min(var(--cols, 2), 2), minmax(0, 1fr)); } }

.assistant { display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.chat-log { flex: 1; overflow-y: auto; padding: 1rem 16px; display: flex; flex-direction: column; gap: .6rem; }
/* Bubbles keep their full height (with clips) and the log scrolls, instead of
   flexbox shrinking them so videos overflow onto the next message. */
.chat-log > * { flex-shrink: 0; }
.msg { max-width: min(680px, 88%); padding: .55rem .85rem; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.msg.error { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.msg.pending { color: var(--muted); }
.clips { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .5rem; margin-top: .5rem; white-space: normal; }
.clip { margin: 0; background: var(--surface); border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.clip video, .clip img { width: 100%; aspect-ratio: 16/9; background: #000; display: block; }
.clip .meta { padding: .35rem .55rem; font-size: .82rem; color: var(--text-2); }
.chat-input { display: flex; gap: .5rem; padding: .6rem 16px calc(.6rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); align-items: center; }
.chat-input input { flex: 1; min-width: 0; }
.mic { width: 56px; height: 56px; border-radius: 50%; padding: 0; flex: none; }
.mic svg { width: 26px; height: 26px; fill: currentColor; }
.mic.listening { background: var(--danger); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgb(230 103 103 / 25%); } }
@media (prefers-reduced-motion: reduce) { .mic.listening { animation: none; } }

/* Analytics */
.analytics-pane { overflow-y: auto; padding: 1rem 16px 2rem; }
.filters { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: 1rem; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.seg button { background: transparent; color: var(--text-2); min-height: 36px; padding: .3rem .8rem; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.analytics { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 1rem; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; min-width: 0; }
.panel h3 { margin: 0 0 .6rem; font-size: .95rem; color: var(--text-2); font-weight: 600; }
.panel.wide { grid-column: 1 / -1; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; }
.tile .v { font-size: 1.9rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.tile .k { color: var(--text-2); font-size: .85rem; }
.chart { display: block; max-width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--text-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .bar { fill: var(--series-1); }
.chart .hit { fill: transparent; }
.chart .hit:hover + .bar, .chart g:hover .bar { opacity: .8; }
.chart-tip { position: fixed; pointer-events: none; z-index: 50; background: var(--text); color: var(--bg); padding: .3rem .55rem; border-radius: 6px; font-size: .8rem; white-space: nowrap; }
details.table-view { margin-top: .5rem; font-size: .85rem; }
details.table-view table { border-collapse: collapse; width: 100%; }
details.table-view td, details.table-view th { text-align: left; padding: .2rem .4rem; border-bottom: 1px solid var(--grid); }
.recent { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .5rem; }
.recent button { flex-direction: column; align-items: stretch; padding: 0; background: var(--surface-2); color: var(--text); overflow: hidden; }
.recent img { width: 100%; aspect-ratio: 4/3; object-fit: cover; background: #000; }
.recent span { padding: .3rem .5rem; font-size: .8rem; text-align: left; }
.empty-state { color: var(--muted); padding: 2rem 0; text-align: center; grid-column: 1 / -1; }

/* Dialogs & toasts */
dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 1.5rem; width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); }
dialog::backdrop { background: rgb(0 0 0 / 50%); }
.layout-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .3rem; }
.layout-list li { display: flex; align-items: center; gap: .5rem; background: var(--surface-2); border-radius: 8px; padding: .25rem .5rem; }
.layout-list label { flex: 1; margin: 0; grid-template-columns: auto 1fr; align-items: center; display: grid; gap: .5rem; }
.layout-list button { min-height: 36px; padding: .2rem .5rem; }
.feed-dialog { width: min(1280px, calc(100vw - 16px)); padding: 0; background: #000; }
.feed-dialog img, .feed-dialog video { width: 100%; display: block; background: #000; }
.feed-dialog .close { position: absolute; right: 8px; top: 8px; color: #fff; background: rgb(0 0 0 / 50%); z-index: 1; }
.toasts { position: fixed; top: 56px; right: 16px; left: 16px; display: grid; justify-items: end; gap: .4rem; pointer-events: none; z-index: 40; }
.toast { background: var(--text); color: var(--bg); padding: .5rem .8rem; border-radius: 8px; font-size: .88rem; box-shadow: var(--shadow); max-width: 100%; }
.voice-or { border-left: 3px solid var(--border); padding-left: .8rem; margin-left: .2rem; }
.mic.busy { opacity: .7; }

/* Searchable model picker */
.combo { position: relative; display: block; }
.combo-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30; margin: 0; padding: .25rem; list-style: none;
  max-height: 280px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); font-weight: 400; }
.combo-list li { padding: .45rem .6rem; border-radius: 6px; cursor: pointer; display: grid; gap: .1rem; }
.combo-list li[aria-selected="true"], .combo-list li:hover { background: var(--surface-2); }
.combo-list .combo-name { color: var(--text); }
.combo-list .combo-id { color: var(--muted); font-size: .8rem; overflow-wrap: anywhere; }
.combo-list .combo-empty { color: var(--muted); cursor: default; }

/* Detection & face recognition */
dialog.wide { width: min(920px, calc(100vw - 16px)); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; padding: .4rem 0 .6rem; }
.chips label { display: inline-flex; align-items: center; gap: .4rem; margin: 0; padding: .35rem .7rem; border: 1px solid var(--border);
  border-radius: 999px; font-weight: 400; background: var(--surface-2); cursor: pointer; min-height: 40px; }
.chips label:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--surface)); }
.chips input { width: 18px; min-height: 18px; margin: 0; }
details.group { border: 1px solid var(--border); border-radius: 10px; padding: .3rem .9rem; margin: .7rem 0; }
details.group summary { cursor: pointer; padding: .4rem 0; font-weight: 600; }
.person { border: 1px solid var(--border); border-radius: 10px; padding: .7rem .9rem; margin: .7rem 0; }
.person-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.person-head h3 { margin: 0 auto 0 0; font-size: 1rem; }
.person-head button, .face-actions button { min-height: 36px; padding: .3rem .7rem; }
.face-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .5rem; margin-top: .6rem; }
.face { position: relative; background: var(--surface-2); border-radius: 8px; overflow: hidden; }
.face img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #000; }
.face .x { position: absolute; top: 4px; right: 4px; min-height: 28px; width: 28px; padding: 0; border-radius: 50%; background: rgb(0 0 0 / 60%); color: #fff; font-size: .8rem; }
.face figcaption { font-size: .75rem; padding: .25rem .4rem; color: var(--text-2); }
.recent-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.face-actions { display: grid; gap: .3rem; padding: .4rem; }
.face-actions select { min-height: 36px; padding: .2rem .4rem; }
.row { display: flex; gap: .5rem; align-items: end; }
.row label { flex: 1; margin: 0; }

/* Accounts */
.form-note { color: var(--good); margin: .6rem 0; }
footer.split { display: flex; justify-content: space-between; align-items: center; gap: .6rem; margin-top: 1.2rem; flex-wrap: wrap; }
button.link { background: transparent; color: var(--accent); padding: .4rem 0; min-height: 44px; }
button.danger { color: var(--danger); }
.accounts { display: grid; gap: .5rem; margin-top: 1rem; }
.account { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 10px; padding: .6rem .9rem; }
.account .who { flex: 1; min-width: 180px; display: grid; gap: .1rem; }
.account .who strong { font-weight: 600; }
.account .who span { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.badge { font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.badge.admin { background: color-mix(in srgb, var(--accent) 22%, var(--surface)); color: var(--text); }
.badge.off { color: var(--danger); }
.account button { min-height: 36px; padding: .3rem .8rem; }
.user-extra { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .8rem; }
.live-pane.no-feeds { grid-template-rows: minmax(0, 1fr); }
.live-pane.no-feeds .feeds { display: none; }
.live-pane.no-assistant .assistant { display: none; }
.live-pane.no-assistant .feeds { max-height: none; }
.live-pane.no-feeds.no-assistant::before { content: "Nothing has been switched on for your account yet. Ask the owner."; padding: 2rem 16px; color: var(--muted); }

/* Counting lines */
.line-stage { position: relative; margin: .8rem 0; background: #000; border-radius: 8px; overflow: hidden; }
.line-stage img { width: 100%; display: block; }
.line-stage svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.line-stage.drawing { cursor: crosshair; }
.line-stage line.cl { stroke: #ffcf33; stroke-width: 4; vector-effect: non-scaling-stroke; }
.line-stage line.cl.sel { stroke: #3ee07a; }
.line-stage .arrow { fill: #ffcf33; }
.line-stage .arrow.sel { fill: #3ee07a; }
.line-stage text { fill: #fff; font: 600 13px system-ui, sans-serif; paint-order: stroke; stroke: #000; stroke-width: 3px; }
.line-stage circle { fill: #3ee07a; }
.account input.line-name { min-height: 36px; padding: .3rem .5rem; max-width: 240px; }
.zone-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.zone-table th, .zone-table td { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid var(--grid); }
.zone-table td.num { font-variant-numeric: tabular-nums; }
.footfall-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6rem; margin-bottom: .6rem; }
.heat-stage canvas.heat-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.heat-legend { margin: .2rem 0; }
.feed-stage { position: relative; }
.feed-stage canvas.heat-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.overlay-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; padding: .5rem .75rem; background: #111; color: #ddd; font-size: .9rem; }
.overlay-bar button { min-height: 36px; padding: .25rem .7rem; background: #2a2a28; color: #eee; }
.overlay-bar button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.overlay-bar .muted { color: #aaa; }
.clip .clip-actions { display: flex; justify-content: flex-end; padding: 0 .4rem .4rem; }
.clip .clip-actions button { min-height: 32px; padding: .2rem .7rem; font-size: .85rem; }
#export-progress progress { width: 100%; height: 10px; }
#export-video { width: 100%; margin: .6rem 0; background: #000; border-radius: 8px; }

/* Notifications & alerts */
.bell { position: relative; }
.bell svg { width: 22px; height: 22px; fill: currentColor; }
.bell-count { position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; border-radius: 9px; background: var(--danger); color: #fff;
  font-size: .7rem; line-height: 18px; text-align: center; padding: 0 4px; }
.notes { display: grid; gap: .5rem; margin-top: .5rem; }
.note { display: grid; grid-template-columns: 1fr auto; gap: .6rem; border: 1px solid var(--border); border-radius: 10px; padding: .6rem .8rem; }
.note.unread { border-color: var(--accent); }
.note h3 { margin: 0; font-size: .95rem; }
.note p { margin: .2rem 0 0; white-space: pre-wrap; font-size: .9rem; }
.note .when { color: var(--muted); font-size: .8rem; }
.note img { width: 160px; aspect-ratio: 16/9; object-fit: cover; border-radius: 6px; background: #000; }
.note .kind-guard h3 { color: var(--danger); }
.hours-grid { display: grid; grid-template-columns: auto 1fr 1fr auto; gap: .3rem .6rem; align-items: center; }
.hours-grid input { min-height: 36px; padding: .2rem .4rem; }
.digest-preview { white-space: pre-wrap; background: var(--surface-2); padding: .7rem; border-radius: 8px; font: .85rem/1.4 ui-monospace, monospace; }
.widget-code textarea { width: 100%; font: .8rem/1.4 ui-monospace, monospace; min-height: 70px; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: .5rem; }
.cond-row { display: grid; grid-template-columns: 1fr 1fr .6fr 1.3fr auto; gap: .4rem; align-items: end; margin: .4rem 0; }
.cond-row label { margin: 0; }
.cond-row input, .cond-row select { min-height: 38px; padding: .3rem .4rem; }
#alerts-tabs { margin-bottom: .6rem; }
@media (max-width: 600px) { .cond-row { grid-template-columns: 1fr 1fr; } .note { grid-template-columns: 1fr; } .note img { width: 100%; } }

/* Site map */
.map-pane { overflow-y: auto; padding: .6rem 16px 1rem; display: flex; flex-direction: column; gap: .6rem; }
.map-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.map-bar #map-setup { margin-left: auto; }
.map-replay { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.map-replay input { width: auto; min-height: 38px; padding: .2rem .5rem; }
.map-replay button { min-height: 38px; }
.map-banner { margin: 0; background: var(--surface-2); border-radius: 10px; padding: .5rem .8rem; font-size: .9rem; }
.map-body { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 1rem 1.4rem; align-items: start; }
/* Width follows the available height so the drawing and the overlays always share one exact shape. */
.map-stage { position: relative; width: 100%; aspect-ratio: 1080 / 1100; border-radius: 12px; overflow: hidden; background: #2d2c29; }
.map-stage svg, .map-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.map-stage canvas { pointer-events: none; }
.map-stage.editing svg { cursor: grab; }
.map-label { font: 600 24px system-ui, sans-serif; fill: #3a352b; pointer-events: none; }
.map-label.on-dark { fill: #f7f4ec; paint-order: stroke; stroke: rgba(0,0,0,.55); stroke-width: 4px; }
.map-label.attribution { fill: #fff; font-size: 15px; paint-order: stroke; stroke: rgba(0,0,0,.7); stroke-width: 4px; }
.map-label.small { font-size: 17px; font-weight: 500; }
.map-label.door { fill: #ff8a80; }
#map-cams .cone { fill: rgba(90, 169, 255, .14); stroke: rgba(90, 169, 255, .7); stroke-width: 2; }
#map-cams .planned .cone { fill: rgba(200, 120, 255, .10); stroke: rgba(200, 120, 255, .7); stroke-dasharray: 10 8; }
#map-cams .coverage { fill: rgba(80, 220, 140, .12); stroke: rgba(80, 220, 140, .9); stroke-width: 2; stroke-dasharray: 6 6; }
#map-cams .dot { fill: #e2463b; stroke: #fff; stroke-width: 4; }
#map-cams .planned .dot { fill: #b06ae8; }
#map-cams .sel .dot { stroke: #ffd24a; stroke-width: 6; }
#map-cams .cam-label { fill: #fff; font-size: 17px; paint-order: stroke; stroke: rgba(0,0,0,.75); stroke-width: 5px; }
.map-side { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: .8rem 1.4rem; align-items: start; }
.map-side-info { display: grid; gap: .6rem; align-content: start; }
.map-clock { font-size: 1.15rem; font-weight: 650; }
.map-stats { display: grid; gap: .3rem; }
.map-stats .stat { display: flex; justify-content: space-between; gap: .5rem; border-bottom: 1px solid var(--grid); padding: .2rem 0; font-size: .92rem; }
.map-stats b { font-variant-numeric: tabular-nums; }
#map-spark { width: 100%; height: 70px; background: var(--surface-2); border-radius: 8px; cursor: pointer; }
.map-legend { font-size: .85rem; color: var(--text-2); display: flex; flex-wrap: wrap; gap: .3rem .6rem; align-items: center; }
.lg { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: -.3rem; }
.lg.lg-person { background: #f5a93b; } .lg.lg-dog { background: #4fd37f; } .lg.lg-staff { background: #5aa9ff; } .lg.lg-named { background: #ff6ad5; }
/* The map's size follows the screen height (so it and its controls fit), but never takes more than 60% of the width. */
.map-main { display: grid; gap: .5rem; min-width: 0; width: min(60vw, calc((100dvh - 290px) * 1080 / 1100)); }
.map-player { display: flex; gap: .6rem; align-items: center; width: 100%; }
.map-player input[type=range] { flex: 1; min-height: 30px; padding: 0; }
.map-player select { width: auto; }
.map-player button { min-width: 52px; }
.map-setup { border: 1px solid var(--border); border-radius: 10px; padding: .6rem .8rem; }
.map-setup .chips button { min-height: 34px; padding: .2rem .6rem; font-size: .85rem; }
.map-setup .chips button.on { background: var(--accent); color: #fff; }
.map-setup label { margin: .4rem 0; }
dialog.calib { width: min(1200px, calc(100vw - 16px)); }
.calib-panes { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.calib-box { position: relative; background: #000; border-radius: 8px; overflow: hidden; cursor: crosshair; }
.calib-box img, .calib-box svg { width: 100%; display: block; }
.calib-box svg { aspect-ratio: 1080 / 1100; }
.calib-marks { position: absolute; inset: 0; pointer-events: none; }
.calib-mark { position: absolute; transform: translate(-50%, -50%); width: 24px; height: 24px; border-radius: 50%; background: #ffd24a; color: #000;
  font: 700 13px/24px system-ui; text-align: center; box-shadow: 0 0 0 2px #000; }
.calib-mark.pending { background: #fff; }
@media (max-width: 860px) {
  .map-body { grid-template-columns: 1fr; }
  .map-main { width: 100%; }
  .calib-panes { grid-template-columns: 1fr; }
}
.lg.lg-cook { background: #c38bff; } .lg.lg-server { background: #3fd0d8; } .lg.lg-gm { background: #fff; box-shadow: 0 0 0 1px #888; }
.map-scenario { border: 1px solid var(--border); border-radius: 10px; padding: .5rem .8rem; }
.map-scenario summary { cursor: pointer; font-weight: 650; padding: .2rem 0; }
.map-scenario select { margin: .3rem 0; }
.scn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .6rem; }
.scn-field { font-size: .8rem; font-weight: 500; margin: .3rem 0; }
.scn-field input { min-height: 36px; padding: .2rem .4rem; }
.scn-results { width: 100%; border-collapse: collapse; font-size: .85rem; margin-top: .6rem; }
.scn-results th, .scn-results td { text-align: left; padding: .25rem .3rem; border-bottom: 1px solid var(--grid); }
.scn-results td:nth-child(2) { font-variant-numeric: tabular-nums; font-weight: 600; }
.scn-results tr.warn td:nth-child(2) { color: var(--danger); }
.scn-buttons { flex-wrap: wrap; }
.scn-results caption { text-align: left; font-size: .8rem; color: var(--muted); padding-bottom: .3rem; }
.scn-results.many td:nth-child(2) { color: var(--accent); }
.table-scroll { overflow-x: auto; }
.nights input { min-height: 34px; padding: .2rem .4rem; min-width: 160px; }
.nights td { white-space: nowrap; }
.clip-actions button.kept { color: var(--good); opacity: 1; }
.clip .clip-actions { gap: .4rem; }
.kept-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.kept-note { margin: 0; padding: 0 .55rem .4rem; font-size: .82rem; color: var(--text-2); }
.audit-table td { font-size: .85rem; vertical-align: top; }

@media (max-width: 480px) {
  .topbar { gap: .35rem; padding: .4rem 10px; }
  .tabs button { padding: .3rem .5rem; font-size: .88rem; }
  .topbar > button.icon { padding: .4rem .45rem; }
}

/* Notifications: "Manage alerts" sits at the top, under the title. */
.notes-actions { display: flex; margin: 0 0 .6rem; }
