:root {
  --bg: #0b0c0e;
  --surface: #15171b;
  --surface-2: #1e2126;
  --surface-3: #272b31;
  --line: #2b2f36;
  --text: #f2f3f5;
  --muted: #9aa1ac;
  --faint: #6b717b;
  --ok: #34c759;
  --soon: #ff9f0a;
  --late: #ff453a;
  --unknown: #8e8e93;
  --accent: #c8f31d;
  --on-accent: #0b0c0e;
  --radius: 16px;
  --tabbar-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, system-ui, sans-serif;
}

html[data-accent="bleu"] { --accent: #4d82ff; --on-accent: #ffffff; }
html[data-accent="cyan"] { --accent: #2fd5f0; --on-accent: #0b0c0e; }
html[data-accent="blanc"] { --accent: #e9eaec; --on-accent: #0b0c0e; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

body { min-height: 100dvh; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; }
.num { font-variant-numeric: tabular-nums; }

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 12px) 16px calc(var(--tabbar-h) + var(--safe-bottom) + 24px);
}
.view:focus { outline: none; }

/* ---------- Header ---------- */
.top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 2px 16px;
}
.top h1 { margin: 0; font-size: 30px; line-height: 1.1; letter-spacing: -0.02em; font-weight: 800; }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.top-actions { display: flex; gap: 8px; }
.back {
  display: inline-flex; align-items: center; gap: 2px;
  background: none; border: 0; padding: 6px 0; color: var(--accent); font-weight: 600; font-size: 16px;
}
.back svg { width: 22px; height: 22px; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2); border: 0; color: var(--text);
}
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 700; margin: 0; }
.link { background: none; border: 0; padding: 4px 0; color: var(--accent); font-weight: 600; font-size: 15px; }

.section-title {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 24px 2px 10px; font-size: 20px; font-weight: 700; letter-spacing: -0.01em;
}
.section-title .link { font-size: 15px; }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.strong { font-weight: 700; }
.mt8 { margin-top: 8px; }
.mt12 { margin-top: 12px; }
.mt16 { margin-top: 16px; }
.center { text-align: center; }

/* ---------- Odometer ---------- */
.odo { position: relative; overflow: hidden; }
.odo::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 180px; height: 180px;
  border-radius: 50%; border: 18px solid var(--accent); opacity: 0.08; pointer-events: none;
}
.odo-value { font-size: 46px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; margin: 2px 0 6px; font-variant-numeric: tabular-nums; }
.odo-value span { font-size: 20px; color: var(--muted); font-weight: 600; letter-spacing: 0; margin-left: 4px; }
.odo-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 12px; border: 0;
  background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 16px;
  transition: transform .08s ease, opacity .15s;
}
.btn:active { transform: scale(0.97); }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.block { width: 100%; }
.btn.danger { background: rgba(255, 69, 58, 0.14); color: var(--late); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.sm { min-height: 36px; padding: 0 14px; font-size: 14px; border-radius: 10px; }
.btn-row { display: flex; gap: 10px; }
.btn-row > * { flex: 1; }

/* ---------- Pills / chips ---------- */
.pills { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px; font-size: 14px; font-weight: 600;
  background: var(--surface); border: 0; color: var(--text);
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); font-size: 14px; font-weight: 600;
}
.chip.on { background: var(--text); border-color: var(--text); color: var(--bg); }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--surface-3); color: var(--muted); }

.seg { display: flex; background: var(--surface); border-radius: 12px; padding: 3px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: transparent; color: var(--muted); padding: 8px; border-radius: 9px; font-weight: 600; font-size: 14px; }
.seg button.on { background: var(--surface-3); color: var(--text); }

/* ---------- State colours ---------- */
.s-ok { --s: var(--accent); }
.s-soon { --s: var(--soon); }
.s-late { --s: var(--late); }
.s-unknown, .s-track, .s-off { --s: var(--unknown); }
.state-text { color: var(--s); font-weight: 700; }
.dot { background: var(--s, var(--unknown)); }

.bar { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: var(--s, var(--accent)); }

/* ---------- Lists ---------- */
.list { background: var(--surface); border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; }
.row {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 14px 16px; position: relative;
}
.row + .row::before { content: ""; position: absolute; left: 16px; right: 0; top: 0; height: 1px; background: var(--line); }
.row:active { background: var(--surface-2); }
.row-main { display: flex; align-items: center; gap: 12px; }
.row-text { flex: 1; min-width: 0; }
.row-title { font-weight: 600; font-size: 16px; line-height: 1.3; }
.row-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.row-right { text-align: right; flex: none; font-size: 14px; }
.row .bar { margin-top: 10px; }
.chev { color: var(--faint); width: 18px; height: 18px; flex: none; }
.row-group { margin: 18px 2px 8px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; display: flex; justify-content: space-between; }

.empty { text-align: center; padding: 28px 16px; color: var(--muted); }
.empty svg { width: 36px; height: 36px; margin: 0 auto 10px; color: var(--faint); }

/* ---------- Chain gauge ---------- */
.gauge-wrap { display: flex; align-items: center; gap: 16px; }
.ring { position: relative; width: 92px; height: 92px; flex: none; }
.ring svg { width: 92px; height: 92px; transform: rotate(-90deg); }
.ring .track { stroke: var(--surface-3); }
.ring .val { stroke: var(--s); transition: stroke-dashoffset .5s ease; }
.ring-label { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; line-height: 1.1; }
.ring-label b { font-size: 20px; font-variant-numeric: tabular-nums; }
.ring-label small { display: block; font-size: 11px; color: var(--muted); font-weight: 600; }
.ring.big { width: 140px; height: 140px; }
.ring.big svg { width: 140px; height: 140px; }
.ring.big .ring-label b { font-size: 30px; }

/* ---------- Tyres ---------- */
.tyre-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tyre-mini { background: var(--surface-2); border-radius: 12px; padding: 12px; border: 0; text-align: left; color: var(--text); }
.tyre-mini .lbl { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.tyre-mini .val { font-size: 20px; font-weight: 700; margin: 4px 0 8px; font-variant-numeric: tabular-nums; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.stat { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; }
.stat .lbl { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat .val { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; margin-top: 2px; font-variant-numeric: tabular-nums; }

.banner {
  display: flex; gap: 12px; align-items: flex-start;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; font-size: 14px;
}
.banner svg { width: 22px; height: 22px; flex: none; color: var(--accent); margin-top: 1px; }
.banner.warn { background: rgba(255, 159, 10, 0.1); border-color: rgba(255, 159, 10, 0.35); }
.banner.warn svg { color: var(--soon); }
.banner .x { margin-left: auto; background: none; border: 0; color: var(--muted); padding: 0 0 0 8px; font-size: 20px; line-height: 1; }

.allgood { display: flex; align-items: center; gap: 12px; padding: 16px; }
.allgood .ic { width: 40px; height: 40px; border-radius: 50%; background: rgba(52, 199, 89, 0.15); color: var(--ok); display: grid; place-items: center; }
.allgood .ic svg { width: 22px; height: 22px; }

/* ---------- Chart ---------- */
.chart { width: 100%; height: 180px; }
.chart text { fill: var(--faint); font-size: 10px; font-family: var(--font); }

/* ---------- Forms ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 48px; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font-size: 16px; outline: none; -webkit-appearance: none; appearance: none;
}
textarea.input { min-height: 90px; resize: vertical; line-height: 1.4; }
select.input {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 21px, calc(100% - 15px) 21px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px;
}
.input:focus { border-color: var(--accent); }
input[type="date"].input { display: block; }
.input-big { font-size: 32px; font-weight: 800; text-align: center; letter-spacing: -0.02em; min-height: 64px; font-variant-numeric: tabular-nums; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.suffix { position: relative; }
.suffix .input { padding-right: 46px; }
.suffix em { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--muted); font-size: 15px; pointer-events: none; }
.input-big + em { font-size: 18px; }

.check {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px;
  background: var(--surface-2); margin-bottom: 8px; font-size: 15px;
}
.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; margin: 0; }
.check small { display: block; color: var(--muted); font-size: 12px; }
.checklist { max-height: 260px; overflow-y: auto; margin-bottom: 14px; }
.form-error { color: var(--late); font-size: 14px; margin: -4px 0 12px; }
.hint { font-size: 13px; color: var(--muted); margin: -6px 0 14px; }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; }
.switch input { appearance: none; -webkit-appearance: none; width: 50px; height: 30px; border-radius: 15px; background: var(--surface-3); position: relative; transition: background .2s; flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; left: 2px; top: 2px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { transform: translateX(20px); }

.swatches { display: flex; gap: 12px; }
.swatch { width: 40px; height: 40px; border-radius: 50%; border: 3px solid transparent; }
.swatch.on { border-color: var(--text); }

/* ---------- Sheet ---------- */
.sheet-root { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); animation: fade .2s ease; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px;
  max-height: calc(100dvh - var(--safe-top) - 24px);
  background: var(--surface); border-radius: 22px 22px 0 0;
  display: flex; flex-direction: column; animation: up .26s cubic-bezier(.2, .8, .2, 1);
}
.sheet-grip { width: 38px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 8px auto 0; flex: none; }
.sheet-body { overflow-y: auto; padding: 8px 16px calc(var(--safe-bottom) + 20px); -webkit-overflow-scrolling: touch; }
.sheet-body h2 { font-size: 22px; margin: 8px 0 4px; letter-spacing: -0.01em; }
.sheet-body .sub { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.sheet-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
@keyframes up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: center;
  padding: 6px 8px calc(var(--safe-bottom) + 6px);
  background: rgba(16, 17, 20, 0.86);
  -webkit-backdrop-filter: saturate(160%) blur(18px); backdrop-filter: saturate(160%) blur(18px);
  border-top: 1px solid var(--line);
}
.tabbar-inner { display: flex; width: 100%; max-width: 560px; }
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  border: 0; background: none; color: var(--faint); font-size: 11px; font-weight: 600; padding: 6px 0;
  position: relative;
}
.tab svg { width: 24px; height: 24px; }
.tab.on { color: var(--accent); }
.tab .badge {
  position: absolute; top: 2px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: 9px; background: var(--late); color: #fff; font-size: 11px; font-weight: 700; line-height: 17px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 60;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 14px);
  background: var(--text); color: var(--bg); border-radius: 14px; padding: 12px 16px;
  font-weight: 600; font-size: 15px; display: flex; gap: 14px; align-items: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); max-width: calc(100vw - 32px); width: max-content;
  animation: fade .2s ease; pointer-events: none;
}
.toast button { background: none; border: 0; color: var(--bg); font-weight: 800; text-decoration: underline; padding: 0; pointer-events: auto; }

/* ---------- Onboarding ---------- */
.welcome { padding-top: 24px; }
.welcome .logo { width: 84px; height: 84px; border-radius: 20px; margin-bottom: 18px; }
.welcome h1 { font-size: 34px; line-height: 1.1; margin: 0 0 8px; letter-spacing: -0.02em; font-weight: 800; }
.welcome p.lead { color: var(--muted); margin: 0 0 24px; }

.spec h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin: 0 0 10px; }
.spec .kv { font-size: 15px; gap: 9px 14px; }

@media (min-width: 600px) {
  .app { padding-top: calc(var(--safe-top) + 24px); }
}

/* ---------- Ajouts : sheets, guide pneus ---------- */
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-head h2 { margin: 8px 0 4px; }

.press-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.press-grid > div { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; }
.press-grid .lbl { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.press { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; margin-top: 4px; font-variant-numeric: tabular-nums; }
.press small { font-size: 15px; color: var(--muted); font-weight: 600; letter-spacing: 0; }
.psi { color: var(--accent); font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }

.ptable { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
.ptable th { text-align: right; font-size: 12px; color: var(--muted); font-weight: 700; padding: 0 0 8px; }
.ptable td { padding: 8px 0; border-top: 1px solid var(--line); text-align: right; font-weight: 700; }
.ptable td:first-child { text-align: left; color: var(--muted); font-weight: 600; }
.ptable td small { display: block; font-size: 12px; color: var(--accent); font-weight: 600; }

.tips { margin: 14px 0 0; padding-left: 18px; font-size: 14px; color: var(--muted); }
.tips li + li { margin-top: 6px; }
.tips b { color: var(--text); }

.conv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.conv > div { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; display: flex; justify-content: space-between; align-items: baseline; font-variant-numeric: tabular-nums; font-size: 14px; }
.conv span { color: var(--muted); font-size: 13px; }
.conv .on { outline: 2px solid var(--accent); outline-offset: -2px; }
.conv .on span { color: var(--accent); font-weight: 700; }

.guide-group + .guide-group { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.models { list-style: none; margin: 10px 0 0; padding: 0; }
.models li { display: flex; flex-direction: column; padding: 8px 0; border-top: 1px solid var(--line); font-size: 15px; }
.models li:first-child { border-top: 0; }
.models span { font-size: 13px; color: var(--muted); }
