:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --ink: #16191f;
  --ink-2: #4a5160;
  --muted: #6b7280;
  --line: #e2e5ea;
  --brand: #0b6bcb;
  --brand-ink: #ffffff;
  --brand-soft: #e6f0fb;
  --ok: #157f3c;
  --ok-soft: #e3f4e8;
  --warn: #9a5b00;
  --warn-soft: #fdf1dc;
  --bad: #b42318;
  --bad-soft: #fde8e6;
  --route-alt: #9aa3b2;
  --unleaded: #2a9d8f;
  --premium: #e76f51;
  --diesel: #6a4c93;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --surface: #171b21; --surface-2: #1f242c; --ink: #e8ebf0; --ink-2: #b7bfcc; --muted: #8b94a3;
    --line: #2a3039; --brand: #4c9cf0; --brand-soft: #16273b; --ok: #4cc47a; --ok-soft: #12291b; --warn: #e3a64a;
    --warn-soft: #2e2312; --bad: #f2776b; --bad-soft: #321613; --route-alt: #5d6675; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1216; --surface: #171b21; --surface-2: #1f242c; --ink: #e8ebf0; --ink-2: #b7bfcc; --muted: #8b94a3;
  --line: #2a3039; --brand: #4c9cf0; --brand-soft: #16273b; --ok: #4cc47a; --ok-soft: #12291b; --warn: #e3a64a;
  --warn-soft: #2e2312; --bad: #f2776b; --bad-soft: #321613; --route-alt: #5d6675; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3 { margin: 0; line-height: 1.25; }
h3 { font-size: 15px; margin-bottom: 12px; }
a { color: var(--brand); }
/* Mobile / installed-app support */
html { -webkit-text-size-adjust: 100%; }
body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); padding-bottom: env(safe-area-inset-bottom); }
.topbar { padding-top: max(12px, env(safe-area-inset-top)); }
button, a, select, input { touch-action: manipulation; }
.offline-banner { background: var(--warn-soft); color: var(--warn); padding: 8px 16px; text-align: center; font-size: 13.5px; font-weight: 600; }
.offline-banner[hidden] { display: none; }
.primary.small { width: auto; padding: 8px 14px; }
.icon-close { border: 0; background: transparent; color: var(--muted); font-size: 16px; width: 36px; height: 36px; cursor: pointer; }
.env-banner { padding: 6px 16px; text-align: center; font-size: 13px; font-weight: 700; letter-spacing: .04em; color: #fff; }
.env-banner.development { background: #7c3aed; }
.env-banner.test { background: #c2410c; }
.muted { color: var(--muted); margin: 4px 0 12px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 1000;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand svg { width: 30px; height: 30px; fill: var(--brand); }
.brand h1 { font-size: 18px; }
.brand p { margin: 0; font-size: 13px; color: var(--muted); }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 10px; }
.tab { border: 0; background: transparent; color: var(--ink-2); padding: 7px 14px; border-radius: 7px; font: inherit; font-weight: 600; cursor: pointer; }
.tab.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

main { max-width: 1280px; margin: 0 auto; padding: 20px 24px 48px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.section-title { font-size: 18px; margin: 28px 0 4px; }

/* Trip layout */
.trip-layout { display: grid; grid-template-columns: 360px 1fr; gap: 16px; align-items: stretch; }
.map-wrap { padding: 0; overflow: hidden; min-height: 460px; }
#map { width: 100%; height: 100%; min-height: 460px; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; position: relative; }
label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
input[type=text], input[type=number], select {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; min-height: 40px;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.input-row { display: flex; gap: 6px; }
.icon-btn { flex: none; width: 40px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.icon-btn svg { width: 20px; height: 20px; fill: var(--ink-2); }
.swap { display: block; margin: -6px auto 2px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: 50%; width: 30px; height: 30px; cursor: pointer; font-size: 15px; }
.stop-actions { display: flex; align-items: center; justify-content: space-between; margin: -4px 0 8px; }
.stop-actions .swap { margin: 0; }
.add-stop { border: 1px dashed var(--brand); color: var(--brand); background: transparent; border-radius: 8px; padding: 6px 12px; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; min-height: 36px; }
.add-stop:hover { background: var(--brand-soft); }
.add-stop:disabled { opacity: .45; cursor: default; border-style: solid; }
.field.stop label { display: flex; align-items: center; gap: 6px; }
.stop-num, .stop-pin span { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: #e76f51; color: #fff; font-size: 12px; font-weight: 700; }
.stop-pin span { width: 24px; height: 24px; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.stop-pin { background: none; border: 0; }
.legs { list-style: none; margin: 10px 0 0; padding: 0; font-size: 12.5px; color: var(--ink-2); }
.legs li { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-top: 1px dashed var(--line); }
.legs .leg-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.legs .leg-km { white-space: nowrap; font-variant-numeric: tabular-nums; }
.suffix-input { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.suffix-input input { border: 0; }
.suffix-input span { padding: 0 10px; color: var(--muted); font-size: 13px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 80px; gap: 10px; }
.hint { font-size: 12.5px; margin-top: 2px; }
.guide { margin-top: 16px; }
.guide summary { cursor: pointer; font-weight: 700; font-size: 15px; }
.guide[open] summary { margin-bottom: 8px; }
.use-btn { border: 1px solid var(--brand); color: var(--brand); background: transparent; border-radius: 6px; padding: 4px 10px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.use-btn:hover { background: var(--brand-soft); }
tr.selected-vehicle td { background: var(--brand-soft); }
tr.recommended td { background: var(--ok-soft); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 2px 0 14px; color: var(--ink); }
.primary { width: 100%; border: 0; border-radius: 8px; background: var(--brand); color: var(--brand-ink); font: inherit; font-weight: 700; padding: 11px; cursor: pointer; }
.primary:disabled { opacity: .6; cursor: progress; }
.error { color: var(--bad); font-size: 14px; min-height: 1em; margin: 10px 0 0; }
.fineprint { color: var(--muted); font-size: 12.5px; margin: 12px 0 0; }

.suggestions { list-style: none; margin: 0; padding: 4px; position: absolute; top: 100%; left: 0; right: 0; z-index: 1200;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.15); max-height: 260px; overflow: auto; }
.suggestions:empty { display: none; }
.suggestions li { padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.suggestions li:hover, .suggestions li[aria-selected=true] { background: var(--brand-soft); }

/* Results */
.route-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 14px; margin-top: 10px; }
.route-cards > * { min-width: 0; }
.route-card { text-align: left; font: inherit; color: inherit; background: var(--surface); border: 2px solid var(--line); border-radius: 16px; padding: 18px; cursor: pointer; box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s, background .15s; }
.route-card:hover { border-color: var(--brand); }
/* The selected route summary is the highlight of the results */
.route-card.selected { border: 3px solid var(--brand); background: linear-gradient(180deg, var(--brand-soft) 0%, var(--surface) 70%); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent), 0 10px 28px rgba(11, 107, 203, .18); }
.rc-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.rc-label { background: var(--brand); color: var(--brand-ink); font-size: 12.5px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; padding: 3px 10px; border-radius: 999px; }
.route-card:not(.selected) .rc-label { background: var(--surface-2); color: var(--ink-2); }
.rc-via { color: var(--ink-2); font-size: 13.5px; font-weight: 600; }
.rc-main { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-top: 10px; }
.route-card .km { font-size: 40px; font-weight: 800; letter-spacing: -.02em; line-height: 1; color: var(--brand); font-variant-numeric: tabular-nums; }
.route-card .km small { font-size: 20px; font-weight: 700; }
.route-card:not(.selected) .km { color: var(--ink); }
.route-card .time { font-size: 22px; font-weight: 700; color: var(--ink); }
.rc-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; font-size: 14px; color: var(--ink-2); font-weight: 600; }
.rc-tag { background: var(--surface-2); padding: 2px 8px; border-radius: 6px; font-size: 12.5px; }
.toll-chip { background: #fff3c4; color: #6b4e00; border: 1px solid #f0d26b; padding: 3px 10px; border-radius: 999px; font-weight: 800; }
.toll-chip.warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.rc-total-label { margin-top: 14px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.route-card .costs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 6px; }
.route-card .cost { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.route-card .cost span { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.route-card .cost b { display: block; font-size: 21px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 2px; }
.route-card .cost.usual { border: 2px solid var(--ok); background: var(--ok-soft); }
.route-card .cost.usual span { color: var(--ok); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toll-chip { background: #3a2f0b; color: #f3d97a; border-color: #6b5413; } }
:root[data-theme="dark"] .toll-chip { background: #3a2f0b; color: #f3d97a; border-color: #6b5413; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tr.total td { font-weight: 700; border-bottom: 0; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }
.note { color: var(--muted); font-size: 12.5px; }
.toll-sum { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.toll-sum b { font-size: 20px; }
.callout { border-radius: 8px; padding: 8px 10px; font-size: 13px; margin-top: 10px; }
.callout.warn { background: var(--warn-soft); color: var(--warn); }
.callout.info { background: var(--brand-soft); color: var(--ink-2); }

.badge { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.badge.official { background: var(--ok-soft); color: var(--ok); }
.badge.needs-verification { background: var(--warn-soft); color: var(--warn); }
.badge.missing { background: var(--bad-soft); color: var(--bad); }
.badge.estimate { background: var(--surface-2); color: var(--ink-2); }

/* Dashboard */
.dash-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.update-pill { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; color: var(--ink-2); margin: 0 0 12px; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); border-top: 4px solid var(--c); }
.kpi .name { font-weight: 700; }
.kpi .grade { font-size: 12.5px; color: var(--muted); }
.kpi .price { font-size: 30px; font-weight: 800; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.kpi .price small { font-size: 14px; font-weight: 600; color: var(--muted); }
.kpi .range { font-size: 13px; color: var(--ink-2); }
.delta.up { color: var(--bad); } .delta.down { color: var(--ok); }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .grid { stroke: var(--line); }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--ink-2); margin-top: 6px; flex-wrap: wrap; }
.lookup-result { font-size: 22px; font-weight: 700; margin: 6px 0 0; }
.lookup-result small { display: block; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.log { list-style: none; padding: 0; margin: 0; font-size: 13.5px; }
.log li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.log li:last-child { border-bottom: 0; }
.log .when { color: var(--muted); font-size: 12.5px; }
.ok-text { color: var(--ok); font-weight: 600; } .bad-text { color: var(--bad); font-weight: 600; }

@media (max-width: 900px) {
  .trip-layout, .detail-grid { grid-template-columns: 1fr; }
  .map-wrap, #map { min-height: 340px; }
  .kpis { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  main { padding: 16px 16px 40px; }
  .topbar { padding: max(10px, env(safe-area-inset-top)) 16px 10px; gap: 10px; }
  .tabs { width: 100%; }
  .tab { flex: 1; padding: 9px 8px; }
  .brand p { display: none; }
  .route-cards { grid-template-columns: minmax(0, 1fr); }
  .route-card .costs { grid-template-columns: 1fr 1fr 1fr; }
  .route-card .km { font-size: 36px; }
  .route-card .cost b { font-size: 18px; }
  .route-card .cost { padding: 7px 8px; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .map-wrap, #map { min-height: 300px; }
  .kpi .price { font-size: 26px; }
  table.data { font-size: 13.5px; }
  table.data th, table.data td { padding: 7px 8px; }
}
/* Phone layouts: grid children may shrink (so tables scroll inside their panel), and some
   table columns are replaced by a compact line under the first column. */
.trip-layout > *, .detail-grid > * { min-width: 0; }
.only-sm { display: none; }
.toll-cards { display: grid; gap: 12px; }
.toll-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.toll-card h4 { margin: 0; font-size: 15px; }
.toll-card .trips { margin: 10px 0 0; padding: 0; list-style: none; }
.toll-card .trips li { padding: 7px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.toll-card .fares { display: flex; gap: 12px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.toll-card .fares span { color: var(--muted); }
.toll-card .fares b { color: var(--ink); }
@media (max-width: 520px) {
  .hide-sm { display: none !important; }
  .only-sm { display: block; }
  .toll-cards.only-sm { display: grid; }
}
/* Touch devices: 16px inputs stop iPhone Safari from zooming in on focus. */
@media (pointer: coarse) {
  input[type=text], input[type=number], select { font-size: 16px; min-height: 44px; }
  .icon-btn { width: 44px; }
  .suggestions li { padding: 11px 10px; }
}
/* Installed app (no browser bar): keep the header clear of the notch / status bar. */
@media (display-mode: standalone) {
  .topbar { padding-top: max(12px, env(safe-area-inset-top)); }
}

/* ---------------- Ad placements & footer ----------------
   Web: left + right rails (wide screens only) and a bottom banner.
   iPhone / Android apps: one bottom banner, fixed above the home indicator. */
.ad-rail, .ad-bottom-app { display: none; }
.ad-slot { box-sizing: border-box; max-width: 100%; }
.ad-slot.placeholder {
  display: grid; place-items: center; text-align: center; border: 1px dashed var(--line); border-radius: 8px;
  background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 10px, var(--surface) 10px, var(--surface) 20px);
  color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
}
@media (min-width: 1560px) {
  .platform-web .page { display: grid; grid-template-columns: 160px minmax(0, 1280px) 160px; gap: 24px; justify-content: center; padding: 0 24px; }
  .platform-web .page > main { margin: 0; width: 100%; }
  .platform-web .ad-rail { display: block; padding-top: 20px; }
  .platform-web .ad-rail .ad-slot { position: sticky; top: 96px; }
}
.ad-bottom-web { display: flex; justify-content: center; max-width: 1280px; margin: 8px auto 0; padding: 0 24px; }
.ad-bottom-web .ad-slot { width: 728px; height: 90px; }
@media (max-width: 760px) {
  .ad-bottom-web { padding: 0 16px; }
  .ad-bottom-web .ad-slot { width: 320px; height: 50px; }
}
.platform-ios .ad-bottom-web, .platform-android .ad-bottom-web { display: none; }
.platform-ios .ad-bottom-app, .platform-android .ad-bottom-app {
  display: flex; justify-content: center; align-items: center; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1100;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 4px 0 calc(4px + env(safe-area-inset-bottom));
}
.platform-ios .ad-bottom-app .ad-slot, .platform-android .ad-bottom-app .ad-slot { width: 320px; height: 50px; }
.platform-ios body, .platform-android body { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
.ad-hidden { display: none !important; }

.site-footer { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; padding: 18px 16px 22px; color: var(--muted); font-size: 13px; text-align: center; }
.site-footer b { color: var(--ink-2); }
.ad-rail .ad-slot { width: 160px; height: 600px; }

/* Ferries */
.ferry-chip { background: #dff3f1; color: #0f5a52; border: 1px solid #8fd1c8; padding: 3px 10px; border-radius: 999px; font-weight: 800; }
.ferry-chip.warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ferry-chip { background: #10332f; color: #8fe0d4; border-color: #1f5c55; } }
:root[data-theme="dark"] .ferry-chip { background: #10332f; color: #8fe0d4; border-color: #1f5c55; }
.ferry-block { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.label-note { font-weight: 500; color: var(--muted); }
.trip-options { align-items: end; }
.trip-options .check { margin: 0 0 12px; min-height: 40px; }

/* About Byaheros (search-engine friendly description; website only) */
.about { margin-top: 18px; }
.about h2 { font-size: 20px; margin: 0 0 6px; }
.about h3 { font-size: 15px; margin: 14px 0 6px; }
.about p { margin: 0 0 8px; }
.about ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.about-cols { display: grid; grid-template-columns: 3fr 2fr; gap: 24px; }
@media (max-width: 760px) { .about-cols { grid-template-columns: minmax(0, 1fr); gap: 0; } }
.platform-ios .about, .platform-android .about { display: none; }
.site-footer a { color: var(--muted); }

/* Cost split per passenger */
.route-card .cost .each { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 1px; font-variant-numeric: tabular-nums; }
.route-card .rc-split { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.about ul + p { margin-top: 12px; }
