:root {
  --bg: #f6f7f9; --panel: #fff; --text: #1b1f24; --muted: #667085; --line: #e3e6eb; --accent: #0b6bcb; --hover: #f0f4fa;
  --danger: #c0392b; --ok: #1a7f37; --warn: #b54708;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14171b; --panel: #1c2026; --text: #e8eaed; --muted: #98a1ad; --line: #2d333b; --accent: #5aa7ff; --hover: #232a33; --danger: #ff7b6b; --ok: #3fb950; --warn: #f79009; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }
h1, h2 { margin: 0; }
a { color: var(--accent); }

.btn { border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 6px; padding: 7px 14px; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ver { font-size: 12px; font-weight: 400; color: var(--muted); }
.hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.error { min-height: 20px; margin: 12px 0 0; color: var(--danger); }
.muted { color: var(--muted); }

/* sign-in */
#login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 28px 24px; }
.card h1 { font-size: 20px; margin-bottom: 8px; }
.card p { margin: 0 0 18px; color: var(--muted); }
.card label, dialog label { display: block; font-weight: 600; margin-bottom: 6px; }
.card input, dialog input { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); margin-bottom: 14px; }
.card .btn { width: 100%; }

/* header and bars */
header { max-width: 1500px; margin: 0 auto; padding: 18px 16px 6px; display: flex; gap: 10px; align-items: flex-start; }
header > div { flex: 1; }
.title { font-size: 20px; }
.sub { color: var(--muted); font-size: 13px; }
.sub.warn { color: var(--warn); font-weight: 600; }
.sub.bad { color: var(--danger); font-weight: 600; }
.bar { max-width: 1500px; margin: 0 auto; padding: 8px 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.bar label { display: flex; gap: 6px; align-items: center; color: var(--muted); }
.bar input[type=datetime-local], .ctl input[type=datetime-local], select { padding: 7px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 999px; padding: 4px 12px; }
.chip[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: #fff; }
.zone { color: var(--muted); font-size: 12px; }
#notice:not(:empty) { max-width: 1500px; margin: 4px auto; padding: 0 16px; }
.banner { padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); }
.banner.warn { border-color: var(--warn); }
.banner.bad { border-color: var(--danger); color: var(--danger); }

main { max-width: 1500px; margin: 0 auto; padding: 4px 16px 40px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: auto; }
.msg { padding: 36px 16px; text-align: center; color: var(--muted); }
.intro { color: var(--muted); margin: 4px 0 10px; max-width: 80ch; }
.listbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.listbar .count { margin-left: auto; color: var(--muted); }

/* truck table */
table { border-collapse: collapse; width: 100%; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--hover); }
tr:last-child td { border-bottom: 0; }
.linkish { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; background: var(--hover); border: 1px solid var(--line); font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.ok { color: var(--ok); border-color: var(--ok); }
.pill.warn { color: var(--warn); border-color: var(--warn); }
.pill.bad { color: var(--danger); border-color: var(--danger); }
.small { font-size: 12px; color: var(--muted); }
.hint { cursor: help; }

/* truck detail */
.dtop { display: flex; gap: 14px; align-items: flex-start; margin: 6px 0 12px; flex-wrap: wrap; }
.dtop > div { flex: 1; min-width: 240px; }
.dhead h2 { font-size: 20px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.dgrid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 980px) { .dgrid { grid-template-columns: minmax(320px, 440px) minmax(0, 1fr); align-items: start; } }
.col h3 { margin: 0 0 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.mlist { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
@media (min-width: 980px) { .mlist { max-height: calc(100vh - 260px); overflow: auto; } }
.item { display: block; width: 100%; text-align: left; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: inherit; }
.item:last-child { border-bottom: 0; }
.item:hover { background: var(--hover); }
.item.sel { background: var(--hover); box-shadow: inset 3px 0 0 var(--accent); }
.item > span { display: block; }
.item .l1 { display: flex; gap: 8px; justify-content: space-between; font-weight: 600; }
.item .l2 { color: var(--text); overflow-wrap: anywhere; }
.item .l3 { color: var(--muted); font-size: 12px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.filters select { margin-left: auto; }

/* viewer */
.vhead { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; margin-bottom: 12px; }
.vhead p { margin: 4px 0 10px; }
.vhead .sentence { font-size: 15px; font-weight: 600; }
.ctl { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.ctl label { color: var(--muted); }
.shot { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-bottom: 12px; }
.shothead { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; font-weight: 600; }
.pair { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.cam { margin: 0; }
.cam figcaption { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.frame { min-height: 140px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); display: grid; place-items: center; overflow: hidden; }
.frame img { width: 100%; display: block; cursor: zoom-in; }
.state { padding: 14px; text-align: center; color: var(--muted); font-size: 13px; }
.state strong { display: block; color: var(--text); margin-bottom: 4px; }
.state.bad strong { color: var(--danger); }
.state.warn strong { color: var(--warn); }
.state .btn { margin-top: 8px; }
.spin { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -4px; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

/* dialog and lightbox */
dialog { max-width: 440px; width: calc(100% - 32px); background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 22px 22px 18px; }
dialog::backdrop { background: rgba(0, 0, 0, .55); }
dialog h2 { font-size: 18px; margin-bottom: 8px; }
dialog p { color: var(--muted); }
.row { display: flex; gap: 8px; }
#lb { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: rgba(0, 0, 0, .9); }
#lb img { max-width: min(94vw, 1500px); max-height: 82vh; border-radius: 6px; background: #000; }
#lbCap { color: #e8eaed; }
.lb-close { position: absolute; top: 14px; right: 16px; width: 44px; height: 44px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .16); color: #fff; font-size: 26px; line-height: 1; }

@media (max-width: 700px) {
  body { font-size: 15px; }
  .btn { min-height: 40px; }
  input, select { font-size: 16px; } /* stops iOS zooming in on focus */
  header { padding: 12px 12px 4px; flex-wrap: wrap; }
  header > div { flex: 1 1 100%; }
  .bar, #notice:not(:empty), main { padding-left: 12px; padding-right: 12px; }
  .opt { display: none; }
  th, td { padding: 8px 5px; }
  th { font-size: 11px; letter-spacing: 0; white-space: normal; }
  .pill { font-size: 11px; padding: 1px 6px; white-space: normal; }
}

.demo-banner { background: var(--warn); color: #fff; text-align: center; padding: 4px 8px; font-size: 13px; font-weight: 600; position: sticky; top: 0; z-index: 40; }

.minstop { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
