:root {
  color-scheme: light dark;
  --bg: #f2f4f1; --paper: #ffffff; --ink: #1c2420; --muted: #5c665f; --line: #d5dad4; --line2: #e6e9e4;
  --accent: #255c45; --accent-ink: #ffffff; --accent-soft: #e2ede6; --tan: #a67f45;
  --ok: #2e8b57; --ok-soft: #e1f1e6; --soon: #c57a10; --soon-soft: #fbeedb; --over: #b8322a; --over-soft: #f8e3e0;
  --unk: #6b6f6c; --unk-soft: #e9ebe8; --done: #3b6e8f; --done-soft: #e1ebf2;
  --display: 'Barlow Condensed', 'Arial Narrow', Impact, sans-serif;
  --body: 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif;
  --mono: 'IBM Plex Mono', Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141916; --paper: #1c231f; --ink: #e8ece8; --muted: #a3aca6; --line: #334038; --line2: #28322c;
    --accent: #7fc29b; --accent-ink: #0f1a14; --accent-soft: #213229; --tan: #d1a96a;
    --ok: #7fc29b; --ok-soft: #1f3328; --soon: #e5a04a; --soon-soft: #3a2c17; --over: #ef7c73; --over-soft: #3e2320;
    --unk: #9aa39d; --unk-soft: #2a302c; --done: #8cc0e6; --done-soft: #1e2c37;
  }
}
:root[data-theme="dark"] {
  --bg: #141916; --paper: #1c231f; --ink: #e8ece8; --muted: #a3aca6; --line: #334038; --line2: #28322c;
  --accent: #7fc29b; --accent-ink: #0f1a14; --accent-soft: #213229; --tan: #d1a96a;
  --ok: #7fc29b; --ok-soft: #1f3328; --soon: #e5a04a; --soon-soft: #3a2c17; --over: #ef7c73; --over-soft: #3e2320;
  --unk: #9aa39d; --unk-soft: #2a302c; --done: #8cc0e6; --done-soft: #1e2c37;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 22px 20px 80px; }
h1, h2, h3 { font-family: var(--display); text-wrap: balance; margin: 0; line-height: 1.05; }
h1 { font-size: 44px; font-weight: 700; letter-spacing: .01em; }
h2 { font-size: 26px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 18px; font-weight: 600; }
.eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
a { color: var(--accent); }
p { margin: 0 0 10px; max-width: 68ch; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 4px; padding: 7px 9px; max-width: 100%; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
section { margin-top: 36px; }
.hidden { display: none !important; }

/* top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 14px; margin-bottom: 8px; }
.brand { font-family: var(--display); font-size: 22px; font-weight: 700; letter-spacing: .02em; text-decoration: none; color: var(--ink); display: inline-flex; align-items: center; gap: 10px; }
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); display: inline-block; }
.brand small { font-family: var(--mono); font-size: 11px; font-weight: 400; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.crumbs { font-size: 13px; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.topbar form { margin: 0; }
.linkbtn { border: 0; background: transparent; color: var(--muted); font-size: 13px; text-decoration: underline; padding: 0; }

/* flashes */
.flash { padding: 10px 14px; border-radius: 4px; margin: 10px 0; font-size: 14px; border-left: 4px solid var(--accent); background: var(--accent-soft); }
.flash.error { border-color: var(--over); background: var(--over-soft); }

/* pills + colours */
.pill { display: inline-block; font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; background: var(--s, var(--unk-soft)); color: var(--c, var(--unk)); white-space: nowrap; font-weight: 500; }
.st-overdue, .st-expired { --c: var(--over); --s: var(--over-soft); }
.st-soon, .st-expiring { --c: var(--soon); --s: var(--soon-soft); }
.st-unknown, .st-none { --c: var(--unk); --s: var(--unk-soft); }
.st-ok, .st-current { --c: var(--ok); --s: var(--ok-soft); }
.st-check, .st-done { --c: var(--done); --s: var(--done-soft); }
.cat-service { --c: var(--accent); } .cat-repair { --c: var(--tan); } .cat-inspection { --c: var(--done); }
.cat-tyres, .cat-parts, .cat-fuel, .cat-other { --c: var(--unk); } .cat-ownership { --c: var(--ink); } .cat-estimate { --c: var(--line); } .cat-insurance { --c: var(--soon); }

/* garage home */
.home-head { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: end; padding-bottom: 18px; border-bottom: 3px solid var(--accent); }
.home-head .sub { color: var(--muted); margin-top: 6px; }
.cars { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; margin-top: 20px; }
.car-card { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; text-decoration: none; color: inherit; display: grid; grid-template-rows: auto 1fr; transition: transform .15s, border-color .15s; }
.car-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.car-card .photo { aspect-ratio: 16 / 8; background: linear-gradient(135deg, var(--accent-soft), var(--line2)); position: relative; display: grid; place-items: center; overflow: hidden; }
.car-card .photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.car-card .photo .plate { position: absolute; left: 12px; bottom: 10px; font-family: var(--mono); font-size: 12px; letter-spacing: .12em; background: var(--paper); color: var(--ink); padding: 3px 8px; border-radius: 3px; border: 1px solid var(--line); }
.car-card .photo .nophoto { font-family: var(--display); font-size: 64px; color: var(--accent); opacity: .35; font-weight: 700; }
.car-card .body { padding: 14px 16px 16px; display: grid; gap: 10px; }
.car-card h2 { font-size: 24px; margin: 0; }
.car-card .odo { font-family: var(--display); font-size: 30px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.car-card .odo small { font-size: 14px; font-weight: 500; margin-left: 3px; font-family: var(--body); color: var(--muted); }
.keydocs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 13px; }
.keydocs div { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; border-bottom: 1px dashed var(--line2); padding-bottom: 4px; }
.keydocs .lbl { color: var(--muted); }
.keydocs .val { font-family: var(--mono); font-size: 12px; color: var(--c, var(--ink)); white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips .pill { font-size: 10.5px; }
.status-sold { opacity: .6; }
.due-strip { margin-top: 26px; }
.due-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.due-list li { background: var(--paper); border: 1px solid var(--line); border-left: 5px solid var(--c, var(--unk)); border-radius: 4px; padding: 9px 14px; display: grid; grid-template-columns: auto 1fr auto; gap: 4px 14px; align-items: baseline; font-size: 14px; }
.due-list li .car { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.due-list li .when { font-family: var(--mono); font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.newcar { margin-top: 36px; }
.newcar details { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 12px 16px; }
.newcar summary { cursor: pointer; font-weight: 600; }

/* car page header */
.head { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: end; padding-bottom: 20px; border-bottom: 3px solid var(--accent); }
.head .sub { color: var(--muted); margin-top: 6px; }
.spec { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 22px; margin-top: 16px; font-size: 13.5px; }
.spec div span { display: block; font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.odo-box { background: var(--accent); color: var(--accent-ink); padding: 16px 20px; border-radius: 6px; min-width: 250px; }
.odo-box label { display: block; font-family: var(--mono); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; opacity: .85; }
.odo-box .big { font-family: var(--display); font-size: 46px; font-weight: 700; line-height: 1; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.odo-box .big small { font-size: 20px; font-weight: 600; margin-left: 4px; }
.odo-box .asof { font-size: 12px; opacity: .85; }
.odo-box form { display: none; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.odo-box.editing form { display: flex; }
.odo-box.editing .big, .odo-box.editing .asof, .odo-box.editing .editbtn { display: none; }
.odo-box input { width: 130px; border-color: transparent; }
.odo-box button { border: 0; border-radius: 4px; padding: 7px 12px; background: var(--paper); color: var(--ink); font-weight: 500; }
.odo-box .editbtn { margin-top: 10px; background: transparent; color: var(--accent-ink); border: 1px solid rgba(255,255,255,.5); padding: 5px 10px; border-radius: 4px; font-size: 13px; }

/* tabs */
.tabs { display: flex; gap: 4px; margin-top: 18px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs a { text-decoration: none; color: var(--muted); padding: 10px 14px; font-family: var(--display); font-size: 18px; font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--ink); border-color: var(--accent); }
.tabs a .n { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-left: 6px; }
.tabpane { display: none; }
.tabpane.active { display: block; }

/* tiles + attention */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 14px 16px; border-top: 4px solid var(--c); }
.tile .n { font-family: var(--display); font-size: 40px; font-weight: 700; line-height: 1; color: var(--c); font-variant-numeric: tabular-nums; }
.tile .l { font-weight: 500; margin-top: 4px; }
.tile .d { color: var(--muted); font-size: 13px; }
.todo { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.todo li { background: var(--paper); border: 1px solid var(--line); border-left: 5px solid var(--c); border-radius: 4px; padding: 11px 14px; display: grid; grid-template-columns: auto 1fr auto; gap: 4px 14px; align-items: baseline; }
.todo li b { font-weight: 600; }
.todo li .why { grid-column: 2 / span 2; color: var(--muted); font-size: 13.5px; }
.todo li .when { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.doc-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin-top: 14px; }
.doc-strip .doc { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; border-left: 4px solid var(--c, var(--unk)); font-size: 13.5px; }
.doc-strip .doc b { display: block; font-weight: 600; }
.doc-strip .doc .val { font-family: var(--mono); font-size: 12px; color: var(--muted); }

/* tables */
.tablewrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 6px; }
table { border-collapse: collapse; width: 100%; min-width: 820px; font-size: 14px; }
th { font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-weight: 500; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line2); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
td .by { display: block; color: var(--muted); font-size: 12.5px; }
td .why { display: block; color: var(--muted); font-size: 13px; max-width: 46ch; }
tr.st-overdue td:first-child, tr.st-unknown td:first-child, tr.st-soon td:first-child, tr.st-expired td:first-child, tr.st-expiring td:first-child { box-shadow: inset 4px 0 0 var(--c); }
tr.superseded { opacity: .55; }
.rowform { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.rowform input { width: 120px; padding: 4px 7px; font-size: 13px; }
.rowform button, .btn { border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 4px; padding: 5px 10px; font-size: 13px; }
.btn.primary, .save { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.danger { color: var(--over); }
details.inline { display: inline; }
details.inline summary { cursor: pointer; font-size: 13px; color: var(--accent); list-style: none; text-decoration: underline; }
details.inline[open] summary { margin-bottom: 6px; }

/* chart */
.chart { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 14px 10px 6px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { font-family: var(--mono); font-size: 11px; fill: var(--muted); }
.chart .grid { stroke: var(--line2); }
.chart .axis { stroke: var(--line); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.chart .area { fill: var(--accent); opacity: .08; }
.chart .dot { fill: var(--paper); stroke: var(--accent); stroke-width: 1.5; }
.chart .dot.end { fill: var(--tan); stroke: var(--tan); }
.chart .lbl { fill: var(--ink); font-weight: 500; }
.chart .today { stroke: var(--tan); stroke-dasharray: 3 3; }

/* timeline */
.tl { list-style: none; margin: 0 0 0 6px; padding: 0; border-left: 2px solid var(--line); }
.tl li { position: relative; padding: 0 0 18px 20px; display: grid; grid-template-columns: 150px 1fr auto; gap: 4px 16px; align-items: baseline; }
.tl li::before { content: ''; position: absolute; left: -6px; top: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--paper); border: 2px solid var(--c, var(--line)); }
.tl .when { font-family: var(--mono); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tl .when small { display: block; color: var(--muted); }
.tl .what b { font-weight: 600; }
.tl .what .by { color: var(--muted); font-size: 13px; }
.tl .what .src { color: var(--muted); font-size: 12px; font-style: italic; }
.tl .files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.tl .files a, .doc-file { font-family: var(--mono); font-size: 11.5px; text-decoration: none; background: var(--accent-soft); color: var(--accent); padding: 2px 8px; border-radius: 3px; display: inline-flex; align-items: center; gap: 5px; max-width: 100%; }
.tl .files a:hover, .doc-file:hover { text-decoration: underline; }
.tl .cost { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; white-space: nowrap; }
.tl .del { border: 0; background: transparent; color: var(--muted); font-size: 12px; padding: 0 4px; text-decoration: underline; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.filters button { border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 999px; padding: 4px 12px; font-size: 13px; }
.filters button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* forms */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 18px 20px; max-width: 820px; }
.panel .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 12px; }
.panel label { display: block; font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.panel input, .panel select, .panel textarea { width: 100%; }
.panel textarea { min-height: 60px; resize: vertical; }
.chipset { display: flex; flex-wrap: wrap; gap: 6px; }
.chipset label { display: inline-flex; align-items: center; gap: 6px; font: inherit; text-transform: none; letter-spacing: 0; color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; cursor: pointer; margin: 0; font-size: 13px; }
.chipset label:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); }
.chipset input { width: auto; margin: 0; }
.save { border: 0; border-radius: 4px; padding: 10px 18px; font-size: 15px; }
.missing { margin: 0; padding-left: 20px; max-width: 75ch; }
.missing li { margin-bottom: 6px; }

/* documents */
.doc-groups { display: grid; gap: 14px; }
.doc-card { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 14px 16px; border-left: 5px solid var(--c, var(--unk)); display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; }
.doc-card h3 { font-size: 20px; }
.doc-card .meta { font-size: 13.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 4px; }
.doc-card .meta b { color: var(--ink); font-weight: 500; }
.doc-card .actions { display: flex; gap: 8px; align-items: start; }
.doc-card .history { grid-column: 1 / -1; font-size: 13px; color: var(--muted); border-top: 1px dashed var(--line2); padding-top: 8px; }
.doc-card .history a { color: var(--muted); }
.doc-missing { border-style: dashed; color: var(--muted); }

/* photos */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.photo-card { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; text-decoration: none; color: inherit; display: grid; grid-template-rows: auto 1fr; }
.photo-card .img { aspect-ratio: 4 / 3; background: var(--line2); display: grid; place-items: center; overflow: hidden; }
.photo-card .img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-card .img .ext { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); text-align: center; padding: 12px; }
.photo-card .cap { padding: 10px 12px; font-size: 13.5px; }
.photo-card .cap small { display: block; color: var(--muted); font-family: var(--mono); font-size: 11.5px; margin-top: 2px; }
.photo-card form { padding: 0 12px 10px; }

/* edit tab */
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.versions { font-size: 13px; }
.versions li { margin-bottom: 4px; }

.foot { margin-top: 48px; color: var(--muted); font-size: 12.5px; border-top: 1px solid var(--line); padding-top: 14px; max-width: 80ch; }

/* login */
.login-shell { max-width: 420px; margin: 14vh auto 0; padding: 0 20px; }
.login-shell .panel { margin-top: 18px; }

@media (max-width: 720px) {
  h1 { font-size: 34px; }
  .head, .home-head { grid-template-columns: 1fr; }
  .tl li { grid-template-columns: 1fr; gap: 2px; }
  .tl .cost { justify-self: start; }
  .due-list li { grid-template-columns: 1fr; }
  .doc-card { grid-template-columns: 1fr; }
  .todo li { grid-template-columns: auto 1fr; }
  .todo li .when { grid-column: 2; }
}
