:root {
  --bg: #0d1117;
  --panel: #131a24;
  --panel-2: #172231;
  --line: #22304a;
  --text: #e6edf7;
  --muted: #93a4bd;
  --accent: #4f8cff;
  --ok: #35c46b;
  --warn: #e3b341;
  --err: #f0616d;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
h2 { margin: 0; font-size: 17px; }
h3 { margin: 22px 0 8px; font-size: 15px; }
h4 { margin: 14px 0 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
a { color: var(--accent); }
code, pre, textarea, .mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 8px; }
.right { display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--warn); }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--err); }
.tag {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 2px 9px; font-size: 12px;
}
.tabs { display: flex; gap: 6px; padding: 10px 16px 0; flex-wrap: wrap; }
.tab {
  background: var(--panel); color: var(--muted); border: 1px solid var(--line);
  border-bottom: none; border-radius: 8px 8px 0 0; padding: 8px 14px; cursor: pointer;
}
.tab.active { background: var(--panel-2); color: var(--text); border-color: var(--accent); }
main { padding: 16px; }
.panel { display: none; }
.panel.active { display: block; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.space { justify-content: space-between; }
.split { display: flex; gap: 14px; align-items: flex-start; margin-top: 12px; flex-wrap: wrap; }
.grow { flex: 1 1 520px; min-width: 320px; }
.side {
  flex: 0 0 320px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px;
}
.side.wide { flex: 1 1 460px; }
input, select, textarea, button {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 7px; padding: 6px 9px; font-size: 13px;
}
textarea { width: 100%; min-height: 460px; padding: 10px; line-height: 1.5; }
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { background: #3a1b21; border-color: var(--err); color: #ffd7db; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; display: flex; flex-direction: column; gap: 8px;
}
.card h3 { margin: 0; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.thumb {
  background: #05080d; border: 1px solid var(--line); border-radius: 6px;
  aspect-ratio: 16 / 9; display: flex; align-items: center; justify-content: center;
  overflow: hidden; color: var(--muted); font-size: 12px;
}
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.pill { border-radius: 999px; padding: 1px 8px; font-size: 11px; border: 1px solid var(--line); }
.pill.idle { color: var(--muted); }
.pill.running { background: #10261c; color: var(--ok); border-color: #1d5a38; }
.pill.done { background: #12233a; color: #8bb6ff; border-color: #24457a; }
.pill.error { background: #2c1418; color: #ff9aa3; border-color: #6b2530; }
.pill.queued { color: var(--warn); }
.bar { height: 5px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); width: 0; }
.report {
  background: #070b11; border: 1px solid var(--line); border-radius: 8px;
  padding: 9px; font-size: 12px; white-space: pre-wrap; word-break: break-word;
  max-height: 260px; overflow: auto; margin: 0;
}
.report.scroll { max-height: 200px; }
.table-wrap { overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; background: var(--panel-2); position: sticky; top: 0; }
tbody tr:hover { background: #16202e; }
tbody tr.sel { background: #1b2a40; }
.stream-wrap { background: #05080d; border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
#live-frame { width: 100%; display: block; border-radius: 6px; image-rendering: auto; }
/* The live frame is the operator's pointing device: real cursor, real focus. */
#live-stage { cursor: crosshair; outline: none; position: relative; }
/* Click markers: the operator sees where their click actually landed, which is
   the difference between "that tile is selected" and "I clicked but missed". */
#live-hud { position: absolute; pointer-events: none; z-index: 2; }
/* Magnifier: a lens over the frame, for reading small or blurry content. It
   shows pixels and decides nothing — the operator still picks the answer. */
#live-lens { position: fixed; z-index: 60; width: 196px; height: 196px;
             border-radius: 50%; border: 2px solid var(--accent);
             box-shadow: 0 8px 24px rgba(0,0,0,.55); overflow: hidden;
             pointer-events: none; display: none; background: #05080d; }
#live-lens.on.here { display: block; }
#live-lens canvas { width: 100%; height: 100%; display: block; }
#live-stage:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(90, 140, 255, .25); }

/* ---- needs-a-human alert ---- */
.needs-human {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin: 10px 16px 0; padding: 10px 14px;
  background: #2a1e08; border: 1px solid #8a6a1a; border-left: 5px solid #f0b429;
  border-radius: 10px; color: #ffe6b0;
  animation: nh-pulse 2s ease-in-out infinite;
}
.needs-human[hidden] { display: none; }
.needs-human .nh-text { display: flex; flex-direction: column; gap: 2px; }
.needs-human strong { font-size: 15px; }
@keyframes nh-pulse {
  0%, 100% { border-left-color: #f0b429; }
  50% { border-left-color: #ffd777; }
}
.card.needs-human-card {
  border-color: #f0b429; box-shadow: 0 0 0 2px rgba(240, 180, 41, .25);
}
.pill.needs_human {
  background: #2a1e08; color: #ffd777; border-color: #8a6a1a;
}
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; font-size: 11px; color: var(--muted); }
.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-top: 12px; }
.shots figure { margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px; }
.shots img { width: 100%; border-radius: 5px; display: block; }
.shots figcaption { font-size: 11px; color: var(--muted); margin-top: 4px; word-break: break-all; }
.files { margin-top: 12px; display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
#evidence-video { width: 100%; background: #000; border: 1px solid var(--line); border-radius: 10px; min-height: 240px; }
.ok { color: var(--ok); } .bad { color: var(--err); }
.foot { padding: 14px 16px 26px; }
