/* Client reports — tokens and layout. See docs/client_reports_redesign.md.
   Light, editorial. The SOP step colours are the only saturated colour
   besides the accent; the chrome is ink on paper. */

:root {
  --paper: #EFEFEC;
  --paper-2: #F7F7F4;
  --ink: #17202A;
  --ink-2: #3D4753;
  --muted: #7A838D;
  --rule: #D6DAE0;
  --rule-2: #E6E8EC;
  --accent: #2F5A8A;
  --accent-soft: #E1E9F2;
  --pass: #2B7A4B;
  --pass-soft: #E4F2EA;
  --fail: #B4433A;
  --fail-soft: #F7E6E4;
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --topbar-h: 56px;
  --tabs-h: 44px;
  --rail-w: 300px;
  --steps-w: 340px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  font-feature-settings: "tnum" 1;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 0 20px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--rule);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 600; font-size: 16px; letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.brand img { width: 26px; height: 26px; display: block; }
.topbar-center { font-weight: 500; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }
.topbar-right { display: flex; justify-content: flex-end; align-items: center; gap: 18px; color: var(--muted); }
.topbar-right a { color: var(--ink-2); }

/* ---------- tabs (report page) ---------- */
.tabs {
  position: sticky; top: var(--topbar-h); z-index: 19;
  height: var(--tabs-h);
  display: flex; align-items: stretch; gap: 2px;
  padding: 0 12px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--rule);
  overflow-x: auto; scrollbar-width: thin;
}
.tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 0 12px; white-space: nowrap;
  color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); text-decoration: none; background: var(--rule-2); }
.tab[aria-current="page"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }
.tab .n { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }

/* ---------- home ---------- */
.home { width: 100%; padding: 28px 32px 64px; }
.masthead h1 { font-size: 32px; line-height: 1.1; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 6px; }
.masthead p { margin: 0; color: var(--ink-2); font-size: 14px; }
.project + .project { margin-top: 56px; }
.project h2 { font-size: 18px; font-weight: 600; margin: 28px 0 8px; letter-spacing: -0.01em; }
.masthead { margin-bottom: 20px; }
.ledger { border-top: 1px solid var(--ink); }
.row {
  display: grid; grid-template-columns: minmax(220px, 2fr) minmax(200px, 3fr) 90px 90px 90px 80px;
  gap: 24px; align-items: center;
  padding: 7px 0; border-bottom: 1px solid var(--rule); color: inherit;
}
.row:hover { text-decoration: none; }
.row:hover .title { text-decoration: underline; text-underline-offset: 3px; }
.row .title { font-size: 15px; font-weight: 500; letter-spacing: -0.01em; }
.row .num { text-align: right; font-variant-numeric: tabular-nums; font-size: 14px; }
.row .num.pass { color: var(--pass); }
.row .num.fail { color: var(--fail); }
.row .num.muted { color: var(--muted); }
.row.head { padding: 5px 0; border-bottom: 1px solid var(--rule); color: var(--muted); font-size: 12.5px; }
.row.head .title, .row.head .num { font-size: 13px; font-weight: 400; color: var(--muted); }
.bar { display: flex; height: 6px; border-radius: 2px; overflow: hidden; background: var(--rule-2); }
.bar .pass { background: var(--pass); }
.bar .fail { background: var(--fail); }
@media (max-width: 760px) { .row { grid-template-columns: 1fr 70px 70px; } .row .bar, .row .num.fail, .row .num.muted { display: none; } }
.files { border-top: 1px solid var(--rule); margin-top: 28px; padding-top: 4px; }
.files h2 { font-size: 18px; font-weight: 600; margin: 14px 0 4px; }
.files p { margin: 0 0 10px; color: var(--ink-2); }
.file { display: grid; grid-template-columns: 120px 1fr auto; gap: 16px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--rule-2); }
.file .label { font-weight: 600; }
.file .uri { font-family: var(--mono); font-size: 13px; color: var(--ink-2); word-break: break-all; }
.file .note { color: var(--muted); font-size: 12.5px; margin-top: 0; }
.copy { border: 1px solid var(--rule); background: var(--paper-2); border-radius: 4px; padding: 4px 10px; cursor: pointer; color: var(--ink-2); }
.copy:hover { border-color: var(--ink-2); color: var(--ink); }
.empty { color: var(--muted); padding: 40px 0; }

/* ---------- report page frame ---------- */
.frame {
  display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--steps-w);
  height: calc(100vh - var(--topbar-h) - var(--tabs-h));
}
.rail, .steps { background: var(--paper-2); overflow: hidden; display: flex; flex-direction: column; }
.rail { border-right: 1px solid var(--rule); }
.steps { border-left: 1px solid var(--rule); }
.stage { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

/* rail */
.rail-head { padding: 12px 12px 8px; border-bottom: 1px solid var(--rule); display: grid; gap: 8px; }
.search { width: 100%; border: 1px solid var(--rule); border-radius: 4px; padding: 7px 10px; font: inherit; background: var(--paper); }
.search:focus { border-color: var(--accent); outline: none; }
.rail-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chip { border: 1px solid var(--rule); border-radius: 999px; padding: 3px 10px; background: var(--paper-2); cursor: pointer; color: var(--ink-2); font-size: 13px; }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.rail select { border: 1px solid var(--rule); border-radius: 4px; padding: 4px 8px; background: var(--paper-2); font: inherit; font-size: 13px; color: var(--ink-2); margin-left: auto; }
.reasons .chip { font-size: 12px; padding: 2px 9px; border-style: dashed; }
.reasons .chip[aria-pressed="true"] { border-style: solid; }
.reasons .chip .n { color: var(--muted); margin-left: 4px; }
.reasons .chip[aria-pressed="true"] .n { color: #cfd6dd; }
.rail-count { color: var(--muted); font-size: 13px; padding: 6px 14px 4px; }
.ep-list { overflow-y: auto; flex: 1; scrollbar-width: thin; }
.ep {
  display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: center;
  padding: 5px 12px; cursor: pointer; border-left: 3px solid transparent;
}
.ep:hover { background: var(--rule-2); }
.ep[aria-selected="true"] { background: var(--accent-soft); border-left-color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--rule); }
.dot.pass { background: var(--pass); }
.dot.fail { background: var(--fail); }
.ep .id { font-family: var(--mono); font-size: 12.5px; color: var(--ink); }
.ep .sub { color: var(--muted); font-size: 11.5px; margin-top: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ep .dur { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.ep .flag { color: var(--accent); font-size: 12px; }

/* stage */
.stage-head { display: flex; align-items: baseline; gap: 14px; padding: 12px 20px 6px; }
.stage-head h1 { font-size: 16px; font-weight: 600; margin: 0; font-family: var(--mono); letter-spacing: 0; }
.stage-head .sub { color: var(--muted); font-size: 13px; }
.stage-head .spacer { flex: 1; }
.verdict { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-weight: 500; font-size: 13px; }
.verdict.pass { background: var(--pass-soft); color: var(--pass); }
.verdict.fail { background: var(--fail-soft); color: var(--fail); }
.video-wrap { position: relative; margin: 0 20px; background: #0E1216; border-radius: 6px; overflow: hidden; flex: 1; min-height: 200px; display: grid; }
.video-wrap video { width: 100%; height: 100%; object-fit: contain; display: block; background: #0E1216; }
.video-wrap:not(.grid) video.primary {
  position: absolute;
  inset: 0;
  min-width: 0;
  min-height: 0;
}
.video-wrap.grid { grid-template-columns: 1fr 1fr; gap: 2px; }
.video-wrap.grid video { aspect-ratio: 16/9; height: auto; }
.video-wrap:not(.grid) video:not(.primary) { display: none; }
.cams { display: flex; gap: 8px; align-items: center; padding: 8px 20px 0; }
.cam { width: 96px; aspect-ratio: 16/9; border: 1px solid var(--rule); border-radius: 4px; overflow: hidden; background: #0E1216; padding: 0; cursor: pointer; opacity: .75; }
.cam video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.cam[aria-pressed="true"] { border-color: var(--ink); opacity: 1; }
.cam:hover { opacity: 1; }
.controls { display: flex; align-items: center; gap: 10px; padding: 10px 20px 0; }
.btn { border: 1px solid var(--rule); background: var(--paper-2); border-radius: 4px; padding: 5px 11px; cursor: pointer; color: var(--ink-2); line-height: 1.2; }
.btn:hover { border-color: var(--ink-2); color: var(--ink); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #000; }
.btn[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.clock { font-family: var(--mono); font-size: 13px; color: var(--ink-2); min-width: 130px; }
.controls select { border: 1px solid var(--rule); border-radius: 4px; padding: 4px 6px; background: var(--paper-2); font: inherit; font-size: 13px; }

/* timeline — the hero. Every step is a band from the previous mark to its own
   mark (a mark records the moment a step completes), so the episode reads as a
   sequence of coloured durations. A zoomed band sits above the whole strip,
   joined by a fan. */
.timeline { padding: 12px 20px 14px; user-select: none; }
.tl-zoom { position: relative; height: 64px; border-radius: 4px; overflow: hidden; background: var(--rule-2); }
.tl-fan { display: block; width: 100%; height: 22px; }
.tl-full { position: relative; height: 26px; border-radius: 3px; overflow: hidden; background: var(--rule-2); }
.tl-track { position: absolute; inset: 0; cursor: pointer; }
.seg { position: absolute; top: 0; bottom: 0; background: var(--c, var(--ink)); box-shadow: inset 1px 0 0 rgba(255,255,255,.55); }
.seg.custom { background: repeating-linear-gradient(135deg, var(--muted) 0 4px, #b9c0c8 4px 8px); }
.tl-zoom .seg { display: flex; align-items: flex-start; padding: 6px 0 0 6px; overflow: hidden; }
.tl-zoom .seg .lbl {
  background: rgba(247,247,244,.94); color: var(--ink); border: 1px solid var(--c, var(--rule));
  border-radius: 3px; padding: 1px 7px; font-size: 12px; line-height: 1.4;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: calc(100% - 8px);
}
.tl-zoom .seg .end { position: absolute; right: 6px; bottom: 5px; font-family: var(--mono); font-size: 11px; color: rgba(23,32,42,.72); }
.tl-zoom .seg.current { box-shadow: inset 0 0 0 2px var(--ink); z-index: 1; }
.tl-zoom .seg.current .lbl { font-weight: 600; }
.tl-full .seg.current { box-shadow: inset 0 0 0 2px var(--ink); }
.playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--ink); transform: translateX(-1px); pointer-events: none; z-index: 2; }
.tl-window { position: absolute; top: 0; bottom: 0; border: 2px solid var(--ink); border-radius: 3px; pointer-events: none; z-index: 1; }
.tl-times { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; color: var(--muted); padding-top: 4px; }
.tl-legend { display: flex; gap: 14px; flex-wrap: wrap; padding: 10px 0 0; color: var(--ink-2); font-size: 12.5px; }
.tl-legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--c); margin-right: 6px; vertical-align: -1px; }
.tl-hint { color: var(--muted); font-size: 12px; margin-left: auto; }

/* steps column */
.steps-head { padding: 14px 16px 10px; border-bottom: 1px solid var(--rule); }
.steps-head h2 { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
.steps-head .reason { color: var(--fail); font-size: 13px; margin-top: 4px; }
.steps-head .meta { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.step-list { overflow-y: auto; flex: 1; scrollbar-width: thin; padding: 6px 0 12px; }
.phase-h { padding: 12px 16px 4px; color: var(--muted); font-size: 12.5px; }
.step {
  display: grid; grid-template-columns: 46px 8px 1fr; gap: 10px; align-items: center;
  padding: 5px 16px; cursor: pointer; border-left: 3px solid transparent;
}
.step:hover { background: var(--rule-2); }
.step.current { background: var(--accent-soft); border-left-color: var(--ink); }
.step .t { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.step .sw { width: 8px; height: 8px; border-radius: 2px; background: var(--c); }
.step .name { font-size: 13.5px; }
.step .attr { color: var(--muted); font-size: 12px; margin-left: 6px; }
.step .custom { font-style: italic; }
.steps-foot { border-top: 1px solid var(--rule); padding: 12px 16px; display: grid; gap: 8px; }
.fb { border: 1px solid var(--rule); border-radius: 6px; padding: 10px 12px; background: var(--paper); font-size: 13px; }
.fb .who { color: var(--muted); font-size: 12px; margin-bottom: 4px; display: flex; justify-content: space-between; }
.fb .who button { border: 0; background: none; color: var(--fail); cursor: pointer; padding: 0; }
.fb-form { display: none; gap: 8px; }
.fb-form.open { display: grid; }
.fb-form textarea { width: 100%; min-height: 72px; border: 1px solid var(--rule); border-radius: 4px; padding: 8px; font: inherit; resize: vertical; background: var(--paper); }
.fb-form .row { display: flex; gap: 8px; align-items: center; }
.fb-form label { display: inline-flex; gap: 6px; align-items: center; color: var(--ink-2); font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 6px; font-size: 13px; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }
.loading { color: var(--muted); padding: 24px; }

@media (max-width: 1100px) {
  :root { --steps-w: 300px; --rail-w: 260px; }
}
@media (max-width: 860px) {
  .frame { grid-template-columns: 1fr; height: auto; }
  .rail, .steps { border: 0; border-top: 1px solid var(--rule); max-height: 40vh; }
  .video-wrap { min-height: 220px; }
}

/* In grid mode every camera is already on screen; the thumbnail row goes. */
.video-wrap.grid + .cams { display: none; }

/* Comfortable controls and a workspace that fits the available screen. */
[hidden] { display: none !important; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button, .tab, .ep, .ledger a { transition: background-color .15s, border-color .15s, color .15s; }
button:disabled { opacity: .45; cursor: default; }
button:disabled:hover { border-color: var(--rule); }
.brand { justify-self: start; }
.topbar { gap: 20px; }
.topbar-center { min-width: 0; }
.rail-title { display: flex; align-items: center; justify-content: space-between; }
.rail-title h2 { font-size: 14px; font-weight: 600; margin: 0; }
.text-btn { border: 0; background: transparent; color: var(--accent); padding: 4px 0; cursor: pointer; font-size: 12px; }
.search { min-height: 38px; border-radius: 6px; }
.rail-head { padding: 16px 14px 12px; gap: 12px; }
.rail select { width: 100%; margin: 4px 0 0; min-height: 32px; }
.rail-count { padding: 12px 16px 8px; }
.ep { min-height: 30px; }
.ep > span { min-width: 0; }
.empty-state { padding: 28px 18px; color: var(--muted); }
.empty-state strong { color: var(--ink-2); font-weight: 500; }
.empty-state p { margin: 6px 0 0; }
.stage { overflow-y: auto; }
.stage-head { flex-wrap: wrap; align-items: center; padding: 16px 20px 12px; gap: 8px 12px; }
.stage-head h1 { font-size: 13.5px; font-weight: 500; }
.stage-head .sub { flex-basis: 100%; order: 1; }
.video-wrap { flex: 1 0 200px; }
.video-message { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 32px; color: #d3dbe4; text-align: center; }
.video-message strong { color: white; font-size: 16px; }
.cam { position: relative; width: 88px; border-width: 2px; }
.cam[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.cam span { position: absolute; bottom: 0; left: 0; right: 0; padding: 2px 4px; background: #17202acc; color: white; font-size: 10px; }
.cams { flex-wrap: wrap; }
.controls { flex-wrap: wrap; gap: 8px; }
.btn { min-height: 34px; border-radius: 6px; }
.controls select { min-height: 34px; }
.clock { min-width: 0; font-size: 12px; }
.timeline-heading { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; font-weight: 500; margin: 6px 0 8px; }
.timeline-heading .muted { color: var(--muted); font-weight: 400; }
.scrubber { width: 100%; margin: 4px 0 12px; accent-color: var(--accent); cursor: pointer; }
.timeline { flex-shrink: 0; }
.step { width: 100%; border: 0; border-left: 3px solid transparent; background: transparent; text-align: left; min-height: 38px; }
.steps-head .meta { overflow-wrap: anywhere; }
.steps-foot { max-height: 48%; overflow-y: auto; flex-shrink: 0; }
.fb-form .row { padding: 0; border: 0; flex-wrap: wrap; }
.toast { z-index: 100; max-width: calc(100vw - 32px); text-align: center; }
.home { padding-top: 24px; }
.masthead p { color: var(--muted); }
.home-stats { display: flex; gap: 36px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--rule); }
.home-stat { display: flex; flex-direction: column; gap: 2px; color: var(--muted); font-size: 13px; }
.home-stat strong { color: var(--ink); font-size: 22px; font-weight: 500; letter-spacing: -.02em; }
.ledger { border-top-color: var(--rule); }
.ledger .row { padding: 6px 10px; gap: 24px; grid-template-columns: minmax(220px, 2fr) minmax(200px, 3fr) 90px 90px 90px 80px; }
.ledger .row.head { padding-top: 4px; padding-bottom: 4px; }
.ledger a:hover { background: var(--accent-soft); }
.ledger a:hover .title { text-decoration: none; color: var(--accent); }
.bar { height: 5px; }
.files .file { padding: 6px 0; }
.copy { min-height: 34px; white-space: nowrap; }
@media (min-width: 861px) and (max-width: 1280px) {
  :root { --rail-w: 230px; --steps-w: 260px; }
  .stage-head, .controls, .cams { padding-left: 14px; padding-right: 14px; }
  .video-wrap { margin-left: 14px; margin-right: 14px; }
  .timeline { padding-left: 14px; padding-right: 14px; }
}
@media (max-width: 860px) {
  .frame { grid-template-columns: minmax(0, 1fr); }
  .rail { max-height: 300px; }
  .ep-list { min-height: 90px; }
  .rail-head { gap: 8px; }
  .rail select { width: auto; margin: 0 0 0 auto; }
  .stage { overflow: visible; }
  .video-wrap { flex: none; height: min(52vw, 420px); min-height: 200px; }
  .steps { max-height: none; }
  .step-list { max-height: 420px; }
  .steps-foot { max-height: none; }
  .ledger .row { grid-template-columns: minmax(130px, 1fr) 70px 70px 70px; gap: 10px; }
  .ledger .bar, .ledger .num.muted { display: none; }
  .ledger .num.fail { display: block; }
  .topbar { grid-template-columns: auto minmax(0, 1fr) auto; padding: 0 16px; gap: 14px; }
  .topbar-right > span { display: none; }
  .topbar-center { text-align: center; font-size: 13px; }
}
@media (max-width: 480px) {
  .home { padding: 32px 16px 48px; }
  .masthead h1 { font-size: 32px; }
  .home-stats { gap: 24px; flex-wrap: wrap; }
  .home-stat strong { font-size: 24px; }
  .ledger .row { grid-template-columns: minmax(90px, 1fr) 60px 55px 55px; padding-left: 4px; padding-right: 4px; gap: 8px; }
  .row .title, .row .num { font-size: 14px; }
  .file { grid-template-columns: minmax(0, 1fr) auto; }
  .file .label { grid-column: 1 / -1; }
  .timeline-heading .muted { display: none; }
  .brand { font-size: 14px; gap: 6px; }
  .brand img { width: 22px; height: 22px; }
}

/* scrubber: a quiet range under the heading, ink thumb, hairline track */
.scrubber { width: 100%; margin: 4px 0 8px; accent-color: var(--ink); height: 18px; }
.timeline-heading { display: flex; justify-content: space-between; font-weight: 600; font-size: 13px; }
.timeline-heading .muted { color: var(--muted); font-weight: 400; }

.stage-head .reason { color: var(--fail); font-size: 13px; }
