:root {
  --bg: #eef1ec; --card: #fff; --ink: #1c2420; --muted: #66706a; --line: #dde2dc;
  --brand: #214a36; --brand2: #2f6a4d; --accent: #f2c14e; --in: #2f6a4d; --out: #c7782a;
  --danger: #b3261e; --warn: #c7782a; --ok: #1f8a4c; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121614; --card: #1b201d; --ink: #e6ebe7; --muted: #98a39c; --line: #2c3430; --brand: #173527; --in: #4fae7e; --out: #e39a4f; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
h2 { font-size: 15px; margin: 0; letter-spacing: .01em; }
.muted { color: var(--muted); } .small { font-size: 12px; }
button, input, select { font: inherit; color: inherit; }

/* header */
.top { display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--brand); color: #fff; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; line-height: 1.1; }
.brand b { display: block; font-size: 16px; } .brand small { opacity: .75; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; }
.logo { width: 34px; height: 34px; border-radius: 8px; background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M4 23h24v3H4zM9 12h14l3 10H6z' fill='%23214a36'/%3E%3C/svg%3E") center/26px no-repeat; }
.brand.big .logo { width: 46px; height: 46px; background-size: 34px; } .brand.big b { font-size: 22px; color: var(--ink); } .brand.big small { color: var(--muted); }
nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
nav button { background: transparent; border: 0; color: #fff; opacity: .8; padding: 8px 12px; border-radius: 8px; cursor: pointer; }
nav button:hover { background: rgba(255,255,255,.08); opacity: 1; }
nav button.on { background: rgba(255,255,255,.16); opacity: 1; font-weight: 600; }
.pill { background: var(--accent); color: #1c2420; border-radius: 10px; padding: 0 7px; font-size: 12px; font-weight: 700; margin-left: 4px; }
.who { display: flex; gap: 12px; align-items: center; font-size: 13px; }
#clock { font-variant-numeric: tabular-nums; opacity: .85; }
.link { background: none; border: 0; color: #fff; text-decoration: underline; cursor: pointer; opacity: .85; padding: 0; }
.poc { background: var(--accent); color: #1c2420; text-align: center; font-size: 12px; padding: 3px 12px; font-weight: 600; }

main { max-width: 1320px; margin: 0 auto; padding: 16px; }
.view { display: none; } .view.on { display: block; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 960px) { .grid2 { grid-template-columns: 1fr; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0; }
.grid2 > .card { margin-bottom: 0; }
.card-h { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); padding: 8px 14px; border-radius: 8px; cursor: pointer; text-decoration: none; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--brand2); color: #fff; border-color: var(--brand2); }
.btn.primary:hover { background: var(--brand); }
.btn.primary:disabled { background: var(--line); border-color: var(--line); color: var(--muted); cursor: not-allowed; }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.big { padding: 12px 22px; font-size: 16px; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
input, select { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 8px 10px; font-size: 14px; min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--brand2); outline-offset: -1px; }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.span2 { grid-column: span 2; }
@media (max-width: 560px) { .fgrid { grid-template-columns: 1fr; } .span2 { grid-column: auto; } }
.check { flex-direction: row; align-items: center; gap: 8px; margin-top: 10px; font-size: 14px; color: var(--ink); }
.actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.err { color: var(--danger); min-height: 1.2em; margin: 0; }

/* camera */
.cam { border-radius: 8px; overflow: hidden; background: #000; }
.cam svg { display: block; width: 100%; height: auto; }
.live { font-size: 11px; font-weight: 700; color: var(--danger); display: flex; align-items: center; gap: 5px; letter-spacing: .1em; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.anpr { margin-top: 12px; }
.plate-wrap { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.uk-plate { background: #f7c600; color: #111; border: 2px solid #111; border-radius: 6px; font: 700 30px/1 "Arial Narrow", "Roboto Condensed", Arial, sans-serif; letter-spacing: .06em; text-align: center; width: 230px; padding: 8px 6px; text-transform: uppercase; }
.uk-plate::placeholder { color: rgba(0,0,0,.3); }
.conf { flex: 1; min-width: 160px; font-size: 13px; color: var(--muted); }
.conf .bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin-bottom: 4px; }
.conf .bar i { display: block; height: 100%; width: 0; background: var(--ok); transition: width .5s; }
.conf .bar i.low { background: var(--warn); }
.btns { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.suggest { background: #fff4d6; color: #5b4300; border: 1px solid #f2c14e; border-radius: 8px; padding: 8px 10px; margin-top: 8px; font-size: 13px; }
.suggest button { margin-left: 6px; }

/* indicator */
.indicator { background: #0d130f; border-radius: 10px; padding: 14px 18px; border: 3px solid #2c3430; }
.lamps { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.lamp { font: 700 11px/1 ui-monospace, Consolas, monospace; letter-spacing: .08em; color: #3c4a40; border: 1px solid #2c3a30; padding: 4px 7px; border-radius: 4px; }
.lamp.on { color: #0d130f; background: #39ff7a; border-color: #39ff7a; box-shadow: 0 0 10px rgba(57,255,122,.5); }
.lamp.warn.on { background: #ff5a4e; border-color: #ff5a4e; box-shadow: 0 0 10px rgba(255,90,78,.5); }
#lampMotion.on { background: #ffc24e; border-color: #ffc24e; box-shadow: 0 0 10px rgba(255,194,78,.5); }
.readout { text-align: right; font: 700 clamp(44px, 7vw, 76px)/1.05 ui-monospace, "Cascadia Mono", Consolas, monospace; color: #39ff7a; text-shadow: 0 0 14px rgba(57,255,122,.45); font-variant-numeric: tabular-nums; }
.readout small { font-size: 22px; margin-left: 10px; opacity: .7; }
.vehinfo { margin: 12px 0; font-size: 14px; }
.vehinfo b { color: var(--ink); }
.stage { font-weight: 700; padding: 8px 12px; border-radius: 8px; background: var(--bg); margin-bottom: 12px; border-left: 4px solid var(--muted); }
.stage.first { border-color: var(--brand2); } .stage.second { border-color: var(--out); } .stage.single { border-color: #3b6fb6; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 10px; background: var(--bg); color: var(--muted); letter-spacing: .03em; white-space: nowrap; }
.tag.in { background: rgba(47,106,77,.14); color: var(--in); } .tag.out { background: rgba(199,120,42,.15); color: var(--out); }
.tag.open { background: #fff4d6; color: #7a5a00; } .tag.complete { background: rgba(31,138,76,.13); color: var(--ok); } .tag.void { background: rgba(179,38,30,.12); color: var(--danger); }
.tag.over { background: var(--danger); color: #fff; }

/* tables */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); padding: 8px; white-space: nowrap; }
td { border-bottom: 1px solid var(--line); padding: 8px; vertical-align: middle; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--bg); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.plate-sm { background: #f7c600; color: #111; font: 700 13px/1 "Arial Narrow", Arial, sans-serif; padding: 3px 6px; border-radius: 3px; border: 1px solid #111; white-space: nowrap; letter-spacing: .04em; }
.empty { color: var(--muted); padding: 16px 0; text-align: center; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters input[type=search] { min-width: 220px; }

.events { list-style: none; margin: 0; padding: 0; max-height: 330px; overflow: auto; font-size: 13px; }
.events li { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; }
.events time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* reports */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
@media (max-width: 760px) { .kpis { grid-template-columns: 1fr 1fr; } }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.kpi span { font-size: 12px; color: var(--muted); } .kpi b { display: block; font-size: 28px; font-variant-numeric: tabular-nums; }
.legend { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; } .k-in { background: var(--in); } .k-out { background: var(--out); margin-left: 8px; }
#chart svg { width: 100%; height: auto; display: block; }
#chart text { fill: var(--muted); font-size: 11px; }
.about li { margin-bottom: 6px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 28px; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.login-card p { margin: 0; font-size: 14px; }

/* modal & toast */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 32px)); background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(10,15,12,.5); }
.modal-in { padding: 20px; }
.modal-in h3 { margin: 0 0 14px; }
.modal-in .actions { justify-content: flex-end; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(100px); background: #1c2420; color: #fff; padding: 10px 18px; border-radius: 10px; transition: transform .25s; z-index: 50; max-width: calc(100vw - 32px); }
.toast.show { transform: translateX(-50%) translateY(0); } .toast.err { background: var(--danger); }

/* weighbridge ticket */
.wbt { font-family: ui-monospace, Consolas, monospace; font-size: 13px; color: #111; background: #fff; border: 1px dashed #999; padding: 16px; }
.wbt h4 { margin: 0; font-size: 16px; text-align: center; } .wbt .sub { text-align: center; font-size: 11px; margin-bottom: 10px; }
.wbt table { font-size: 13px; } .wbt td { border: 0; padding: 2px 0; } .wbt td:last-child { text-align: right; }
.wbt .net td { font-size: 18px; font-weight: 700; border-top: 2px solid #111; padding-top: 6px; }
.wbt .sig { margin-top: 26px; display: flex; gap: 20px; } .wbt .sig div { flex: 1; border-top: 1px solid #111; padding-top: 4px; font-size: 11px; }
.wbt .voidmark { color: #b3261e; font-weight: 700; text-align: center; font-size: 20px; border: 2px solid #b3261e; margin: 6px 0; }
#printArea { display: none; }
@media print {
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block; } #printArea .wbt { border: 0; max-width: 80mm; margin: 0 auto; }
}
@media (max-width: 640px) {
  .top { padding: 8px 12px; gap: 8px; }
  nav { order: 3; flex-basis: 100%; flex-wrap: nowrap; overflow-x: auto; }
  .who { margin-left: auto; } #clock { display: none; }
  main { padding: 12px; }
}

/* dual LPR cameras */
.reads { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.read { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 13px; min-width: 0; flex-wrap: wrap; }
.read .cam-l { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; flex-basis: 100%; }
.read .rp { background: #f7c600; color: #111; border: 1px solid #111; border-radius: 3px; font: 700 16px/1 "Arial Narrow", Arial, sans-serif; padding: 4px 6px; letter-spacing: .04em; }
.read .rp.none { background: var(--bg); color: var(--muted); border-color: var(--line); font: 600 12px/1 inherit; padding: 5px 6px; }
.read .rc { font-variant-numeric: tabular-nums; color: var(--ok); font-weight: 600; }
.read .rc.low { color: var(--warn); }
.read.first { border-color: var(--brand2); box-shadow: inset 3px 0 0 var(--brand2); }
.match { margin-top: 8px; padding: 8px 10px; border-radius: 8px; font-size: 13px; font-weight: 600; background: var(--bg); color: var(--muted); }
.match.agree { background: rgba(31,138,76,.12); color: var(--ok); }
.match.single { background: #fff4d6; color: #7a5a00; }
.match.disagree { background: rgba(179,38,30,.1); color: var(--danger); }
.match.none { background: rgba(179,38,30,.1); color: var(--danger); }
.match .btn { margin: 6px 6px 0 0; }
.plate-wrap { margin-top: 10px; }
.plate-l { font-size: 11px; }
.anpr-bars { display: flex; height: 22px; border-radius: 6px; overflow: hidden; margin-bottom: 10px; }
.anpr-bars i { display: block; height: 100%; }
.anpr-leg { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; }
.anpr-leg b { font-variant-numeric: tabular-nums; }
.anpr-leg span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; background: var(--c); }
@media (max-width: 420px) { .reads { grid-template-columns: 1fr; } }
.check.auto { margin-top: 0; margin-left: auto; }
