:root {
  --bg: #f3f4f0;
  --panel: #ffffff;
  --ink: #16201e;
  --muted: #5a6764;
  --line: #dde1dc;
  --line-soft: #ebeeea;
  --accent: #0e5a4b;
  --accent-ink: #ffffff;
  --accent-soft: #e2f0ec;
  --ok: #17693f;       --ok-bg: #e2f3e8;
  --diff: #8f4e00;     --diff-bg: #fdefd6;
  --ask: #40399f;      --ask-bg: #eae9fb;
  --bad: #a3231c;      --bad-bg: #fbe5e3;
  --idle: #45525a;     --idle-bg: #e7ebed;
  --qb: #1f6f2b;       --ac: #1b4f8f;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(22, 32, 30, .06), 0 4px 14px rgba(22, 32, 30, .05);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 6px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 22px 0 10px; }
p { margin: 0 0 12px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { max-width: 1440px; margin: 0 auto; padding: 0 20px; }
main.wrap { padding-top: 26px; padding-bottom: 60px; }
:focus-visible { outline: 3px solid #1d7a66; outline-offset: 2px; border-radius: 4px; }

/* top bar */
.top { background: var(--panel); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; gap: 24px; min-height: 58px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: var(--ink); text-decoration: none; letter-spacing: -.01em; }
.brand-lg { font-size: 19px; margin-bottom: 18px; }
.brand-mark { display: inline-grid; grid-template-columns: 9px 9px; gap: 3px; align-items: end; height: 20px; }
.brand-mark i { display: block; background: var(--accent); border-radius: 2px; height: 20px; }
.brand-mark i + i { height: 13px; background: #d08a1c; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { padding: 8px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 600; }
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.who { display: flex; align-items: center; gap: 10px; color: var(--muted); margin: 0; }

/* buttons + fields */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 7px 14px;
  border: 1px solid #c5ccc7; border-radius: 8px; background: var(--panel); color: var(--ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #97a29c; background: #fafbf9; }
.btn-main { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-main:hover { background: #0a4a3d; border-color: #0a4a3d; }
.btn-quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn-quiet:hover { background: var(--bg); border-color: transparent; color: var(--ink); }
.btn-sm { min-height: 30px; padding: 3px 10px; font-size: 13px; }
.btn-lg { min-height: 46px; padding: 10px 22px; font-size: 16px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
input[type=text], input[type=password], input[type=search], input:not([type]) {
  width: 100%; min-height: 40px; padding: 8px 11px; border: 1px solid #c5ccc7; border-radius: 8px;
  background: #fff; color: var(--ink); font: inherit;
}
.stack { display: grid; gap: 14px; }
.stack label { display: grid; gap: 5px; font-weight: 600; }
.stack .btn { justify-self: start; }

/* panels */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); margin-top: 22px; }
.card.narrow, .card.auth { max-width: 420px; margin: 8vh auto 0; }
.intro { margin-bottom: 20px; max-width: 760px; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 22px; }
.two .card { margin-top: 0; }
.flash { padding: 11px 14px; border-radius: 8px; margin: 0 0 18px; border: 1px solid; font-weight: 600; }
.flash-ok { background: var(--ok-bg); border-color: #b5dcc4; color: var(--ok); }
.flash-err { background: var(--bad-bg); border-color: #efbcb7; color: var(--bad); }

/* upload */
.upload { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.drop {
  position: relative; display: grid; gap: 4px; align-content: start; padding: 22px; min-height: 190px;
  background: var(--panel); border: 2px dashed #bcc5bf; border-radius: var(--radius); cursor: pointer;
}
.drop:hover, .drop.over { border-color: var(--accent); background: #fbfdfc; }
.drop.has { border-style: solid; border-color: var(--accent); }
.drop-err { border-color: var(--bad); }
.drop input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.drop:focus-within { outline: 3px solid #1d7a66; outline-offset: 2px; }
.drop-tag { justify-self: start; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; color: #fff; }
.tag-qb { background: var(--qb); }
.tag-ac { background: var(--ac); }
.drop-title { font-size: 19px; font-weight: 700; margin-top: 8px; }
.drop-hint { color: var(--muted); }
.drop-file { margin-top: 14px; padding: 9px 12px; border-radius: 8px; background: var(--bg); font-weight: 600; overflow-wrap: anywhere; }
.drop.has .drop-file { background: var(--accent-soft); color: var(--accent); }
.drop-error { color: var(--bad); font-weight: 600; margin-top: 6px; }
.upload-go { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

/* tables */
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
.plain th, .plain td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.plain th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.plain tr:last-child td { border-bottom: 0; }
.plain form { margin: 0; }
td.end { text-align: right; }

/* results header */
.run-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.run-head p { margin: 0; }
.run-actions { display: flex; gap: 10px; }
.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }
.check { display: flex; gap: 12px; padding: 12px 14px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); }
.check div { display: grid; }
.check span { color: var(--muted); }
.check-icon { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff !important; background: var(--ok); margin-top: 2px; }
.check-bad { border-color: #efbcb7; background: var(--bad-bg); }
.check-bad .check-icon { background: var(--bad); }
.check-note .check-icon { background: var(--idle); }
.skipped { margin-top: 10px; color: var(--muted); }
.skipped summary { cursor: pointer; font-weight: 600; }
.compare { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 20px 0 14px; font-weight: 600; }
.compare .muted { font-weight: 400; }
.seg { display: inline-flex; border: 1px solid #c5ccc7; border-radius: 9px; overflow: hidden; background: var(--panel); }
.seg a { padding: 7px 14px; text-decoration: none; color: var(--muted); font-weight: 600; }
.seg a + a { border-left: 1px solid #c5ccc7; }
.seg a.on { background: var(--accent); color: #fff; }
.attention { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 14px 16px; margin-bottom: 14px; border-radius: var(--radius); background: var(--ask-bg); border: 1px solid #cbc8f2; color: #2c2675; }

/* filter tabs */
.tabs { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.tab {
  display: grid; gap: 2px; text-align: left; padding: 11px 14px; border-radius: var(--radius); border: 1px solid var(--line);
  border-left: 5px solid #9aa5a0; background: var(--panel); color: var(--ink); font: inherit; cursor: pointer;
}
.tab span { font-size: 13px; font-weight: 600; color: var(--muted); }
.tab b { font-size: 24px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.tab:hover { border-color: #97a29c; }
.tab.on { box-shadow: inset 0 0 0 2px var(--ink); border-color: var(--ink); }
.t-matched { border-left-color: var(--ok); }
.t-different { border-left-color: #d08a1c; }
.t-confirm { border-left-color: #5b53d1; }
.t-missing { border-left-color: var(--bad); }
.t-aconly { border-left-color: var(--idle); }
.tools { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 14px 0 10px; }
.search { flex: 0 1 320px; }
.check-box { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check-box input { width: 17px; height: 17px; accent-color: var(--accent); }
.count { margin-left: auto; }

/* results table */
.results-scroll { max-height: 72vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.results { font-size: 14px; min-width: 1080px; }
.results thead th { position: sticky; top: 0; z-index: 2; background: #f7f8f5; border-bottom: 1px solid var(--line); padding: 0; text-align: left; white-space: nowrap; }
.results thead button { width: 100%; padding: 10px 12px; border: 0; background: none; font: inherit; font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); cursor: pointer; text-align: inherit; }
.results thead th.amt button { text-align: right; }
.results thead th.used button { color: var(--ink); }
.results thead th.sorted button::after { content: " \25B2"; font-size: 9px; }
.results thead th.sorted.desc button::after { content: " \25BC"; }
.results td { padding: 8px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.results tbody tr:hover td { background: #fafbf8; }
.results tbody tr:target td { background: #fff8dc; }
.results tbody tr { scroll-margin-top: 60px; }
.results tr.zero { display: none; }
.results.show-zero tr.zero { display: table-row; }
.results tr[hidden] { display: none !important; }
.cs { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.nm { min-width: 190px; }
.amt { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.amt.used { font-weight: 700; }
td.amt.dim { color: #7b8784; }
.tentative { color: #7b8784; font-style: italic; }
.none { color: #8a9592; font-style: italic; }
td.diff.has { color: var(--diff); font-weight: 700; }
tr.st-matched td.diff { color: var(--ok); }
.mark { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 999px; font-size: 11.5px; font-style: normal; font-weight: 700; background: var(--accent-soft); color: var(--accent); vertical-align: 1px; }
.mark-q { background: var(--ask-bg); color: var(--ask); }
.stat { min-width: 170px; max-width: 320px; }
.issue { display: block; margin-top: 4px; font-size: 13px; color: var(--muted); }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.chip-matched { background: var(--ok-bg); color: var(--ok); }
.chip-different { background: var(--diff-bg); color: var(--diff); }
.chip-confirm { background: var(--ask-bg); color: var(--ask); }
.chip-missing { background: var(--bad-bg); color: var(--bad); }
.chip-aconly { background: var(--idle-bg); color: var(--idle); }
.act { white-space: nowrap; text-align: right; }
.act form.inline { display: inline; margin: 0; }
.empty { padding: 28px; text-align: center; color: var(--muted); margin: 0; }

.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; margin-top: 16px; }
.totals div { display: grid; gap: 2px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.totals span { font-size: 13px; color: var(--muted); }
.totals b { font-size: 19px; font-variant-numeric: tabular-nums; }
.totals .warn b { color: var(--diff); }
.totals .good b { color: var(--ok); }

/* driver picker */
dialog { width: min(640px, calc(100vw - 24px)); padding: 0; border: 0; border-radius: 14px; box-shadow: 0 24px 70px rgba(10, 20, 18, .35); color: var(--ink); }
dialog::backdrop { background: rgba(16, 26, 24, .5); }
dialog form { display: grid; gap: 12px; padding: 22px; margin: 0; }
dialog h2 { margin: 0; font-size: 19px; }
.pick-qb { margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pick-list { list-style: none; margin: 0; padding: 0; height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.pick-list button { display: grid; grid-template-columns: 62px 1fr auto; gap: 10px; width: 100%; padding: 8px 12px; border: 0; border-bottom: 1px solid var(--line-soft); background: none; font: inherit; text-align: left; cursor: pointer; color: var(--ink); }
.pick-list button:hover { background: #f6f8f5; }
.pick-list button[aria-pressed=true] { background: var(--accent-soft); box-shadow: inset 4px 0 0 var(--accent); }
.pick-list .pc { font-weight: 700; font-variant-numeric: tabular-nums; }
.pick-list .pb { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pick-hint { margin: 0; font-size: 13px; min-height: 20px; }
.pick-foot { display: flex; gap: 8px; flex-wrap: wrap; }
.pick-foot .push { margin-left: auto; }

@media (max-width: 1000px) {
  .tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .wrap { padding: 0 14px; }
  .upload { grid-template-columns: 1fr; }
  .tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .count { margin-left: 0; }
  h1 { font-size: 22px; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .tab, .drop { transition: background-color .12s, border-color .12s; }
}
@media print {
  .top, .run-actions, .tabs, .tools, .act, .attention, .compare .seg { display: none !important; }
  body { background: #fff; }
  .results-scroll { max-height: none; overflow: visible; border: 0; box-shadow: none; }
  .results { min-width: 0; font-size: 11px; }
}
