/* GauGer — iOS-flavoured design tokens and components (no framework). */
:root {
  color-scheme: light dark;
  --bg: #f2f2f7;
  --bg-elev: #ffffff;
  --bg-elev2: #f2f2f7;
  --label: #000000;
  --secondary: rgba(60, 60, 67, 0.6);
  --tertiary: rgba(60, 60, 67, 0.3);
  --separator: rgba(60, 60, 67, 0.29);
  --fill: rgba(120, 120, 128, 0.12);
  --tint: #007aff;
  --tint-soft: rgba(0, 122, 255, 0.12);
  --green: #34c759; --orange: #ff9500; --red: #ff3b30; --purple: #af52de; --teal: #30b0c7; --yellow: #ffcc00; --gray: #8e8e93; --indigo: #5856d6; --mint: #00c7be;
  --bar: rgba(249, 249, 249, 0.94);
  --radius: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 50px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --bg-elev: #1c1c1e; --bg-elev2: #2c2c2e; --label: #ffffff;
    --secondary: rgba(235, 235, 245, 0.6); --tertiary: rgba(235, 235, 245, 0.3); --separator: rgba(84, 84, 88, 0.65);
    --fill: rgba(120, 120, 128, 0.24); --tint: #0a84ff; --tint-soft: rgba(10, 132, 255, 0.2);
    --green: #30d158; --orange: #ff9f0a; --red: #ff453a; --purple: #bf5af2; --teal: #40c8e0; --yellow: #ffd60a; --gray: #8e8e93; --indigo: #5e5ce6; --mint: #63e6e2;
    --bar: rgba(29, 29, 31, 0.94);
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --bg-elev: #1c1c1e; --bg-elev2: #2c2c2e; --label: #ffffff;
  --secondary: rgba(235, 235, 245, 0.6); --tertiary: rgba(235, 235, 245, 0.3); --separator: rgba(84, 84, 88, 0.65);
  --fill: rgba(120, 120, 128, 0.24); --tint: #0a84ff; --tint-soft: rgba(10, 132, 255, 0.2); --bar: rgba(29, 29, 31, 0.94);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--label);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 17px; line-height: 1.3; overscroll-behavior-y: none;
}
body.sheet-open { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--tint); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--secondary); }
.small { font-size: 13px; }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- Layout ---------- */
#app { min-height: 100vh; padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 24px); }
.page { max-width: 680px; margin: 0 auto; padding: 0 16px; }
.page-header { padding-top: calc(var(--safe-top) + 6px); padding-bottom: 4px; }
.page-header-row { display: flex; justify-content: space-between; align-items: center; min-height: 44px; }
.large-title { font-size: 34px; font-weight: 700; letter-spacing: 0.37px; margin: 2px 0 4px; line-height: 1.2; }
.page-subtitle { color: var(--secondary); font-size: 15px; margin-bottom: 8px; }
.nav-btn { background: none; border: 0; color: var(--tint); font-size: 17px; padding: 8px 4px; min-height: 44px; min-width: 44px; }
.nav-btn.bold { font-weight: 600; }
.nav-btn.back { padding-left: 0; }
.nav-btn:disabled { opacity: 0.4; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; background: var(--fill); display: inline-flex; align-items: center; justify-content: center; border: 0; color: var(--tint); font-size: 20px; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  height: calc(var(--tabbar-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--separator); display: flex; justify-content: center;
}
.tabbar-inner { display: flex; width: 100%; max-width: 680px; }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: none; color: var(--gray); font-size: 10px; font-weight: 500; padding: 4px 0 0; }
.tab svg { width: 26px; height: 26px; fill: currentColor; }
.tab.active { color: var(--tint); }

/* ---------- Grouped lists ---------- */
.group { margin: 18px 0 8px; }
.group-title { font-size: 13px; color: var(--secondary); text-transform: uppercase; letter-spacing: 0.04em; padding: 0 16px 7px; }
.group-body { background: var(--bg-elev); border-radius: var(--radius); overflow: hidden; }
.group-footer { font-size: 13px; color: var(--secondary); padding: 7px 16px 0; }
.row { position: relative; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 10px 16px; }
.row:not(:last-child)::after { content: ""; position: absolute; left: 16px; right: 0; bottom: 0; height: 0.5px; background: var(--separator); }
.row.tappable { cursor: pointer; }
.row.tappable:active { background: var(--fill); }
.row.danger .row-label { color: var(--red); }
.row.center { justify-content: center; }
.row.center .row-label { color: var(--tint); }
.row-icon { width: 30px; height: 30px; border-radius: 7px; background: var(--tint); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; flex: none; }
.row-text { flex: 1; min-width: 0; }
.row-label { font-size: 17px; }
.row-sub { font-size: 13px; color: var(--secondary); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-value { color: var(--secondary); font-size: 17px; text-align: right; flex: none; font-variant-numeric: tabular-nums; }
.row-value strong { color: var(--label); }
.chevron::after { content: "›"; color: var(--tertiary); font-size: 22px; line-height: 1; margin-left: -4px; }
.row-control { flex: none; }

/* ---------- Form fields ---------- */
.row.field .row-label { flex: 0 0 auto; min-width: 40%; }
.field-input { flex: 1; min-width: 0; text-align: right; border: 0; background: transparent; padding: 6px 0; outline: none; font-variant-numeric: tabular-nums; -webkit-appearance: none; appearance: none; }
.field-input::placeholder { color: var(--tertiary); }
select.field-input { text-align: right; direction: rtl; padding-right: 0; }
select.field-input option { direction: ltr; }
.field-wrap { flex: 1; display: flex; align-items: center; justify-content: flex-end; gap: 6px; min-width: 0; }
.field-suffix { color: var(--secondary); font-size: 15px; flex: none; }
textarea.field-input { text-align: left; resize: none; min-height: 60px; }
input[type="range"].field-input { padding: 0; accent-color: var(--tint); }
.row.stacked { flex-direction: column; align-items: stretch; gap: 6px; }
.row.stacked .row-label { font-size: 15px; color: var(--secondary); }

/* ---------- Buttons ---------- */
.btn { border: 0; border-radius: var(--radius); min-height: 50px; padding: 0 18px; font-size: 17px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.primary { background: var(--tint); color: #fff; }
.btn.secondary { background: var(--tint-soft); color: var(--tint); }
.btn.plain { background: transparent; color: var(--tint); }
.btn.danger { background: transparent; color: var(--red); }
.btn.block { width: 100%; }
.btn.small { min-height: 34px; font-size: 15px; padding: 0 12px; border-radius: 9px; }
.inline-link { background: none; border: 0; color: var(--tint); font-size: 15px; padding: 0 0 0 6px; white-space: nowrap; }
.btn:active { opacity: 0.7; }
.btn:disabled { opacity: 0.5; }
.btn-row { display: flex; gap: 10px; margin: 12px 0; }
.btn-row .btn { flex: 1; }
.chip { border: 0; border-radius: 999px; background: var(--fill); color: var(--label); font-size: 15px; font-weight: 600; padding: 7px 14px; min-height: 34px; margin: 2px 0 10px; }
.chip.active { background: var(--tint-soft); color: var(--tint); }
.badge { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 2px 8px; background: var(--fill); color: var(--secondary); }
.badge.red { background: rgba(255, 59, 48, 0.15); color: var(--red); }
.badge.green { background: rgba(52, 199, 89, 0.15); color: var(--green); }
.badge.orange { background: rgba(255, 149, 0, 0.15); color: var(--orange); }
.badge.blue { background: var(--tint-soft); color: var(--tint); }

/* ---------- Segmented control ---------- */
.segmented { display: flex; background: var(--fill); border-radius: 9px; padding: 2px; margin: 8px 0; }
.seg { flex: 1; border: 0; background: transparent; border-radius: 7px; min-height: 32px; font-size: 13px; font-weight: 500; color: var(--label); }
.seg.active { background: var(--bg-elev); box-shadow: 0 1px 3px rgba(0,0,0,0.12); font-weight: 600; }

/* ---------- Stats & cards ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.stat { background: var(--bg-elev); border-radius: var(--radius); padding: 12px 12px 10px; min-width: 0; }
.stat-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-label { font-size: 12px; color: var(--secondary); margin-top: 2px; }
.stat-sub { font-size: 11px; color: var(--tertiary); }
.card { background: var(--bg-elev); border-radius: 16px; padding: 16px; margin: 12px 0; }
.card.hero { background: linear-gradient(135deg, var(--tint), #5856d6); color: #fff; }
.card.hero .muted { color: rgba(255,255,255,0.75); }
.hero-big { font-size: 44px; font-weight: 800; letter-spacing: -1px; line-height: 1; font-variant-numeric: tabular-nums; }
.hero-big small { font-size: 18px; font-weight: 600; letter-spacing: 0; }
.vehicle-card { background: var(--bg-elev); border-radius: 16px; padding: 16px; margin: 12px 0; cursor: pointer; }
.vehicle-card:active { opacity: 0.8; }
.vc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.vc-name { font-size: 20px; font-weight: 700; line-height: 1.2; }
.vc-meta { font-size: 13px; color: var(--secondary); margin-top: 2px; }
.vc-big { font-size: 30px; font-weight: 800; letter-spacing: -0.5px; text-align: right; line-height: 1; font-variant-numeric: tabular-nums; }
.vc-big small { font-size: 13px; font-weight: 500; color: var(--secondary); letter-spacing: 0; }
.vc-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.vc-actions { display: flex; gap: 6px; margin-top: 12px; }
.vc-actions .btn { flex: 1; min-height: 44px; font-size: 15px; padding: 0 8px; white-space: nowrap; }
.pt-icon { width: 40px; height: 40px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; font-size: 20px; color: #fff; flex: none; }
.pt-ev { background: var(--green); } .pt-ice { background: var(--orange); }

.stack-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--fill); margin: 10px 0 4px; }
.stack-bar > span { display: block; height: 100%; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: middle; }
.c-depreciation { background: var(--purple); } .c-financing { background: var(--indigo); } .c-insurance { background: var(--tint); } .c-registration { background: var(--teal); }
.c-repairs { background: var(--orange); } .c-other { background: var(--gray); } .c-energy { background: var(--green); } .c-tires { background: var(--mint); } .c-maintenance { background: var(--yellow); }

.empty { text-align: center; padding: 48px 16px 24px; color: var(--secondary); }
.empty-icon { font-size: 52px; margin-bottom: 8px; }
.empty-title { font-size: 20px; font-weight: 700; color: var(--label); margin-bottom: 4px; }
.empty-text { font-size: 15px; margin-bottom: 16px; }

/* ---------- Sheets ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.4); opacity: 0; transition: opacity 0.22s; z-index: 100; }
.scrim.open { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 101; max-height: 92vh; display: flex; flex-direction: column;
  background: var(--bg); border-radius: 14px 14px 0 0; transform: translateY(100%); transition: transform 0.22s ease-out;
  box-shadow: 0 -8px 30px rgba(0,0,0,0.2); margin: 0 auto; max-width: 720px;
}
.sheet.open { transform: translateY(0); }
.sheet.tall { height: 92vh; }
.sheet-handle { width: 36px; height: 5px; border-radius: 3px; background: var(--tertiary); margin: 6px auto 0; flex: none; }
.sheet-nav { display: flex; justify-content: space-between; align-items: center; padding: 0 12px; min-height: 44px; flex: none; }
.sheet-title { font-weight: 600; font-size: 17px; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 16px calc(24px + var(--safe-bottom)); flex: 1; min-height: 0; overscroll-behavior: contain; }
.sheet-body .group:first-child { margin-top: 4px; }

.action-sheet { position: fixed; left: 8px; right: 8px; bottom: calc(8px + var(--safe-bottom)); z-index: 101; transform: translateY(120%); transition: transform 0.22s ease-out; max-width: 500px; margin: 0 auto; }
.action-sheet.open { transform: translateY(0); }
.action-group { background: var(--bg-elev); border-radius: 14px; overflow: hidden; margin-top: 8px; }
.action-title { padding: 14px 16px; text-align: center; font-size: 13px; color: var(--secondary); border-bottom: 0.5px solid var(--separator); }
.action { display: block; width: 100%; border: 0; background: transparent; min-height: 57px; font-size: 20px; color: var(--tint); }
.action:not(:last-child) { border-bottom: 0.5px solid var(--separator); }
.action.destructive { color: var(--red); }
.action.bold { font-weight: 600; }
.action.selected { font-weight: 600; }

.toast { position: fixed; top: calc(var(--safe-top) + 12px); left: 50%; transform: translate(-50%, -20px); opacity: 0; background: var(--label); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: 15px; font-weight: 500; z-index: 200; transition: all 0.25s; max-width: calc(100% - 32px); text-align: center; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.error { background: var(--red); color: #fff; }

/* ---------- Auth ---------- */
.auth { max-width: 400px; margin: 0 auto; padding: calc(var(--safe-top) + 48px) 20px 40px; }
.auth-logo { width: 84px; height: 84px; border-radius: 20px; display: block; margin: 0 auto 16px; }
.auth h1 { text-align: center; font-size: 30px; margin: 0 0 2px; }
.auth .tagline { text-align: center; color: var(--secondary); margin-bottom: 24px; }
.auth .error { color: var(--red); font-size: 14px; text-align: center; margin-top: 10px; }

/* ---------- Misc ---------- */
.item-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 16px; }
.item-chip { border: 0; border-radius: 999px; background: var(--fill); padding: 7px 12px; font-size: 14px; font-weight: 500; }
.item-chip.on { background: var(--tint); color: #fff; }
.month-title { font-size: 13px; color: var(--secondary); text-transform: uppercase; letter-spacing: 0.04em; padding: 18px 16px 6px; }
table.compare { width: 100%; border-collapse: collapse; font-size: 14px; }
table.compare th, table.compare td { padding: 8px 6px; text-align: right; border-bottom: 0.5px solid var(--separator); white-space: nowrap; }
table.compare th:first-child, table.compare td:first-child { text-align: left; }
.sources li { font-size: 12px; word-break: break-all; }
@media (min-width: 720px) { .large-title { font-size: 38px; } }
@media (prefers-reduced-motion: reduce) { .sheet, .scrim, .toast, .action-sheet { transition: none; } }

/* ---------- Charts ---------- */
.stats-2 { grid-template-columns: repeat(2, 1fr); }
.chart-card { padding: 14px 14px 10px; }
.chart-title { font-size: 13px; font-weight: 600; color: var(--secondary); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }
.chart { position: relative; }
.chart-svg { width: 100%; height: auto; display: block; touch-action: pan-y; }
.chart-svg .grid { stroke: var(--separator); stroke-width: 0.5; }
.chart-svg .axis { font-size: 9px; fill: var(--secondary); font-family: inherit; }
.chart-svg .axis.mid { text-anchor: middle; }
.chart-svg .series { fill: none; stroke: var(--tint); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .dot { fill: var(--bg-elev); stroke: var(--tint); stroke-width: 2; }
.chart-svg .dot.hot { fill: var(--tint); r: 5; }
.chart-svg .label { font-size: 10px; font-weight: 600; fill: var(--label); font-family: inherit; }
.chart-svg .label.end { text-anchor: end; }
.chart-svg .crosshair { stroke: var(--secondary); stroke-width: 1; stroke-dasharray: 2 3; }
.chart-svg .bar { fill: var(--tint); opacity: 0.85; }
.chart-svg .bar.hot { opacity: 1; }
.chart-tip { position: absolute; top: 0; background: var(--label); color: var(--bg); font-size: 12px; font-weight: 500; padding: 5px 9px; border-radius: 8px; pointer-events: none; white-space: nowrap; }
