:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #f7f9fa;
  --border: #dfe4e9;
  --border-strong: #c5ccd4;
  --text: #16202a;
  --muted: #5a6875;
  --primary: #1b5fc1;
  --primary-ink: #ffffff;
  --primary-soft: #e7effb;
  --focus: #2f7dff;

  --ok: #17703f;      --ok-bg: #e3f3e9;
  --warn: #8a5300;    --warn-bg: #fcefd2;
  --bad: #b3261e;     --bad-bg: #fce6e4;
  --info: #1b5fc1;    --info-bg: #e5eefb;
  --attn: #6a3db3;    --attn-bg: #eee7fa;
  --neutral: #3f4c58; --neutral-bg: #eaeef2;
  --muted-c: #5a6875; --muted-bg: #f0f2f4;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .07);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --tap: 44px;
  --nav-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141a;
    --surface: #171e26;
    --surface-2: #1c242e;
    --border: #2a3440;
    --border-strong: #3a4654;
    --text: #e8edf2;
    --muted: #9aa8b5;
    --primary: #5b9bff;
    --primary-ink: #0b1220;
    --primary-soft: #1a2a44;
    --ok: #5fd28f;      --ok-bg: #12301f;
    --warn: #f2b84b;    --warn-bg: #352710;
    --bad: #ff8077;     --bad-bg: #3a1714;
    --info: #7fb0ff;    --info-bg: #15253f;
    --attn: #b99bff;    --attn-bg: #271c40;
    --neutral: #c3ccd5; --neutral-bg: #232c36;
    --muted-c: #9aa8b5; --muted-bg: #1f2730;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 28px; height: 28px; }

/* ------------------------------------------------------------------ Shell */
.app { min-height: 100vh; display: flex; }
.sidebar {
  position: sticky; top: 0; height: 100vh; width: 236px; flex: none;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 12px; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; font-weight: 750; font-size: 1.15rem; color: var(--text); }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--primary); color: var(--primary-ink); display: grid; place-items: center; flex: none; }
.brand-mark .icon { width: 20px; height: 20px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; min-height: var(--tap); padding: 0 12px;
  border-radius: 10px; color: var(--muted); font-weight: 560; text-decoration: none !important;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--primary-soft); color: var(--primary); }
.nav-link .count { margin-left: auto; font-size: .78rem; background: var(--bad); color: #fff; border-radius: 999px; padding: 1px 8px; font-weight: 700; }
.sidebar .spacer { flex: 1; }
.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); cursor: pointer; text-align: left; width: 100%;
}
.user-chip:hover { border-color: var(--border-strong); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--neutral-bg); color: var(--neutral); font-weight: 700; font-size: .85rem;
}
.avatar.lg { width: 48px; height: 48px; font-size: 1.05rem; }
.avatar.sm { width: 26px; height: 26px; font-size: .7rem; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  padding: 10px 24px; min-height: 60px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.topbar .title { font-weight: 700; font-size: 1.1rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .back { margin-left: -8px; }
.content { padding: 8px 24px 40px; width: 100%; max-width: 1240px; margin: 0 auto; }
.bottom-nav { display: none; }

@media (max-width: 1023px) and (min-width: 768px) {
  .sidebar { width: 92px; padding: 14px 8px; align-items: stretch; }
  .brand { justify-content: center; padding: 4px 0 14px; }
  .brand span, .user-chip .user-meta { display: none; }
  .nav-link { flex-direction: column; justify-content: center; gap: 2px; font-size: .72rem; padding: 8px 4px; text-align: center; min-height: 60px; }
  .nav-link .count { position: absolute; margin: -34px 0 0 34px; }
  .nav-link { position: relative; }
  .user-chip { justify-content: center; padding: 6px; }
  .content { padding: 8px 20px 40px; }
  .topbar { padding: 10px 20px; }
}

@media (max-width: 767px) {
  .sidebar { display: none; }
  .content { padding: 4px 16px calc(var(--nav-h) + 32px + env(safe-area-inset-bottom)); }
  .topbar { padding: 8px 12px 8px 16px; min-height: 56px; }
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    height: var(--nav-h); color: var(--muted); font-size: .75rem; font-weight: 600; position: relative; text-decoration: none !important;
  }
  .bottom-nav a.active { color: var(--primary); }
  .bottom-nav a .count { position: absolute; top: 6px; left: 50%; margin-left: 6px; font-size: .7rem; background: var(--bad); color: #fff; border-radius: 999px; padding: 0 6px; font-weight: 700; }
  h1 { font-size: 1.3rem; }
}

/* ---------------------------------------------------------------- Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 16px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer; text-decoration: none !important;
  white-space: nowrap; transition: background .12s, border-color .12s, transform .05s; -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--primary) 88%, #000); }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); }
.btn-danger:hover { background: var(--bad-bg); }
.btn-danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .9rem; border-radius: 8px; }
.btn-lg { min-height: 52px; padding: 0 22px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-icon { width: var(--tap); padding: 0; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.link-btn { background: none; border: 0; color: var(--primary); font-weight: 600; cursor: pointer; padding: 6px 0; min-height: 32px; }

/* ---------------------------------------------------------------- Badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px 3px 8px; border-radius: 999px;
  font-size: .82rem; font-weight: 650; line-height: 1.3; white-space: nowrap; background: var(--neutral-bg); color: var(--neutral);
}
.badge .icon { width: 14px; height: 14px; stroke-width: 2.5; }
.tone-ok { background: var(--ok-bg); color: var(--ok); }
.tone-warn { background: var(--warn-bg); color: var(--warn); }
.tone-bad { background: var(--bad-bg); color: var(--bad); }
.tone-info { background: var(--info-bg); color: var(--info); }
.tone-attn { background: var(--attn-bg); color: var(--attn); }
.tone-neutral { background: var(--neutral-bg); color: var(--neutral); }
.tone-muted { background: var(--muted-bg); color: var(--muted-c); }
.text-ok { color: var(--ok); } .text-warn { color: var(--warn); } .text-bad { color: var(--bad); } .text-info { color: var(--info); }
.plate {
  display: inline-block; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-weight: 700; font-size: .85rem;
  letter-spacing: .04em; padding: 1px 7px; border: 1.5px solid var(--text); border-radius: 5px; background: var(--surface); white-space: nowrap;
}

/* ---------------------------------------------------------------- Layout */
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 8px 0 18px; }
.page-head p { margin-top: 4px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.cols-main { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1023px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols-main { grid-template-columns: 1fr; } }
@media (max-width: 767px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
@media (max-width: 767px) { .card-pad { padding: 14px; } }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: 1.02rem; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 6px 18px; }
@media (max-width: 767px) { .card-head { padding: 12px 14px; } .card-body { padding: 4px 14px; } }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--border); }
.list > li:last-child { border-bottom: 0; }
.list-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 0; min-height: 56px; color: inherit; text-decoration: none !important;
}
a.list-row:hover .list-title, button.list-row:hover .list-title { color: var(--primary); }
button.list-row { width: 100%; background: none; border: 0; text-align: left; cursor: pointer; }
.list-title { font-weight: 600; }
.list-sub { color: var(--muted); font-size: .9rem; }
.chev { color: var(--muted); }

.kv { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 10px 18px; margin: 0; }
.kv dt { color: var(--muted); font-size: .92rem; }
.kv dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- Tiles */
.tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
@media (max-width: 1279px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 767px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
.tile {
  display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow); color: inherit; text-decoration: none !important; min-height: 98px;
}
a.tile:hover { border-color: var(--border-strong); }
.tile .tile-label { display: flex; align-items: center; gap: 6px; font-size: .88rem; font-weight: 600; color: var(--muted); }
.tile .tile-value { font-size: 1.9rem; font-weight: 750; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile .tile-ico { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; }
.tile .tile-ico .icon { width: 16px; height: 16px; stroke-width: 2.4; }

/* ---------------------------------------------------------------- Forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field-label { font-weight: 600; font-size: .95rem; }
.field .hint { color: var(--muted); font-size: .85rem; }
.field .req { color: var(--bad); margin-left: 2px; }
.input, select.input, textarea.input {
  width: 100%; min-height: var(--tap); padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-size: 16px;
}
textarea.input { min-height: 88px; resize: vertical; line-height: 1.4; }
.input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.input[aria-invalid="true"] { border-color: var(--bad); }
.input-lg { font-size: 1.6rem; font-weight: 700; min-height: 60px; text-align: center; font-variant-numeric: tabular-nums; }
.field-error { color: var(--bad); font-size: .88rem; font-weight: 600; display: flex; gap: 6px; align-items: flex-start; }
.form-error { background: var(--bad-bg); color: var(--bad); padding: 10px 12px; border-radius: 10px; font-weight: 600; display: flex; gap: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 599px) { .form-grid { grid-template-columns: 1fr; } }
.check-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.check-row input { width: 22px; height: 22px; margin: 1px 0 0; flex: none; accent-color: var(--primary); }
.check-row.danger:has(input:checked) { border-color: var(--bad); background: var(--bad-bg); }
.search { position: relative; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search .input { padding-left: 40px; }
input[type=range] { width: 100%; height: 36px; accent-color: var(--primary); }

/* Segmented controls & chips */
.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.seg button, .chip {
  min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface); font-weight: 600; font-size: .92rem; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.seg button[aria-pressed="true"], .chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--surface); }
.chip .n { font-variant-numeric: tabular-nums; opacity: .75; font-weight: 700; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
@media (max-width: 767px) { .chips { margin: 0 -16px; padding: 2px 16px 6px; } }
.seg.block { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
.seg.block button { border-radius: 10px; justify-content: center; min-height: var(--tap); }

/* Result buttons (Pass / Needs attention / N/A) */
.results { display: grid; grid-template-columns: 1fr 1.25fr .7fr; gap: 6px; min-width: 300px; }
.results button {
  min-height: 48px; border-radius: 10px; border: 1.5px solid var(--border-strong); background: var(--surface);
  font-weight: 650; font-size: .92rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 8px;
}
.results button .icon { width: 18px; height: 18px; stroke-width: 2.6; }
.results button[aria-pressed="true"].r-pass { background: var(--ok); border-color: var(--ok); color: #fff; }
.results button[aria-pressed="true"].r-attention { background: var(--bad); border-color: var(--bad); color: #fff; }
.results button[aria-pressed="true"].r-na { background: var(--neutral); border-color: var(--neutral); color: var(--surface); }
@media (prefers-color-scheme: dark) {
  .results button[aria-pressed="true"].r-pass, .results button[aria-pressed="true"].r-attention { color: #0b1220; }
}

/* ---------------------------------------------------------------- Fleet */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.toolbar .search { flex: 1 1 260px; }
.car-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.car-card { display: flex; flex-direction: column; overflow: hidden; color: inherit; text-decoration: none !important; transition: border-color .12s, box-shadow .12s; }
.car-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-lg); }
.car-photo { aspect-ratio: 16 / 9; background: var(--surface-2); object-fit: cover; width: 100%; }
.car-card .car-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.car-title { font-weight: 700; font-size: 1.05rem; }
.car-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: .9rem; align-items: center; }
.car-meta span { display: inline-flex; align-items: center; gap: 5px; }
.alerts { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: .9rem; }
.alerts li { display: flex; align-items: flex-start; gap: 7px; font-weight: 560; }
.alerts li .icon { width: 16px; height: 16px; margin-top: 2px; }
.alerts .ok { color: var(--ok); }
.car-list .list-row { padding: 12px 14px; }
.car-thumb { width: 92px; height: 58px; border-radius: 8px; object-fit: cover; background: var(--surface-2); flex: none; }
@media (max-width: 767px) { .car-thumb { width: 76px; height: 50px; } }
.car-list .list-row .car-status { flex: none; }
@media (max-width: 599px) {
  .car-list .list-row { flex-wrap: wrap; align-items: flex-start; }
  .car-list .list-row .car-status { width: 100%; padding-left: 88px; margin-top: -4px; }
}

/* ---------------------------------------------------------------- Car page */
.car-hero { display: grid; grid-template-columns: 280px 1fr; gap: 20px; align-items: center; margin: 4px 0 16px; }
.car-hero img { border-radius: var(--radius); aspect-ratio: 16 / 9; object-fit: cover; width: 100%; border: 1px solid var(--border); }
.car-hero h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hero-facts { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 10px; color: var(--muted); }
.hero-facts b { color: var(--text); font-variant-numeric: tabular-nums; }
@media (max-width: 767px) {
  .car-hero { grid-template-columns: 112px 1fr; gap: 14px; align-items: start; }
  .car-hero h1 { font-size: 1.15rem; }
  .hero-facts { gap: 4px 14px; font-size: .9rem; }
}
.quick-actions { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.quick-actions .btn { flex-direction: column; height: 76px; gap: 6px; white-space: normal; text-align: center; line-height: 1.15; font-size: .9rem; padding: 6px; }
.quick-actions .btn .icon { width: 22px; height: 22px; }
@media (max-width: 1023px) { .quick-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 380px) { .quick-actions .btn { font-size: .82rem; } }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 0 14px; min-height: 46px; display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none !important; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.tabs a .n { font-size: .78rem; background: var(--neutral-bg); color: var(--neutral); padding: 0 7px; border-radius: 999px; }
@media (max-width: 767px) { .tabs { margin: 0 -16px 16px; padding: 0 8px; } }
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); margin-bottom: 14px; font-weight: 550; }
.banner .icon { margin-top: 1px; }
.banner .grow > * + * { margin-top: 4px; }

.svc-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 0; align-items: center; }
.svc-row .svc-detail { grid-column: 1 / -1; color: var(--muted); font-size: .88rem; }
.meter { height: 6px; border-radius: 999px; background: var(--neutral-bg); overflow: hidden; grid-column: 1 / -1; }
.meter span { display: block; height: 100%; border-radius: 999px; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { display: grid; grid-template-columns: 40px 1fr; gap: 12px; padding: 0 0 18px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: 19px; top: 40px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.tl-dot { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; }
.tl-dot .icon { width: 18px; height: 18px; }
.tl-body { padding-top: 8px; min-width: 0; }
.tl-title { font-weight: 600; }
.tl-meta { color: var(--muted); font-size: .88rem; display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 2px; }
.tl-notes { margin-top: 6px; font-size: .92rem; white-space: pre-wrap; }
.month-label { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 6px 0 12px; }

/* Photos */
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumb { position: relative; width: 76px; height: 76px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); flex: none; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb a { display: block; width: 100%; height: 100%; }
.thumb .file-ico { display: grid; place-items: center; height: 100%; color: var(--muted); font-size: .7rem; text-align: center; padding: 4px; gap: 2px; }
.thumb .remove { position: absolute; top: 3px; right: 3px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; display: grid; place-items: center; cursor: pointer; }
.thumb .remove .icon { width: 14px; height: 14px; }
.add-photo {
  width: 76px; height: 76px; border-radius: 8px; border: 1.5px dashed var(--border-strong); background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; color: var(--muted); font-size: .75rem; font-weight: 600;
}
.add-photo:hover { border-color: var(--primary); color: var(--primary); }
.uploading { opacity: .6; }

/* Checklist */
.progress { height: 10px; border-radius: 999px; background: var(--neutral-bg); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--ok); transition: width .2s; }
.check-section { margin-bottom: 18px; }
.check-section .section-head h2 { font-size: 1rem; }
.check-item { padding: 14px 0; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 16px; align-items: center; scroll-margin-top: 140px; }
.check-item:last-child { border-bottom: 0; }
.check-item .ci-label { font-weight: 600; display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.check-item .ci-extra { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 10px; }
.check-item.invalid { background: var(--bad-bg); margin: 0 -12px; padding: 14px 12px; border-radius: 10px; }
@media (max-width: 899px) {
  .check-item { grid-template-columns: 1fr; }
  .results { min-width: 0; }
}
.hint-box { border-radius: 10px; padding: 10px 12px; font-size: .9rem; display: flex; flex-direction: column; gap: 4px; }
.sticky-foot {
  position: sticky; bottom: 0; z-index: 15; margin: 16px -24px -40px; padding: 12px 24px; background: var(--surface);
  border-top: 1px solid var(--border); display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
@media (max-width: 1023px) { .sticky-foot { margin: 16px -20px -40px; padding: 12px 20px; } }
@media (max-width: 767px) {
  .sticky-foot { bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); margin: 16px -16px 0; padding: 10px 16px; }
  .sticky-foot { gap: 8px; }
  .sticky-foot .btn { flex: 1; }
  .sticky-foot .btn-ghost { flex: 0 0 auto; }
  .sticky-foot .save-state { flex-basis: 100%; font-size: .8rem; }
  .sticky-foot .btn-lg { min-height: 48px; font-size: 1rem; padding: 0 12px; }
}
.save-state { color: var(--muted); font-size: .88rem; display: inline-flex; align-items: center; gap: 6px; }
.save-state.error { color: var(--bad); font-weight: 600; }
.fuel-box { display: flex; align-items: center; gap: 14px; }
.fuel-box output { white-space: nowrap; font-weight: 750; font-size: 1.2rem; min-width: 56px; text-align: right; font-variant-numeric: tabular-nums; }

/* Stepper */
.stepper { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 8px; margin-bottom: 14px; scrollbar-width: none; counter-reset: step; }
.stepper::-webkit-scrollbar { display: none; }
.stepper button {
  display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 14px 0 6px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); font-weight: 600; font-size: .9rem; cursor: pointer; white-space: nowrap; color: var(--muted);
}
.stepper button .n { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--neutral-bg); font-size: .8rem; font-weight: 700; }
.stepper button.done .n { background: var(--ok); color: #fff; }
.stepper button.err .n { background: var(--bad); color: #fff; }
.stepper button[aria-current="step"] { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.stepper button[aria-current="step"] .n { background: var(--primary); color: var(--primary-ink); }
@media (max-width: 767px) { .stepper { margin: 0 -16px 12px; padding: 2px 16px 8px; } }

/* Car diagram */
.diagram { width: 100%; max-width: 360px; margin: 0 auto; display: block; }
.diagram .zone { fill: var(--surface-2); stroke: var(--border-strong); stroke-width: 1.5; cursor: pointer; transition: fill .1s; }
.diagram .zone:hover, .diagram .zone:focus { fill: var(--primary-soft); stroke: var(--primary); outline: none; }
.diagram .zone.has-old { fill: var(--neutral-bg); }
.diagram .zone.has-new { fill: var(--bad-bg); stroke: var(--bad); }
.diagram .marker { pointer-events: none; font-size: 12px; font-weight: 800; }
.diagram text.lbl { font-size: 10px; fill: var(--muted); pointer-events: none; font-weight: 600; }

/* Compare */
.compare { width: 100%; border-collapse: collapse; }
.compare th, .compare td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.compare th { font-size: .85rem; color: var(--muted); font-weight: 600; }
.compare td.num { font-variant-numeric: tabular-nums; }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th { text-align: left; font-size: .82rem; color: var(--muted); font-weight: 650; padding: 10px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .r { text-align: right; }
.table-wrap { overflow-x: auto; }
.bar { height: 10px; border-radius: 999px; background: var(--primary); min-width: 2px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; min-width: 0; }
.bars .b span.col { width: 100%; max-width: 38px; background: var(--primary); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.bars .b small { font-size: .72rem; color: var(--muted); white-space: nowrap; }

/* Empty state */
.empty { text-align: center; padding: 34px 18px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty .icon { width: 36px; height: 36px; stroke-width: 1.6; color: var(--border-strong); }
.empty h3 { color: var(--text); }
.empty p { max-width: 380px; }

/* ---------------------------------------------------------------- Dialog */
dialog.sheet {
  border: 0; padding: 0; border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: hidden;
}
dialog.sheet.wide { width: min(780px, calc(100vw - 32px)); }
dialog.sheet::backdrop { background: rgba(10, 16, 24, .5); }
dialog.sheet[open] { display: flex; flex-direction: column; animation: pop .14s ease-out; }
@keyframes pop { from { transform: translateY(8px) scale(.98); } }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 12px 20px; border-bottom: 1px solid var(--border); }
.sheet-head h2 { flex: 1; font-size: 1.12rem; }
.sheet-body { padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.sheet-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
@media (max-width: 599px) {
  dialog.sheet, dialog.sheet.wide {
    width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 18px 18px 0 0;
  }
  dialog.sheet[open] { animation: slideup .18s ease-out; }
  .sheet-body { padding: 16px; }
  .sheet-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .sheet-foot .btn { flex: 1; }
}
@keyframes slideup { from { transform: translateY(40px); } }

.picker-list { max-height: 55vh; overflow-y: auto; margin: 0 -4px; }
.option-list { display: flex; flex-direction: column; gap: 8px; }
.option {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--border);
  background: var(--surface); cursor: pointer; text-align: left; width: 100%; min-height: 56px;
}
.option:hover { border-color: var(--border-strong); }
.option:has(input:checked), .option[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); }
.option input { width: 20px; height: 20px; accent-color: var(--primary); }

/* Toast */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(520px, calc(100vw - 24px)); }
@media (max-width: 767px) { .toasts { bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); } }
.toast {
  pointer-events: auto; background: var(--text); color: var(--surface); padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px; font-weight: 600; animation: pop .16s ease-out; max-width: 100%;
}
.toast.bad { background: var(--bad); color: #fff; }
.toast .icon { flex: none; }

/* Who-are-you screen */
.welcome { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.welcome .card { width: min(480px, 100%); }

/* Signature */
.sig-wrap { border: 1.5px dashed var(--border-strong); border-radius: 12px; background: #fff; position: relative; touch-action: none; }
.sig-wrap canvas { width: 100%; height: 170px; display: block; border-radius: 12px; cursor: crosshair; }
.sig-wrap .sig-hint { position: absolute; left: 14px; bottom: 10px; color: #8a96a3; font-size: .85rem; pointer-events: none; }
.sig-img { background: #fff; border-radius: 8px; border: 1px solid var(--border); max-width: 320px; }

/* Template editor */
.tpl-item { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.tpl-item .opts { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
@media (max-width: 767px) { .tpl-item { grid-template-columns: 1fr auto; } .tpl-item .opts { grid-column: 1 / -1; } }

/* QR labels */
.qr-labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.qr-label { border: 1px solid var(--border); border-radius: 12px; padding: 14px; text-align: center; background: #fff; color: #111; break-inside: avoid; }
.qr-label img { width: 160px; height: 160px; margin: 0 auto 8px; }

/* Print */
@media print {
  .sidebar, .bottom-nav, .topbar, .no-print, .sticky-foot, .toasts { display: none !important; }
  body { background: #fff; color: #000; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
}
@media (max-width: 599px) { .hide-sm { display: none; } }
code { font-family: ui-monospace, Menlo, monospace; font-size: .9em; background: var(--neutral-bg); padding: 1px 5px; border-radius: 4px; }
.check-item > .badge { justify-self: start; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (max-width: 599px) {
  [data-part-row] { flex-wrap: wrap; padding-bottom: 8px; border-bottom: 1px dashed var(--border); }
  [data-part-row] .field.grow { flex-basis: 100%; }
  [data-part-row] .field:not(.grow) { flex: 1; width: auto !important; }
}
.dist-row { display: flex; gap: 8px; align-items: center; }
.dist-row .input { flex: 1; min-width: 0; }
.dist-suffix { flex: none; font-weight: 700; color: var(--muted); min-width: 24px; }
.unit-switch { display: inline-flex; gap: 2px; padding: 2px; border-radius: 999px; background: var(--neutral-bg); vertical-align: middle; }
.unit-switch button { min-height: 30px; min-width: 40px; padding: 0 10px; border: 0; border-radius: 999px; background: transparent; font-weight: 700; font-size: .85rem; color: var(--muted); cursor: pointer; }
.unit-switch button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.unit-switch button:disabled { cursor: default; }
