:root {
  --bg: #f4f6f7; --panel: #fff; --ink: #1d262d; --muted: #5f6b74; --line: #cfd6db;
  --accent: #0e7a8a; --accent-soft: #d7eef1; --ok: #2e7d4f; --ok-soft: #dff2e6;
  --bad: #a3472a; --bad-soft: #f9e2dc; --warn: #c4641a; --warn-soft: #fbe6d3; --pad: #e6eaed;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #12181d; --panel: #1a2229; --ink: #e4e9ec; --muted: #9aa6ae; --line: #34404a;
    --accent: #4fc0d0; --accent-soft: #123e46; --ok: #6cc48f; --ok-soft: #1e3a2a;
    --bad: #f08a6a; --bad-soft: #4a2620; --warn: #f0954f; --warn-soft: #4a2c14; --pad: #2a343b; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); }
.top { display: flex; align-items: center; gap: 1.2rem; padding: .6rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 600; color: var(--ink); text-decoration: none; }
nav a { color: var(--muted); text-decoration: none; margin-right: .9rem; padding-bottom: .2rem; }
nav a.active { color: var(--ink); border-bottom: 2px solid var(--accent); }
nav a.off { opacity: .45; cursor: default; }
.spacer { flex: 1; }
main { max-width: 1040px; margin: 0 auto; padding: 1.2rem 1rem 4rem; }
h1 { font-size: 1.4rem; margin: .2rem 0 .8rem; }
h2 { font-size: 1.05rem; margin: 1.6rem 0 .5rem; }
.muted { color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: .9rem 1rem; margin: .8rem 0; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: .4rem .55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--pad); }
.wrap { overflow-x: auto; }
.badge { display: inline-block; font-size: .74rem; letter-spacing: .04em; text-transform: uppercase; padding: .15em .55em; border-radius: 3px; font-weight: 600; white-space: nowrap; }
.badge.pass { background: var(--ok-soft); color: var(--ok); }
.badge.fail { background: var(--bad-soft); color: var(--bad); }
.badge.run { background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.big { font-size: 1.15rem; font-weight: 600; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .6rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: .6rem .8rem; }
.stat .k { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 1.3rem; font-weight: 600; font-variant-numeric: tabular-nums; }
form.row { display: flex; gap: .8rem; flex-wrap: wrap; align-items: flex-end; }
label { display: flex; flex-direction: column; gap: .2rem; font-size: .84rem; color: var(--muted); }
input, select { font: inherit; padding: .4rem .5rem; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); color: var(--ink); min-width: 9rem; }
button { font: inherit; padding: .45rem .9rem; border-radius: 4px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; }
button.link { background: none; border: none; color: var(--accent); padding: 0; }
button[disabled] { opacity: .5; cursor: default; }
.error { color: var(--bad); }
.timeline { display: flex; gap: .4rem; flex-wrap: wrap; margin: .5rem 0; }
.step { padding: .25rem .6rem; border-radius: 999px; border: 1px solid var(--line); font-size: .82rem; color: var(--muted); }
.step.done { border-color: var(--ok); color: var(--ok); }
.step.now { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.bar { height: 6px; background: var(--pad); border-radius: 3px; overflow: hidden; margin: .4rem 0; }
.bar > i { display: block; height: 100%; background: var(--accent); transition: width .4s; }
pre { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: .8rem; overflow-x: auto; font-size: .82rem; }
ul.flips { padding-left: 1.2rem; } ul.flips li { margin: .2rem 0; }
.login { max-width: 420px; margin: 3rem auto; }
.soon { border: 1px dashed var(--line); padding: 1rem; color: var(--muted); border-radius: 6px; }
.coming { display: inline-flex; gap: .9rem; margin-left: .6rem; padding-left: .9rem; border-left: 1px solid var(--line); font-size: .9rem; }
.coming a { margin-right: 0; }
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin: .2rem 0 1rem; flex-wrap: wrap; }
.tab { padding: .45rem .9rem; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tab.off { opacity: .45; cursor: default; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin: 0 0 .6rem; }
.chip { background: var(--panel); color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: .2rem .7rem; font-size: .85rem; }
.chip.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
div.row { display: flex; gap: .8rem; flex-wrap: wrap; align-items: flex-end; margin: .4rem 0; }
div.row > label { flex: 1 1 14rem; }
div.row > label textarea { width: 100%; }
textarea { font: .85rem "IBM Plex Mono", ui-monospace, monospace; padding: .4rem .5rem; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); color: var(--ink); }
label.inline { display: inline-flex; flex-direction: row; align-items: center; gap: .4rem; color: var(--ink); font-size: .9rem; margin-left: .8rem; }
input[type=checkbox] { min-width: 0; margin: 0; }

/* camera run: the per-clip labelling cell */
.labelgrid { display: grid; grid-template-columns: repeat(3, minmax(4.8rem, 1fr)); gap: .2rem .4rem; min-width: 16rem; }
.labelgrid label { font-size: .75rem; gap: .1rem; }
.labelgrid select, .labelgrid input { min-width: 0; width: 100%; padding: .2rem .3rem; }
td a { overflow-wrap: anywhere; }
.labelgrid.wide { grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); }
tr.editing td { background: var(--bg); }
button.link { background: none; border: none; color: var(--accent); padding: 0; cursor: pointer; text-decoration: underline; }
button.secondary { background: var(--panel); color: var(--accent); }

/* health trends: one measure per sparkline, theme colours only */
.grid.trends { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-top: .6rem; }
.sparkwrap { position: relative; margin: .3rem 0 .1rem; }
svg.spark { width: 100%; height: 56px; display: block; touch-action: none; }
svg.spark .base { stroke: var(--line); stroke-width: 1; }
svg.spark .area { fill: var(--accent-soft); opacity: .6; }
svg.spark .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.spark .cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 2; }
svg.spark .dot { fill: var(--accent); stroke: var(--panel); stroke-width: 2; }
.sparkwrap .tip { position: absolute; top: -1.6rem; width: 110px; text-align: center; font-size: .75rem; background: var(--panel);
  border: 1px solid var(--line); border-radius: 3px; padding: .1rem .3rem; color: var(--ink); pointer-events: none; white-space: nowrap; }
details.trace h3 { font-size: .95rem; margin: .8rem 0 .3rem; }
details.trace q { color: var(--ink); }

/* candidate settings editor */
.knobs details { border-top: 1px solid var(--line); padding: .3rem 0; }
.knobs summary { cursor: pointer; font-weight: 600; }
.knob { display: grid; grid-template-columns: minmax(12rem, 2fr) minmax(8rem, 1fr) minmax(6rem, auto); gap: .6rem; align-items: center; padding: .35rem .3rem; }
.knob.changed { background: var(--accent-soft); border-radius: 4px; }
.knob .muted { font-size: .8rem; }
.detector { padding: .3rem 0 .5rem; border-bottom: 1px dashed var(--line); }
@media (max-width: 640px) { .knob { grid-template-columns: 1fr; } }

/* Settings: the camera table fits its card; inputs take their column, never more */
table.cameras { table-layout: fixed; width: 100%; }
table.cameras input { width: 100%; min-width: 0; box-sizing: border-box; }
table.cameras td { vertical-align: middle; }
@media (max-width: 640px) {
  table.cameras, table.cameras tbody, table.cameras tr, table.cameras td { display: block; width: 100%; }
  table.cameras thead, table.cameras colgroup { display: none; }
  table.cameras tr { border-bottom: 1px solid var(--line); padding: .5rem 0; }
  table.cameras td { border: none; padding: .15rem 0; }
  table.cameras td[data-label]::before { content: attr(data-label); display: block; font-size: .78rem; color: var(--muted); }
}
