:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #16181d;
  --muted: #6b7280;
  --line: #e3e6ea;
  --accent: #3b6ef5;
  --ok: #128a5b;
  --warn: #b26a00;
  --bad: #c0362c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 20, 30, .06), 0 6px 20px rgba(16, 20, 30, .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #171a20;
    --ink: #e9ecf1;
    --muted: #9aa3af;
    --line: #262b33;
    --accent: #6d93ff;
    --ok: #3fbc86;
    --warn: #e0a33a;
    --bad: #ef6b5f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

.wrap { max-width: 940px; margin: 0 auto; padding: 20px 16px 60px; }

header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
header h1 { font-size: 19px; margin: 0; letter-spacing: -.01em; }
header .sub { color: var(--muted); font-size: 13px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}

h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 14px; font-weight: 600; }

.odo { font-size: 42px; font-weight: 650; letter-spacing: -.025em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.odo small { font-size: 17px; font-weight: 500; color: var(--muted); margin-left: 6px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 14px; margin-top: 18px; }
.stat .v { font-size: 22px; font-weight: 620; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat .k { font-size: 12px; color: var(--muted); margin-top: 2px; }

canvas { max-width: 100%; }

/* ---- tires ---- */
.tire { padding: 16px 0; border-top: 1px solid var(--line); }
.tire:first-of-type { border-top: 0; padding-top: 0; }
.tire-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.tire-name { font-weight: 620; font-size: 16px; }
.badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.badge.on { background: color-mix(in srgb, var(--ok) 14%, transparent); border-color: transparent; color: var(--ok); }

.bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 12px 0 8px; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--ok); transition: width .3s; }
.bar > i.warn { background: var(--warn); }
.bar > i.bad  { background: var(--bad); }

.tire-meta { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.tire-meta b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---- forms ---- */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
input, select, button {
  font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; width: 100%;
}
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 12px; margin-bottom: 12px; }
button { background: var(--accent); color: #fff; border: 0; font-weight: 600; cursor: pointer; }
button:hover { filter: brightness(1.07); }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); font-weight: 500; }
details > summary { cursor: pointer; color: var(--accent); font-size: 14px; font-weight: 550; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details[open] > summary { margin-bottom: 14px; }

.msg { font-size: 13px; padding: 9px 12px; border-radius: 9px; margin-top: 10px; }
.msg.err { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
.msg.ok  { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); }

.foot { color: var(--muted); font-size: 12px; text-align: center; margin-top: 26px; }
.hidden { display: none !important; }

#login { max-width: 360px; margin: 12vh auto; }

.empty { color: var(--muted); font-size: 13px; margin: 4px 0 2px; line-height: 1.55; }
