/* Self-hosted fonts (SIL Open Font License, see fonts/). No request leaves the app. */
@font-face { font-family: "Figtree"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/figtree-latin-400-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Figtree"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/figtree-latin-ext-400-normal.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Figtree"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/figtree-latin-500-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Figtree"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/figtree-latin-ext-500-normal.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Figtree"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/figtree-latin-600-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Figtree"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/figtree-latin-ext-600-normal.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Bricolage Grotesque"; font-style: normal; font-weight: 200 800; font-display: swap; src: url("../fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2-variations"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Bricolage Grotesque"; font-style: normal; font-weight: 200 800; font-display: swap; src: url("../fonts/bricolage-grotesque-latin-ext-wght-normal.woff2") format("woff2-variations"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* Layout: one calm column on Home; on a trip, itinerary left and map right (Wanderlog-like). Details open in ONE drawer at a time. */
:root {
  --bg: #f4f7f6;
  --surface: #ffffff;
  --ink: #142120;
  --muted: #5b6b69;
  --line: #dce4e2;
  --accent: #0b7a68;
  --accent-soft: #e0f1ed;
  --night: #4a4fa8;
  --night-soft: #e9e9f8;
  --warn: #a55f00;
  --warn-soft: #fbf0df;
  --good: #2c7a3a;
  --land: #dfe7e5;
  --sea: #eef3f2;
  --map-land: #d6e0dd;
  --cat-food: #c9822b;
  --cat-act: #b8527a;
  --cat-other: #8a9896;
  --cat-local: #3d84a8;
  --shadow: 0 1px 2px rgba(20, 33, 32, .06), 0 8px 24px rgba(20, 33, 32, .06);
  --font-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-body: "Figtree", "Segoe UI", system-ui, -apple-system, sans-serif;
  --cc0: #0b7a68; --cc1: #3d84a8; --cc2: #c9822b; --cc3: #b8527a; --cc4: #5b60b8; --cc5: #5f8f3e; --cc6: #a8613d; --cc7: #2f8a8a; --cc8: #8a6d3b; --cc9: #7a5aa8; --on-cc: #ffffff;
  --radius: 14px;
  --radius-sm: 9px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1514; --surface: #151f1e; --ink: #e4edeb; --muted: #93a4a1; --line: #263330;
    --accent: #3cc1a6; --accent-soft: #143430; --night: #a3a6f2; --night-soft: #23244a;
    --warn: #e5a54a; --warn-soft: #362812; --good: #6cc77b; --land: #22302d; --sea: #111a19; --map-land: #263532; --cat-food: #e3a557; --cat-act: #e08aac; --cat-other: #6f7f7c; --cat-local: #7ab8d6; --cc0: #3cc1a6; --cc1: #7ab8d6; --cc2: #e3a557; --cc3: #e08aac; --cc4: #a3a6f2; --cc5: #9ccf73; --cc6: #e09a72; --cc7: #6fcfcf; --cc8: #d1b07a; --cc9: #c3a6ec; --on-cc: #0e1514;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1514; --surface: #151f1e; --ink: #e4edeb; --muted: #93a4a1; --line: #263330;
  --accent: #3cc1a6; --accent-soft: #143430; --night: #a3a6f2; --night-soft: #23244a;
  --warn: #e5a54a; --warn-soft: #362812; --good: #6cc77b; --land: #22302d; --sea: #111a19; --map-land: #263532; --cat-food: #e3a557; --cat-act: #e08aac; --cat-other: #6f7f7c; --cat-local: #7ab8d6; --cc0: #3cc1a6; --cc1: #7ab8d6; --cc2: #e3a557; --cc3: #e08aac; --cc4: #a3a6f2; --cc5: #9ccf73; --cc6: #e09a72; --cc7: #6fcfcf; --cc8: #d1b07a; --cc9: #c3a6ec; --on-cc: #0e1514;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.15; margin: 0; text-wrap: balance; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.2rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.02rem; font-weight: 500; }
p { margin: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.eyebrow { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* Top bar */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.topbar-inner { max-width: 1320px; margin: 0 auto; height: 60px; display: flex; align-items: center; gap: 28px; }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; letter-spacing: -.02em; }
.brand-mark { width: 28px; height: 28px; fill: var(--accent); stroke: var(--accent); }
.topnav { display: flex; gap: 4px; }
.topnav a { text-decoration: none; padding: 6px 12px; border-radius: 999px; color: var(--muted); font-weight: 500; }
.topnav a.active { color: var(--ink); background: var(--surface); box-shadow: 0 0 0 1px var(--line); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.proto-pill { font-size: .75rem; color: var(--muted); border: 1px dashed var(--line); padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; border: 0; background: transparent; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: var(--surface); color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; fill: currentColor; stroke: currentColor; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: .85rem; background: var(--accent-soft); color: var(--accent); flex: none; }
.avatar.b { background: var(--night-soft); color: var(--night); }
.avatar-stack { display: flex; }
.avatar-stack .avatar { width: 28px; height: 28px; font-size: .78rem; box-shadow: 0 0 0 2px var(--bg); }
.avatar-stack .avatar + .avatar { margin-left: -6px; }

/* Page frame */
.app { outline: none; }
.page {
  max-width: 1120px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 40px 72px;
  display: grid; gap: 40px;
}
.page-head { display: grid; gap: 6px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; border-radius: 10px; padding: 9px 16px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 500; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); padding-inline: 8px; }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }

/* Home KPIs */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { background: var(--surface); border-radius: var(--radius); padding: 18px 20px; display: grid; gap: 6px; align-content: start; box-shadow: var(--shadow); }
.kpi-value { font-family: var(--font-display); font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: .95rem; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.kpi-note { font-size: .85rem; color: var(--muted); }
.kpi-note.good { color: var(--good); }
.bar { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: 4px; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }

/* Trip cards */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.trips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.trip-card { background: var(--surface); border-radius: var(--radius); overflow: hidden; text-decoration: none; display: grid; grid-template-rows: auto 1fr; border: 1px solid var(--line); transition: border-color .15s, transform .15s; }
.trip-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.trip-thumb { background: var(--sea); aspect-ratio: 16 / 7; max-width: 100%; }
.trip-thumb svg { width: 100%; height: 100%; display: block; }
.trip-body { padding: 16px 18px 18px; display: grid; gap: 10px; }
.trip-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .85rem; color: var(--muted); }
.trip-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.pill.night { background: var(--night-soft); color: var(--night); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.quiet { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.trip-new { border: 1.5px dashed var(--line); border-radius: var(--radius); display: grid; place-items: center; text-align: center; padding: 28px; text-decoration: none; color: var(--muted); gap: 6px; min-height: 220px; }
.trip-new:hover { border-color: var(--accent); color: var(--accent); }
.trip-new strong { font-family: var(--font-display); font-size: 1.1rem; color: var(--ink); }

/* Trip page */
.trip-page { max-width: 1320px; padding-block: 28px 0; gap: 20px; }
.trip-header { display: grid; gap: 14px; }
.back { font-size: .88rem; color: var(--muted); text-decoration: none; display: inline-flex; gap: 6px; align-items: center; width: fit-content; }
.back:hover { color: var(--accent); }
.trip-title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.trip-title-row .trip-meta { margin-top: 8px; font-size: .92rem; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs a { text-decoration: none; padding: 10px 14px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--ink); border-bottom-color: var(--accent); }

/* Route tab */
.route { display: grid; grid-template-columns: minmax(0, 440px) minmax(0, 1fr); gap: 28px; align-items: start; padding-bottom: 48px; }
.itinerary { display: grid; gap: 0; }
.itin-summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-bottom: 14px; }
.stop, .leg, .gap-row { position: relative; padding-left: 44px; }
.stop::before, .leg::before, .gap-row::before { content: ""; position: absolute; left: 15px; top: 0; bottom: 0; width: 2px; background: var(--line); }
.itinerary > :first-child::before { top: 22px; }
.itinerary > .stop:last-child::before { bottom: calc(100% - 22px); }
.stop-btn { width: 100%; text-align: left; border: 1px solid transparent; background: var(--surface); border-radius: var(--radius-sm); padding: 12px 14px; cursor: pointer; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; box-shadow: var(--shadow); }
.stop-btn:hover, .stop-btn.sel { border-color: var(--accent); }
.stop-dot { position: absolute; left: 4px; top: 12px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 2px solid var(--accent); color: var(--accent); font-size: .72rem; font-weight: 700; z-index: 1; font-variant-numeric: tabular-nums; }
.stop.home .stop-dot { background: var(--accent); color: var(--surface); }
.stop-name { font-family: var(--font-display); font-weight: 500; font-size: 1.05rem; }
.stop-sub { font-size: .84rem; color: var(--muted); grid-column: 1; }
.stop-cost { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.stop-cost small { display: block; font-weight: 400; font-size: .78rem; color: var(--muted); }
.stop.home .stop-btn { box-shadow: none; background: transparent; border-color: var(--line); }

.leg { padding-block: 6px; }
.leg-btn { width: 100%; text-align: left; background: transparent; border: 0; border-radius: var(--radius-sm); padding: 8px 10px; cursor: pointer; display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .86rem; flex-wrap: wrap; }
.leg-btn:hover { background: var(--surface); color: var(--ink); }
.leg-ico { position: absolute; left: 6px; width: 20px; height: 20px; border-radius: 6px; background: var(--bg); display: grid; place-items: center; color: var(--muted); z-index: 1; }
.leg-ico svg, .mode svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.leg-cost { margin-left: auto; color: var(--ink); font-weight: 600; }
.leg-route { font-weight: 600; color: var(--ink); letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.leg.overnight .leg-ico { color: var(--night); }
.gap-row { padding-block: 4px; }
.gap-row .pill { margin-left: 10px; }

.map-wrap { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 76px); background: var(--sea); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.map-wrap svg.map { width: 100%; height: auto; display: block; }
.map .land { fill: var(--land); }
.map .r-flight { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-dasharray: 5 5; opacity: .85; }
.map .r-ground { fill: none; stroke: var(--accent); stroke-width: 2.6; stroke-linecap: round; }
.map .r-night { stroke: var(--night); }
.map .pin { fill: var(--surface); stroke: var(--accent); stroke-width: 2; cursor: pointer; }
.map .pin.home { fill: var(--accent); }
.map .pin.sel { fill: var(--accent); r: 7; }
.map.thumb path, .map.thumb circle { vector-effect: non-scaling-stroke; }
.map .pin-label { font: 600 11px var(--font-body); fill: var(--ink); paint-order: stroke; stroke: var(--sea); stroke-width: 3px; pointer-events: none; }
.map-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 10px 14px; font-size: .8rem; color: var(--muted); border-top: 1px solid var(--line); background: var(--surface); }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.map-legend i { display: inline-block; width: 22px; height: 0; border-top: 2px solid var(--accent); }
.map-legend i.dash { border-top-style: dashed; }
.map-legend i.night { border-top-color: var(--night); border-top-width: 3px; }
.map-tools { position: absolute; top: 12px; right: 12px; display: flex; gap: 6px; }
.map-tools .btn { padding: 6px 10px; font-size: .82rem; box-shadow: var(--shadow); }

/* Money tab */
.segmented { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented button { border: 0; background: transparent; padding: 6px 14px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 500; }
.segmented button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.money { display: grid; gap: 28px; max-width: 920px; padding-bottom: 56px; }
.money-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.figures { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.figure { display: grid; gap: 2px; padding: 4px 0; }
.figure .kpi-value { font-size: 1.6rem; }
.card { background: var(--surface); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); display: grid; gap: 16px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.stack { display: flex; height: 14px; border-radius: 99px; overflow: hidden; gap: 2px; }
.stack span { display: block; height: 100%; }
.cat-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px 20px; font-size: .88rem; }
.cat-list div { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.cat-list i { width: 10px; height: 10px; border-radius: 3px; }
.tier-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tier { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; display: grid; gap: 2px; }
.tier.on { border-color: var(--accent); background: var(--accent-soft); }
.tier strong { font-family: var(--font-display); font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; padding: 0 12px 8px 0; }
td { padding: 10px 12px 10px 0; border-top: 1px solid var(--line); vertical-align: middle; }
td.r, th.r { text-align: right; }
.person { display: flex; align-items: center; gap: 10px; }
.expense-list { display: grid; }
.exp-date { font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 14px 0 6px; }
.expense { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); text-align: left; background: none; border-left: 0; border-right: 0; border-bottom: 0; cursor: pointer; width: 100%; }
.expense:hover .exp-title { color: var(--accent); }
.exp-ico { width: 36px; height: 36px; border-radius: 10px; background: var(--bg); display: grid; place-items: center; color: var(--muted); }
.exp-ico svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.exp-title { font-weight: 500; }
.exp-sub { font-size: .82rem; color: var(--muted); }
.exp-amt { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.balances { display: grid; gap: 12px; }
.bal-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.bal-amt { font-weight: 600; font-variant-numeric: tabular-nums; }
.bal-amt.pos { color: var(--good); }
.bal-amt.neg { color: var(--warn); }
.settle { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; background: var(--accent-soft); border-radius: var(--radius-sm); padding: 14px 16px; }

/* Lists tab */
.lists { display: grid; gap: 14px; max-width: 760px; padding-bottom: 56px; }
.lists-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
details.section { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
details.section summary { list-style: none; cursor: pointer; padding: 16px 20px; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 14px; }
details.section summary::-webkit-details-marker { display: none; }
details.section summary .chev { width: 16px; height: 16px; stroke: var(--muted); fill: none; stroke-width: 2; transition: transform .15s; }
details.section[open] summary .chev { transform: rotate(90deg); }
.sec-name { font-family: var(--font-display); font-weight: 500; font-size: 1.05rem; display: flex; align-items: center; gap: 10px; }
.sec-progress { font-size: .84rem; color: var(--muted); font-variant-numeric: tabular-nums; display: flex; gap: 10px; align-items: center; }
.mini-bar { width: 64px; height: 5px; background: var(--line); border-radius: 99px; overflow: hidden; }
.mini-bar span { display: block; height: 100%; background: var(--accent); }
.items { padding: 0 20px 12px; display: grid; }
.item { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.item input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.item.done .item-title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }
.item-sub { font-size: .8rem; color: var(--muted); }
.item-right { display: flex; gap: 8px; align-items: center; font-size: .84rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.add-item { padding: 10px 0 4px; border-top: 1px solid var(--line); }

/* Settings tab */
.settings { display: grid; gap: 24px; max-width: 820px; padding-bottom: 56px; }
.field-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.field { display: grid; gap: 6px; font-size: .85rem; color: var(--muted); }
.field input, .field select { font: inherit; font-size: .95rem; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 12px; width: 100%; min-width: 0; }
.invite { display: flex; gap: 10px; flex-wrap: wrap; }
.invite input { flex: 1 1 220px; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 12px; min-width: 0; }

/* Drawer: one at a time, overlays, never squeezes the page */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(10, 20, 19, .28); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 41;
  width: min(420px, 100%);
  background: var(--surface); box-shadow: -12px 0 40px rgba(0, 0, 0, .14);
  transform: translateX(100%); transition: transform .22s ease;
  display: grid; grid-template-rows: auto 1fr;
  padding-top: env(safe-area-inset-top, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.drawer:not(.open) { visibility: hidden; transition: transform .22s ease, visibility 0s .22s; }
.drawer.open { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 22px 22px 14px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin-top: 4px; }
.drawer-body { overflow-y: auto; padding: 18px 22px 28px; display: grid; gap: 20px; align-content: start; }
.dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 18px; font-size: .9rem; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.breakdown { display: grid; gap: 0; font-size: .9rem; }
.breakdown div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.breakdown div.total { font-weight: 600; border-top: 1.5px solid var(--ink); }
.source { font-size: .8rem; color: var(--muted); background: var(--bg); border-radius: var(--radius-sm); padding: 10px 12px; }
.note { font-size: .86rem; color: var(--muted); padding-left: 10px; border-left: 2px solid var(--night); }

/* Responsive */
@media (max-width: 1000px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .trips { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .route { grid-template-columns: minmax(0, 1fr); }
  .map-wrap { position: relative; top: 0; order: -1; }
}
@media (max-width: 640px) {
  .proto-pill { display: none; }
  .topbar-inner { gap: 12px; }
  .page { padding-block: 24px 56px; gap: 28px; }
  .kpis, .trips, .figures, .field-row { grid-template-columns: minmax(0, 1fr); }
  .tier-row { grid-template-columns: minmax(0, 1fr); }
  .kpi-value { font-size: 1.6rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* v2: map links, buffer, bookings, settings, export */
.kpi-note.bad { color: var(--warn); }
.title-actions { display: flex; align-items: center; gap: 14px; }
.map .hit { fill: none; stroke: transparent; stroke-width: 12; cursor: pointer; pointer-events: stroke; }
.map .hit:hover + .hit, .map .r-sel { stroke-width: 3.4; opacity: 1; }
.map .r-flight.r-sel { stroke-dasharray: none; }
.map-hint { margin-left: auto; font-size: .78rem; }
@keyframes flash { 0% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 3px transparent; } }
.stop.flash .stop-btn, .leg.flash .leg-btn { animation: flash 1.6s ease-out; }
.leg-btn.sel { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--accent); }
.booked { display: inline-flex; align-items: center; gap: 3px; color: var(--good); font-weight: 600; font-size: .78rem; }
.booked svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.hatch { background-image: repeating-linear-gradient(135deg, transparent 0 3px, var(--surface) 3px 5px); }
.booking { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; display: grid; gap: 6px; }
.booking.empty { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: .9rem; border-style: dashed; }
.booking-by { font-weight: 500; }
.booking-code { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.booking-code .btn { padding: 6px 10px; font-size: .84rem; }
.code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 1.05rem; letter-spacing: .08em; font-weight: 600; }
.booking .code { font-size: 1.3rem; }

.settings-page { max-width: 820px; }
.set-rows { display: grid; }
.set-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 11px 0; border-top: 1px solid var(--line); font-size: .95rem; }
.set-row select { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 7px 10px; }
.num-input { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: .88rem; }
.num-input input { width: 84px; font: inherit; font-size: .95rem; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 7px 10px; text-align: right; font-variant-numeric: tabular-nums; }
.switch { width: 40px; height: 24px; border-radius: 99px; background: var(--line); position: relative; display: inline-block; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch.on { background: var(--accent); }
.switch.on::after { left: 19px; }
.rates { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.rate { display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: center; gap: 8px; font-weight: 600; font-size: .85rem; }
.rate input { min-width: 0; font: inherit; font-weight: 400; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 7px 10px; text-align: right; font-variant-numeric: tabular-nums; }

.export-page { max-width: 880px; gap: 16px; }
.export-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.sheet { background: #fff; color: #172322; border-radius: 6px; box-shadow: var(--shadow); padding: clamp(20px, 5vw, 48px); display: grid; gap: 28px; font-size: .9rem; }
.sheet .muted, .sheet .exp-sub, .sheet .eyebrow, .sheet th { color: #5b6b69; }
.sheet h2 { font-size: 1.05rem; margin-bottom: 10px; }
.sheet td { border-top-color: #dce4e2; }
.sheet .breakdown div { border-top-color: #dce4e2; }
.sheet .breakdown div.total { border-top-color: #172322; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; padding-bottom: 18px; border-bottom: 2px solid #0b7a68; }
.sheet-head h1 { font-size: 1.7rem; margin: 4px 0; }
.sheet-figures { display: flex; gap: 18px; flex-wrap: wrap; color: #5b6b69; }
.sheet-figures strong { color: #172322; font-size: 1.05rem; }
.sheet-table td { vertical-align: top; }
.sheet-table .code { font-size: .9rem; }
.sheet-table tr.leg-r td { color: #5b6b69; }
.sheet-table tr.gap td { color: #a55f00; font-weight: 600; }
.nowrap { white-space: nowrap; }
.sheet-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px; }
.todo { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
@media (max-width: 640px) {
  .sheet-cols { grid-template-columns: minmax(0, 1fr); }
  .title-actions .btn { padding: 7px 10px; }
  .map-hint { display: none; }
}
@media print {
  .topbar, .export-bar, .export-page > p { display: none !important; }
  body { background: #fff; }
  .page { padding: 0; }
  .sheet { box-shadow: none; padding: 0; }
}

/* ---------- App (Phase 1) ---------- */
.ico { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.btn .ico { width: 16px; height: 16px; }
.icon-btn .ico { fill: none; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.small { font-size: .86rem; }
.bad { color: var(--warn); }
.good { color: var(--good); }
.spacer { flex: 1; }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn.danger { color: var(--warn); }
.btn.danger-armed { background: var(--warn); border-color: var(--warn); color: var(--surface); }
label.btn { cursor: pointer; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: .9rem; z-index: 60; box-shadow: var(--shadow); max-width: calc(100% - 32px); text-align: center; }

.empty-home { max-width: 560px; margin: 8vh auto 0; display: grid; gap: 14px; justify-items: start; }
.empty-home h1 { font-size: clamp(2rem, 1.5rem + 2vw, 2.8rem); }

.map .r-unknown { fill: none; stroke: var(--muted); stroke-width: 1.4; stroke-dasharray: 2 4; opacity: .7; }
.map path.r-flight, .map path.r-ground, .map path.r-unknown, .map .pin, .map .hit { vector-effect: non-scaling-stroke; }
.map-empty { aspect-ratio: 1000 / 340; max-width: 100%; display: grid; place-items: center; align-content: center; gap: 6px; color: var(--muted); }
.map-empty .ico { width: 28px; height: 28px; }
.itin-foot { padding: 14px 0 0 44px; }
.stop-warn, .stop-info { grid-column: 1 / -1; display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; margin-top: 4px; }
.stop-warn { color: var(--warn); }
.stop-info { color: var(--night); }
.stop-warn .ico { width: 14px; height: 14px; }
.leg-btn.add { color: var(--accent); font-weight: 500; }
.pill .ico { width: 13px; height: 13px; }
.plus { font-size: .74rem; color: var(--night); font-weight: 600; vertical-align: super; }

/* Forms in the side panel */
#drawer-body form { display: grid; gap: 14px; }
.field textarea { font: inherit; font-size: .95rem; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 12px; width: 100%; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.field-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px 14px; margin: 0; display: grid; gap: 12px; min-width: 0; }
.fieldset legend { padding: 0 6px; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.code-input { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace !important; letter-spacing: .08em; text-transform: uppercase; }
.form-error { color: var(--warn); font-size: .88rem; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding-top: 4px; }
.mode-pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.mode-opt { position: relative; display: grid; justify-items: center; gap: 4px; padding: 10px 6px; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; font-size: .82rem; color: var(--muted); }
.mode-opt input { position: absolute; opacity: 0; pointer-events: none; }
.mode-opt .ico { width: 20px; height: 20px; }
.mode-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.mode-opt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.overnight-box { display: grid; gap: 12px; }
.place-picker { position: relative; display: grid; gap: 4px; }
.place-results { list-style: none; margin: 0; padding: 4px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow); max-height: 280px; overflow-y: auto; }
.place-results li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 7px; cursor: pointer; }
.place-results li[aria-selected="true"], .place-results li:hover { background: var(--accent-soft); }
.place-status:empty { display: none; }

.traveller-list { display: grid; gap: 10px; }
.traveller-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) 36px; gap: 10px; align-items: center; }
.traveller-row input { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 12px; min-width: 0; }
form.settings { max-width: 820px; }
.sheet-warn { color: #a55f00; font-weight: 600; }

@media (max-width: 640px) {
  .field-pair { grid-template-columns: minmax(0, 1fr); }
}
@media print {
  .no-print, .drawer, .drawer-backdrop, .toast { display: none !important; }
  @page { margin: 14mm; }
  .sheet-table tr { break-inside: avoid; }
}

/* Phase 2: live map (Leaflet) */
.lm { position: relative; isolation: isolate; z-index: 0; height: min(calc(100vh - 170px), 680px); min-height: 360px; background: var(--sea); font: inherit; }
.lm.leaflet-container { background: var(--sea); font-family: var(--font-body); }
.map-wrap .map-tools { z-index: 2; }
.map-note { position: absolute; left: 12px; bottom: 56px; z-index: 2; margin: 0; max-width: calc(100% - 24px); padding: 6px 10px; border-radius: 8px; background: var(--surface); color: var(--muted); font-size: .8rem; box-shadow: var(--shadow); }
.lm .leaflet-control-zoom { border: 0; box-shadow: var(--shadow); border-radius: 10px; overflow: hidden; }
.lm .leaflet-control-zoom a { background: var(--surface); color: var(--ink); border-color: var(--line); width: 32px; height: 32px; line-height: 30px; }
.lm .leaflet-control-zoom a:hover { background: var(--accent-soft); }
.lm .leaflet-control-attribution { background: color-mix(in srgb, var(--surface) 82%, transparent); color: var(--muted); font-size: 10px; }
.lm .leaflet-control-attribution a { color: var(--muted); }
.lm-route { fill: none; stroke: var(--accent); stroke-linecap: round; stroke-linejoin: round; transition: stroke-width .12s; }
.lm-route.is-flight { stroke-dasharray: 6 7; stroke-width: 2.2px; }
.lm-route.is-ground { stroke-width: 3.5px; }
.lm-route.is-night { stroke: var(--night); }
.lm-route.is-unknown { stroke: var(--muted); stroke-dasharray: 2 6; stroke-width: 2px; }
.lm-route.is-sel, .lm-route.is-hover { stroke-width: 5.5px; stroke-dasharray: none; }
.lm-route.is-flight.is-sel, .lm-route.is-flight.is-hover { stroke-width: 3.5px; }
.lm-pin { display: grid; place-items: center; }
.lm-pin span { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); color: var(--accent); border: 2px solid var(--accent); font: 700 11px/1 var(--font-body); font-variant-numeric: tabular-nums; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .12s; }
.lm-pin.is-home span { width: 16px; height: 16px; background: var(--accent); }
.lm-pin.is-sel span, .lm-pin.is-hover span { background: var(--accent); color: var(--surface); transform: scale(1.25); }
.lm-pin:focus-visible { outline: none; }
.lm-pin:focus-visible span { outline: 3px solid var(--night); outline-offset: 2px; }
.lm-moon { color: var(--night); pointer-events: none; }
.lm-moon svg { width: 18px; height: 18px; fill: var(--surface); stroke: var(--night); stroke-width: 2; padding: 2px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, .2); box-sizing: border-box; }
.lm-tip.leaflet-tooltip { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); font: 500 .8rem var(--font-body); padding: 4px 8px; }
.lm-tip.leaflet-tooltip-top::before { border-top-color: var(--surface); }
.leaflet-container .leaflet-marker-icon.lm-pin { background: none; border: 0; }
.stop-btn.hover { border-color: var(--accent); }
.leg-btn.hover { background: var(--surface); color: var(--ink); }
.code-chip { display: inline-block; font: 600 .74rem/1.4 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .04em; padding: 0 5px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); }
.leg-facts { margin: -4px 0 0; color: var(--ink); font-weight: 500; }
.leg-facts:empty { display: none; }
.leg-facts.bad { color: var(--warn); }
.ends { display: grid; gap: 12px; }
.airport-field { position: relative; display: grid; gap: 6px; }
.ap-near { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ap-near:empty { display: none; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 3px 10px; font: 600 .78rem var(--font-body); cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
@media (max-width: 1000px) { .lm { height: 380px; min-height: 0; } }
@media (max-width: 640px) { .lm { height: 300px; } .map-note { bottom: 52px; } }
@media print { .lm, .map-tools, .map-note { display: none !important; } }
[hidden] { display: none !important; }
.toast { pointer-events: none; }
/* OpenStreetMap's colourful tiles, toned down to match the app; inverted for dark mode */
.lm.lm-osm .leaflet-tile-pane { filter: saturate(.45) contrast(.95) brightness(1.03); }
html[data-theme="dark"] .lm.lm-osm .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) saturate(.35) brightness(.8) contrast(.9); }
@media (prefers-color-scheme: dark) { html:not([data-theme="light"]) .lm.lm-osm .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) saturate(.35) brightness(.8) contrast(.9); } }

/* Phase 3: money */
.segmented .seg-link { text-decoration: none; padding: 6px 14px; border-radius: 7px; color: var(--muted); font-weight: 500; }
.segmented .seg-link[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }
.seg-opt { position: relative; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-opt span { display: block; padding: 6px 14px; border-radius: 7px; color: var(--muted); font-weight: 500; }
.seg-opt input:checked + span { background: var(--accent-soft); color: var(--accent); }
.seg-opt input:focus-visible + span { outline: 2px solid var(--accent); }
.stack .buffer, .cat-list i.buffer { background: repeating-linear-gradient(135deg, var(--cat-other) 0 3px, transparent 3px 6px); }
.note-box { background: var(--bg); border-radius: var(--radius-sm); padding: 10px 14px; color: var(--muted); margin: 0; }
.note-box a, .kpi-note a, p.muted a { color: inherit; }
.ideas { list-style: none; margin: 0; padding: 0; display: grid; }
.idea { width: 100%; display: flex; justify-content: space-between; gap: 16px; align-items: baseline; text-align: left; background: none; border: 0; border-top: 1px solid var(--line); padding: 11px 0; cursor: pointer; color: var(--ink); font: inherit; }
.ideas li:first-child .idea { border-top: 0; }
.idea:hover span:first-child { color: var(--accent); }
.idea .num { white-space: nowrap; font-weight: 600; }
.tier { font: inherit; color: var(--ink); background: var(--surface); text-align: left; cursor: pointer; }
.tier:hover { border-color: var(--accent); }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--ink); font-weight: 500; cursor: pointer; text-align: left; }
.link-btn:hover { color: var(--accent); text-decoration: underline; }
.src { display: inline-block; font-size: .7rem; font-weight: 600; letter-spacing: .02em; padding: 1px 7px; border-radius: 99px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.src.fixed { background: var(--accent-soft); color: var(--accent); }
.src.warn { background: var(--warn-soft); color: var(--warn); }
details.fold > summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: baseline; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary h3 { margin: 0; }
details.fold .chev, details.fold-fields > summary::after { width: 16px; height: 16px; stroke: var(--muted); fill: none; stroke-width: 2; transition: transform .15s; align-self: center; }
details.fold[open] .chev { transform: rotate(90deg); }
details.fold:not([open]) { gap: 0; }
details.fold-fields { display: grid; gap: 12px; }
details.fold-fields > summary { cursor: pointer; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; display: flex; gap: 8px; align-items: center; }
details.fold-fields:not([open]) > summary { margin-bottom: -4px; }
td.good, td.bad { font-weight: 600; }
tr.leg-r td { color: var(--muted); font-size: .85rem; }
.small-btn { padding: 4px 8px; font-size: .82rem; }
.kpi-link { text-decoration: none; color: inherit; }
.kpi-link:hover { box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.traveller-block { display: grid; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.traveller-block:first-child { border-top: 0; padding-top: 0; }
.traveller-money { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding-left: 46px; }
.small-field { font-size: .8rem; }
.small-field input { padding: 7px 10px; }
.input-suffix { display: flex; align-items: center; gap: 6px; }
.input-suffix span { color: var(--muted); }
.buffer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 14px; }
.field-label { font-size: .85rem; color: var(--muted); margin: 0 0 8px; }
.price-grid { display: grid; gap: 8px; }
.price-row { display: grid; grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(0, 1fr)); gap: 8px; align-items: center; font-size: .85rem; }
.price-row.head span { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.price-row input, .fx-grid input { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; width: 100%; min-width: 0; font-variant-numeric: tabular-nums; }
.fx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--ink); margin-right: 14px; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; }
.split-even, .split-shares { display: flex; flex-wrap: wrap; gap: 8px 4px; }
.split-shares .field { flex: 1 1 120px; }
.price-table td { padding: 8px 10px 8px 0; }
@media (max-width: 640px) {
  .traveller-money { grid-template-columns: minmax(0, 1fr); padding-left: 0; }
  .figures, .tier-row { grid-template-columns: minmax(0, 1fr); }
  .idea { flex-direction: column; gap: 2px; }
}
.funds-table { min-width: 520px; }
.funds-table .bar-col { width: 22%; min-width: 90px; }
.funds-table .bar { margin: 0; }
@media (max-width: 640px) {
  details.fold > summary { grid-template-columns: minmax(0, 1fr) auto; }
  details.fold > summary .muted { display: none; }
  .funds-table .bar-col { display: none; }
  .funds-table { min-width: 0; }
}

/* Phase 4: Home */
.home-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.kpis.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis + .coming, .kpis + section { margin-top: 0; }
.coming { margin: 24px 0 32px; }
.coming .items { padding: 0; }
.trip-thumb { position: relative; overflow: hidden; }
.trip-thumb.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-pill { position: absolute; top: 10px; right: 10px; box-shadow: 0 1px 4px rgba(0, 0, 0, .12); background: var(--surface); }
.thumb-pill.quiet { background: var(--surface); }
.progs { display: grid; gap: 6px; }
.prog { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; align-items: center; gap: 10px; font-size: .8rem; color: var(--muted); }
.prog .mini-bar { width: auto; }
.trip-foot .num { font-size: .88rem; }
.trip-foot .pill .ico { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; }
.cover-row { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 18px; align-items: center; }
.cover-prev { aspect-ratio: 16 / 7; border-radius: var(--radius-sm); overflow: hidden; background: var(--sea); border: 1px solid var(--line); }
.cover-prev img, .cover-prev svg { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Phase 5: Lists */
.lists-top { align-items: center; }
.lists-stats { font-size: .92rem; color: var(--muted); }
.lists-stats strong { color: var(--ink); }
.lists-stats a { color: inherit; }
.lists-empty { display: grid; gap: 10px; max-width: 620px; }
.lists-empty h3 { margin: 0; }
.item { grid-template-columns: 22px minmax(0, 1fr) auto; }
.item-main { all: unset; cursor: pointer; display: grid; gap: 2px; min-width: 0; padding: 2px 0; border-radius: 6px; }
.item-main:hover .item-title { color: var(--accent); }
.item-main:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.item-title { overflow-wrap: anywhere; }
.item input { cursor: pointer; }
.item-none { padding: 10px 0; border-top: 1px solid var(--line); margin: 0; }
.add-item { display: flex; gap: 6px; flex-wrap: wrap; }
.avatar.mini { width: 24px; height: 24px; font-size: .68rem; }
.avatar.mini.all { background: var(--line); color: var(--muted); }
.item-right .pill { font-size: .72rem; }
.segmented.wrap { flex-wrap: wrap; }
.sec-progress { white-space: nowrap; }
@media (max-width: 640px) {
  .kpis.three { grid-template-columns: minmax(0, 1fr); }
  .item { grid-template-columns: 22px minmax(0, 1fr); }
  .item-right { grid-column: 2; flex-wrap: wrap; }
  details.section summary { grid-template-columns: minmax(0, 1fr) auto; }
  details.section summary > .small { display: none; }
  .cover-row { grid-template-columns: minmax(0, 1fr); }
  .lists-top .row-actions { width: 100%; }
}
@media (max-width: 1000px) and (min-width: 641px) { .kpis.three { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media print { .todo .exp-sub { font-size: .8rem; } }
.trip-foot > .num .muted { white-space: nowrap; }

/* Review pass (Phase 6) */
.trip-page { max-width: 1120px; }
.trip-page.wide { max-width: 1320px; }
.money { max-width: none; }
.lists { max-width: 860px; }
.figure { align-content: start; }
.card-head { align-items: center; min-height: 36px; }
.leg-route { flex-basis: 100%; letter-spacing: 0; }
.gap-row .pill { margin-left: 0; }
a.expense { text-decoration: none; color: inherit; }
a.expense .exp-title { color: var(--accent); }
.lists-top .row-actions { align-items: center; }
.trip-money { font-size: .88rem; margin: 0; }
.trip-flags { display: flex; flex-wrap: wrap; gap: 6px; }
.trip-flags .pill .ico { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; }
.autosave-note { font-size: .82rem; color: var(--muted); }
@media (max-width: 640px) {
  .trip-header { position: relative; gap: 10px; }
  .trip-title-row h1 { padding-right: 52px; }
  .title-actions { position: absolute; top: 0; right: 0; }
  .title-actions .avatar-stack { display: none; }
  .title-actions .btn .btn-label { display: none; }
  .title-actions .btn { padding: 8px; }
  .itin-summary { flex-direction: column; align-items: flex-start; gap: 6px; }
  details.section summary > span:nth-child(2) { display: none; }
  .tabs { overflow-x: auto; scrollbar-width: none; }
}

/* Export sheet: itinerary rows, A4 and phone formats */
.itin-sheet { display: grid; }
.it-row { display: grid; grid-template-columns: 74px minmax(0, 1fr) minmax(0, 34%); gap: 4px 16px; padding: 10px 0; border-top: 1px solid #dce4e2; break-inside: avoid; }
.it-row.it-leg .it-what strong { font-weight: 500; }
.it-row.it-leg { color: #3f4f4d; }
.it-date { display: grid; font-variant-numeric: tabular-nums; }
.it-date span { font-size: .78rem; color: #5b6b69; }
.it-what { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.it-book { display: grid; gap: 2px; font-size: .86rem; overflow-wrap: anywhere; }
.it-book .code { font-weight: 700; letter-spacing: .04em; color: #0b7a68; }
.it-book.none { color: #8a9896; }
.it-row.it-gap { color: #a55f00; font-weight: 600; border-top-style: dashed; }
.sheet.phone { max-width: 380px; margin-inline: auto; padding: 18px 16px; gap: 20px; font-size: .86rem; }
.sheet.phone .sheet-head h1 { font-size: 1.35rem; }
.sheet.phone .it-row { grid-template-columns: 48px minmax(0, 1fr); gap: 2px 10px; }
.sheet.phone .it-book { grid-column: 2; background: #f1f6f5; border-radius: 6px; padding: 6px 8px; margin-top: 4px; }
.sheet.phone .it-book.none { display: none; }
.sheet.phone .sheet-table th, .sheet.phone .sheet-table td { padding-inline: 4px; }
@media (max-width: 640px) {
  .it-row { grid-template-columns: 48px minmax(0, 1fr); }
  .it-book { grid-column: 2; }
  .export-bar .row-actions { width: 100%; }
}
@media print {
  .sheet.phone { max-width: none; padding: 0; }
  .it-row { break-inside: avoid; }
}

/* Quick expense */
.fab { display: none; }
@media (max-width: 640px) {
  .fab { display: inline-flex; align-items: center; gap: 6px; position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 30; border: 0; border-radius: 999px; padding: 14px 20px 14px 16px; background: var(--accent); color: #fff; font: 600 .95rem var(--font-body); box-shadow: 0 6px 20px rgba(11, 122, 104, .35); cursor: pointer; }
  .fab .ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; }
  .page { padding-bottom: 96px; }
}
.quick { display: grid; gap: 16px; }
.quick-amount { display: grid; grid-template-columns: minmax(0, 1fr) 96px; gap: 8px; }
.quick-amount input, .quick-amount select { font: 700 1.8rem var(--font-display); color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 14px; min-width: 0; }
.quick-amount select { font-size: 1rem; font-family: var(--font-body); }
.quick-amount input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.quick-cats { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.qcat { position: relative; }
.qcat input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.qcat span { display: grid; justify-items: center; gap: 4px; padding: 10px 4px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: .8rem; color: var(--muted); background: var(--surface); text-align: center; }
.qcat .ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.qcat input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.qcat input:focus-visible + span { outline: 2px solid var(--accent); }
.btn.wide { width: 100%; justify-content: center; padding-block: 13px; }
.offline-pill { margin-right: 6px; }
.it-what .code { font-size: .78rem; font-weight: 700; color: #0b7a68; letter-spacing: .04em; }
@media (max-width: 640px) { .toast { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); } }

/* Route: one row of countries along the trip's dates, and the itinerary grouped by country in travel order */
.route-strip { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 10px; margin-bottom: 20px; }
.rs-scroll { overflow-x: auto; padding-block: 4px; }
.rs-inner { display: grid; gap: 6px; }
.rs-row { position: relative; height: 34px; background: var(--bg); border-radius: var(--radius-sm); }
.cblock { position: absolute; top: 0; bottom: 0; border: 0; margin: 0; padding: 0 4px; border-radius: 7px; background: var(--cc); color: var(--on-cc); font: 600 .8rem/1 var(--font-body); display: flex; align-items: center; justify-content: flex-start; white-space: nowrap; overflow: hidden; cursor: pointer; min-width: 3px; box-shadow: 0 0 0 1px var(--surface); }
.cblock:hover, .cblock:focus-visible { filter: brightness(1.08); }
.cblock.sel { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--cc); z-index: 1; }
.cgap { position: absolute; top: 0; bottom: 0; min-width: 4px; border-radius: 3px; background: repeating-linear-gradient(45deg, var(--warn) 0 3px, var(--warn-soft) 3px 6px); }
.rs-months { position: relative; height: 16px; font-size: .74rem; color: var(--muted); }
.rs-months span { position: absolute; top: 0; padding-left: 4px; border-left: 1px solid var(--line); line-height: 16px; }
.cpop { position: fixed; z-index: 60; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 10px 12px; width: max-content; max-width: min(300px, calc(100vw - 16px)); font-size: .84rem; pointer-events: none; }
.cpop-head { margin: 0 0 6px; display: flex; align-items: center; gap: 8px; font-weight: 600; }
.cpop-head .muted { margin-left: auto; font-weight: 400; padding-left: 12px; }
.cpop ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.cpop li { display: grid; }
.cpop li span { color: var(--muted); font-size: .8rem; }
.cg-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--cc); flex: none; }
.cgroup > summary { list-style: none; position: relative; padding: 12px 6px 8px 44px; cursor: pointer; display: grid; grid-template-columns: minmax(0, 1fr) auto 20px; gap: 2px 10px; align-items: center; border-radius: var(--radius-sm); }
.cgroup > summary::-webkit-details-marker { display: none; }
.cgroup > summary::before { content: ""; position: absolute; left: 15px; top: 0; bottom: 0; width: 2px; background: var(--line); }
.cgroup > summary:hover { background: var(--surface); }
.cgroup > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cgroup .cg-dot { position: absolute; left: 9px; top: 15px; width: 14px; height: 14px; box-shadow: 0 0 0 3px var(--bg); }
.cg-name { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; min-width: 0; }
.cg-cost { font-weight: 600; text-align: right; }
.cg-meta { grid-column: 1; font-size: .82rem; color: var(--muted); }
.cg-total { grid-column: 1 / -1; font-size: .8rem; color: var(--muted); }
.cg-chev { grid-row: 1; grid-column: 3; display: grid; place-items: center; color: var(--muted); transition: transform .15s; }
.cg-chev svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cgroup[open] > summary .cg-chev { transform: rotate(90deg); }
@media (max-width: 760px) { .rs-inner { min-width: 720px; } .route-strip { padding-inline: 12px; } }
@media (prefers-reduced-motion: reduce) { .cg-chev { transition: none; } }
@media print { .route-strip { display: none; } }
.trip-page { grid-template-columns: minmax(0, 1fr); }

/* Planning view v2: each country is a card with a coloured edge; its stops sit inside, legs between countries link the cards */
.cgroup { background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--cc); border-radius: var(--radius); box-shadow: var(--shadow); margin: 6px 0; overflow: hidden; }
.cgroup > summary { padding: 14px 16px; grid-template-columns: minmax(0, 1fr) auto 24px; border-radius: 0; }
.cgroup > summary::before { display: none; }
.cgroup > summary:hover { background: var(--bg); }
.cgroup .cg-dot { display: none; }
.cg-name { font-size: 1.15rem; color: var(--ink); }
.cgroup[open] > summary { border-bottom: 1px solid var(--line); }
.cg-body { padding: 10px 12px 12px; }
.cg-body > .stop, .cg-body > .leg, .cg-body > .gap-row { padding-left: 40px; }
.cg-body > .stop::before, .cg-body > .leg::before, .cg-body > .gap-row::before { left: 13px; background: var(--cc); opacity: .35; }
.cg-body > :first-child::before { top: 22px; }
.cg-body > .stop:last-child::before { bottom: calc(100% - 22px); }
.cg-body .stop-btn { background: var(--bg); box-shadow: none; border-color: var(--line); }
.cg-body .stop-btn:hover, .cg-body .stop-btn.sel { border-color: var(--cc); }
.cg-body .stop-dot { left: 2px; border-color: var(--cc); color: var(--cc); }
.cg-body .leg-ico { left: 4px; }
.cg-body .leg-btn:hover { background: var(--bg); }
/* travel between countries, and start/end points, stay on the plain timeline outside the cards */
.itinerary > .leg, .itinerary > .gap-row { padding-block: 8px; }
.itinerary > .stop.home .stop-btn { background: var(--surface); }
.cgroup:not([open]) .cg-chev { transform: none; }

/* Clean rows: name and cost only; the rest shows in a hover popover */
.stop-name { display: inline-flex; align-items: center; gap: 8px; }
.stop-btn { padding: 10px 14px; align-items: center; }
.leg-btn { flex-wrap: nowrap; padding: 6px 10px; }
.leg-route { flex-basis: auto; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.leg-btn:hover .leg-route, .leg-btn.sel .leg-route { color: var(--ink); }
.ico-badge { display: inline-grid; place-items: center; width: 18px; height: 18px; flex: none; }
.ico-badge svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ico-badge.ok { color: var(--good); }
.ico-badge.night { color: var(--night); }
.ico-badge.warn { color: var(--warn); }
.cg-meta { grid-column: 2; grid-row: auto; font-size: .82rem; }
.cgroup > summary { grid-template-columns: minmax(0, 1fr) auto auto 24px; }
.cg-cost { grid-column: 3; }
.cg-meta { grid-column: 2; grid-row: 1; }
.cg-chev { grid-column: 4; }
.cpop .pop-head { margin: 0 0 6px; font-weight: 600; }
.pop-grid { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; margin: 0; }
.pop-grid dt { color: var(--muted); }
.pop-grid dd { margin: 0; font-variant-numeric: tabular-nums; }
.pop-note { margin: 8px 0 0; color: var(--muted); font-size: .8rem; }

/* Places tab: marked campsites, sights and routes on a map */
.plan { display: grid; gap: 14px; padding-bottom: 56px; }
.plan-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.plan-grid { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 24px; align-items: start; }
.plan-side { display: grid; gap: 12px; min-width: 0; }
.plan-filters { display: grid; gap: 8px; }
.plan-text, .plan-find input { font: inherit; font-size: .92rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 12px; width: 100%; min-width: 0; }
.plan-text:focus, .plan-find input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.spot-list { display: grid; gap: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.spot-list:empty { display: none; }
.spot-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: center; width: 100%; text-align: left; font: inherit; color: var(--ink); background: transparent; border: 0; border-top: 1px solid var(--line); padding: 11px 14px; cursor: pointer; }
.spot-row:first-child { border-top: 0; }
.spot-row:hover { background: var(--bg); }
.spot-row.sel { background: var(--accent-soft); }
.spot-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.spot-row.done .spot-name { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }
.spot-ico { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: color-mix(in srgb, var(--tc) 16%, var(--surface)); color: var(--tc); }
.spot-ico .ico { width: 18px; height: 18px; }
.spot-main { display: grid; gap: 1px; min-width: 0; }
.spot-name { font-weight: 600; overflow-wrap: anywhere; }
.spot-sub { font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }
.spot-right { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.spot-empty, .spot-none { background: var(--surface); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.spot-empty h3 { margin: 0 0 6px; }
.spot-none { margin: 0; }

.plan-map { min-width: 0; }
.plan-find { position: absolute; top: 12px; left: 56px; z-index: 2; width: min(260px, calc(100% - 200px)); }
.plan-find input { box-shadow: var(--shadow); }
.plan-find .place-results { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 3; margin: 0; }
.plan-bar { position: absolute; left: 12px; right: 12px; bottom: 28px; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 8px 12px; flex-wrap: wrap; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); border: 1px solid var(--night); }
.plan-bar[hidden] { display: none; }
.plan-hint { font-weight: 600; font-size: .9rem; }
.plan-bar-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.lm.plan-adding, .lm.plan-adding .leaflet-interactive { cursor: crosshair; }
.linklike { border: 0; background: none; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }
.check-grid { display: flex; flex-wrap: wrap; gap: 8px 4px; }

/* map markers */
.leaflet-container .leaflet-marker-icon.sp-pin { background: none; border: 0; }
.sp-dot { display: grid; place-items: center; border-radius: 50%; background: var(--tc); color: var(--on-cc); border: 2px solid var(--surface); box-shadow: 0 1px 4px rgba(0, 0, 0, .35); transition: transform .12s; box-sizing: border-box; }
.sp-dot .ico { width: 58%; height: 58%; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sp-dot.imp-must { box-shadow: 0 0 0 3px color-mix(in srgb, var(--tc) 35%, transparent), 0 1px 4px rgba(0, 0, 0, .35); }
.sp-dot.imp-maybe { opacity: .72; border-style: dashed; }
.sp-dot.is-done { filter: grayscale(.85); opacity: .6; }
.sp-dot.is-sel { transform: scale(1.3); outline: 3px solid var(--night); outline-offset: 1px; }
.sp-pin:focus-visible .sp-dot { outline: 3px solid var(--night); outline-offset: 2px; }

@media (max-width: 1000px) {
  .plan-grid { grid-template-columns: minmax(0, 1fr); }
  .plan-map { position: relative; top: 0; order: -1; }
}
@media (max-width: 640px) {
  .plan-find { width: calc(100% - 190px); }
  .spot-row { grid-template-columns: 34px minmax(0, 1fr); }
  .spot-right { grid-column: 2; justify-content: flex-start; }
}
@media print { .plan { display: none; } }

/* Route variants: the chip next to the title and its menu */
.title-line { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.vmenu { position: relative; }
.vmenu summary { list-style: none; cursor: pointer; }
.vmenu summary::-webkit-details-marker { display: none; }
.vchip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px 4px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--accent); font-weight: 600; font-size: .85rem; }
.vchip:hover { border-color: var(--muted); }
.vchip .chev { width: 14px; height: 14px; transform: rotate(90deg); stroke: currentColor; fill: none; stroke-width: 2; }
.vmenu[open] .vchip .chev { transform: rotate(-90deg); }
.vpop { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; min-width: 230px; display: grid; gap: 2px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.vpop a, .vpop button { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 0; border-radius: 7px; background: none; color: var(--ink); font: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.vpop a:hover, .vpop button:hover { background: var(--accent-soft); }
.vpop a[aria-current] { font-weight: 600; }
.vpop svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.vpop hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }
.vpop .danger-text { color: var(--warn); }

/* Insights: country by country */
.insights { display: grid; gap: 16px; }
.ins { display: grid; }
.ins-row { display: grid; grid-template-columns: minmax(120px, 1.2fr) minmax(0, 3fr) 90px 120px; gap: 16px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); font-size: .92rem; }
.ins-head { border-top: 0; padding-top: 0; font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ins-row .r { text-align: right; }
.ins-name { display: flex; align-items: center; gap: 10px; font-weight: 500; min-width: 0; }
.ins-name i { width: 10px; height: 10px; border-radius: 3px; background: var(--cc); flex: none; }
.ins-nights { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ins-bar { height: 10px; border-radius: 99px; background: var(--cc); flex: none; max-width: calc(100% - 40px); }
.ins-foot { color: var(--muted); }
.ins-foot.total { color: var(--ink); font-weight: 600; }
@media (max-width: 640px) {
  .ins-head { display: none; }
  .ins-row { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
  .ins-row .ins-nights { grid-column: 1 / -1; order: 3; }
  .ins-row > :nth-child(4) { display: none; }
}
.good { color: var(--good); }

.leg-nights { font-size: .78rem; color: var(--night); font-weight: 600; }

/* Activities of a place */
.act-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 36px; gap: 8px; align-items: center; margin-bottom: 10px; }
.act-row input[name="actTitle"] { grid-column: 1 / 3; }
.act-row .icon-btn { grid-column: 3; grid-row: 1; }
.act-row input, .act-row select { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 12px; min-width: 0; }
.stop-acts { grid-column: 1 / -1; display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--muted); margin-top: 2px; min-width: 0; }
.stop-acts .ico { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; flex: none; }

/* Common fund in Travellers & trip */
.fund-block { margin-top: 4px; padding-top: 16px; border-top: 1px solid var(--line); }
.fund-head { display: grid; gap: 2px; margin-bottom: 10px; }

/* Country dates, changes of transport */
.cg-name { display: grid; gap: 1px; min-width: 0; }
.cg-title { display: inline-flex; align-items: center; gap: 8px; }
.cg-dates, .ins-dates { display: block; font-size: .74rem; font-weight: 400; color: var(--muted); letter-spacing: 0; }
.ins-title { display: grid; gap: 1px; min-width: 0; }
.stop.via .stop-btn { background: transparent; box-shadow: none; border: 1px dashed var(--line); padding: 6px 12px; }
.stop.via .stop-btn:hover, .stop.via .stop-btn.sel { border-color: var(--accent); }
.stop.via .stop-name { font-family: var(--font-body); font-size: .9rem; font-weight: 500; color: var(--muted); }
.stop.via .stop-dot { left: 11px; top: 15px; width: 10px; height: 10px; min-width: 10px; font-size: 0; background: var(--surface); border: 2px solid var(--muted); }
.lm-pin.is-via span { width: 12px; height: 12px; border-width: 2px; border-color: var(--muted); }
.field-row { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

/* One size for controls: buttons, text fields and dropdowns are 40px tall (compact ones 32px), same font and corners */
:root { --ctl-h: 40px; --ctl-h-sm: 32px; --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a9a97' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); }
.btn { min-height: var(--ctl-h); padding: 0 16px; font: 500 .95rem var(--font-body); justify-content: center; }
.btn.ghost { padding-inline: 10px; }
.map-tools .btn, .booking-code .btn, .btn.small-btn { min-height: var(--ctl-h-sm); padding: 0 12px; font-size: .84rem; }
.field input:not([type="checkbox"]):not([type="radio"]), .field select, .invite input, .set-row select, .num-input input, .traveller-row input, .act-row input, .act-row select, .small-field input {
  font: 400 .95rem var(--font-body); color: var(--ink); background-color: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0 12px; min-height: var(--ctl-h);
}
.field textarea { font: 400 .95rem var(--font-body); padding: 9px 12px; border-radius: var(--radius-sm); min-height: 76px; }
.field select, .set-row select, .act-row select, .field-pair select, .rate select, .price-row select {
  -webkit-appearance: none; appearance: none; padding-right: 34px; background-image: var(--chev); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; cursor: pointer;
}
.rate input, .price-row input, .fx-grid input { min-height: var(--ctl-h-sm); font: 400 .9rem var(--font-body); padding: 0 8px; border-radius: 8px; }
.chip { min-height: var(--ctl-h-sm); padding: 0 14px; font-size: .82rem; display: inline-flex; align-items: center; }
.segmented { min-height: var(--ctl-h); align-items: center; }
.segmented button, .segmented .seg-link, .seg-opt span { display: inline-flex; align-items: center; min-height: var(--ctl-h-sm); padding: 0 14px; font-size: .92rem; }
.seg-opt { display: inline-flex; }
.seg-opt span { display: inline-flex; }
.traveller-row { grid-template-columns: 32px minmax(0, 1fr) var(--ctl-h); }
.act-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) var(--ctl-h); }
.traveller-row .icon-btn, .act-row .icon-btn { width: var(--ctl-h); height: var(--ctl-h); }

/* "Split differently" stays a quiet link until opened */
details.split-fold, details.quick-split { border: 0; padding: 0; background: none; }
.split-fold > summary, .quick-split > summary { text-transform: none; letter-spacing: 0; font-size: .88rem; font-weight: 500; color: var(--accent); }

/* Every trip tab has the same page width, so the header and tabs do not move when you switch */
.trip-page, .trip-page.wide { max-width: 1320px; }
.money, .insights, .compare { max-width: 1120px; }



/* The round "+" left of the list stays in view while you scroll; it adds a stop after the one in the middle of the screen */
.itinerary { position: relative; padding-left: 44px; }
.itin-rail { position: absolute; left: 0; top: 0; bottom: 0; width: 36px; }
.itin-plus { position: sticky; top: calc(45vh - 18px); display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border-radius: 50%; border: 0; background: var(--accent); color: var(--surface); box-shadow: var(--shadow); cursor: pointer; }
.itin-plus:hover { filter: brightness(1.08); }
.itin-plus svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; }
.plus-line { position: absolute; left: 40px; right: 0; height: 0; border-top: 2px dashed var(--accent); z-index: 5; pointer-events: none; }
.plus-line span { position: absolute; right: 0; top: -11px; padding: 2px 10px; border-radius: 999px; background: var(--accent); color: var(--surface); font-size: .74rem; font-weight: 600; }
.plus-line[hidden] { display: none; }
.gap-add { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; color: var(--accent); font-weight: 500; font-size: .84rem; }
.gap-add svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; }
.where-new { margin: 0; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent); font-weight: 500; }
@media (max-width: 640px) {
  .itinerary { padding-left: 0; }
  .itin-rail { position: fixed; left: 14px; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); top: auto; width: auto; z-index: 20; }
  .itin-plus { position: static; width: 48px; height: 48px; }
}

/* Nights without a bed: one quiet line, and a thin mark on the timeline instead of loud stripes */
.cgap { top: auto; bottom: 0; height: 4px; min-width: 6px; border-radius: 2px; background: var(--warn); opacity: .9; pointer-events: auto; }
.gap-btn { width: 100%; display: flex; flex-wrap: nowrap; align-items: center; justify-content: space-between; gap: 12px; padding: 5px 10px; border: 1px dashed var(--line); border-radius: var(--radius-sm); background: transparent; color: var(--muted); font: 400 .82rem var(--font-body); cursor: pointer; text-align: left; }
.gap-btn:hover { border-color: var(--accent); color: var(--ink); }
.gap-text { display: inline-flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gap-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; }
.gap-add { display: inline-flex; align-items: center; gap: 4px; flex: none; margin-left: 0; color: var(--accent); font-weight: 500; white-space: nowrap; }
.gap-add svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; }
.gap-row { padding-block: 5px; }

/* Your own numbers for a country */
.cg-costs { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0 2px 40px; font-size: .8rem; color: var(--muted); }
.cg-costs span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cg-costs .btn { flex: none; }
.leg-cost.guess { color: var(--muted); font-weight: 400; }
.cc-pair { grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); }

.stop-sub { grid-column: 1 / -1; font-size: .78rem; color: var(--muted); margin-top: 2px; }
.cost-trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.cost-trio .field { font-size: .78rem; }
@media (max-width: 400px) { .cost-trio { grid-template-columns: minmax(0, 1fr); } }

/* Add-ons on top of a journey */
.act-row input[name="adTitle"] { grid-column: 1 / 3; }
.leg-btn.addon { padding-block: 4px; font-size: .82rem; }
.addon-ico { display: inline-grid; place-items: center; width: 16px; height: 16px; color: var(--muted); }
.addon-ico svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.leg-btn.addon .leg-route { font-weight: 500; color: var(--muted); }

/* Date fields: the browser's own popup indicator is replaced by a small calendar icon and the page's own calendar (js/datepicker.js) */
:root { --cal: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a9a97' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='5' width='16' height='15' rx='2'/%3E%3Cpath d='M4 10h16M9 3v4M15 3v4'/%3E%3C/svg%3E"); }
.field input[data-dp] { padding-right: 38px; background-image: var(--cal); background-repeat: no-repeat; background-position: right 11px center; background-size: 17px; cursor: pointer; font-variant-numeric: tabular-nums; }
.dp { position: fixed; z-index: 80; width: 296px; padding: 12px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow), 0 12px 36px rgba(0, 0, 0, .18); display: grid; gap: 8px; }
.dp[hidden] { display: none; }
.dp-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dp-title { font-family: var(--font-display); font-weight: 600; font-size: 1rem; text-transform: capitalize; }
.dp-nav { width: 32px; height: 32px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; }
.dp-nav:hover { background: var(--accent-soft); color: var(--accent); }
.dp-nav svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.dp-nav:not(.next) svg { transform: rotate(180deg); }
.dp-week, .dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.dp-week span { font-size: .72rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding-block: 4px; }
.dp-day { height: 36px; padding: 0; border: 0; border-radius: 10px; background: transparent; color: var(--ink); font: 500 .9rem var(--font-body); font-variant-numeric: tabular-nums; cursor: pointer; }
.dp-day:hover { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.dp-day.today { box-shadow: inset 0 0 0 1.5px var(--accent); font-weight: 700; }
.dp-day.sel { background: var(--accent); color: var(--surface); box-shadow: none; font-weight: 700; }
.dp-foot { display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 6px; }
.field-open { justify-self: start; font-size: .8rem; color: var(--accent); }

/* Drag a stay by its number to move it */
.stop-dot[data-drag] { cursor: grab; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.stop-dot[data-drag]:hover { background: var(--accent); color: var(--surface); }
body.dragging, body.dragging * { cursor: grabbing !important; -webkit-user-select: none !important; user-select: none !important; }
.stop.is-dragged { opacity: .4; }
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 90; pointer-events: none; display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: 999px; background: var(--surface); color: var(--ink); border: 1.5px solid var(--accent); box-shadow: var(--shadow), 0 8px 24px rgba(0, 0, 0, .25); font-size: .86rem; font-weight: 500; }
.drag-ghost b { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--surface); font-size: .72rem; }
.drag-line { position: absolute; left: 40px; right: 0; height: 0; border-top: 2px solid var(--accent); z-index: 6; pointer-events: none; }
.drag-line[hidden] { display: none; }
.drag-line span { position: absolute; right: 0; top: -11px; padding: 2px 10px; border-radius: 999px; background: var(--accent); color: var(--surface); font-size: .74rem; font-weight: 600; }

/* Review pass: widths and small alignments */
.page:not(.trip-page):not(.settings-page):not(.export-page) { max-width: 1320px; }  /* Home lines up with the top bar and the trip pages */
.money, .insights, .compare { max-width: none; }                                   /* Money and Insights end where the header ends */
.funds-table th:last-child, .funds-table td:last-child { padding-right: 0; }
.chip { gap: 6px; }
.chip .muted { margin: 0; }
.card-head .btn.ghost { margin-right: -10px; } /* the text of a quiet button lines up with the card's right edge */

.monthly-total { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; margin: 0; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--bg); font-size: .9rem; }

/* Monthly costs of a traveller */
.mc { display: grid; gap: 8px; margin-top: 10px; }
.mc .field-label { margin: 0; }
.mc-row { display: grid; grid-template-columns: minmax(0, 1fr) 120px var(--ctl-h); gap: 8px; align-items: center; margin-bottom: 8px; }
.mc-row input { font: 400 .95rem var(--font-body); color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0 12px; min-height: var(--ctl-h); min-width: 0; }
.mc-row .icon-btn { width: var(--ctl-h); height: var(--ctl-h); }
.mc .btn.ghost { justify-self: start; }
@media (max-width: 400px) { .mc-row { grid-template-columns: minmax(0, 1fr) 96px var(--ctl-h); } }
.mc { margin-left: 46px; }
.mc-row { grid-template-columns: minmax(0, 1fr) 120px var(--ctl-h); }
details.split-costs { border: 0; padding: 0; background: none; margin-top: 4px; }
.split-costs > summary { text-transform: none; letter-spacing: 0; font-size: .88rem; font-weight: 500; color: var(--accent); }
@media (max-width: 640px) { .mc { margin-left: 0; } }
