/* ==========================================================================
   Buku Rekod — "Premium Personal Utility" design system (from the Stitch export)

   Mobile first: every screen is laid out for a ~390px phone and the content
   column simply stops growing at --shell-max on larger screens, so the app
   keeps its one-handed ergonomics on a desktop instead of stretching.

   Tokens first (light, then dark), then base elements, shared components,
   and finally one block per screen.
   ========================================================================== */

:root {
  color-scheme: light;

  /* Canvas & surfaces */
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;      /* embedded containers: inputs, inner panels */
  --surface-3: #e2e8f0;
  --tint: #ebf5fc;           /* active tab, selected rows */
  --tint-strong: #d1e4ff;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;

  /* Text */
  --ink: #0f172a;
  --muted: #64748b;
  --subtle: #94a3b8;

  /* Brand */
  --primary: #0f6fb8;        /* fills: buttons, FAB, active chips */
  --primary-hover: #005692;
  --primary-bright: #1689df;
  --primary-ink: #0f6fb8;    /* brand-coloured text and icons */
  --on-primary: #ffffff;

  /* Status: text / fill / edge / solid (stripes, dots) */
  --danger: #b91c1c;
  --danger-fill: #fef2f2;
  --danger-edge: #fecaca;
  --danger-solid: #ef4444;
  --warn: #b45309;
  --warn-fill: #fffbeb;
  --warn-edge: #fde68a;
  --warn-solid: #f59e0b;
  --ok: #047857;
  --ok-fill: #ecfdf5;
  --ok-edge: #a7f3d0;
  --ok-solid: #10b981;

  /* Type */
  --font-display: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Shape */
  --radius-sm: 8px;
  --radius: 10px;            /* buttons, inputs */
  --radius-lg: 14px;         /* cards */
  --radius-xl: 20px;         /* sheets */
  --radius-full: 9999px;

  /* Elevation */
  --shadow-1: 0 1px 3px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.02);
  --shadow-2: 0 4px 12px rgba(15, 111, 184, 0.14), 0 2px 4px rgba(15, 23, 42, 0.05);
  --shadow-3: 0 -8px 24px rgba(15, 23, 42, 0.08);
  --shadow-pop: 0 12px 32px rgba(15, 23, 42, 0.14), 0 2px 6px rgba(15, 23, 42, 0.06);
  --scrim: rgba(15, 23, 42, 0.4);

  /* Motion */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur: 200ms;
  --press: scale(0.98);

  /* Layout */
  --shell-max: 560px;
  --gutter: 16px;
  --topbar-h: 56px;
  --nav-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f141c;
    --surface: #171c24;
    --surface-2: #1f2530;
    --surface-3: #2a313c;
    --tint: rgba(46, 149, 236, 0.16);
    --tint-strong: rgba(46, 149, 236, 0.28);
    --line: #262d38;
    --line-strong: #353d4a;
    --ink: #e6e9f2;
    --muted: #9aa4b5;
    --subtle: #6b7587;
    --primary: #1a73bf;
    --primary-hover: #2582d3;
    --primary-bright: #2e95ec;
    --primary-ink: #9ecaff;
    --danger: #fca5a5;
    --danger-fill: rgba(239, 68, 68, 0.14);
    --danger-edge: rgba(239, 68, 68, 0.35);
    --warn: #fcd34d;
    --warn-fill: rgba(245, 158, 11, 0.14);
    --warn-edge: rgba(245, 158, 11, 0.35);
    --ok: #6ee7b7;
    --ok-fill: rgba(16, 185, 129, 0.14);
    --ok-edge: rgba(16, 185, 129, 0.35);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-2: 0 6px 16px rgba(0, 0, 0, 0.4);
    --shadow-3: 0 -8px 24px rgba(0, 0, 0, 0.4);
    --shadow-pop: 0 14px 36px rgba(0, 0, 0, 0.5);
    --scrim: rgba(0, 0, 0, 0.55);
  }
}

/* Dark chosen in Settings → Appearance, whatever the phone is set to. Keep
   these tokens identical to the prefers-color-scheme block above. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f141c;
  --surface: #171c24;
  --surface-2: #1f2530;
  --surface-3: #2a313c;
  --tint: rgba(46, 149, 236, 0.16);
  --tint-strong: rgba(46, 149, 236, 0.28);
  --line: #262d38;
  --line-strong: #353d4a;
  --ink: #e6e9f2;
  --muted: #9aa4b5;
  --subtle: #6b7587;
  --primary: #1a73bf;
  --primary-hover: #2582d3;
  --primary-bright: #2e95ec;
  --primary-ink: #9ecaff;
  --danger: #fca5a5;
  --danger-fill: rgba(239, 68, 68, 0.14);
  --danger-edge: rgba(239, 68, 68, 0.35);
  --warn: #fcd34d;
  --warn-fill: rgba(245, 158, 11, 0.14);
  --warn-edge: rgba(245, 158, 11, 0.35);
  --ok: #6ee7b7;
  --ok-fill: rgba(16, 185, 129, 0.14);
  --ok-edge: rgba(16, 185, 129, 0.35);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 6px 16px rgba(0, 0, 0, 0.4);
  --shadow-3: 0 -8px 24px rgba(0, 0, 0, 0.4);
  --shadow-pop: 0 14px 36px rgba(0, 0, 0, 0.5);
  --scrim: rgba(0, 0, 0, 0.55);
}

/* ---- Base ---- */

* {
  box-sizing: border-box;
}

/* Keep the hidden attribute authoritative — class rules that set `display`
   (e.g. .app-shell, .app-loading, .chips) would otherwise override it and
   leave "hidden" elements visible. */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--primary-ink);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  color: var(--ink);
}

svg {
  flex: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--primary-bright);
  outline-offset: 2px;
}

/* ---- App frame ---- */

.app-shell {
  width: 100%;
  max-width: var(--shell-max);
  margin: 0 auto;
  padding:
    calc(var(--topbar-h) + var(--safe-top) + 12px)
    var(--gutter)
    calc(var(--nav-h) + var(--safe-bottom) + 32px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Pages with a floating action button keep the last card clear of it. */
.app-shell.has-fab {
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 96px);
}

/* Pages with a sticky save bar reserve room for it above the tabs. */
.app-shell.has-action-bar {
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 104px);
}

.app-loading {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
}

.app-loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--line);
  border-top-color: var(--primary-bright);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Topbar: fixed, frosted, 56px. Lead button · title · page actions. */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 960;
  padding-top: var(--safe-top);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  backdrop-filter: saturate(1.6) blur(16px);
  box-shadow: 0 1px 0 var(--line);
}

.topbar-inner {
  max-width: var(--shell-max);
  height: var(--topbar-h);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-title {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar-actions:empty {
  display: none;
}

/* App icon + chevron: opens the launcher. */
.brand {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 44px;
  margin-left: -6px;
  padding: 4px 6px 4px 4px;
  border: 0;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--primary-ink);
  touch-action: manipulation;
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}

.brand:hover {
  background: var(--surface-3);
}

.brand:active {
  transform: var(--press);
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: block;
}

.brand-chevron {
  width: 18px;
  height: 18px;
}

.icon-back,
.icon-button {
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  color: var(--ink);
  display: grid;
  place-items: center;
  text-decoration: none;
  touch-action: manipulation;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.icon-back {
  margin-left: -4px;
}

.icon-back:hover,
.icon-button:hover {
  background: var(--surface-3);
}

.icon-back:active,
.icon-button:active {
  transform: var(--press);
}

.icon-back svg,
.icon-button svg {
  width: 20px;
  height: 20px;
}

/* Bottom tab bar: 64px + safe area, active tab gets a tinted pill. */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 950;
  padding-bottom: var(--safe-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  backdrop-filter: saturate(1.6) blur(16px);
  box-shadow: 0 -1px 0 var(--line);
}

.bottom-nav-inner {
  max-width: var(--shell-max);
  height: var(--nav-h);
  margin: 0 auto;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-around;
}

.bottom-nav-tab {
  flex: 1 1 0;
  max-width: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  touch-action: manipulation;
  transition: color var(--dur) var(--ease);
}

.bottom-nav-icon {
  display: grid;
  place-items: center;
  width: 60px;
  height: 30px;
  border-radius: var(--radius-full);
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.bottom-nav-icon svg {
  width: 22px;
  height: 22px;
  display: block;
}

.bottom-nav-tab:hover {
  color: var(--ink);
}

.bottom-nav-tab:active .bottom-nav-icon {
  transform: scale(0.94);
}

.bottom-nav-tab.is-active {
  color: var(--primary-ink);
}

.bottom-nav-tab.is-active .bottom-nav-icon {
  background: var(--tint);
}

.bottom-nav-label {
  line-height: 1;
}

/* ---- Typography helpers ---- */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.page-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 26px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.page-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.section {
  display: grid;
  gap: 12px;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.section-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.group-label {
  margin: 8px 4px -4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.label-caps {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
}

.hint {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.hint svg {
  width: 14px;
  height: 14px;
  margin-top: 1px;
}

/* Big tabular readouts: odometer, cost, counts. */
.metric {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.metric small {
  margin-left: 4px;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.5em;
  font-weight: 600;
  letter-spacing: 0;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

/* ---- Cards ---- */

.card,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  padding: 16px;
}

.card-flush {
  padding: 0;
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.card-head-text {
  flex: 1 1 auto;
  min-width: 0;
}

.card-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card-sub {
  margin-top: 1px;
  color: var(--muted);
  font-size: 13px;
}

/* Small square icon tile used in card heads and list rows. */
.icon-tile {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--tint);
  color: var(--primary-ink);
}

.icon-tile svg {
  width: 20px;
  height: 20px;
}

.icon-tile-sm {
  width: 32px;
  height: 32px;
  border-radius: 10px;
}

.icon-tile-sm svg {
  width: 17px;
  height: 17px;
}

.icon-tile.is-overdue { background: var(--danger-fill); color: var(--danger); }
.icon-tile.is-due-soon { background: var(--warn-fill); color: var(--warn); }
.icon-tile.is-ok { background: var(--ok-fill); color: var(--ok); }
.icon-tile.is-solid { background: var(--primary); color: var(--on-primary); }

/* ---- Pills, tags, counters ---- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 24px;
  padding: 2px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.pill svg {
  width: 14px;
  height: 14px;
}

.pill-overdue { background: var(--danger-fill); border-color: var(--danger-edge); color: var(--danger); }
.pill-due-soon { background: var(--warn-fill); border-color: var(--warn-edge); color: var(--warn); }
.pill-ok { background: var(--ok-fill); border-color: var(--ok-edge); color: var(--ok); }
.pill-primary { background: var(--tint); color: var(--primary-ink); }
.pill-solid { background: var(--primary); color: var(--on-primary); }

/* Plate numbers, odometer stamps, model/year. */
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 1px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.tag-primary {
  background: var(--tint);
  color: var(--primary-ink);
}

.count-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 1px 9px;
  border-radius: var(--radius-full);
  background: var(--tint);
  color: var(--primary-ink);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok-solid);
}

/* ---- Buttons ---- */

.primary-action,
.ghost-action,
.tonal-action,
.danger-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  touch-action: manipulation;
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease),
    border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), opacity var(--dur) var(--ease);
}

.primary-action svg,
.ghost-action svg,
.tonal-action svg,
.danger-action svg {
  width: 18px;
  height: 18px;
}

.primary-action:active,
.ghost-action:active,
.tonal-action:active,
.danger-action:active,
.chip:active,
.secondary-line:active {
  transform: var(--press);
}

.primary-action {
  background: var(--primary);
  color: var(--on-primary);
}

.primary-action:hover {
  background: var(--primary-hover);
}

.ghost-action {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.ghost-action:hover {
  background: var(--surface-2);
}

.tonal-action {
  background: var(--tint);
  color: var(--primary-ink);
}

.tonal-action:hover {
  background: var(--tint-strong);
}

/* Destructive: tinted by default, solid when it's the dialog's confirm. */
.danger-action,
.ghost-action.danger-action {
  border-color: transparent;
  background: var(--danger-fill);
  color: var(--danger);
}

.danger-action:hover,
.ghost-action.danger-action:hover {
  border-color: var(--danger-edge);
}

.primary-action.danger-action {
  background: #c62828;
  color: #fff;
}

.primary-action.danger-action:hover {
  background: #a31f1f;
}

button:disabled {
  cursor: default;
  opacity: 0.6;
}

.btn-sm {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

/* Small tinted inline control (e.g. the odometer "Update"). */
.inline-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--primary-ink);
  font-size: 14px;
  font-weight: 700;
  touch-action: manipulation;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.inline-btn:hover {
  background: var(--tint);
}

.inline-btn:active {
  transform: var(--press);
}

.inline-btn svg {
  width: 17px;
  height: 17px;
}

/* Dashed "add another" / "suggest" control. */
.secondary-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-self: start;
  min-height: 40px;
  padding: 0 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: transparent;
  color: var(--primary-ink);
  font-size: 14px;
  font-weight: 700;
  touch-action: manipulation;
}

.secondary-line:hover {
  background: var(--tint);
}

.secondary-line svg {
  width: 16px;
  height: 16px;
}

/* Floating action: extended pill above the tab bar, right-aligned within
   the content column. */
.fab {
  position: fixed;
  z-index: 900;
  right: max(var(--gutter), calc((100vw - var(--shell-max)) / 2 + var(--gutter)));
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 0 22px 0 18px;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: var(--shadow-2);
  font-size: 15px;
  font-weight: 700;
  touch-action: manipulation;
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}

.fab:hover {
  background: var(--primary-hover);
}

.fab:active {
  transform: var(--press);
}

.fab svg {
  width: 22px;
  height: 22px;
}

/* Sticky save bar for the form pages. */
.action-bar {
  position: fixed;
  z-index: 940;
  left: 0;
  right: 0;
  bottom: calc(var(--nav-h) + var(--safe-bottom));
  padding: 12px var(--gutter);
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}

.action-bar-inner {
  max-width: calc(var(--shell-max) - 2 * var(--gutter));
  margin: 0 auto;
  display: flex;
  gap: 10px;
}

.action-bar .primary-action {
  flex: 1 1 auto;
  box-shadow: var(--shadow-2);
}

.action-bar .ghost-action {
  flex: none;
}

.saved-flash {
  align-self: center;
  color: var(--ok);
  font-weight: 700;
}

/* ---- Forms ---- */

.form-stack {
  display: grid;
  gap: 16px;
}

.field-grid {
  display: grid;
  gap: 14px;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label,
.field {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.field-label {
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.req {
  color: var(--danger);
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
}

input,
textarea,
select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 16px; /* 16px stops iOS zooming into the field */
  font-weight: 600;
  outline: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}

input::placeholder,
textarea::placeholder {
  color: var(--subtle);
  font-weight: 500;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary-bright);
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-bright) 22%, transparent);
}

textarea {
  resize: vertical;
  min-height: 96px;
}

input[type="date"]::-webkit-date-and-time-value {
  text-align: left;
  margin: 0;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0.6;
}

/* On touch devices the native date control keeps an intrinsic width and
   overflows its container; dropping the native appearance lets it shrink.
   (Scoped to coarse pointers so desktop keeps its calendar picker button.) */
@media (pointer: coarse) {
  input[type="date"] {
    -webkit-appearance: none;
    appearance: none;
  }
}

input[type="checkbox"] {
  width: 20px;
  height: 20px;
  min-height: 0;
  padding: 0;
  accent-color: var(--primary);
}

/* Input with a leading icon and/or trailing unit / button. */
.input-with-affix {
  position: relative;
  display: grid;
}

.input-with-affix > svg {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 19px;
  height: 19px;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.input-with-affix.has-lead input {
  padding-left: 44px;
}

.input-with-affix.has-trail input {
  padding-right: 64px;
}

.input-prefix,
.input-suffix {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  pointer-events: none;
}

.input-prefix {
  left: 14px;
}

.input-suffix {
  right: 14px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--tint);
  color: var(--primary-ink);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.input-with-affix.has-prefix input {
  padding-left: 48px;
}

.input-affix-btn {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--primary-ink);
  font-size: 14px;
  font-weight: 700;
  touch-action: manipulation;
}

.input-affix-btn:hover {
  background: var(--tint);
}

/* Oversized numeric entry (odometer, cost). */
.input-metric input {
  min-height: 60px;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--primary-ink);
}

.input-metric input::placeholder {
  color: var(--subtle);
  font-weight: 700;
}

/* ---- Chips (selectable) ---- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Single-row, side-scrolling chip strip (vehicle filter, categories). */
.chips-scroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  margin: 0 calc(-1 * var(--gutter));
  padding: 2px var(--gutter);
  scrollbar-width: none;
}

.chips-scroll::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  touch-action: manipulation;
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease),
    border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.chip svg {
  width: 16px;
  height: 16px;
}

.chip:hover {
  background: var(--surface-2);
}

.chip-on,
.chip[aria-pressed="true"],
.chip[aria-checked="true"] {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--on-primary);
}

.chip-on:hover,
.chip[aria-pressed="true"]:hover,
.chip[aria-checked="true"]:hover {
  background: var(--primary-hover);
}

.chip .tag {
  min-height: 18px;
  padding: 0 6px;
  font-size: 10px;
}

.chip-on .tag,
.chip[aria-pressed="true"] .tag {
  background: rgba(255, 255, 255, 0.2);
  color: inherit;
}

/* Soft variant for multi-select item chips: tinted when on, not solid. */
.chip-soft[aria-pressed="true"] {
  border-color: var(--tint-strong);
  background: var(--tint);
  color: var(--primary-ink);
}

.chip-soft[aria-pressed="true"]:hover {
  background: var(--tint-strong);
}

.chip-sm {
  min-height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

/* Read-only item list on record cards. */
.item-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.item-chip {
  padding: 3px 10px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

/* ---- Segmented control ---- */

.segmented {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-2);
}

.segmented-btn {
  min-height: 40px;
  padding: 0 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  touch-action: manipulation;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.segmented-btn:hover {
  color: var(--ink);
}

.segmented-btn.is-active {
  background: var(--surface);
  color: var(--primary-ink);
  box-shadow: var(--shadow-1), 0 0 0 1px var(--line);
}

.segmented-count {
  margin-left: 3px;
  font-weight: 600;
  opacity: 0.75;
}

/* Solid variant (reminder lead-time presets). */
.segmented-solid .segmented-btn.is-active {
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: none;
}

/* ---- Toggle switch ---- */

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}

.switch {
  position: relative;
  flex: none;
  width: 48px;
  height: 28px;
}

.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.switch-track {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  transition: background var(--dur) var(--ease);
  pointer-events: none;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
  transition: transform var(--dur) var(--ease);
}

.switch input:checked + .switch-track {
  background: var(--primary);
}

.switch input:checked + .switch-track::after {
  transform: translateX(20px);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--primary-bright);
  outline-offset: 2px;
}

/* ---- Menus (⋮) ---- */

.menu-wrap {
  position: relative;
  flex: none;
}

.menu-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  touch-action: manipulation;
}

.menu-btn:hover,
.menu-btn[aria-expanded="true"] {
  background: var(--surface-2);
  color: var(--ink);
}

.menu-btn svg {
  width: 20px;
  height: 20px;
}

.menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  min-width: 200px;
  display: grid;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  animation: pop-in 140ms var(--ease);
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  touch-action: manipulation;
}

.menu button svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.menu button:hover {
  background: var(--surface-2);
}

.menu .is-danger,
.menu .is-danger svg {
  color: var(--danger);
}

.menu .is-ok,
.menu .is-ok svg {
  color: var(--ok);
}

/* ---- Empty & loading states ---- */

.empty-state {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 32px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  color: var(--muted);
  text-align: center;
}

.empty-state .icon-tile {
  width: 52px;
  height: 52px;
  border-radius: 16px;
}

.empty-state .icon-tile svg {
  width: 24px;
  height: 24px;
}

.empty-state p {
  max-width: 32ch;
  font-size: 14px;
}

.empty-state .primary-action {
  margin-top: 4px;
}

.skeleton-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.skeleton-line {
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
}

.skeleton-line-lg {
  height: 20px;
  width: 60%;
}

.skeleton-line-sm {
  width: 40%;
}

@keyframes skeleton-shimmer {
  from { background-position: 100% 0; }
  to { background-position: 0 0; }
}

.pull-refresh {
  position: fixed;
  top: calc(var(--topbar-h) + var(--safe-top) + 8px);
  left: 50%;
  z-index: 1000;
  width: 36px;
  height: 36px;
  margin-left: -18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  opacity: 0;
  pointer-events: none;
}

.pull-refresh-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line);
  border-top-color: var(--primary-bright);
  border-radius: 50%;
}

.pull-refresh.ready .pull-refresh-spinner {
  transform: rotate(180deg);
}

.pull-refresh.refreshing .pull-refresh-spinner {
  animation: spin 0.7s linear infinite;
}

/* ---- Dialogs (confirm / prompt, built by core.js) ---- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  align-items: end;
  justify-items: center;
  padding: 16px;
  padding-bottom: calc(16px + var(--safe-bottom));
  background: var(--scrim);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: fade-in var(--dur) var(--ease);
}

.modal {
  width: min(420px, 100%);
  display: grid;
  gap: 8px;
  padding: 22px;
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  animation: rise-in 240ms var(--ease);
}

.modal-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.modal-message {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  /* Dialogs that list what they're about to change (backup restore) pass a
     multi-line message; keep those line breaks without allowing raw HTML. */
  white-space: pre-line;
}

.modal-field {
  margin-top: 6px;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: none; }
}

/* ---- App launcher (bottom sheet) ---- */

.launcher-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  align-items: end;
  justify-items: center;
  background: var(--scrim);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  animation: fade-in var(--dur) var(--ease);
}

.launcher-sheet {
  width: min(var(--shell-max), 100%);
  padding: 10px 20px calc(20px + var(--safe-bottom));
  border-radius: 24px 24px 0 0;
  background: var(--surface);
  box-shadow: var(--shadow-3);
  animation: rise-in 280ms var(--ease);
}

.sheet-handle {
  display: block;
  width: 40px;
  height: 5px;
  margin: 0 auto 14px;
  border-radius: 3px;
  background: var(--surface-3);
}

.launcher-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.launcher-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.launcher-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 14px;
}

.launcher-close {
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink);
  display: grid;
  place-items: center;
  touch-action: manipulation;
}

.launcher-close svg {
  width: 18px;
  height: 18px;
}

.launcher-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.launcher-app {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.launcher-app:hover {
  box-shadow: var(--shadow-1);
}

.launcher-app:active {
  transform: var(--press);
}

.launcher-app.is-current {
  border-color: transparent;
  background: var(--tint);
}

.launcher-app-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 14px;
}

.launcher-app-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--primary);
  color: var(--on-primary);
}

.launcher-app-icon svg {
  width: 24px;
  height: 24px;
}

.launcher-app-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
}

.launcher-app-tagline {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
}

.launcher-app-cta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
  color: var(--primary-ink);
  font-size: 14px;
  font-weight: 700;
}

.launcher-app-cta svg {
  width: 16px;
  height: 16px;
}

.launcher-version {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

/* ==========================================================================
   Vehicles — Home (vehicle picker, card, calendar + upcoming & due)
   ========================================================================== */

/* Dropdown that picks which vehicle Home shows. Reuses the ⋮ menu styles,
   stretched to the button's width. */
.vehicle-picker-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 60px;
  padding: 8px 14px 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  color: var(--ink);
  text-align: left;
  touch-action: manipulation;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.vehicle-picker-btn:hover,
.vehicle-picker-btn[aria-expanded="true"] {
  border-color: var(--line-strong);
}

.vehicle-picker-btn:focus-visible {
  outline: 2px solid var(--primary-bright);
  outline-offset: 2px;
}

.vehicle-picker-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--tint);
  color: var(--primary-ink);
}

.vehicle-picker-icon svg {
  width: 22px;
  height: 22px;
}

.vehicle-picker-text {
  display: grid;
  flex: 1;
  min-width: 0;
}

.vehicle-picker-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.vehicle-picker-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.vehicle-picker-name > span:first-child,
.vehicle-picker-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vehicle-picker-chevron {
  flex: none;
  width: 20px;
  height: 20px;
  color: var(--muted);
  transition: transform var(--dur) var(--ease);
}

.vehicle-picker-btn[aria-expanded="true"] .vehicle-picker-chevron {
  transform: rotate(180deg);
}

.vehicle-picker-menu {
  left: 0;
  right: 0;
  max-height: min(60vh, 360px);
  overflow-y: auto;
}

.menu .vehicle-picker-item-name {
  flex: 1;
  min-width: 0;
}

.menu button[aria-checked="true"],
.menu button[aria-checked="true"] svg {
  color: var(--primary-ink);
}

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.cal-head-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.cal-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.cal-today-btn {
  min-height: 26px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--tint);
  color: var(--primary-ink);
  font-size: 12px;
  font-weight: 700;
  touch-action: manipulation;
}

.cal-nav {
  display: flex;
  gap: 4px;
}

.cal-nav-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  touch-action: manipulation;
  transition: background var(--dur) var(--ease);
}

.cal-nav-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.cal-nav-btn svg {
  width: 20px;
  height: 20px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  row-gap: 4px;
}

.cal-weekday {
  padding: 2px 0 6px;
  color: var(--subtle);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.cal-cell {
  position: relative;
  height: 44px;
  margin: 0 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 10px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.cal-cell.is-blank {
  visibility: hidden;
}

.cal-cell.has-events {
  cursor: pointer;
}

.cal-cell.has-events:hover {
  background: var(--surface-2);
}

.cal-cell.has-overdue {
  background: var(--danger-fill);
  color: var(--danger);
}

.cal-cell.is-today {
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 800;
}

.cal-cell.is-selected {
  box-shadow: inset 0 0 0 2px var(--primary-bright);
}

.cal-cell.is-today.is-selected {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--primary-bright);
}

.cal-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.cal-dot-overdue { background: var(--danger-solid); }
.cal-dot-due-soon { background: var(--warn-solid); }
.cal-dot-ok { background: var(--primary-bright); }
.cal-dot-today { background: var(--primary); }
.is-today .cal-dot { box-shadow: 0 0 0 1.5px var(--on-primary); }

.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.cal-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cal-day-detail {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.cal-day-detail-title {
  font-size: 14px;
  font-weight: 800;
}

/* Upcoming & due cards: status stripe on the left edge. */
.due-list {
  display: grid;
  gap: 12px;
}

.due-card {
  position: relative;
  display: grid;
  gap: 6px;
  padding: 14px 16px 14px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  color: inherit;
  text-decoration: none;
  overflow: hidden;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.due-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--primary-bright);
}

.due-card.is-overdue::before { background: var(--danger-solid); }
.due-card.is-due-soon::before { background: var(--warn-solid); }
.due-card.is-ok::before { background: var(--ok-solid); }

.due-card:hover {
  box-shadow: var(--shadow-2);
}

.due-card:active {
  transform: var(--press);
}

.due-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.due-card-title {
  min-width: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.due-card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.due-card.is-overdue .due-card-meta { color: var(--danger); }
.due-card.is-due-soon .due-card-meta { color: var(--warn); }

.due-card-meta svg {
  width: 15px;
  height: 15px;
}

/* ==========================================================================
   Vehicles — vehicle card (Home)
   ========================================================================== */

.vehicle-card {
  padding: 0;
  overflow: visible;
}

.vehicle-card-top {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 4px;
  padding: 16px 12px 14px 16px;
}

.vehicle-open {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  touch-action: manipulation;
}

.vehicle-thumb-wrap {
  position: relative;
  flex: none;
  width: 96px;
  height: 80px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--subtle);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.vehicle-thumb-wrap svg {
  width: 36px;
  height: 36px;
}

.vehicle-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.vehicle-card-id {
  min-width: 0;
  display: grid;
  gap: 6px;
  padding-top: 2px;
}

.vehicle-name {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.vehicle-idline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.vehicle-due {
  justify-self: start;
  white-space: normal;
}

.vehicle-card-stats {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-2) 50%, var(--surface));
}

.vehicle-card-stats .metric {
  display: block;
  margin-top: 4px;
  font-size: 30px;
}

.vehicle-last-wrap {
  text-align: right;
}

.vehicle-last {
  display: block;
  margin-top: 4px;
  font-size: 15px;
  font-weight: 700;
}

.vehicle-last-km {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.vehicle-card-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.vehicle-card-foot svg {
  width: 16px;
  height: 16px;
}

.vehicle-card-foot.is-due-soon { color: var(--warn); }
.vehicle-card-foot.is-overdue { color: var(--danger); }
.vehicle-card-foot.is-ok svg { color: var(--ok); }

.vehicle-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 16px 16px;
}

.vehicle-card-foot + .vehicle-card-actions,
.vehicle-card-stats + .vehicle-card-actions {
  padding-top: 14px;
}

/* ==========================================================================
   Vehicles — Vehicle detail
   ========================================================================== */

.vehicle-hero {
  display: grid;
  gap: 14px;
}

.vehicle-hero-id {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.vehicle-hero .vehicle-thumb-wrap {
  width: 104px;
  height: 84px;
}

.vehicle-hero-text {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  gap: 6px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.vehicle-hero-name {
  font-size: 21px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.vehicle-hero-meta {
  color: var(--muted);
  font-size: 13px;
}

.odo-panel {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--surface-2);
}

.odo-panel-head,
.odo-panel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.odo-panel-head .muted {
  font-size: 12px;
  font-weight: 600;
}

.odo-panel .metric {
  font-size: 34px;
  color: var(--primary-ink);
}

.expiry-list {
  display: grid;
  gap: 8px;
}

.expiry-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-2);
}

.expiry-row.is-due-soon { background: var(--warn-fill); }
.expiry-row.is-overdue { background: var(--danger-fill); }

.expiry-row-text {
  flex: 1 1 auto;
  min-width: 0;
}

.expiry-row strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
}

.expiry-row .icon-tile {
  background: var(--surface);
}

/* Horizontal reminder rail, one card per category. */
.reminder-rail {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  margin: 0 calc(-1 * var(--gutter));
  padding: 2px var(--gutter) 6px;
  scrollbar-width: none;
}

.reminder-rail::-webkit-scrollbar {
  display: none;
}

.reminder-card {
  flex: none;
  width: min(236px, 72vw);
  display: grid;
  gap: 4px;
  align-content: start;
  scroll-snap-align: start;
}

.reminder-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.reminder-card-label {
  font-size: 15px;
  font-weight: 700;
}

.reminder-card .metric {
  font-size: 22px;
  color: var(--primary-ink);
}

.reminder-card.is-overdue .metric { color: var(--danger); }
.reminder-card.is-due-soon .metric { color: var(--warn); }

.reminder-card-sub {
  color: var(--muted);
  font-size: 13px;
}

.reminder-card-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.reminder-card-foot strong {
  color: var(--ink);
}

.reminder-card.is-overdue .reminder-card-foot { background: var(--danger-fill); color: var(--danger); }
.reminder-card.is-overdue .reminder-card-foot strong { color: var(--danger); }

/* Service record timeline. */
.timeline {
  position: relative;
  display: grid;
  gap: 14px;
  padding-left: 26px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 12px;
  bottom: 12px;
  width: 2px;
  border-radius: 1px;
  background: var(--line);
}

.record-card {
  position: relative;
}

.timeline-dot {
  position: absolute;
  left: -26px;
  top: 18px;
  width: 18px;
  height: 18px;
  border: 4px solid var(--bg);
  border-radius: 50%;
  background: var(--primary-bright);
  box-shadow: 0 0 0 2px var(--tint-strong);
}

.record-card.is-overdue .timeline-dot { background: var(--danger-solid); box-shadow: 0 0 0 2px var(--danger-edge); }
.record-card.is-due-soon .timeline-dot { background: var(--warn-solid); box-shadow: 0 0 0 2px var(--warn-edge); }
.record-card.is-done .timeline-dot { background: var(--ok-solid); box-shadow: 0 0 0 2px var(--ok-edge); }
.record-card.is-history .timeline-dot { background: var(--subtle); box-shadow: 0 0 0 2px var(--line); }

.record-body {
  display: grid;
  gap: 10px;
}

.record-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.record-when {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.record-date {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.record-right {
  display: flex;
  align-items: flex-start;
  gap: 2px;
  margin-right: -8px;
  margin-top: -4px;
}

.record-cost {
  padding-top: 7px;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 800;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.record-workshop {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-top: -4px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.record-workshop svg {
  width: 16px;
  height: 16px;
  margin-top: 2px;
}

.record-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.record-notes {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.record-next {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.record-next svg {
  width: 15px;
  height: 15px;
}

.record-next strong {
  color: var(--ink);
}

/* ==========================================================================
   Vehicles — forms (vehicle, service record)
   ========================================================================== */

.vehicle-banner {
  display: flex;
  align-items: center;
  gap: 12px;
}

.vehicle-banner-text {
  min-width: 0;
}

.vehicle-banner-text strong {
  display: block;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vehicle-banner .label-caps {
  color: var(--primary-ink);
}

.recent-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.recent-row .label-caps {
  flex: none;
}

/* Photo drop zone: the whole card is the file picker's label. */
.photo-drop {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 24px 16px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 500;
  text-align: center;
  cursor: pointer;
}

.photo-drop:hover {
  border-color: var(--primary-bright);
}

.photo-drop:focus-within {
  border-color: var(--primary-bright);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-bright) 22%, transparent);
}

.photo-drop input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
}

.photo-drop .icon-tile {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-1);
}

.photo-drop .icon-tile svg {
  width: 26px;
  height: 26px;
}

.photo-drop-title {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
}

.photo-drop-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--primary-ink);
  font-size: 13px;
  font-weight: 700;
}

.photo-drop-cta svg {
  width: 16px;
  height: 16px;
}

.image-preview {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 12px;
}

.image-hint-error {
  color: var(--danger);
}

.photo-remove {
  justify-self: center;
}

/* ==========================================================================
   Reminder settings & categories
   ========================================================================== */

.lead-card {
  display: grid;
  gap: 12px;
}

.lead-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lead-card-head .card-sub {
  display: block;
}

.lead-card-head .card-head-text strong {
  display: block;
  font-size: 16px;
  font-weight: 700;
}

.lead-value {
  flex: none;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 800;
  color: var(--primary-ink);
  font-variant-numeric: tabular-nums;
}

.lead-custom {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.lead-custom input {
  width: 96px;
  min-height: 40px;
  padding: 8px 12px;
  text-align: center;
}

.info-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-lg);
  background: var(--tint);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
}

.info-card svg {
  flex: none;
  width: 20px;
  height: 20px;
  color: var(--primary-ink);
}

.info-card p + p {
  margin-top: 6px;
}

.category-editor {
  display: grid;
  gap: 14px;
}

.category-edit-card {
  display: grid;
  gap: 12px;
}

.category-edit-head {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.category-name-label {
  flex: 1 1 auto;
}

.category-items {
  display: grid;
  gap: 8px;
}

.category-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.category-item-row input {
  flex: 1 1 auto;
  min-height: 44px;
  padding: 10px 12px;
  font-size: 15px;
}

/* ==========================================================================
   Settings, backup, changelog
   ========================================================================== */

.profile-card {
  display: grid;
  gap: 16px;
}

.theme-card {
  display: grid;
  gap: 10px;
}

.theme-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.profile-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.profile-avatar {
  position: relative;
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--tint);
  color: var(--primary-ink);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
}

.profile-info {
  min-width: 0;
}

.account-email {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.account-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

/* Grouped link list (settings menu). */
.list-card {
  display: grid;
  padding: 4px 0;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  padding: 10px 16px;
  color: var(--ink);
  text-decoration: none;
  touch-action: manipulation;
  transition: background var(--dur) var(--ease);
}

.list-row + .list-row,
.list-rows:not(:empty) + .list-row {
  border-top: 1px solid var(--line);
}

a.list-row:hover,
button.list-row:hover {
  background: var(--surface-2);
}

button.list-row {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
}

.list-row-text {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  gap: 1px;
}

.list-row-title {
  font-size: 15px;
  font-weight: 700;
}

.list-row-sub {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-row-end {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--subtle);
}

.list-row-end > svg {
  width: 18px;
  height: 18px;
}

.backup-summary {
  display: grid;
}

.backup-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}

.backup-row + .backup-row {
  border-top: 1px solid var(--line);
}

.backup-row-name {
  flex: 1 1 auto;
  font-weight: 700;
}

.backup-row-detail {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.action-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 72px;
  padding: 12px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  background: var(--tint);
  color: var(--ink);
  text-align: left;
  touch-action: manipulation;
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}

.action-row:hover {
  background: var(--tint-strong);
}

.action-row:active {
  transform: var(--press);
}

.action-row.is-plain {
  border-color: var(--line);
  background: var(--surface);
}

.action-row.is-plain:hover {
  background: var(--surface-2);
}

.action-row > svg {
  width: 20px;
  height: 20px;
  color: var(--primary-ink);
}

.status-line {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.status-line.is-error {
  color: var(--danger);
}

.changelog-list {
  display: grid;
  gap: 12px;
}

.changelog-entry {
  display: grid;
  gap: 8px;
}

.changelog-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.changelog-version {
  font-size: 18px;
  font-weight: 800;
}

.changelog-date {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.changelog-notes {
  margin: 0;
  padding-left: 18px;
  color: var(--ink);
  font-size: 14px;
}

.changelog-notes li {
  margin: 4px 0;
  line-height: 1.5;
}

.changelog-notes li::marker {
  color: var(--primary-ink);
}

/* ==========================================================================
   Login
   ========================================================================== */

.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(360px 280px at 50% 30%, color-mix(in srgb, var(--primary-bright) 14%, transparent), transparent 70%),
    var(--bg);
}

.login-shell {
  width: min(420px, 100%);
  padding: calc(32px + var(--safe-top)) var(--gutter) calc(32px + var(--safe-bottom));
  display: grid;
  gap: 24px;
}

.login-brand {
  display: grid;
  justify-items: center;
  gap: 8px;
  text-align: center;
}

.login-icon {
  width: 84px;
  height: 84px;
  margin-bottom: 10px;
  border-radius: 22px;
  box-shadow: 0 16px 36px color-mix(in srgb, var(--primary-bright) 35%, transparent);
}

.login-brand h1 {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.login-copy {
  color: var(--muted);
  font-size: 16px;
}

.login-panel {
  padding: 22px;
  border-radius: 20px;
}

.auth-form {
  display: grid;
  gap: 16px;
}

.auth-form .primary-action {
  min-height: 52px;
  margin-top: 4px;
  font-size: 16px;
  box-shadow: var(--shadow-2);
}

.auth-message {
  min-height: 20px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

.auth-message.is-error {
  color: var(--danger);
}

.login-foot {
  color: var(--subtle);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

/* ==========================================================================
   Movies — watchlist & search
   ========================================================================== */

.watchlist-controls {
  display: grid;
  gap: 12px;
}

.watchlist-control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.watchlist {
  display: grid;
  gap: 24px;
}

.watchlist-group {
  display: grid;
  gap: 12px;
}

.watchlist-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.watchlist-group-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.watchlist-group-label::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary-bright);
}

.watchlist-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 12px;
}

.poster-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.poster-frame {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  overflow: hidden;
  box-shadow: var(--shadow-1);
}

.poster-img,
.poster-fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.poster-img {
  display: block;
  object-fit: cover;
  transition: opacity var(--dur) var(--ease), filter var(--dur) var(--ease);
}

.poster-fallback {
  display: grid;
  place-items: center;
  color: var(--subtle);
}

.poster-fallback svg {
  width: 36%;
  max-width: 56px;
  height: auto;
}

/* Media-type badge pinned to the poster's top-left. */
.poster-type {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

[data-type="tv"] .poster-type { background: #0f766e; }

/* Watched toggle: a circle in the top-right that fills in when watched. */
.watch-toggle {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.45);
  color: #fff;
  display: grid;
  place-items: center;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  touch-action: manipulation;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.watch-toggle:active {
  transform: scale(0.92);
}

.watch-toggle svg {
  width: 22px;
  height: 22px;
}

.watch-toggle .check-mark {
  opacity: 0;
}

.watch-toggle[aria-pressed="true"] {
  background: var(--ok-solid);
}

.watch-toggle[aria-pressed="true"] .check-mark {
  opacity: 1;
}

.poster-watched-flag {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.92);
  color: #0f172a;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.poster-watched-flag svg {
  width: 15px;
  height: 15px;
  color: var(--ok-solid);
}

.poster-card.is-watched .poster-img {
  opacity: 0.45;
  filter: grayscale(0.4);
}

.poster-body {
  display: flex;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
}

.poster-text {
  flex: 1 1 auto;
  min-width: 0;
}

.poster-title {
  overflow: hidden;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.poster-card.is-watched .poster-title {
  color: var(--muted);
}

.poster-meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.poster-remove {
  margin: -6px -8px 0 0;
}

/* Search */
.search-bar {
  position: relative;
  display: flex;
  align-items: center;
}

.search-bar > svg {
  position: absolute;
  left: 16px;
  width: 22px;
  height: 22px;
  color: var(--primary-ink);
  pointer-events: none;
}

.search-input {
  min-height: 56px;
  padding: 0 52px;
  border-radius: 16px;
  font-size: 17px;
}

/* Clear the default WebKit search decorations so it matches other inputs. */
.search-input::-webkit-search-decoration,
.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-results-button {
  -webkit-appearance: none;
}

.search-clear {
  position: absolute;
  right: 8px;
}

.search-status {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.search-status strong {
  color: var(--ink);
}

.search-status.is-error {
  color: var(--danger);
}

.result-list {
  display: grid;
  gap: 12px;
}

.result-card {
  display: flex;
  gap: 14px;
  padding: 12px;
}

.result-card .poster-frame {
  flex: none;
  width: 84px;
  border-radius: 10px;
  box-shadow: none;
}

.result-card .poster-type {
  top: 6px;
  left: 6px;
  padding: 2px 6px;
  font-size: 10px;
}

.result-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.result-title {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.result-overview {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.result-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: auto;
  padding-top: 6px;
}

.poster-add {
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-full);
  font-size: 14px;
}

.poster-add.is-saved {
  background: var(--tint);
  color: var(--primary-ink);
  opacity: 1;
}

/* ---- Motion preference ---- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- Narrow phones ---- */

@media (max-width: 360px) {
  .field-row {
    grid-template-columns: 1fr;
  }

  .vehicle-thumb-wrap {
    width: 76px;
    height: 64px;
  }
}

/* ---- Wider screens: the column stays phone-width, grids get a bit more room ---- */

@media (min-width: 600px) {
  .watchlist-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .modal-backdrop {
    align-items: center;
  }
}

/* ---- Small layout helpers ---- */

.card-head-end {
  margin-left: auto;
}

.page-head .pill {
  margin-bottom: 8px;
}

/* Single-column grids must be allowed to shrink below their widest child —
   side-scrolling chip strips and native date inputs would otherwise stretch
   the track (and the page) past the viewport. */
.form-stack,
.field-grid,
.section,
.vehicle-hero,
.record-body,
.watchlist-controls,
label,
.field {
  grid-template-columns: minmax(0, 1fr);
}

.app-shell > * {
  min-width: 0;
}

/* Big numeric fields read as a readout, not a stepper. */
.input-metric input::-webkit-outer-spin-button,
.input-metric input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.input-metric input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* Inside a gapped grid card the head's own margin would double the gap. */
.field-grid > .card-head {
  margin-bottom: 0;
}
