:root {
  --bg: #ecebe6;
  --card: #fbfaf7;
  --ink: #1f2523;
  --muted: #6c716c;
  --line: #dcdad2;
  --chip: #e3e1d9;
  --accent: #5b6b62;
  --signal: #e8692f;
  --signal-deep: #c4521d;
  --ok: #3f7d5a;
  --soon: #c98a12;
  --over: #c23b2b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 25, 22, .05), 0 6px 18px rgba(20, 25, 22, .06);
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  --display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816; --card: #1d2220; --ink: #ecefe9; --muted: #9aa29b; --line: #2e3532;
    --chip: #262d2a; --ok: #5fb07f; --soon: #e3a83a; --over: #ec6a58;
    --shadow: 0 1px 2px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 15px/1.45 Inter, system-ui, -apple-system, sans-serif; -webkit-text-size-adjust: 100%; }
#app { max-width: 920px; margin: 0 auto; padding: 0 16px calc(64px + env(safe-area-inset-bottom)); }
h1, h2, h3 { font-family: var(--display); font-weight: 700; margin: 0; letter-spacing: .01em; }
h2 { font-size: 26px; line-height: 1.1; }
h3 { font-size: 20px; }
.page-title { font-size: 30px; }
a { color: inherit; }
.link { color: var(--signal-deep); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.err { color: var(--over); min-height: 1.2em; margin: 4px 0 0; font-size: 14px; }
.err:empty { min-height: 0; margin: 0; }
.loading { color: var(--muted); padding: 40px 0; text-align: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.eyebrow { font: 600 11px/1 Inter, sans-serif; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 4px; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; padding: 18px 0 10px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand h1 { font-size: 32px; text-transform: uppercase; letter-spacing: .04em; }
.gauge { width: 30px; height: 30px; border-radius: 8px; background: var(--ink); position: relative; flex: none; }
.gauge::before { content: ''; position: absolute; left: 6px; right: 6px; top: 9px; height: 18px; border: 3.5px solid var(--signal); border-bottom: 0; border-radius: 18px 18px 0 0; }
.gauge::after { content: ''; position: absolute; left: 14px; top: 13px; width: 3px; height: 10px; background: var(--bg); border-radius: 2px; transform: rotate(40deg); transform-origin: bottom center; }
.top-right { display: flex; align-items: center; gap: 8px; }
.status { font-size: 12px; color: var(--muted); }
.status.bad { color: var(--over); }

.tabs { display: flex; gap: 4px; background: var(--chip); padding: 4px; border-radius: 999px; margin: 4px 0 18px; position: sticky; top: 8px; z-index: 5; }
.tabs a { flex: 1; text-align: center; text-decoration: none; color: var(--muted); font: 600 14px Inter, sans-serif; padding: 9px 8px; border-radius: 999px; white-space: nowrap; }
.tabs a.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow), inset 0 0 0 1px var(--line); }

/* building blocks */
.card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; text-decoration: none; color: inherit; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.section { margin-top: 22px; }
.section > h3, .section > .row { margin-bottom: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: 600 14px Inter, sans-serif; padding: 9px 14px; border-radius: 10px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--signal); border-color: var(--signal-deep); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.danger { color: var(--over); }
.btn.block { display: flex; width: 100%; }
.btn.big { padding: 14px; font-size: 16px; }
.icon { border: 0; background: transparent; color: var(--muted); font-size: 20px; width: 34px; height: 34px; border-radius: 8px; cursor: pointer; flex: none; }
.icon:hover { background: var(--chip); }

.lbl { display: block; font: 600 12px Inter, sans-serif; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; }
input, textarea, select { width: 100%; font: 16px Inter, sans-serif; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
input[type=date] { width: auto; min-height: 42px; }
.grid2 input[type=date] { width: 100%; }
input[type=color] { padding: 4px; height: 44px; }
input:focus, textarea:focus { outline: 2px solid var(--signal); outline-offset: 1px; border-color: transparent; }
textarea { resize: vertical; }

.pill { font: 600 11px/1 Inter, sans-serif; text-transform: uppercase; letter-spacing: .06em; padding: 5px 8px; border-radius: 999px; white-space: nowrap; }
.pill.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.pill.soon { background: color-mix(in srgb, var(--soon) 18%, transparent); color: var(--soon); }
.pill.overdue { background: var(--over); color: #fff; }
.pill.unknown { background: var(--chip); color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--chip); border-radius: 999px; padding: 6px 11px; font-size: 13px; font-weight: 500; }
.chip.tiny { padding: 2px 8px; font-size: 11px; white-space: nowrap; }
.chip.toggle { cursor: pointer; border: 1px solid transparent; user-select: none; }
.chip.toggle input { display: none; }
.chip.toggle:has(input:checked) { background: var(--ink); color: var(--bg); }

/* odometer */
.odo-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 14px 0 12px; }
.odo { display: inline-flex; align-items: flex-end; gap: 2px; font-family: var(--mono); font-weight: 600; }
.odo b { display: inline-block; min-width: .8em; text-align: center; font-size: 26px; line-height: 1; padding: 6px 3px; background: var(--ink); color: var(--bg); border-radius: 4px; }
.odo i { font-style: normal; font-size: 20px; color: var(--muted); padding: 0 1px; }

/* due rows */
.dues { display: grid; gap: 12px; }
.due-head, .due-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.due-name { font-weight: 600; }
.due-foot { font-size: 13px; margin-top: 6px; }
.bar { height: 8px; background: var(--chip); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.bar span { display: block; height: 100%; background: var(--ok); border-radius: 999px; }
.due.soon .bar span { background: var(--soon); }
.due.overdue .bar span { background: var(--over); }
.due .small { margin-top: 3px; }

/* garage */
.check-banner { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-left: 5px solid var(--line); }
.check-banner.due { border-left-color: var(--signal); }
.cb-title { font: 700 21px/1.15 var(--display); }
.vgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.vgrid .card { margin: 0; }
.vcard, .vhero, .cblock, .result-v { border-top: 5px solid var(--accent); }
.vcard-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.vcard h2 { font-size: 30px; text-transform: uppercase; }
.vhero .row:last-child { margin-top: 16px; }

/* lists */
.list { padding: 4px 16px; }
.svc { display: flex; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); text-decoration: none; }
.svc:last-child { border-bottom: 0; }
.svc-title { font-weight: 600; }
.svc-notes { font-size: 13px; margin-top: 4px; white-space: pre-wrap; }
.svc-kinds { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; align-content: flex-start; max-width: 40%; }
.hist-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.hist-row:last-child { border-bottom: 0; }
.hist-vals { display: flex; gap: 16px; flex-wrap: wrap; margin-left: auto; text-align: right; }
.list > p { margin: 12px 0; }

/* car check */
.cblock { border-left: 1px solid var(--line); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 0 14px; min-width: 0; }
.cblock h2 { text-transform: uppercase; }
.cblock .lbl { margin-top: 12px; }
.mi-wrap { position: relative; }
.mi { font: 600 30px/1.1 var(--mono); padding: 12px 52px 12px 14px; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.mi-unit { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; }
.preview:not(:empty) { margin-top: 14px; }
.extras { margin-top: 12px; }
.extras summary { cursor: pointer; color: var(--muted); font-size: 14px; font-weight: 500; }
.extras .chips { margin: 10px 0; }
.result-v { border-top-width: 4px; padding-top: 12px; }
.result-v .dues { margin: 10px 0; }

/* log form */
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg label { flex: 1; min-width: 110px; }
.seg input { display: none; }
.seg span { display: block; text-align: center; padding: 11px; border: 1px solid var(--line); border-radius: 10px; font-weight: 600; cursor: pointer; background: var(--bg); }
.seg input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }

/* vehicle detail */
.details { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
.details dt { color: var(--muted); font-size: 13px; }
.details dd { margin: 0; overflow-wrap: anywhere; }
.notes { white-space: pre-wrap; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 14px; }
.drow { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 6px; align-items: center; }
#dRows:not(:empty) { margin-bottom: 8px; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 12px; font-weight: 500; box-shadow: var(--shadow); z-index: 20; max-width: calc(100% - 32px); }
.toast.bad { background: var(--over); color: #fff; }

/* login */
.login-page { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 16px; }
.login { width: 100%; max-width: 360px; }
.login .brand { justify-content: center; margin-bottom: 18px; }

@media (max-width: 520px) {
  .grid2 { grid-template-columns: 1fr; }
  .grid2:has(#lDate) { grid-template-columns: 1fr 1fr; }
  .check-banner { flex-direction: column; align-items: stretch; }
  .check-banner .btn { width: 100%; }
  .svc-kinds { display: none; }
  .vgrid { grid-template-columns: 1fr; }
  .odo b { font-size: 23px; }
}
