/* Shared by gate.html and fuel.html */
[hidden] { display: none !important; } /* styled elements (button: inline-flex) would otherwise ignore hidden */
:root {
  color-scheme: light dark;
  --bg: #f4f6f8; --surface: #fff; --text: #14171a; --muted: #5b6470; --border: #dde1e6;
  --accent: #0b5cad; --new-bg: #fff4c2; --new-edge: #c98a00;
  --ok: #1a7f37; --warn: #8a5a00; --warn-bg: #fff6d6; --err: #b42318; --err-bg: #fde8e6;
  --avis: #c8102e; --budget: #0b3a82;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1115; --surface: #161a20; --text: #e8ebef; --muted: #9aa4b1; --border: #2a313a;
    --accent: #6cb0ff; --new-bg: #3a3100; --new-edge: #f0c000;
    --ok: #4ac26b; --warn: #e3b341; --warn-bg: #2d2500; --err: #ff8f85; --err-bg: #3a1513;
    --avis: #ff5a6e; --budget: #7aa7ff;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 18px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code { font: 0.9em ui-monospace, Menlo, monospace; background: rgb(127 127 127 / 0.15); padding: 1px 6px; border-radius: 4px; }

header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; margin-bottom: 12px; }
h1 { margin: 0; font-size: 1.6rem; line-height: 1.2; }
.sub { color: var(--muted); font-size: 0.95rem; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.controls label { color: var(--muted); font-size: 0.95rem; display: flex; align-items: center; gap: 8px; }
button, select { font: inherit; font-size: 1rem; min-height: 44px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
button { display: inline-flex; align-items: center; gap: 8px; }
button:hover:not(:disabled), select:hover { border-color: var(--muted); }
button:disabled { opacity: 0.6; cursor: progress; }
button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { button[aria-pressed="true"] { color: #0e1115; } }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.hint { font-size: 0.85rem; color: var(--warn); }

.statusbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 12px; font-size: 0.95rem; }
.pill { display: inline-flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.err { background: var(--err); }
.statusbar .spacer { flex: 1; }
.muted { color: var(--muted); }
.count { font-weight: 600; }

.banner { padding: 12px 14px; border-radius: 10px; margin-bottom: 12px; border-left: 5px solid; }
.banner.err { background: var(--err-bg); border-color: var(--err); }
.banner.warn { background: var(--warn-bg); border-color: var(--warn); }

.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { position: sticky; top: 0; background: var(--surface); text-align: left; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--border); }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
td.time strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
td.time span { display: block; font-size: 0.85rem; color: var(--muted); }
td.name { font-size: 1.2rem; font-weight: 600; }
td.num { font-variant-numeric: tabular-nums; }
tr.new td { background: var(--new-bg); }
tr.new td:first-child { box-shadow: inset 5px 0 var(--new-edge); }
.badge { display: inline-block; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; vertical-align: middle; }
.badge.new { background: var(--new-edge); color: #1a1400; margin-right: 8px; }
.brand { font-weight: 700; }
.brand.avis { color: var(--avis); } .brand.budget { color: var(--budget); }
tr.group th { position: static; padding: 18px 14px 8px; border-top: 6px solid var(--bg); }
td.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
@media (prefers-reduced-motion: no-preference) {
  tr.arrived td { animation: flash 1.2s ease-out 3; }
  @keyframes flash { 50% { background: var(--new-edge); } }
}
@media (max-width: 640px) { .hide-sm { display: none; } td, th { padding: 10px; } }

/* Page switcher */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tabs a { padding: 10px 14px; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }

/* Fuel sheets */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 12px; }
.card h2 { margin: 0 0 12px; font-size: 1.1rem; }
.fields { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .field > label, legend { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
input { font: inherit; font-size: 1rem; min-height: 44px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
input:hover { border-color: var(--muted); }
input[aria-invalid="true"] { border-color: var(--err); background: var(--err-bg); }
fieldset { border: 0; padding: 0; margin: 0; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-top: 6px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; min-height: 0; }
.seg span { display: block; min-height: 44px; line-height: 44px; padding: 0 16px; cursor: pointer; border-left: 1px solid var(--border); }
.seg label:first-child span { border-left: 0; }
.seg input:checked + span { background: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .seg input:checked + span { color: #0e1115; } }
.seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: -3px; }
.veh-head, .veh-row { display: grid; grid-template-columns: 2.5rem minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 0.8fr) 44px; gap: 8px; align-items: center; }
.veh-head { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 0 0 6px; }
.veh-row { margin-bottom: 8px; }
.veh-row .n { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.veh-row input { width: 100%; font-variant-numeric: tabular-nums; }
.veh-row .rego { text-transform: uppercase; }
.icon-btn { padding: 0; justify-content: center; width: 44px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { button.primary { color: #0e1115; } }
.help { font-size: 0.85rem; color: var(--muted); margin: 8px 0 0; }
.ra { font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.small { display: block; font-size: 0.85rem; color: var(--muted); }
.badge.matched { background: var(--ok); color: #fff; }
.badge.guessed { background: var(--warn); color: #fff; }
.badge.review, .badge.error { background: var(--err); color: #fff; }
@media (prefers-color-scheme: dark) { .badge.matched, .badge.guessed, .badge.review, .badge.error { color: #0e1115; } }
tr.pending td { color: var(--muted); }
.summary { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
@media (max-width: 640px) {
  .card { padding: 12px; }
  /* Too narrow for four columns: MVA on its own line, rego + KM under it */
  .veh-head { display: none; }
  .veh-row { grid-template-columns: 1.25rem minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 0.8fr) 40px; grid-template-areas: "n mva mva mva x" "n rego km litres x"; gap: 6px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
  .veh-row .n { grid-area: n; } .veh-row .mva { grid-area: mva; } .veh-row .rego { grid-area: rego; } .veh-row .km-box { grid-area: km; } .veh-row .litres-box { grid-area: litres; } .veh-row .remove { grid-area: x; }
  .veh-row input { padding: 0 8px; }
  .icon-btn { width: 40px; }
}
@media print {
  .tabs, .no-print, .actions { display: none !important; }
  body { background: #fff; color: #000; font-size: 12px; }
  .card, .table-wrap { border: 0; padding: 0; }
  th { position: static; }
}

/* Photo reader */
.photo-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 20px; }
.veh-row input.unsure { border-color: var(--warn); background: var(--warn-bg); box-shadow: inset 0 0 0 1px var(--warn); }

/* Phone access */
.phone-grid { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
#phoneQr { width: 200px; flex: none; background: #fff; padding: 8px; border-radius: 8px; } /* QR needs a light background to scan, even in dark mode */
#phoneQr svg { display: block; width: 100%; height: auto; }
#phonePanel p { margin: 0 0 8px; }
#phoneLink { word-break: break-all; }


/* Litres by brand */
.litres-table { width: auto; min-width: min(100%, 28rem); margin: 0 0 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; border-collapse: separate; border-spacing: 0; overflow: hidden; }
.litres-table caption { text-align: left; font-weight: 700; padding: 0 0 6px; }
.litres-table th, .litres-table td { padding: 8px 14px; border-bottom: 1px solid var(--border); text-align: right; position: static; }
.litres-table th[scope="row"], .litres-table thead th:first-child { text-align: left; }
.litres-table tbody tr:last-child th, .litres-table tbody tr:last-child td { border-bottom: 0; }
.actions .spacer { flex: 1; }
.litres-table th[scope="row"] { text-transform: none; letter-spacing: 0; font-size: 0.95rem; color: var(--text); font-weight: 400; }
.litres-table tbody tr:last-child th[scope="row"] { font-weight: 700; }
.badge.info { background: var(--muted); color: #fff; }
@media (prefers-color-scheme: dark) { .badge.info { color: #0e1115; } }

/* Find similar */
button.similar { margin-top: 6px; }
.similar-row td { padding-top: 0; }
.similar-panel { border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 10px; padding: 12px 14px; background: var(--bg); }
.similar-panel h3 { margin: 0 0 8px; font-size: 1rem; }
.suggestions { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr)); gap: 10px; }
.suggestions li { border: 1px solid var(--border); border-radius: 8px; padding: 10px; background: var(--surface); display: flex; flex-direction: column; gap: 8px; }
.suggestions p { margin: 0; }
.suggestions button.use { align-self: flex-start; }
/* Sheet vs candidate, side by side; differing characters are marked */
.cmp { display: grid; grid-template-columns: repeat(4, auto); justify-content: start; gap: 4px 14px; align-items: baseline; }
@media (max-width: 520px) { .cmp { gap: 4px 8px; font-size: 0.9rem; } }
.cmp .h { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.cmp mark { background: var(--warn-bg); color: var(--warn); font-weight: 700; border-radius: 3px; outline: 1px solid var(--warn); }

/* Tips fold away so the form stays short, especially on phones */
.tips { margin: 8px 0 0; }
.tips summary { cursor: pointer; color: var(--accent); font-weight: 600; min-height: 44px; display: flex; align-items: center; }

/* Phones (portrait and landscape): each result becomes a labelled card instead of a 7-column table */
@media (max-width: 900px) {
  .results .table-wrap { overflow: visible; }
  .results .table-wrap table, .results .table-wrap tbody { display: block; }
  .results .table-wrap thead { display: none; }
  .results .table-wrap tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 14px; padding: 14px; border-bottom: 1px solid var(--border);
    grid-template-areas: "mva ra status" "fuel rafuel rafuel"; }
  .results .table-wrap tr.details, .results .table-wrap tr.similar-row, .results .table-wrap tr.group { display: block; padding: 0 14px 14px; }
  .results .table-wrap tr.group { padding: 14px; }
  .results .table-wrap tr.details { margin-top: -6px; }
  .results .table-wrap tr:last-child { border-bottom: 0; }
  .results .table-wrap td { display: block; padding: 0; border: 0; min-width: 0; }
  .results .table-wrap td:empty { display: none; }
  .results .table-wrap td[data-label]::before { content: attr(data-label); display: block; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
  .results .c-mva { grid-area: mva; } .results .c-ra { grid-area: ra; } .results .c-fuel { grid-area: fuel; }
  .results .c-rafuel { grid-area: rafuel; }
  .results .c-status { grid-area: status; text-align: right; }
  .results .c-status .small { text-align: right; }
  .results .c-status button { margin-left: auto; }
}
/* Narrow portrait: one column for the wordy cells */
@media (max-width: 520px) {
  .results .table-wrap tr { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "mva status" "ra fuel" "rafuel rafuel"; }
}

/* Gate screen on a narrow phone: tighter cells so all columns fit without scrolling sideways */
@media (max-width: 520px) {
  .wrap > .table-wrap th, .wrap > .table-wrap td { padding: 8px 5px; }
  .wrap > .table-wrap td.num { font-size: 0.95rem; }
  .wrap > .table-wrap td.time strong { font-size: 1.05rem; }
  .wrap > .table-wrap td.name { font-size: 1rem; }
  .wrap > .table-wrap .badge.new { margin-right: 4px; }
}
@media (max-width: 400px) {
  .wrap { padding: 12px; }
  .wrap > .table-wrap th, .wrap > .table-wrap td { padding: 8px 4px; }
}

/* Litres by brand: colours from the fuel sheet's boxes. The heading words still say which is which. */
.litres-table .lit-avis { color: var(--avis); border-top: 4px solid var(--avis); }
.litres-table .lit-budget { color: var(--budget); border-top: 4px solid var(--budget); }
.litres-table .lit-vtc { color: var(--ok); border-top: 4px solid var(--ok); }
.litres-table .lit-none { color: var(--warn); border-top: 4px solid var(--warn); background: var(--warn-bg); }
.litres-table td.lit-avis, .litres-table td.lit-budget, .litres-table td.lit-vtc, .litres-table td.lit-none { border-top: 0; font-weight: 700; }
.litres-table thead th { font-weight: 700; }
/* Phones: the litres table scrolls on its own if a batch has many sheets, rather than squashing */
#litresByBrand { overflow-x: auto; }
@media (max-width: 520px) { .litres-table th, .litres-table td { padding: 8px 10px; } }
.litres-table td.num { white-space: nowrap; } /* never split "37.53 L" over two lines */
/* Narrow phones: each figure becomes a labelled tile (two per line), coloured down its left edge */
@media (max-width: 520px) {
  #litresByBrand .litres-table { width: 100%; min-width: 0; }
  #litresByBrand .litres-table, #litresByBrand .litres-table tbody { display: block; }
  #litresByBrand .litres-table thead { display: none; }
  #litresByBrand .litres-table caption { display: block; padding: 10px 10px 0; }
  #litresByBrand .litres-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px; border-bottom: 1px solid var(--border); }
  #litresByBrand .litres-table tbody tr:last-child { border-bottom: 0; }
  #litresByBrand .litres-table th[scope="row"] { grid-column: 1 / -1; padding: 0; border: 0; }
  #litresByBrand .litres-table td { display: block; text-align: left; border: 0; border-left: 4px solid var(--border); border-radius: 4px; padding: 6px 10px; font-size: 1.1rem; }
  #litresByBrand .litres-table td::before { content: attr(data-label); display: block; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
  #litresByBrand .litres-table td.lit-avis { border-left-color: var(--avis); }
  #litresByBrand .litres-table td.lit-budget { border-left-color: var(--budget); }
  #litresByBrand .litres-table td.lit-vtc { border-left-color: var(--ok); }
  #litresByBrand .litres-table td.lit-none { border-left-color: var(--warn); }
  #litresByBrand .litres-table td.lit-total { border-left-color: var(--text); }
}

/* Live sync indicator under the page title */
.live { font-size: 0.85rem; font-weight: 600; color: var(--ok); margin-top: 4px; min-height: 1.2em; }
.live.off { color: var(--muted); }

/* Scan messages: one line per outcome */
.scan-status { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.scan-status:empty { display: none; }
.scan-status li { font-size: 0.95rem; padding: 4px 0 4px 10px; border-left: 4px solid var(--border); }
.scan-status li.ok { border-color: var(--ok); }
.scan-status li.warn { border-color: var(--warn); background: var(--warn-bg); }
.scan-status li.err { border-color: var(--err); background: var(--err-bg); }
.scan-status li.busy { color: var(--muted); }
.scan-status button { margin-left: 8px; }

/* Vehicles heading with the ⋯ menu (New sheet lives there, away from Look up) */
.veh-title { display: flex; align-items: center; justify-content: space-between; margin-top: 20px; }
.veh-title h2 { margin: 0; }
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; border-radius: 8px; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary:hover, .menu[open] summary { background: var(--border); }
.menu > div { position: absolute; right: 0; top: 100%; z-index: 5; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 6px; box-shadow: 0 6px 20px rgb(0 0 0 / 0.15); white-space: nowrap; }

/* Unit inside the KM and litres boxes on phones, where the column headings are hidden */
.unit { position: relative; display: block; min-width: 0; }
.unit::after { content: attr(data-unit); position: absolute; right: 6px; top: 3px; font-size: 0.65rem; line-height: 1; color: var(--muted); pointer-events: none; display: none; }
@media (max-width: 640px) { .unit::after { display: block; } } /* top corner: leaves the whole box for a 6-digit KM */

/* Undo message */
.toast { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 10; display: flex; align-items: center; gap: 12px; max-width: calc(100% - 32px);
  background: var(--text); color: var(--surface); padding: 8px 8px 8px 16px; border-radius: 10px; box-shadow: 0 6px 20px rgb(0 0 0 / 0.25); }
.toast button { background: transparent; color: inherit; border-color: currentColor; font-weight: 700; }

/* "To fix in WAND": strong, but not the red used for Avis and errors */
.badge.fix { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }

/* Result tiles: tap one to show only those rows */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr)); gap: 8px; margin-bottom: 10px; }
.tile { display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 2px; height: auto; min-height: 64px; padding: 10px 12px; text-align: left; border-radius: 10px; }
.tile-n { font-size: 1.5rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile-l { font-size: 0.85rem; font-weight: 600; }
.tile-s { font-size: 0.75rem; color: var(--muted); }
.tile[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 2px var(--text); }
.tile[aria-pressed="true"] .tile-s { color: var(--muted); }
.t-matched .tile-n { color: var(--ok); } .t-guessed .tile-n { color: var(--warn); } .t-review .tile-n, .t-error .tile-n { color: var(--err); }
.tile.t-fix { border: 2px solid var(--accent); } .t-fix .tile-n { color: var(--accent); }
.tile.t-fix.done { border-color: var(--ok); } .t-fix.done .tile-n { color: var(--ok); }
@media (max-width: 520px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } .tile.t-fix { grid-column: 1 / -1; } }

/* To fix in WAND: the amount first */
.fix-amount { display: block; font-size: 1.35rem; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.fixed-btn { margin-top: 6px; }
.fixed-btn[aria-pressed="true"] { background: var(--ok); border-color: var(--ok); color: #fff; }
@media (prefers-color-scheme: dark) { .fixed-btn[aria-pressed="true"] { color: #0e1115; } }
tr.is-fixed .fix-amount { color: var(--muted); text-decoration: line-through; }

/* Slimmer result rows: warnings stay, the rest is behind Details */
.warn-note { color: var(--warn); }
button.link { background: none; border: 0; color: var(--accent); font-weight: 600; padding: 0 2px; text-decoration: underline; text-underline-offset: 3px; }
.c-status button { display: block; margin-top: 6px; }
tr.details td { padding-top: 0; }
tr.details dl { margin: 0; display: flex; flex-wrap: wrap; gap: 8px 28px; padding: 10px 12px; background: var(--bg); border-radius: 8px; font-size: 0.9rem; }
tr.details dt { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
tr.details dd { margin: 0; }
.results tr.group th { text-align: left; text-transform: none; letter-spacing: 0; font-size: 0.95rem; color: var(--text); }

/* Login expired pop-up (login.js) */
.login-dlg { border: 1px solid var(--border); border-radius: 14px; padding: 20px 22px; max-width: min(28rem, calc(100% - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 12px 40px rgb(0 0 0 / 0.3); }
.login-dlg::backdrop { background: rgb(0 0 0 / 0.45); }
.login-dlg h2 { margin: 0 0 8px; }
.login-dlg p { margin: 0 0 8px; }

/* Steps along the top: 1 Scan · 2 Check · 3 Fix in WAND */
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.steps a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px 0 8px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-weight: 700; text-decoration: none; }
.step-n { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--border); color: var(--text); font-size: 0.9rem; }
.steps a[aria-current="step"] { color: var(--text); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.steps a[aria-current="step"] .step-n { background: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .steps a[aria-current="step"] .step-n { color: #0e1115; } }
.steps li.done a { color: var(--text); }
.steps li.done .step-n { background: var(--ok); color: #fff; font-size: 0; }
.steps li.done .step-n::after { content: "✓"; font-size: 0.95rem; }
@media (prefers-color-scheme: dark) { .steps li.done .step-n { color: #0e1115; } }
@media (max-width: 520px) { .steps a { padding: 0 10px 0 6px; gap: 6px; font-size: 0.9rem; } .step-n { width: 24px; height: 24px; } }

/* Settings */
.tag { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 6px; border-radius: 999px; background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn); }
#settings h3 { font-size: 1rem; margin: 16px 0 8px; }
#settings h3:first-of-type { margin-top: 0; }
#phonePanel { margin-top: 12px; }

/* Sheet cards: one per paper sheet */
.sheet-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 12px; background: var(--bg); }
.sheet-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.sheet-title { margin: 0 auto 0 0; font-size: 1.05rem; }
.sheet-fields { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 10px 12px; }
.sheet-head .s-pump, .sheet-head .s-pageno { width: 5rem; }
.sheet-head select.unsure, .sheet-head input.unsure { border-color: var(--warn); background: var(--warn-bg); box-shadow: inset 0 0 0 1px var(--warn); }
.sheet-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 4px; }
.sheet-litres { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-variant-numeric: tabular-nums; }
.lit-chip { font-weight: 700; padding-left: 8px; border-left: 4px solid; }
.lit-chip.lit-avis { color: var(--avis); } .lit-chip.lit-budget { color: var(--budget); } .lit-chip.lit-vtc { color: var(--ok); } .lit-chip.lit-none { color: var(--warn); }
@media (max-width: 640px) {
  .sheet-card { padding: 10px; }
  .sheet-head .field { flex: 1 1 8rem; }
  .sheet-head .field:has(.s-pump), .sheet-head .field:has(.s-pageno) { flex: 1 1 4rem; }
  .sheet-head .s-date, .sheet-head select, .sheet-head .s-pump, .sheet-head .s-pageno { width: 100%; }
}

/* The scanned page beside the cards on wide screens */
.sheets-layout { display: block; }
.with-photo .sheets-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 42%); gap: 16px; align-items: start; }
.photo-panel { position: sticky; top: 12px; display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 24px); }
.photo-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.photo-tabs button[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .photo-tabs button[aria-selected="true"] { color: #0e1115; } }
.photo-view { overflow: auto; border: 1px solid var(--border); border-radius: 8px; background: #fff; cursor: zoom-in; min-height: 0; flex: 1; }
.photo-view img { display: block; width: 100%; height: auto; }
.photo-view.zoomed { cursor: zoom-out; }
.photo-view.zoomed img { width: 220%; max-width: none; }
@media (max-width: 900px) { .with-photo .sheets-layout { display: block; } #photoPanel { display: none !important; } }
/* Phones: one page full screen */
.page-dlg { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: var(--surface); color: var(--text); }
.page-dlg[open] { display: flex; flex-direction: column; }
.page-dlg-bar { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.page-dlg-bar button { margin-left: auto; }
.page-dlg .photo-view { border: 0; border-radius: 0; }

/* Results: the paper row number in front of each car */
.rowno { display: inline-grid; place-items: center; min-width: 1.6em; height: 1.6em; margin-right: 8px; padding: 0 4px; border-radius: 6px; background: var(--border); color: var(--text); font-size: 0.8rem; font-weight: 700; vertical-align: 2px; }

/* Phones: the current step's button stays at the bottom of the screen */
.action-bar { display: none; }
@media (max-width: 640px) {
  .action-bar:not([hidden]) { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 8; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgb(0 0 0 / 0.12); }
  .action-bar button { flex: 1; justify-content: center; min-height: 48px; font-size: 1.05rem; }
  .wrap { padding-bottom: 96px; }
  .toast { bottom: 90px; }
}

/* ---- Gate screen ---- */
/* Monitoring on/off switch */
.switch { gap: 10px; }
.switch[aria-checked] { background: var(--surface); color: var(--text); border-color: var(--border); }
.switch-track { position: relative; width: 40px; height: 24px; border-radius: 999px; background: var(--border); transition: background 0.15s; flex: none; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 0.3); transition: transform 0.15s; }
.switch[aria-checked="true"] .switch-track { background: var(--ok); }
.switch[aria-checked="true"] .switch-track::after { transform: translateX(16px); }

/* The car as the gate sees it: rego like a number plate, then colour and model */
.plate { display: inline-block; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 800; font-size: 1.25rem; letter-spacing: 0.08em; padding: 2px 10px; border: 2px solid #14171a; border-radius: 6px; background: #fff; color: #14171a; }
.plate.unknown { font-size: 0.95rem; letter-spacing: 0; border-style: dashed; color: #5b6470; border-color: #5b6470; }
td.car .small { margin-top: 4px; }
td.name .small { font-weight: 400; }
/* The queue: cars still on their way to the gate are large */
tr.coming td.time strong { font-size: 1.5rem; }
tr.coming td.name { font-size: 1.35rem; }
tr.coming .plate { font-size: 1.5rem; }
tr.gone td { opacity: 0.55; }
.left-btn[aria-pressed="true"] { background: var(--ok); border-color: var(--ok); color: #fff; }
@media (prefers-color-scheme: dark) { .left-btn[aria-pressed="true"] { color: #0e1115; } }
td.left-cell { text-align: right; width: 1%; white-space: nowrap; }
.gate tr.group th button { margin-left: 8px; min-height: 32px; text-transform: none; letter-spacing: 0; font-size: 0.95rem; }
.search { display: block; margin: 0 0 12px; }
.sm-only { display: none; }
@media (max-width: 640px) { .sm-only { display: inline; } }
.search input { width: 100%; max-width: 28rem; }
/* Nothing new for 5 minutes: impossible to miss */
.stale-bar { margin: 0 0 12px; padding: 14px 16px; border-radius: 10px; background: var(--err); color: #fff; font-size: 1.2rem; font-weight: 800; text-align: center; }
@media (prefers-color-scheme: dark) { .stale-bar { color: #0e1115; } }
/* Kiosk (full screen at the booth): bigger everything, only the list and its status */
.kiosk .tabs, .kiosk #settings, .kiosk .search, .kiosk #settingsBtn, .kiosk #refresh, .kiosk #gateToggle, .kiosk .sub { display: none; }
.kiosk .wrap { max-width: none; }
.kiosk { font-size: 1.25rem; }
.kiosk td.time strong { font-size: 1.6rem; }
.kiosk td.name { font-size: 1.5rem; }
.kiosk tr.coming td.name { font-size: 1.9rem; }
.kiosk tr.coming .plate, .kiosk tr.coming td.time strong { font-size: 2.1rem; }
@media (max-width: 640px) {
  .gate .brand-cell { display: none; } /* phones: the brand moves under the name */
  .plate { font-size: 1rem; padding: 1px 6px; letter-spacing: 0.04em; }
  tr.coming .plate { font-size: 1.1rem; }
  .gate thead th:last-child { width: 1%; }
  .left-btn { padding: 0 10px; }
}

/* Sortable result columns */
th[data-sort] { padding-top: 4px; padding-bottom: 4px; }
button.sort { min-height: 40px; padding: 0 4px; margin-left: -4px; border: 0; background: none; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; gap: 6px; }
button.sort:hover { color: var(--text); }
th[aria-sort="ascending"], th[aria-sort="descending"] { color: var(--text); }
th[aria-sort="none"] .arrow { opacity: 0.45; }
.sort-sel { display: none; }
@media (max-width: 900px) { .sort-sel { display: inline-block; } } /* phones show cards without column headings */
@media print { .arrow { display: none; } }

/* Horn alerts */
.horn-main { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.horn-btn { min-height: 56px; font-size: 1.15rem; padding: 0 22px; }
.horn-btn[aria-pressed="true"] { background: var(--surface); color: var(--text); border-color: var(--border); }
.horn-state { font-size: 1.2rem; font-weight: 700; color: var(--muted); }
.horn-state.on { color: var(--ok); }
.meter { position: relative; height: 18px; margin-top: 16px; border-radius: 999px; background: var(--border); overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: var(--muted); transition: width 0.1s linear; }
.meter-fill.hot { background: var(--err); }
.meter-mark { position: absolute; top: 0; bottom: 0; width: 3px; background: var(--text); }
.horn-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.field.check { flex-direction: row; align-items: center; min-height: 44px; }
.field.check input { min-height: 0; width: 20px; height: 20px; }
input[type="range"] { min-height: 44px; padding: 0; width: 12rem; }

/* Pump readings on each sheet card (the paper's bottom-left box) */
.pump-readings { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.pr-title { font-weight: 700; align-self: center; }
.pump-readings input { width: 9rem; font-variant-numeric: tabular-nums; }
.pump-readings input.unsure { border-color: var(--warn); background: var(--warn-bg); box-shadow: inset 0 0 0 1px var(--warn); }
.pr-result { align-self: center; flex: 1 1 16rem; font-variant-numeric: tabular-nums; }
.pr-result.ok { color: var(--ok); }
.pr-result.warn { color: var(--warn); font-weight: 600; }
.pump-readings .calc-it { align-self: center; }
@media (max-width: 640px) { .pr-title { flex-basis: 100%; } .pump-readings .field { flex: 1 1 7rem; } .pump-readings input { width: 100%; } }

/* Calculator */
.calc-grid { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-start; }
.calc-screen { flex: 1 1 16rem; display: flex; flex-direction: column; gap: 6px; }
.calc-screen input { width: 100%; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
#calcOut { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; min-height: 2rem; }
.calc-keys { display: grid; grid-template-columns: repeat(4, 56px); gap: 6px; }
.calc-keys button { justify-content: center; padding: 0; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.calc-keys .calc-wide { grid-column: span 2; }

/* A sheet date far from today: almost always misread or mistyped */
.date-warn { flex-basis: 100%; margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); font-weight: 600; border-left: 4px solid var(--warn); }

/* Flight alerts */
.banner.ok { background: color-mix(in srgb, var(--ok) 14%, var(--surface)); border-color: var(--ok); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.tabs .tab-badge { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; background: var(--ok); color: #fff; }
@media (prefers-color-scheme: dark) { .tabs .tab-badge { color: #0e1115; } }
.badge.muted { background: var(--border); color: var(--text); }
.flight-note-field { flex: 1 1 14rem; }
.flight-note-field input { width: 100%; }
#addForm .fields { align-items: flex-end; }
#addForm #flightInput { width: 9.5rem; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.flights-table td.f-code strong { font-size: 1.2rem; font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.04em; }
.flights-table td.f-act { text-align: right; width: 1%; }
tr.flight-landed td { background: color-mix(in srgb, var(--ok) 10%, var(--surface)); }
tr.flight-landed td:first-child { box-shadow: inset 5px 0 var(--ok); }
@media (max-width: 640px) {
  #addForm #flightInput { width: 100%; }
  #addForm .field { flex: 1 1 100%; }
  .flights .flights-table, .flights .flights-table tbody { display: block; }
  .flights .flights-table thead { display: none; }
  .flights .flights-table tr { display: grid; grid-template-columns: 1fr auto 44px; grid-template-areas: "code status act" "detail detail detail" "note note note"; gap: 4px 10px; padding: 12px; border-bottom: 1px solid var(--border); align-items: center; }
  .flights .flights-table tr:last-child { border-bottom: 0; }
  .flights .flights-table td { display: block; padding: 0; border: 0; }
  .flights .flights-table td.f-code { grid-area: code; }
  .flights .flights-table td.f-status { grid-area: status; }
  .flights .flights-table td.f-act { grid-area: act; width: auto; }
  .flights .flights-table td.f-detail { grid-area: detail; font-size: 0.95rem; }
  .flights .flights-table td.f-note { grid-area: note; font-size: 0.9rem; color: var(--muted); }
  .flights .flights-table td.empty { grid-column: 1 / -1; padding: 32px 12px; }
}
