/* Operator dashboard. System fonts only; all colours are tokens with a dark set. */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --fg: #151922;
  --muted: #5d6573;
  --line: #dde1e8;
  --accent: #0b5cff;
  --accent-fg: #ffffff;
  --danger: #b4232f;
  --danger-bg: #fdecee;
  --focus: rgba(11, 92, 255, .35);
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px -8px rgba(16, 24, 40, .12);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116; --surface: #171b22; --fg: #e8ebf0; --muted: #98a1b0; --line: #2a303a;
    --accent: #5b8cff; --accent-fg: #0b0e13; --danger: #ff7a85; --danger-bg: #3a1b20;
    --focus: rgba(91, 140, 255, .45); --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -8px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--fg); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
h1, h2 { margin: 0; letter-spacing: -0.01em; text-wrap: balance; }

/* Brand mark: a lens inside a frame, drawn in CSS. */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: var(--fg); text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; inset: 8px; border-radius: 50%; border: 2.5px solid var(--accent-fg); }

/* Sign-in */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-left)); }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow); padding: 32px 28px 28px; display: grid; gap: 22px; }
.auth-card h1 { font-size: 1.35rem; }
.auth-card .lead { margin: 4px 0 0; color: var(--muted); font-size: 0.9rem; }
.auth-foot { text-align: center; color: var(--muted); font-size: 0.8rem; margin: 0; }

form.stack { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 0.85rem; font-weight: 600; }
input[type=email], input[type=password], input[type=text], textarea {
  font: inherit; color: var(--fg); background: var(--surface); width: 100%;
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--focus); }

.btn { font: 600 0.95rem var(--font); border-radius: 10px; padding: 11px 16px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--fg); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); width: 100%; }
.btn:hover { filter: brightness(1.05); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--focus); }

.alert { border-radius: 10px; padding: 10px 12px; font-size: 0.9rem; background: var(--danger-bg); color: var(--danger); margin: 0; }

/* App shell */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: 12px max(16px, env(safe-area-inset-left));
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.user { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 0.9rem; }
.role { font: 600 0.72rem var(--font); text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent);
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; }
.user form { margin: 0; }
.page { max-width: 1120px; margin: 0 auto; padding: 28px max(16px, env(safe-area-inset-left)); display: grid; gap: 20px; }
.page h1 { font-size: 1.5rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.panel p { margin: 0; color: var(--muted); max-width: 62ch; }

/* Page head, tabs */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.btn-inline { width: auto; text-decoration: none; display: inline-block; }
a.btn { text-decoration: none; display: inline-block; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.tabs a { color: var(--muted); text-decoration: none; padding: 8px 12px; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600; font-size: 0.9rem; }
.tabs a[aria-current="page"] { color: var(--fg); border-bottom-color: var(--accent); }
.tabs .count { font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; margin-left: 4px; }

/* Table */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table.list { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.list th { text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
  font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.list td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.list tr:last-child td { border-bottom: 0; }
.list .ref { font-weight: 600; white-space: nowrap; }
.list .when { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.list .evidence { white-space: nowrap; }
.muted { color: var(--muted); }

/* UK-style plate: the registration as people read it */
.plate { font: 700 0.85rem var(--mono); letter-spacing: 0.06em; background: #f7d33b; color: #111; border-radius: 4px; padding: 2px 6px; white-space: nowrap; }

/* Status pills: colour by state family */
.pill { display: inline-block; font-size: 0.78rem; font-weight: 600; border-radius: 999px; padding: 2px 10px; white-space: nowrap;
  background: var(--pill-bg, var(--bg)); color: var(--pill-fg, var(--muted)); border: 1px solid var(--line); }
.st-ready-for-review, .st-referred { --pill-bg: #e6efff; --pill-fg: #0b4fd6; border-color: transparent; }
.st-accepted { --pill-bg: #e5f6ec; --pill-fg: #0a7a3d; border-color: transparent; }
.st-retake-required { --pill-bg: #fff3e0; --pill-fg: #a35a00; border-color: transparent; }
.st-processing, .st-submitted, .st-active { --pill-bg: var(--bg); --pill-fg: var(--fg); }
@media (prefers-color-scheme: dark) {
  .st-ready-for-review, .st-referred { --pill-bg: #17284d; --pill-fg: #9dbbff; }
  .st-accepted { --pill-bg: #10301f; --pill-fg: #6fd39b; }
  .st-retake-required { --pill-bg: #3a2a10; --pill-fg: #ffbf66; }
}
.flags { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 4px; }
.flags li { font-size: 0.78rem; border-radius: 6px; padding: 1px 7px; background: var(--danger-bg); color: var(--danger); white-space: nowrap; }

.empty { display: grid; gap: 6px; }
.empty h2 { font-size: 1.05rem; }

/* Forms */
.form-panel { max-width: 560px; display: grid; gap: 18px; }
.actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.mono { font-family: var(--mono) !important; }
.plate-input { text-transform: uppercase; font-family: var(--mono) !important; letter-spacing: 0.05em; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; font-size: 0.85rem; }
.note { font-size: 0.85rem; }
.facts { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.facts dt { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.facts dd { margin: 4px 0 0; }
.flags li.info { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }

/* Pager */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 0.9rem; }
.pager-links { display: flex; align-items: center; gap: 10px; }
.btn.disabled { opacity: .45; cursor: default; }

/* Phones: the table becomes one card per inspection. */
@media (max-width: 760px) {
  .page { padding-top: 20px; gap: 16px; }
  .page h1 { font-size: 1.3rem; }
  .topbar-inner { padding-block: 10px; }
  .topbar-inner { flex-wrap: nowrap; }
  .user > span:first-child { display: none; }
  .user .btn { padding: 7px 12px; font-size: 0.85rem; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tabs a { white-space: nowrap; padding: 8px 10px; }
  .table-wrap { background: none; border: 0; overflow: visible; }
  table.list, .list tbody, .list tr, .list td { display: block; width: 100%; }
  .list thead { display: none; }
  .list tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 12px 14px; margin-bottom: 10px; display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; }
  .list td { padding: 0; border: 0; }
  .list td.ref { grid-column: 1; font-size: 1rem; white-space: normal; overflow-wrap: anywhere; }
  .list td[data-label="Status"] { grid-column: 2; grid-row: 1; text-align: right; }
  .list td[data-label="Registration"] { grid-column: 1; }
  .list td.when { grid-column: 2; grid-row: 2; text-align: right; font-size: 0.8rem; align-self: center; }
  .list td.evidence, .list td.flags-cell { grid-column: 1 / -1; white-space: normal; }
  .list td.flags-cell:has(.muted) { display: none; }
  .pager { justify-content: center; }
  .pager > .muted { width: 100%; text-align: center; }
  .form-panel { padding: 18px; }
  .actions { flex-direction: column-reverse; }
  .actions .btn { width: 100%; text-align: center; }
}

/* Inspection page */
.row-link { color: inherit; text-decoration: none; }
.row-link:hover { color: var(--accent); text-decoration: underline; }
.crumbs { font-size: 0.85rem; color: var(--muted); }
.crumbs a { color: var(--muted); }
.detail-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px 32px; flex-wrap: wrap; }
.detail-title { display: grid; gap: 8px; min-width: 0; }
.detail-title h1 { overflow-wrap: anywhere; }
.detail-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.facts.compact { grid-template-columns: repeat(3, auto); gap: 8px 28px; }
.flag-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--surface);
  border: 1px solid var(--line); border-left: 4px solid var(--danger); border-radius: var(--radius); padding: 10px 14px; font-size: 0.9rem; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.detail-main, .detail-side { display: grid; gap: 20px; min-width: 0; }
.panel h2 { font-size: 1.05rem; }
.panel h3 { font-size: 0.95rem; margin: 22px 0 6px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.small { font-size: 0.85rem; }
.hint { font-size: 0.82rem; color: var(--muted); margin: 6px 0 0; }
.detail-side .panel { display: grid; gap: 8px; align-content: start; }
.detail-side .panel p { margin: 0; }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.photo { margin: 0; display: grid; gap: 6px; }
.photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: var(--bg); display: block; border: 1px solid var(--line); }
.photo a:focus-visible img { box-shadow: 0 0 0 4px var(--focus); }
.photo figcaption { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; font-size: 0.82rem; }
.tag { font-size: 0.75rem; border-radius: 6px; padding: 1px 7px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.tag.warn { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.tag.ok { background: #e5f6ec; color: #0a7a3d; border-color: transparent; }
@media (prefers-color-scheme: dark) { .tag.ok { background: #10301f; color: #6fd39b; } }

video#playback { width: 100%; max-height: 70vh; background: #000; border-radius: 10px; display: block; }
.challenges { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 10px; }
.challenge { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.challenge.is-unable, .challenge.is-open { border-left: 4px solid var(--danger); }
.ch-text { margin: 0 0 6px; font-weight: 600; }
.ch-meta { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 0.82rem; }
.btn.seek { padding: 6px 10px; font-size: 0.82rem; font-variant-numeric: tabular-nums; width: 100%; }
.takes { margin: 0; padding-left: 18px; font-size: 0.85rem; display: grid; gap: 4px; }

.checklist { white-space: pre-wrap; font: 0.82rem/1.5 var(--font); background: var(--bg); border-radius: 8px; padding: 10px 12px; margin: 0; }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; margin: 0; font-size: 0.82rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.wrap { overflow-wrap: anywhere; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; font-size: 0.85rem; }
.timeline li { display: grid; gap: 1px; padding-left: 12px; border-left: 2px solid var(--line); }
.timeline .when { font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }

@media (max-width: 960px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .facts.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
  .photos { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .challenge { grid-template-columns: minmax(0, 1fr); }
  .btn.seek { width: auto; }
  .list td.ref a { color: var(--fg); }
}

/* Decision */
textarea { resize: vertical; min-height: 88px; }
.decision-entry { display: grid; gap: 4px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.decision .reason { color: var(--fg); white-space: pre-wrap; overflow-wrap: anywhere; }
.decision-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.decision-buttons .btn { flex: 1 1 auto; padding: 9px 12px; font-size: 0.9rem; }
.btn-ok { background: #0a7a3d; border-color: #0a7a3d; color: #fff; }
.btn-warn { background: var(--surface); border-color: #c77700; color: #a35a00; }
@media (prefers-color-scheme: dark) {
  .btn-ok { background: #2fa866; border-color: #2fa866; color: #0b0e13; }
  .btn-warn { border-color: #e0a040; color: #f0b860; }
}
.alert.info { background: var(--bg); color: var(--fg); border: 1px solid var(--line); }
.attempts .count { font-size: 0.8rem; }
