/* Plate Review: operator dashboard. Light and dark from the system setting. */
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --text: #16181d;
  --muted: #5e6573;
  --line: #dfe2e8;
  --accent: #1d4ed8;
  --accent-text: #ffffff;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --warn: #a16207;
  --warn-bg: #fef3c7;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --info-bg: #e0e7ff;
  --plate-bg: #ffffff;
  --plate-line: #16181d;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --panel: #181b21;
    --text: #e8eaee;
    --muted: #9aa1ad;
    --line: #2a2f38;
    --accent: #6d8dfa;
    --accent-text: #0f1115;
    --ok: #4ade80;
    --ok-bg: #12301f;
    --warn: #facc15;
    --warn-bg: #352b0a;
    --bad: #f87171;
    --bad-bg: #3a1515;
    --info-bg: #1e2547;
    --plate-bg: #f4f5f7;
    --plate-line: #16181d;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.35rem; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; margin: 1.5rem 0 .6rem; }
h3 { font-size: .95rem; margin: 0 0 .4rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; }
[hidden] { display: none !important; }

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
  padding: .6rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 1000;
}
.brand { font-weight: 700; color: var(--text); }
.topbar nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.topbar nav a {
  color: var(--muted); padding: .35rem .65rem; border-radius: 8px; font-weight: 500;
}
.topbar nav a:hover { text-decoration: none; background: var(--bg); color: var(--text); }
.topbar nav a.active { background: var(--info-bg); color: var(--accent); }
.me { display: flex; gap: .75rem; align-items: center; font-size: .9rem; }
.badge {
  display: inline-block; min-width: 1.4em; padding: 0 .4em; margin-left: .2rem;
  border-radius: 999px; background: var(--bad); color: #fff; font-size: .75rem; text-align: center;
}
.banner { padding: .6rem 1rem; background: var(--warn-bg); color: var(--warn); font-size: .9rem; }

main { max-width: 1200px; margin: 0 auto; padding: 1.25rem 1rem 4rem; }

/* ---- building blocks ---- */
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; box-shadow: var(--shadow);
}
.row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; }
.spread { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
@media (max-width: 800px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
.stack > * + * { margin-top: 1rem; }

button, .button {
  font: inherit; font-weight: 600; cursor: pointer;
  padding: .5rem .9rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text);
}
button:hover { border-color: var(--muted); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.approve { background: #15803d; border-color: #15803d; color: #fff; }
button.reject { background: #b91c1c; border-color: #b91c1c; color: #fff; }
button.link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 500; }
input, textarea, select {
  font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: .5rem .65rem; min-width: 0;
}
input:focus, textarea:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
textarea { width: 100%; min-height: 6rem; resize: vertical; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .25rem; }
.field { margin-bottom: .8rem; }
.field input { width: 100%; }
.error { color: var(--bad); font-size: .9rem; }
.notice { color: var(--ok); font-size: .9rem; }

.tabs { display: flex; gap: .25rem; flex-wrap: wrap; margin: .75rem 0 1rem; }
.tabs a { padding: .3rem .7rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
.tabs a.active { background: var(--text); border-color: var(--text); color: var(--bg); }
.tabs a:hover { text-decoration: none; }

.pill { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.pill.pending_review, .pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.approved, .pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.rejected, .pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.cancelled, .pill.idle { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.pill.info { background: var(--info-bg); color: var(--accent); }

/* A licence plate, drawn like one. */
.plate {
  display: inline-flex; align-items: center; gap: .45em;
  font: 700 1.15rem/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .04em;
  color: #16181d; background: var(--plate-bg); border: 2px solid var(--plate-line); border-radius: 6px;
  padding: .3em .55em; white-space: nowrap;
}
.plate .sep { width: 2px; align-self: stretch; background: var(--plate-line); }
.plate.big { font-size: 1.7rem; }
.plate.small { font-size: .9rem; border-width: 1.5px; }
.plate.partial { border-style: dashed; }

/* ---- lists ---- */
.cards { display: grid; gap: .75rem; }
.card {
  display: grid; grid-template-columns: 168px minmax(0, 1fr) auto; gap: 1rem; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .75rem; color: var(--text); box-shadow: var(--shadow);
}
a.card:hover { text-decoration: none; border-color: var(--accent); }
.card .meta { display: grid; gap: .3rem; min-width: 0; }
.card .side { text-align: right; display: grid; gap: .3rem; justify-items: end; }
@media (max-width: 640px) {
  .card { grid-template-columns: 96px minmax(0, 1fr); }
  .card .side { grid-column: 1 / -1; justify-items: start; text-align: left; display: flex; gap: .5rem; flex-wrap: wrap; }
}

.thumb {
  width: 100%; aspect-ratio: 3 / 1; object-fit: contain; background: #0b0d10; border-radius: 6px; display: block;
}
.noimg {
  width: 100%; aspect-ratio: 3 / 1; border-radius: 6px; border: 1px dashed var(--line);
  display: grid; place-items: center; color: var(--muted); font-size: .75rem; text-align: center;
}
.frame { width: 100%; border-radius: 8px; background: #0b0d10; display: block; }
.evidence { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: .75rem; align-items: start; }
@media (max-width: 640px) { .evidence { grid-template-columns: minmax(0, 1fr); } }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--bg); }
tr.selected td { background: var(--info-bg); }
.table-wrap { overflow-x: auto; }
.reads img { height: 36px; width: 108px; object-fit: contain; background: #0b0d10; border-radius: 4px; display: block; }

.map { height: 380px; border-radius: var(--radius); border: 1px solid var(--line); z-index: 0; }
.map.tall { height: 480px; }

.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .3rem 1rem; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; }
.stat .n { font-size: 1.5rem; font-weight: 700; }
.stat .l { color: var(--muted); font-size: .8rem; }

.device { display: grid; gap: .35rem; }
.devices { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .75rem; }
.flags { display: flex; flex-wrap: wrap; gap: .3rem; }
.flags .pill { white-space: normal; text-align: left; }
.device details summary { cursor: pointer; color: var(--accent); font-size: .85rem; }
.device details .kv { margin-top: .4rem; }

pre {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .75rem;
  overflow: auto; max-height: 60vh; font-size: .8rem; white-space: pre-wrap; word-break: break-word;
}

.login { max-width: 360px; margin: 12vh auto 0; }
.login h1 { margin-bottom: 1rem; }
.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); }
.review-box { border-left: 4px solid var(--warn); }
.more { margin-top: 1rem; text-align: center; }
.reads-title { margin-top: 1rem; }

/* Phones: one line of brand + account, then the sections in a row that scrolls sideways. */
@media (max-width: 640px) {
  .topbar { gap: .5rem; padding: .5rem .75rem; justify-content: space-between; }
  .topbar nav { order: 3; flex-basis: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .topbar nav a { white-space: nowrap; }
  main { padding: 1rem .75rem 3rem; }
  .pill { white-space: normal; }
  .plate.big { font-size: 1.35rem; }
}

.token-box { margin-top: 1rem; padding: .75rem; border: 1px solid var(--warn); border-radius: 8px; background: var(--warn-bg); }
.token-box p { margin: .4rem 0; }
code.token {
  display: block; padding: .6rem; margin: .4rem 0; border-radius: 6px; background: var(--panel); color: var(--text);
  font: 600 .95rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; word-break: break-all; user-select: all;
}
.vehicle-row { margin-top: .5rem; }
.vehicle-row input { flex: 1 1 7rem; }
button.link.danger { color: var(--bad); }
.setup-row { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 1rem; align-items: start; }
svg.qr { width: 220px; height: 220px; display: block; border-radius: 6px; }
@media (max-width: 640px) { .setup-row { grid-template-columns: minmax(0, 1fr); } }
