/*
 * Gasculator styles. Mobile-first: the base rules are for phones, and the
 * @media (min-width: ...) blocks adjust the layout for larger screens.
 */

/* ---------- Design tokens ---------- */
:root {
  --navy-950: #08122a;
  --navy-900: #0f1f3a;
  --navy-800: #1a2d50;
  --navy-700: #273e68;
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-muted: #f7f8fa;
  --border: #dde2ea;
  --border-strong: #c3cad6;
  --text: #17213a;
  --muted: #5a6478;
  --accent: #f2b33d;        /* fuel-gauge amber, used sparingly */
  --accent-soft: #fdf1d8;
  --focus: #2f6fed;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --success: #1d7a52;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 31, 58, .06), 0 1px 3px rgba(15, 31, 58, .08);
  --nav-height: 64px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  /* leave room for the fixed bottom navigation on phones */
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; color: var(--navy-900); }
h1 { font-size: 1.5rem; letter-spacing: -.01em; }
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; margin-top: 1.25rem; }
p { margin: 0 0 .75rem; }
a { color: var(--focus); }
code { background: var(--surface-muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 .3em; font-size: .9em; }

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

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

.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 100;
  background: var(--surface); color: var(--navy-900); padding: 8px 12px; border-radius: var(--radius-sm);
}
.skip-link:focus { top: 8px; }

/* ---------- Header & navigation ---------- */
.app-header {
  background: var(--navy-900);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: env(safe-area-inset-top, 0px);
}
.app-header__inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.125rem; letter-spacing: .01em; }
.brand__mark { width: 30px; height: 30px; color: #fff; }

.env-badge {
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  background: var(--accent); color: var(--navy-950); padding: 2px 8px; border-radius: 999px;
}

/* Phone: fixed bottom tab bar */
.app-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -2px 10px rgba(15, 31, 58, .06);
}
.app-nav a {
  height: var(--nav-height);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: .66rem; font-weight: 600;
  min-width: 0; white-space: nowrap; letter-spacing: -.01em;
}
.app-nav svg { width: 24px; height: 24px; fill: currentColor; }
.app-nav a[aria-current="page"] { color: var(--navy-900); }
.app-nav a[aria-current="page"] svg { fill: var(--navy-900); }
.app-nav a[aria-current="page"]::after {
  content: ""; width: 20px; height: 3px; border-radius: 3px; background: var(--accent); margin-top: 1px;
}
.app-nav a:focus-visible { outline-offset: -4px; }

/* ---------- Layout ---------- */
main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px;
}
main:focus { outline: none; }

.view-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 4px 0 16px;
}
.view-head h1 { margin: 0; }
.view-head h1:focus { outline: none; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}
.card > h2:first-child { margin-bottom: .75rem; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card__head h2 { margin: 0; }
.card--muted { background: var(--surface-muted); box-shadow: none; color: var(--muted); }
.card--muted p { margin: 0; }
.card--callout { border-left: 4px solid var(--accent); }

.banner { padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: .95rem; }
.banner--warn { background: var(--accent-soft); border: 1px solid #f0d08f; color: #5a3d00; }

.empty { color: var(--muted); text-align: center; padding: 16px 8px; margin: 0; }
.link { font-weight: 600; text-decoration: none; }
.link:hover { text-decoration: underline; }
.hint { font-size: .85rem; color: var(--muted); margin: 6px 0 0; }
.optional-tag { color: var(--muted); font-weight: 400; }
.attribution { font-size: .75rem; color: var(--muted); text-align: center; margin: 12px 0 0; }
.attribution a { color: inherit; }
.summary-line { color: var(--muted); font-size: .9rem; margin: 0 0 10px; }
.plain-list { padding-left: 1.2rem; margin: 0 0 .75rem; }
.plain-list li { margin-bottom: .35rem; }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font: inherit; font-weight: 600; font-size: .95rem; line-height: 1.2;
  text-decoration: none; cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease;
}
.btn:disabled { opacity: .6; cursor: progress; }
.btn--primary { background: var(--navy-900); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--navy-700); }
.btn--accent { background: var(--accent); color: var(--navy-950); }
.btn--accent:hover { background: #e6a52a; }
.btn--ghost { background: transparent; color: var(--navy-900); border-color: var(--border-strong); }
.btn--ghost:hover { background: var(--surface-muted); }
.btn--ghost-danger { color: var(--danger); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: #8f1c13; }
.btn--small { min-height: 36px; padding: 0 12px; font-size: .85rem; }
.btn--block { width: 100%; }
.btn--icon { width: 44px; padding: 0; background: var(--surface); border-color: var(--border-strong); color: var(--navy-900); }
.btn--icon svg { width: 20px; height: 20px; fill: currentColor; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; min-width: 0; }
.field label, .fieldset legend { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; color: var(--navy-900); }
.fieldset { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }

input[type="text"], input[type="number"], input[type="search"], input[type="date"],
input[type="datetime-local"], select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
  font-size: 16px; /* 16px stops iOS from zooming in on focus */
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  appearance: none;
  -webkit-appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 36px;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, .25);
}
input[type="file"] { font: inherit; font-size: .9rem; max-width: 100%; }
input::placeholder, textarea::placeholder { color: #8e97a8; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row--3 { grid-template-columns: 1fr; gap: 0; }
.field-row--fuel { grid-template-columns: 1fr 1fr; column-gap: 12px; }
.field-row--fuel .field:first-child { grid-column: 1 / -1; }

.input-prefix { position: relative; }
.input-prefix > span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-prefix > input { padding-left: 26px; }

.radio { display: flex; align-items: flex-start; gap: 8px; margin: 6px 0; font-size: .95rem; cursor: pointer; }
.radio input { margin-top: 5px; accent-color: var(--navy-900); width: 16px; height: 16px; }

.form-error {
  background: var(--danger-soft); color: var(--danger);
  border: 1px solid #f5c2bc; border-radius: var(--radius-sm);
  padding: 10px 12px; margin-bottom: 12px; font-size: .9rem;
}
.form-error .btn { color: var(--navy-900); background: var(--surface); }
.form-error__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.geo-choices { border: 1px solid var(--border-strong); border-left: 4px solid var(--accent); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 12px; background: var(--surface-muted); }
.geo-choices .fieldset { margin: 0; }
.geo-choices__actions { margin-top: 10px; }
.choice__detail--warn { color: #8a5a00; font-weight: 600; }
.route-note { display: block; font-style: normal; font-size: .8rem; color: var(--muted); margin: 0 0 4px 14px; }
.route-note + br { display: none; } /* the note already ends the line */

/* Segmented control built from real radio buttons (keyboard arrows work). */
.segmented {
  display: inline-flex; flex-wrap: wrap;
  background: #e9edf3; border-radius: 10px; padding: 3px; gap: 2px;
}
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.segmented label {
  margin: 0; padding: 7px 12px; border-radius: 8px;
  font-size: .85rem; font-weight: 600; color: var(--muted);
  cursor: pointer; text-align: center; user-select: none;
  display: flex; align-items: center; justify-content: center;
  min-height: 36px;
}
.segmented input:checked + label { background: var(--surface); color: var(--navy-900); box-shadow: var(--shadow); }
.segmented input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 1px; }
.segmented--full { display: flex; width: 100%; }
.segmented--full label { flex: 1; min-height: 40px; }

/* Address inputs with the swap button on the right */
.address-group {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 8px;
}
.address-group .field { grid-column: 1; }
.swap-btn { grid-column: 2; grid-row: 1 / span 2; align-self: center; margin-top: 12px; }

/* ---------- Dashboard ---------- */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.stat {
  background: var(--navy-900);
  background-image: linear-gradient(160deg, var(--navy-800), var(--navy-900) 60%);
  color: #fff;
  border-radius: var(--radius);
  padding: 12px;
  min-width: 0;
  border-bottom: 3px solid var(--accent);
}
.stat__label { color: #b9c3d6; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin: 0 0 4px; }
.stat__value { font-size: 1.2rem; font-weight: 700; margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat__sub { color: #b9c3d6; font-size: .72rem; margin: 2px 0 0; }

.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 0; }
.metric { background: var(--surface-muted); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; min-width: 0; }
.metric dt { font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.metric dd { margin: 2px 0 0; font-size: 1.15rem; font-weight: 700; color: var(--navy-900); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.metrics--compact .metric dd { font-size: 1rem; }

/* ---------- Trip lists ---------- */
.trip-list { list-style: none; margin: 0; padding: 0; }
.trip {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.trip:last-child { border-bottom: 0; }
#recent-trips .trip { cursor: pointer; }
#recent-trips .trip:hover .trip__route { text-decoration: underline; }
.trip__main { min-width: 0; flex: 1; }
.trip__route { font-weight: 600; margin: 0 0 2px; overflow-wrap: anywhere; color: var(--navy-900); }
.trip__meta, .trip__details { font-size: .85rem; color: var(--muted); margin: 0; }
.trip__details { margin-top: 4px; }
.trip__notes { font-size: .875rem; margin: 6px 0 0; padding-left: 10px; border-left: 3px solid var(--border); white-space: pre-wrap; overflow-wrap: anywhere; }
.trip__side { text-align: right; flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.trip__cost { font-weight: 700; font-size: 1.05rem; margin: 0; font-variant-numeric: tabular-nums; color: var(--navy-900); }
.trip__actions { display: flex; gap: 6px; }

.trip-list--full .trip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.trip-list--full .trip:last-child { border-bottom: 1px solid var(--border); }
/* Phones: Edit/Delete get their own row under the trip details */
.trip-list--full .trip { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.trip-list--full .trip__actions { grid-column: 1 / -1; justify-content: flex-end; border-top: 1px solid var(--border); padding-top: 10px; }
.trip-list__more { text-align: center; padding: 8px 0 16px; }

.badge {
  display: inline-block; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  background: var(--accent-soft); color: #6b4a00; border-radius: 999px; padding: 1px 8px; vertical-align: 1px;
}

/* ---------- Calculator ---------- */
.calc-layout { display: grid; gap: 0; }
.results__hero {
  background: var(--navy-900);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 12px;
  border-left: 4px solid var(--accent);
}
.results__label { color: #b9c3d6; font-size: .85rem; margin: 0; }
.results__cost { font-size: 2.25rem; font-weight: 800; margin: 0; line-height: 1.15; font-variant-numeric: tabular-nums; }
.results__route { font-size: .85rem; color: var(--muted); margin: 12px 0 0; overflow-wrap: anywhere; }
.results__route strong { color: var(--text); }
.route-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.route-dot--a { background: var(--success); }
.route-dot--b { background: var(--danger); }
.save-form { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 4px; }

/* ---------- History filters ---------- */
.filters { display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px; }
.filters .field { margin-bottom: 12px; }
.filters__search, .filters__actions { grid-column: 1 / -1; }
.filters__actions .btn { width: 100%; }

/* ---------- Vehicles ---------- */
.vehicle-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.vehicle {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px;
  display: grid; grid-template-columns: 1fr auto; gap: 8px 12px;
}
.vehicle__name { margin: 0; font-size: 1.05rem; overflow-wrap: anywhere; }
.vehicle__desc { margin: 2px 0 0; color: var(--text); }
.vehicle__meta { margin: 2px 0 0; color: var(--muted); font-size: .85rem; }
.vehicle__mpg { margin: 0; text-align: right; color: var(--navy-900); line-height: 1.1; }
.vehicle__mpg strong { display: block; font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.vehicle__mpg span { font-size: .75rem; color: var(--muted); font-weight: 600; letter-spacing: .06em; }
.vehicle__mpg small { display: block; font-size: .75rem; color: var(--muted); margin-top: 2px; white-space: nowrap; }
.vehicle__mpg .vehicle__source { color: var(--success); font-weight: 600; }
.vehicle__actions { grid-column: 1 / -1; display: flex; gap: 8px; border-top: 1px solid var(--border); padding-top: 10px; }

/* ---------- Trip sessions ---------- */
.view-intro { margin: -8px 0 16px; }
.back-link { margin: 0 0 8px; }
.session-group { margin-bottom: 24px; }
.session-group > h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 10px; }

.badge--active { background: #e3f4ec; color: var(--success); }
.badge--session { background: #e8eefc; color: #23408e; text-decoration: none; text-transform: none; letter-spacing: 0; font-weight: 600; }

.session-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.session-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px; padding: 14px;
}
.session-card--compact { box-shadow: none; background: var(--surface-muted); }
.session-card__link { display: flex; flex-direction: column; gap: 2px; color: inherit; text-decoration: none; min-width: 0; }
.session-card__link:hover .session-card__name { text-decoration: underline; }
.session-card__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.session-card__name { font-weight: 700; color: var(--navy-900); font-size: 1.05rem; overflow-wrap: anywhere; }
.session-card__date { color: var(--muted); font-size: .85rem; }
.session-card__stats { font-size: .9rem; font-variant-numeric: tabular-nums; }
.session-card__add { align-self: stretch; }

.session-banner {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--navy-900); color: #fff; border-radius: var(--radius); border-left: 4px solid var(--accent);
  padding: 12px 14px; margin-bottom: 16px;
}
.session-banner p { margin: 0; }
.session-banner__label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: #b9c3d6; font-weight: 600; }
.session-banner__name { font-weight: 700; font-size: 1.05rem; overflow-wrap: anywhere; }
.session-banner__stats { font-size: .85rem; color: #dfe5ef; font-variant-numeric: tabular-nums; }
.session-banner__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.session-banner .btn--ghost { color: #fff; border-color: rgba(255, 255, 255, .35); }
.session-banner .btn--ghost:hover { background: rgba(255, 255, 255, .08); }
.price-hint { margin: -6px 0 12px; }

.view-head--session { align-items: flex-start; margin-bottom: 8px; }
.sd-sub { color: var(--muted); margin: 4px 0 0; }
.sd-notes { white-space: pre-wrap; padding-left: 10px; border-left: 3px solid var(--border); margin-bottom: 14px; }
.session-actions { display: grid; gap: 8px; margin-bottom: 16px; }
.btn--large { min-height: 52px; font-size: 1.05rem; }
.metric--highlight { background: var(--navy-900); border-color: var(--navy-900); }
.metric--highlight dt { color: #b9c3d6; }
.metric--highlight dd { color: #fff; }

.leg-list, .fuel-list { list-style: none; margin: 0; padding: 0; }
.leg, .fuel-stop {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 10px; align-items: start;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.fuel-stop { grid-template-columns: minmax(0, 1fr) auto; }
.leg:last-child, .fuel-stop:last-child { border-bottom: 0; }
.leg__num {
  width: 28px; height: 28px; border-radius: 50%; background: var(--navy-900); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; margin-top: 2px;
}
.leg__main, .fuel-stop__main { min-width: 0; }
.leg__route, .fuel-stop__title { font-weight: 600; color: var(--navy-900); margin: 0 0 2px; overflow-wrap: anywhere; }
.leg__meta { font-size: .85rem; color: var(--muted); margin: 0; font-variant-numeric: tabular-nums; }
.leg__price { color: var(--text); font-weight: 600; }
.leg__cost, .fuel-stop__paid { margin: 0; font-weight: 700; font-size: 1.05rem; color: var(--navy-900); font-variant-numeric: tabular-nums; text-align: right; }
.leg__actions { grid-column: 1 / -1; display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.btn--icon-sm { width: 40px; padding: 0; font-size: 1rem; }
.leg__actions .btn:disabled { opacity: .4; cursor: not-allowed; }
.fuel-list .empty { padding: 8px 0; text-align: left; }

.session-footer { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; margin: 8px 0 24px; }

/* ---------- Vehicle lookup (add/edit vehicle dialog) ---------- */
.vf-intro { margin: -4px 0 14px; }
.vf-switch { margin: 4px 0 14px; }
.link-btn {
  background: none; border: 0; padding: 4px 0; font: inherit; font-size: .9rem; font-weight: 600;
  color: var(--focus); text-decoration: underline; cursor: pointer;
}
.vf-current {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  background: var(--surface-muted); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; margin-bottom: 12px;
}
.vf-current p { margin: 0; }
.lookup-status { font-size: .9rem; color: var(--muted); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lookup-status:empty { display: none; }
.lookup-status--error { color: var(--danger); background: var(--danger-soft); border: 1px solid #f5c2bc; border-radius: var(--radius-sm); padding: 10px 12px; }
.lookup-status--error .btn { color: var(--navy-900); background: var(--surface); }
.spinner {
  width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--border-strong); border-top-color: var(--navy-900);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.choice-list { display: grid; gap: 8px; }
.choice {
  display: flex; align-items: flex-start; gap: 10px; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 10px 12px;
  background: var(--surface);
}
.choice:hover { background: var(--surface-muted); }
.choice input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--navy-900); flex-shrink: 0; }
.choice:has(input:checked) { border-color: var(--navy-900); box-shadow: 0 0 0 1px var(--navy-900); }
.choice__body { display: flex; flex-direction: column; min-width: 0; }
.choice__title { font-weight: 600; color: var(--navy-900); overflow-wrap: anywhere; }
.choice__mpg { font-size: .9rem; color: var(--text); font-variant-numeric: tabular-nums; }
.choice__detail { font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }

.epa-card {
  border: 1px solid var(--border); border-left: 4px solid var(--success);
  border-radius: var(--radius-sm); background: #f3faf6; padding: 12px 14px; margin-bottom: 12px;
}
.epa-card--warn { border-left-color: var(--accent); background: var(--accent-soft); }
.epa-card p { margin: 0 0 6px; }
.epa-card__headline { font-size: 1.05rem; color: var(--navy-900); }
.epa-card__headline strong { font-size: 1.3rem; }
.epa-card__sub { color: var(--text); font-variant-numeric: tabular-nums; }
.epa-card__note { font-size: .85rem; color: var(--muted); }
.epa-card__specs { display: grid; grid-template-columns: 1fr; gap: 2px 12px; margin: 8px 0; font-size: .85rem; }
.epa-card__specs div { display: flex; gap: 8px; }
.epa-card__specs dt { color: var(--muted); min-width: 96px; }
.epa-card__specs dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.epa-card__fineprint { font-size: .8rem; color: var(--muted); margin-top: 8px !important; }

/* ---------- Dialogs ---------- */
.dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  border: 0;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(8, 18, 42, .35);
  color: var(--text);
}
.dialog--small { width: min(420px, calc(100vw - 24px)); }
.dialog::backdrop { background: rgba(8, 18, 42, .55); }
.dialog .form { padding: 20px; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-height) + 16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 50;
  background: var(--navy-950);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: .9rem;
  box-shadow: 0 8px 24px rgba(8, 18, 42, .3);
  max-width: calc(100vw - 32px);
}

/* ---------- Larger phones / small tablets ---------- */
@media (min-width: 560px) {
  .stat { padding: 16px; }
  .stat__value { font-size: 1.6rem; }
  .stat__label, .stat__sub { font-size: .8rem; }
  .field-row--3 { grid-template-columns: 1fr 1.4fr 1.4fr; gap: 12px; }
  .field-row--fuel { grid-template-columns: 1fr 1fr 1fr; }
  .field-row--fuel .field:first-child { grid-column: auto; }
  .metrics { grid-template-columns: repeat(3, 1fr); }
  .metrics--compact { grid-template-columns: repeat(2, 1fr); }
  .vehicle-grid { grid-template-columns: repeat(2, 1fr); }
  /* Wider screens: Edit/Delete sit to the right of the cost */
  .trip-list--full .trip { grid-template-columns: minmax(0, 1fr) auto auto; }
  .trip-list--full .trip__actions { grid-column: auto; border-top: 0; padding-top: 0; }
}

/* ---------- Desktop ---------- */
@media (min-width: 900px) {
  body { padding-bottom: 32px; }
  h1 { font-size: 1.75rem; }
  main { padding: 24px; }
  .card { padding: 20px; }

  .app-header__inner { height: 64px; }
  .app-nav {
    position: static;
    margin-left: auto;
    display: flex;
    gap: 4px;
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0;
  }
  .app-nav a {
    height: 40px;
    flex-direction: row;
    gap: 8px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    color: #c8d1e1;
    font-size: .9rem;
  }
  .app-nav svg { width: 18px; height: 18px; }
  .app-nav a:hover { color: #fff; background: rgba(255, 255, 255, .07); }
  .app-nav a[aria-current="page"] { color: #fff; background: rgba(255, 255, 255, .1); }
  .app-nav a[aria-current="page"] svg { fill: var(--accent); }
  .app-nav a[aria-current="page"]::after { display: none; }
  .app-nav a:focus-visible { outline-color: var(--accent); outline-offset: 2px; }

  .stat-row { gap: 16px; }
  .stat { padding: 20px; }
  .stat__value { font-size: 2rem; }
  .metrics { grid-template-columns: repeat(5, 1fr); }
  .metrics--compact { grid-template-columns: repeat(2, 1fr); }

  .calc-layout { grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 20px; align-items: start; }
  .results-col { position: sticky; top: 84px; }

  .filters { grid-template-columns: 2fr 1.2fr 1fr 1fr 1fr auto; align-items: end; }
  .filters__search, .filters__actions { grid-column: auto; }
  .filters__actions { margin-bottom: 12px; }

  .vehicle-grid { grid-template-columns: repeat(3, 1fr); }

  .session-list { grid-template-columns: repeat(2, 1fr); }
  .session-list--compact { grid-template-columns: 1fr; }
  .session-card--compact { flex-direction: row; align-items: center; justify-content: space-between; }
  .session-card--compact .session-card__add { align-self: center; }
  .session-banner { flex-direction: row; align-items: center; justify-content: space-between; }
  .session-actions { grid-template-columns: 2fr 1fr; }
  .leg { grid-template-columns: auto minmax(0, 1fr) auto auto; }
  .fuel-stop { grid-template-columns: minmax(0, 1fr) auto auto; }
  .leg__actions { grid-column: auto; flex-wrap: nowrap; }

  .toast { bottom: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
  .spinner { animation-duration: 2.4s; }
}
