/* Sähköautoilijan matkasuunnittelija – ulkoasu.
   Rakenne: muuttujat → perusta → yläpalkki → asettelu → reittikortti → kentät → painikkeet → asetusikkunat →
   tulokset → dialogit → kartta → alapalkki → tekstisivut. Värit vain muuttujina (tumma teema). */

/* Inter (OFL-1.1, public/vendor/inter/LICENSE), oma palvelin: CSP sallii vain oman alkuperän. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("vendor/inter/inter-latin-ext-wght-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: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("vendor/inter/inter-latin-wght-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;
}

:root {
  --bg: #f2f5f3;
  --surface: #ffffff;
  --surface-2: #f3f6f4;
  --surface-3: #e7ece9;
  --text: #0f1a15;
  --text-2: #33413b;
  --muted: #5f6d67;
  --border: #e1e7e4;
  --border-strong: #c8d2cd;
  --accent: #0a7457;
  --accent-hover: #075f47;
  --accent-text: #ffffff;
  --accent-soft: #e2f3ec;
  --accent-ink: #065a43;
  --warn: #8f5300;
  --warn-soft: #fff3de;
  --danger: #b3261e;
  --danger-soft: #fdecea;
  --ok: #1d7a3a;
  --ring: 0 0 0 3px rgb(10 116 87 / 0.18);
  --shadow-sm: 0 1px 2px rgb(15 26 21 / 0.06);
  --shadow: 0 1px 2px rgb(15 26 21 / 0.05), 0 10px 30px -12px rgb(15 26 21 / 0.14);
  --shadow-lg: 0 2px 6px rgb(15 26 21 / 0.06), 0 28px 56px -16px rgb(15 26 21 / 0.32);
  --radius: 18px;
  --radius-md: 12px;
  --radius-sm: 9px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1210;
    --surface: #141b18;
    --surface-2: #1a2320;
    --surface-3: #232e2a;
    --text: #e9efec;
    --text-2: #c9d3cf;
    --muted: #97a6a0;
    --border: #25302c;
    --border-strong: #36443e;
    --accent: #4cc79e;
    --accent-hover: #6dd6b2;
    --accent-text: #05140e;
    --accent-soft: #143329;
    --accent-ink: #7fdfbf;
    --warn: #f0b45a;
    --warn-soft: #34291a;
    --danger: #f2948c;
    --danger-soft: #3a1f1d;
    --ok: #74d18f;
    --ring: 0 0 0 3px rgb(76 199 158 / 0.25);
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow: 0 1px 2px rgb(0 0 0 / 0.35), 0 10px 30px -12px rgb(0 0 0 / 0.6);
    --shadow-lg: 0 28px 56px -16px rgb(0 0 0 / 0.75);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c1210;
  --surface: #141b18;
  --surface-2: #1a2320;
  --surface-3: #232e2a;
  --text: #e9efec;
  --text-2: #c9d3cf;
  --muted: #97a6a0;
  --border: #25302c;
  --border-strong: #36443e;
  --accent: #4cc79e;
  --accent-hover: #6dd6b2;
  --accent-text: #05140e;
  --accent-soft: #143329;
  --accent-ink: #7fdfbf;
  --warn: #f0b45a;
  --warn-soft: #34291a;
  --danger: #f2948c;
  --danger-soft: #3a1f1d;
  --ok: #74d18f;
  --ring: 0 0 0 3px rgb(76 199 158 / 0.25);
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow: 0 1px 2px rgb(0 0 0 / 0.35), 0 10px 30px -12px rgb(0 0 0 / 0.6);
  --shadow-lg: 0 28px 56px -16px rgb(0 0 0 / 0.75);
  color-scheme: dark;
}

/* ---------- Perusta */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--font);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
}
a { color: var(--accent); text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { letter-spacing: -0.015em; }
b, strong { font-weight: 650; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 0.85rem; color: var(--muted); margin: 0; }
.hint { color: var(--muted); font-size: 0.84rem; line-height: 1.5; margin: 10px 0 0; }
.hint b { color: var(--text-2); font-weight: 600; }
.stack { display: flex; flex-direction: column; gap: 16px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }

/* ---------- Yläpalkki */
.top {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: 10px 20px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; min-width: 0; }
.brand img { flex: none; border-radius: 10px; box-shadow: 0 2px 6px rgb(10 116 87 / 0.25); }
.brand > span { min-width: 0; }
.brand .brand-name, .brand strong { display: block; margin: 0; font-size: 1.06rem; font-weight: 700; line-height: 1.25; letter-spacing: -0.02em; }
.brand small { display: block; color: var(--muted); font-size: 0.78rem; line-height: 1.35; margin-top: 1px; }
.top-actions { display: flex; gap: 6px; align-items: center; flex: none; }
.top-actions .ghost { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 14px; border-color: transparent; background: transparent; color: var(--text-2); font-weight: 550; }
.top-actions .ghost:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.top-actions .ghost svg { flex: none; }
.account-btn { max-width: 240px; border-color: var(--border) !important; }
.account-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-ink); font-size: 0.74rem; font-weight: 700; font-variant-numeric: tabular-nums;
}

.notice {
  margin: 12px 20px 0;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--warn-soft);
  color: var(--text);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  font-size: 0.95rem;
}

/* ---------- Asettelu
   Leveällä näytöllä sivupaneeli (reittikortti ja tulokset) vasemmalla ja kartta oikealla; kapealla allekkain:
   reittikortti, kartta, tulokset. */
.main { flex: 1; width: 100%; }
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
  width: 100%;
  margin: 0 auto;
}
.plan-col { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.results-col { min-width: 0; }
.layout:not(.has-results) .results-col { display: none; }
.map-wrap { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.map-box { position: relative; flex: 1; display: flex; min-height: 0; }
#map {
  flex: 1;
  height: 52vh;
  min-height: 300px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-3);
  box-shadow: var(--shadow-sm);
  z-index: 0;
}

@media (min-width: 1024px) {
  .layout {
    grid-template-columns: minmax(380px, 440px) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    align-items: start;
    gap: 20px;
    padding: 20px;
  }
  .plan-col { display: contents; }
  #routeCard { grid-column: 1; grid-row: 1; }
  .results-col { grid-column: 1; grid-row: 2; }
  .map-wrap { grid-column: 2; grid-row: 1 / span 2; position: sticky; top: 84px; height: calc(100vh - 104px); }
  #map { height: 100%; }
  /* Yläpalkki pysyy näkyvissä; kartta täyttää loput näkymästä. */
  .top { position: sticky; top: 0; z-index: 1200; }
  .results { scroll-margin-top: 84px; }
}

/* ---------- Kortit */
.card {
  margin: 0;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  min-width: 0;
}
.card legend { float: left; width: 100%; padding: 0; margin-bottom: 10px; font-weight: 650; font-size: 1.05rem; }
.card legend ~ * { clear: both; }
.card legend.sr-only { float: none; width: 1px; margin: -1px; }

/* ---------- Reittikortti */
.route-bar { container-type: inline-size; display: flex; flex-direction: column; }
.stops { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; align-items: center; }
.stop-fields { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.stop-fields .field { margin: 0; }
.vias { display: flex; flex-direction: column; gap: 12px; }
.vias:empty { display: none; }
.rb-swap { margin-top: 26px; border-radius: 999px; width: 40px; min-width: 40px; height: 40px; min-height: 40px; color: var(--text-2); }
.rb-swap:hover { color: var(--accent); border-color: var(--accent); }
.add-via {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 6px;
  margin: 8px 0 0 -4px; padding: 6px 8px; min-height: 36px;
  border: 0; border-radius: var(--radius-sm); background: none; cursor: pointer;
  color: var(--accent); font-weight: 600; font-size: 0.92rem;
}
.add-via:hover { background: var(--accent-soft); }
.trip-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px;
  margin-top: 14px; padding-top: 16px; border-top: 1px solid var(--border);
}
.trip-grid .field { margin: 0; }
.rb-time { grid-column: 1 / -1; }
@container (min-width: 620px) {
  .trip-grid { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr); }
  .rb-time { grid-column: auto; }
}
.settings-rows { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin-top: 16px; }
@container (min-width: 620px) { .settings-rows { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.set-btn, .row-btn {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
  width: 100%; min-height: 60px; padding: 10px 12px 10px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); text-align: left; cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.row-btn { grid-template-columns: minmax(0, 1fr) auto; padding: 10px 12px 10px 14px; margin-top: 4px; }
.set-btn:hover, .row-btn:hover { border-color: var(--border-strong); background: var(--surface-2); }
.set-btn[aria-expanded="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: var(--ring); }
.set-ico { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.set-btn[aria-expanded="true"] .set-ico { background: var(--accent); color: var(--accent-text); }
.set-text { display: flex; flex-direction: column; min-width: 0; }
.set-title { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 0.95rem; }
.set-sum { color: var(--muted); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-chev { color: var(--muted); flex: none; }
.setup-hint {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  background: var(--danger-soft); color: var(--danger); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.01em;
}
.rb-go { width: 100%; margin-top: 16px; }
.route-bar .progress, .route-bar .error { margin-top: 14px; }

/* ---------- Kentät */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; position: relative; min-width: 0; }
.field:last-child { margin-bottom: 0; }
.field > label, .field .label { font-size: 0.8rem; font-weight: 600; color: var(--text-2); letter-spacing: 0.005em; }

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="hidden"]), select, textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 85%, transparent); }
input:not([type="checkbox"]):not([type="radio"]):hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:not([type="checkbox"]):not([type="radio"]):focus, select:focus, textarea:focus { border-color: var(--accent); background: var(--surface); box-shadow: var(--ring); outline: none; }
input[aria-invalid="true"] { border-color: var(--danger) !important; background: var(--danger-soft) !important; }
input[type="number"] { font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="datetime-local"] { font-variant-numeric: tabular-nums; }
select {
  padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6' fill='none' stroke='%235f6d67' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
textarea { min-height: 130px; resize: vertical; line-height: 1.5; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }

.input-wrap { position: relative; }
.input-wrap input { padding-right: 48px !important; }
.in-btn {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); cursor: pointer;
}
.in-btn:hover { background: var(--surface-3); color: var(--accent); }
.unit-wrap { position: relative; }
.unit-wrap input { padding-right: 46px !important; }
.unit-wrap.wide-unit input { padding-right: 104px !important; }
.unit {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 0.88rem; pointer-events: none; white-space: nowrap;
}

.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px 12px; }
.grid2 .field { margin: 0; }
.addr-row { display: flex; gap: 8px; }
.addr-row input { flex: 1; min-width: 0; }

.suggest {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 1000;
  margin: 6px 0 0; padding: 6px; list-style: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 300px; overflow: auto;
}
.suggest li { padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer; font-size: 0.95rem; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--accent-soft); color: var(--accent-ink); }
.suggest li.info { cursor: default; color: var(--muted); }
.suggest li.info:hover { background: none; color: var(--muted); }

/* ---------- Painikkeet */
.primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 22px;
  border: 0; border-radius: var(--radius-md);
  background: var(--accent);
  background-image: linear-gradient(180deg, rgb(255 255 255 / 0.1), rgb(255 255 255 / 0));
  color: var(--accent-text);
  font-weight: 650; font-size: 1.02rem; letter-spacing: -0.005em;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.12), 0 8px 20px -10px var(--accent);
  cursor: pointer;
  transition: background-color 0.15s, transform 0.05s, box-shadow 0.15s;
  text-decoration: none;
}
.primary:hover { background-color: var(--accent-hover); }
.primary:active { transform: translateY(1px); }
.primary:disabled { opacity: 0.6; cursor: progress; }
.ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; padding: 0 16px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  background: var(--surface); color: var(--text);
  font-weight: 550; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s;
}
.ghost:hover { background: var(--surface-2); border-color: var(--muted); }
.icon-btn {
  min-width: 44px; min-height: 44px;
  display: inline-grid; place-items: center;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); color: var(--text-2); cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.close-btn, .dialog-head .icon-btn { min-width: 38px; min-height: 38px; width: 38px; height: 38px; border-radius: 999px; border-color: transparent; background: var(--surface-2); }
.close-btn:hover, .dialog-head .icon-btn:hover { background: var(--surface-3); }
.link-btn { border: 0; background: none; color: var(--accent); padding: 6px 0; cursor: pointer; font-size: 0.9rem; font-weight: 550; }
.link-btn:hover { text-decoration: underline; }
.danger-link { color: var(--danger); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-flex; align-items: center; min-height: 40px; padding: 6px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); cursor: pointer; user-select: none; }
.chip input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Segmenttivalitsin (radiopainikkeet) */
.seg { display: inline-flex; padding: 4px; gap: 4px; border-radius: var(--radius-md); background: var(--surface-2); border: 1px solid var(--border); align-self: flex-start; max-width: 100%; overflow-x: auto; }
.seg label { position: relative; display: flex; align-items: center; justify-content: center; min-height: 38px; padding: 0 14px; border-radius: var(--radius-sm); cursor: pointer; font-weight: 550; font-size: 0.92rem; color: var(--text-2); white-space: nowrap; }
.seg label input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--surface); color: var(--accent-ink); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }

details.adv { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
details.adv summary { cursor: pointer; font-weight: 600; font-size: 0.92rem; padding: 4px 0; list-style: none; display: flex; align-items: center; gap: 8px; }
details.adv summary::-webkit-details-marker { display: none; }
details.adv summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform 0.15s; }
details.adv[open] summary::before { transform: rotate(45deg); }
details.adv[open] summary { margin-bottom: 12px; }

.progress { display: flex; flex-direction: column; gap: 8px; }
.progress .bar { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.progress .bar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width 0.2s; }
.progress p { margin: 0; color: var(--muted); font-size: 0.88rem; }

.error, .warn-box, .ok-box {
  padding: 12px 14px; border-radius: var(--radius-md); font-size: 0.93rem; line-height: 1.5;
}
.error { background: var(--danger-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); }
.warn-box { background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 28%, transparent); }
.warn-box p { margin: 0 0 6px; }
.warn-box p:last-child { margin: 0; }
.ok-box { background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); margin: 0 0 12px; }

/* ---------- Asetusikkunat (Auto, Latausasemat): kartan päällä sivupaneelin vieressä, puhelimessa alhaalta */
.float-panel {
  position: absolute; top: 12px; left: 12px; z-index: 1100;
  width: min(420px, calc(100% - 24px)); max-height: calc(100% - 24px);
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: panel-in 0.16s ease-out;
}
@keyframes panel-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.float-panel[hidden] { display: none; }
.float-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 18px 4px 20px; }
.float-head h2 { margin: 0; font-size: 1.15rem; }
.float-sub { margin: 2px 0 0; color: var(--muted); font-size: 0.84rem; }
.float-body { padding: 14px 20px 16px; overflow: auto; }
.float-foot { padding: 12px 20px 20px; border-top: 1px solid var(--border); }
.float-foot .primary { width: 100%; min-height: 48px; }
.sync-note { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
@media (max-width: 1023px) {
  .float-panel {
    position: fixed; top: auto; left: 0; right: 0; bottom: 0; width: auto;
    max-height: 88vh; border-radius: 22px 22px 0 0; border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
    animation: sheet-in 0.2s ease-out;
  }
  .float-panel::before { content: ""; align-self: center; width: 40px; height: 4px; margin-top: 8px; border-radius: 2px; background: var(--border-strong); }
  .float-head { padding-top: 10px; }
}
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }

/* ---------- Tulokset */
.results { display: flex; flex-direction: column; gap: 16px; scroll-margin-top: 16px; }
.res-head { display: flex; flex-direction: column; gap: 4px; }
.res-kicker { margin: 0; color: var(--accent); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.results h2 { margin: 0; font-size: 1.2rem; line-height: 1.3; overflow-wrap: anywhere; }
.route-title { font-weight: 650; overflow-wrap: anywhere; }
.res-vias { margin: 0; color: var(--muted); font-size: 0.86rem; }
.hero { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; margin-top: 16px; padding: 16px 18px; border-radius: var(--radius-md); background: linear-gradient(135deg, var(--accent-soft), color-mix(in srgb, var(--accent-soft) 40%, var(--surface))); }
.hero-main b { display: block; font-size: 1.9rem; line-height: 1.1; font-weight: 750; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.hero-main small, .hero-side small { color: var(--text-2); font-size: 0.82rem; }
.hero-side { text-align: right; }
.hero-side b { display: block; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin-top: 12px; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.stat { padding: 12px 14px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); min-width: 0; }
.stat:nth-child(2n) { border-right: 0; }
.stat:nth-last-child(-n + 2):nth-child(odd), .stat:last-child { border-bottom: 0; }
.stat b { display: block; font-size: 1.08rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stat small { display: block; color: var(--muted); font-size: 0.78rem; line-height: 1.35; }
.res-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.res-actions .ghost { min-height: 44px; padding: 0 10px; font-size: 0.9rem; }
.res-actions .ghost svg { flex: none; }
.results .card > .warn-box, .results .card > .ok-box { margin: 12px 0 0; }
.res-note { margin: 12px 0 0; }
.res-nav { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.res-nav .ghost { width: 100%; }
.res-nav .ghost svg { color: var(--accent); }
.res-trip { margin: 12px 0 0; color: var(--muted); font-size: 0.8rem; text-align: center; }
.res-strategy { margin-top: 10px; }

/* Valintakortit (latausstrategia) */
.choices { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.choices legend { padding: 0; margin-bottom: 8px; }
.choice { position: relative; display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-md); cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.choice:hover { border-color: var(--border-strong); }
.choice input { margin-top: 3px; width: 18px; height: 18px; flex: none; }
.choice span { display: flex; flex-direction: column; gap: 2px; }
.choice b { font-weight: 600; font-size: 0.95rem; }
.choice small { color: var(--muted); font-size: 0.82rem; line-height: 1.4; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: var(--ring); }
.trip-fields { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.trip-fields .field { margin: 0; }
.car-profiles { margin-bottom: 16px; }
.weather-check { align-items: flex-start; margin-top: 16px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-md); }
.weather-check input { margin-top: 3px; }
.weather-check span { display: flex; flex-direction: column; gap: 2px; }
.weather-check b { font-weight: 600; font-size: 0.95rem; }
.weather-check small { color: var(--muted); font-size: 0.82rem; line-height: 1.4; }

/* Varauskäyrä */
.chart-card { padding-bottom: 16px; }
.chart-title { margin: 0 0 8px; font-size: 1rem; }
.soc-chart { width: 100%; height: auto; display: block; overflow: visible; }
.ch-elev { fill: var(--surface-3); }
.ch-elev-t { fill: var(--muted); font: 500 11px var(--font); }
.ch-grid { stroke: var(--border); stroke-width: 1; }
.ch-min { stroke: var(--warn); stroke-width: 1.2; stroke-dasharray: 4 4; }
.ch-ax { fill: var(--muted); font: 500 11px var(--font); }
.curve-chart { margin: 4px 0 2px; padding: 10px 12px 8px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2); }
.curve-chart svg { display: block; width: 100%; height: auto; }
.curve-area { fill: var(--accent-soft); }
.curve-note { margin: 4px 0 0; font-size: 0.82rem; color: var(--text-2); }
.ch-soc { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.ch-stop { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.ch-stop-t { fill: var(--accent-text); font: 700 10px var(--font); }
.chart-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin: 8px 0 0; color: var(--muted); font-size: 0.78rem; }
.chart-legend span { display: inline-block; width: 14px; height: 4px; border-radius: 2px; margin-right: -8px; }
.lg-soc { background: var(--accent); }
.lg-elev { background: var(--surface-3); height: 10px !important; }
.lg-min { border-top: 2px dashed var(--warn); height: 0 !important; }
.cond-line { margin-top: 10px; }
.car-profiles .op-sub { margin-bottom: 8px; }
.car-save { margin-top: 14px; }

/* Aikajana: pysähdykset yhdessä kortissa pystyviivalla yhdistettyinä */
.timeline-card { padding: 8px 20px; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.tl-item { position: relative; display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 14px; padding: 12px 0; align-items: start; }
.tl-item + .tl-item { border-top: 1px solid var(--border); }
.tl-item::before { content: ""; position: absolute; left: 16px; top: 0; bottom: 0; width: 2px; background: var(--accent-soft); }
.tl-item:first-child::before { top: 30px; }
.tl-item:last-child::before { bottom: calc(100% - 30px); }
.tl-dot {
  position: relative; z-index: 1;
  width: 34px; height: 34px; border-radius: 50%; margin-top: 1px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text); font-weight: 700; font-size: 0.9rem;
  box-shadow: 0 0 0 4px var(--surface);
}
.tl-item.endpoint .tl-dot { background: var(--surface); color: var(--accent-ink); border: 2px solid var(--accent); }
.tl-details { min-width: 0; }
.tl-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 36px; }
.tl-head h3 { margin: 0; font-size: 1rem; font-weight: 650; overflow-wrap: anywhere; }
.tl-title { flex: 1; min-width: 0; }
.tl-km { color: var(--muted); font-size: 0.84rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tl-brief { display: block; color: var(--muted); font-size: 0.82rem; margin-top: 1px; font-variant-numeric: tabular-nums; }
.topup-badge { display: inline-block; margin-top: 4px; padding: 1px 8px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); font-size: 0.76rem; font-weight: 650; }
.own-badge { display: inline-block; margin: 4px 0 0 4px; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font-size: 0.76rem; font-weight: 650; }
.topup-badge + .own-badge, .tl-brief + .own-badge { margin-left: 0; }
/* Pysähdyksen asetukset (latauksen tavoite, aseman vaihto) */
.stop-tools { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.stop-target { display: flex; flex-direction: column; gap: 4px; font-size: 0.82rem; color: var(--muted); font-weight: 550; }
.stop-target select { min-height: 38px; padding: 0 32px 0 10px; font-size: 0.88rem; }
.small-btn { min-height: 38px; padding: 0 12px; font-size: 0.86rem; border-radius: var(--radius-sm); }
.small-btn.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.swap-list { margin-top: 10px; }
/* Latausasemat reitin varrella */
.along-card > summary { display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none; font-weight: 650; }
.along-card > summary::-webkit-details-marker { display: none; }
.along-card > summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform 0.15s; }
.along-card[open] > summary::after { transform: rotate(-135deg); }
.along-count { padding: 1px 9px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-size: 0.8rem; font-weight: 650; }
.along-card[open] > summary { margin-bottom: 8px; }
.along-filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 10px 0 12px; }
.along-filters label { display: flex; flex-direction: column; gap: 4px; font-size: 0.78rem; color: var(--muted); font-weight: 550; min-width: 0; }
.along-filters select { min-height: 38px; padding: 0 28px 0 10px; font-size: 0.86rem; width: 100%; }
.along-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.along-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main btn" "meta btn"; gap: 2px 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.along-row.chosen { border-color: var(--accent); background: var(--accent-soft); }
.along-main { grid-area: main; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; min-width: 0; }
.along-main b { font-weight: 650; font-size: 0.92rem; overflow-wrap: anywhere; }
.along-main span { color: var(--muted); font-size: 0.82rem; }
.along-meta { grid-area: meta; display: flex; flex-wrap: wrap; gap: 2px 12px; color: var(--text-2); font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.along-row .small-btn { grid-area: btn; }
/* Reittivaihtoehdot */
.alt-routes { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-top: 14px; }
.alt-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--surface); color: var(--text); text-align: left; cursor: pointer; font: inherit; transition: border-color 0.15s, background-color 0.15s; }
.alt-btn:hover { border-color: var(--muted); }
.alt-btn b { font-size: 0.86rem; font-weight: 650; }
.alt-btn span { font-size: 0.86rem; font-variant-numeric: tabular-nums; }
.alt-btn small { color: var(--muted); font-size: 0.78rem; }
.alt-btn.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: var(--ring); }
.alt-btn.on small { color: var(--accent-ink); font-weight: 600; }
/* Lisätoiminnot tulosten alla */
.res-more { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 18px; margin-top: 10px; }
.res-more .link-btn { display: inline-flex; align-items: center; gap: 5px; font-size: 0.86rem; }
.res-forced { margin: 10px 0 0; text-align: center; }
.res-forced .link-btn { padding: 0; font-size: inherit; }
/* Taulukko */
.table-scroll { overflow-x: auto; margin: 0 -4px; }
.plan-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; font-variant-numeric: tabular-nums; }
.plan-table th, .plan-table td { padding: 8px 6px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; white-space: nowrap; }
.plan-table thead th { color: var(--muted); font-weight: 600; font-size: 0.78rem; }
.plan-table tbody th { font-weight: 600; white-space: normal; min-width: 150px; max-width: 240px; }
.plan-table tbody th small { display: block; color: var(--muted); font-weight: 550; font-size: 0.74rem; }
.plan-table tbody tr:last-child th, .plan-table tbody tr:last-child td { border-bottom: 0; }
/* Latausasemat määränpään lähellä */
.dest-chargers { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.dest-chargers h4 { margin: 0 0 6px; font-size: 0.88rem; font-weight: 650; }
.dest-chargers ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.dest-chargers li { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 0.86rem; }
.dest-chargers li > span:first-child { display: flex; flex-direction: column; min-width: 0; }
.dest-chargers small { color: var(--muted); font-size: 0.8rem; }
.dc-side { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.dc-side a { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); }
@media (max-width: 600px) {
  .along-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .alt-routes { grid-template-columns: 1fr; }
  .alt-btn { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
}
.amen-brief { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.amen-brief:empty { display: none; }
.amen-tag { display: inline-block; padding: 0 7px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-size: 0.72rem; font-weight: 600; }
.along-main .amen-tag { margin-left: 2px; }
.report-badge { display: inline-block; margin: 4px 0 0 4px; padding: 1px 8px; border-radius: 999px; background: var(--danger-soft); color: var(--danger); font-size: 0.76rem; font-weight: 650; }
.reports { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.reports .small { margin: 0 0 8px; }
.report-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.report-actions select { min-height: 38px; width: auto; padding: 0 32px 0 10px; font-size: 0.86rem; }
.report-actions .small-btn svg { margin-right: 2px; }
.relax-list { display: flex; flex-direction: column; align-items: stretch; gap: 6px; margin-top: 6px; }
.relax-list .small-btn { justify-content: flex-start; white-space: normal; text-align: left; height: auto; padding: 8px 12px; }
.res-tolls { margin: 10px 0 0; color: var(--text-2); }
.soc { font-weight: 650; }
.soc.low, .soc.topup { color: var(--warn); }
.topup-note { color: var(--warn) !important; }
.tl-sub { color: var(--muted); font-size: 0.88rem; margin: 2px 0 10px; overflow-wrap: anywhere; }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 14px; margin: 0; font-size: 0.9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tl-details .small { margin-top: 8px; }
.tl-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin-top: 12px; }
.tl-actions a, .tl-actions button { font-size: 0.88rem; font-weight: 600; }
.tl-actions a.nav-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 999px; background: var(--accent); color: var(--accent-text); text-decoration: none; }
.tl-actions a.nav-btn:hover { background: var(--accent-hover); }
.tl-details > summary { list-style: none; cursor: pointer; border-radius: var(--radius-sm); }
.tl-details > summary::-webkit-details-marker { display: none; }
.tl-details > summary::after {
  content: ""; flex: none; width: 8px; height: 8px; margin: 0 4px 4px 2px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg);
  transition: transform 0.15s;
}
.tl-details[open] > summary::after { transform: rotate(-135deg); margin-bottom: -2px; }
.tl-details > summary:hover h3 { color: var(--accent-ink); }
.tl-details[open] > summary { margin-bottom: 4px; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions .ghost, .actions .primary { flex: 1 1 auto; }

/* ---------- Dialogit */
.dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 22px;
  box-shadow: var(--shadow-lg);
  overflow: auto;
  overscroll-behavior: contain;
}
.dialog[open] { display: flex; flex-direction: column; animation: dialog-in 0.18s ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(0.985); } to { opacity: 1; transform: none; } }
.dialog::backdrop { background: rgb(8 16 12 / 0.5); backdrop-filter: blur(2px); }
.dialog-wide { width: min(660px, calc(100vw - 32px)); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 4px; }
.dialog-head h2 { margin: 0; font-size: 1.25rem; }
.dialog > .hint:first-of-type { margin-top: 4px; }
.dialog .primary { width: 100%; }
.dialog .actions .primary, .dialog .actions .ghost { width: auto; }
@media (max-width: 600px) {
  .dialog { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 22px 22px 0 0; border-bottom: 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); }
  .dialog[open] { animation: sheet-in 0.2s ease-out; }
}
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 0.95rem; }
.check input { width: 18px; height: 18px; flex: none; }

.saved-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.saved-item { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; background: var(--surface); }
.saved-item:hover { border-color: var(--border-strong); }
.saved-item strong { overflow-wrap: anywhere; }
.saved-item .row { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.small-btn { min-height: 38px !important; padding: 0 14px !important; font-size: 0.88rem !important; width: auto !important; box-shadow: none !important; }
.saved-item .row .link-btn { margin-left: auto; }
.saved-head { margin: 14px 0 0; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.saved-empty { margin: 10px 0 0; padding: 18px; border: 1px dashed var(--border-strong); border-radius: var(--radius-md); text-align: center; color: var(--muted); font-size: 0.9rem; }

/* Operaattorit ja hinnat */
.op-summary { margin: 0 0 6px; font-size: 0.92rem; overflow-wrap: anywhere; }
.price-default { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.price-default label { font-weight: 600; font-size: 0.9rem; }
.op-price { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--muted); font-size: 0.88rem; }
.op-price input { width: 88px !important; min-height: 40px !important; padding: 6px 10px !important; text-align: right; }
.op-table { max-height: min(40vh, 420px); overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-md); padding: 4px; background: var(--surface); }
.op-table .group { padding: 10px 10px 4px; color: var(--muted); font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.op-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 10px; border-radius: var(--radius-sm); }
.op-row:hover { background: var(--surface-2); }
.op-row label { display: flex; align-items: center; gap: 10px; min-width: 0; cursor: pointer; flex: 1; }
.op-row label input { width: 18px; height: 18px; flex: none; }
.op-row label span { display: flex; flex-direction: column; min-width: 0; }
.op-row b { font-weight: 600; overflow-wrap: anywhere; }
.op-row small { color: var(--muted); font-size: 0.76rem; letter-spacing: 0.03em; }
.mode-all .op-row label input { display: none; }
.mode-all .op-row label { cursor: default; }
#authBody .error, #authBody .warn-box, #authBody .ok-box { margin: 0 0 14px; }

/* Operaattorit: Kaikki / Valitut järjestyksessä, järjestettävä lista ja tallennetut listat */
.op-stack { gap: 14px; margin-top: 14px; }
#opDialog:not(.mode-all) .op-table { max-height: min(32vh, 300px); }
.seg-full { display: grid; grid-template-columns: 1fr 1fr; align-self: stretch; }
.op-mode-hint { margin: -4px 0 0; }
.op-sub { display: block; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.op-sub small { text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 0.78rem; }
.op-sub-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.op-sub-row .link-btn { padding: 0; font-size: 0.85rem; }
.op-lists .op-sub { margin-bottom: 8px; }
.op-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.op-chip { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); overflow: hidden; }
.op-chip button { border: 0; background: none; cursor: pointer; color: var(--text); font-weight: 600; font-size: 0.9rem; min-height: 36px; }
.op-chip button:first-child { padding: 0 6px 0 14px; display: inline-flex; align-items: center; gap: 6px; }
.op-chip button small { color: var(--muted); font-weight: 600; font-size: 0.74rem; background: var(--surface-2); border-radius: 999px; padding: 0 6px; }
.op-chip .op-chip-x { width: 30px; display: grid; place-items: center; color: var(--muted); }
.op-chip .op-chip-x:hover { color: var(--danger); }
.op-chip:hover { border-color: var(--accent); }
.op-chip.active { background: var(--accent-soft); border-color: var(--accent); }
.op-chip.active button:first-child { color: var(--accent-ink); }
.op-order { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.op-item {
  display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto auto; align-items: center; gap: 10px;
  padding: 8px 8px 8px 6px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface);
}
.op-item:first-child { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); }
.op-item.dragging { opacity: 0.45; }
.op-item.drop { box-shadow: 0 -3px 0 var(--accent); }
.op-grip { color: var(--border-strong); cursor: grab; display: grid; }
.op-rank { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: var(--accent-text); font-weight: 700; font-size: 0.8rem; }
.op-item:not(:first-child) .op-rank { background: var(--surface-3); color: var(--text-2); }
.op-name { display: flex; flex-direction: column; min-width: 0; }
.op-name b { font-weight: 600; overflow-wrap: anywhere; }
.op-name small { color: var(--muted); font-size: 0.76rem; }
.op-move { display: flex; gap: 2px; }
.op-btn { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--text-2); cursor: pointer; }
.op-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--accent); }
.op-btn:disabled { opacity: 0.25; cursor: default; }
.op-btn.op-del:hover { color: var(--danger); }
.op-empty { padding: 16px; border: 1px dashed var(--border-strong); border-radius: var(--radius-md); text-align: center; color: var(--muted); font-size: 0.9rem; }
.op-save { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.op-save .ghost { min-height: 46px; }
.op-label { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.op-label b { font-weight: 600; overflow-wrap: anywhere; }
.op-label small { color: var(--muted); font-size: 0.76rem; }
.op-add-row { padding: 2px; }
.op-add { display: flex; align-items: center; gap: 12px; width: 100%; padding: 6px 8px; border: 0; border-radius: var(--radius-sm); background: none; cursor: pointer; text-align: left; }
.op-add:hover { background: var(--accent-soft); }
.op-add span:last-child { display: flex; flex-direction: column; min-width: 0; }
.op-add b { font-weight: 600; }
.op-add small { color: var(--muted); font-size: 0.76rem; }
.op-plus { flex: none; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; border: 1.5px solid var(--accent); color: var(--accent); font-weight: 700; line-height: 1; }
.op-add:hover .op-plus { background: var(--accent); color: var(--accent-text); }
.rank-tag { display: inline-block; margin-left: 4px; padding: 0 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font-size: 0.74rem; font-weight: 650; }
@media (max-width: 600px) {
  .op-item { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "rank name move" "rank price price"; row-gap: 6px; }
  .op-item .op-grip { display: none; }
  .op-item .op-rank { grid-area: rank; align-self: start; margin-top: 4px; }
  .op-item .op-name { grid-area: name; }
  .op-item .op-move { grid-area: move; }
  .op-item .op-price { grid-area: price; }
}
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.label-row label { font-size: 0.8rem; font-weight: 600; color: var(--text-2); }
.label-row .link-btn { padding: 0; font-size: 0.82rem; }
.auth-alt { margin: 4px 0 0; padding-top: 14px; border-top: 1px solid var(--border); text-align: center; color: var(--muted); font-size: 0.9rem; }
.account-card { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: var(--radius-md); background: var(--surface-2); }
.avatar { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: var(--accent-text); font-weight: 700; font-size: 1.1rem; }
.account-id { display: flex; flex-direction: column; min-width: 0; }
.account-id b { overflow-wrap: anywhere; }
.account-id small { color: var(--muted); font-size: 0.82rem; }

/* Kirjautumiskehotus ja kokeilureitin raja */
.nudge-list { margin: 4px 0 12px; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.nudge-list li, .gate-list li { position: relative; padding-left: 28px; }
.nudge-list li::before, .gate-list li::before {
  content: ""; position: absolute; left: 0; top: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6 12.5 4 4 8-9' fill='none' stroke='%230a7457' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px no-repeat;
}
.gate-list { list-style: none; padding-left: 0; display: flex; flex-direction: column; gap: 10px; }
.dialog.gate { padding: 0; overflow: auto; }
.dialog.gate > :not(.gate-hero) { margin-left: 22px; margin-right: 22px; }
.dialog.gate > .actions { margin-bottom: 22px; }
.gate-hero {
  display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: start;
  padding: 22px; margin-bottom: 16px;
  background: radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--accent) 80%, #2fd3a0), var(--accent) 45%, color-mix(in srgb, var(--accent) 60%, #022a1f));
  color: #fff;
}
.gate-hero h2 { margin: 0 0 4px; font-size: 1.25rem; }
.gate-hero p { margin: 0; opacity: 0.92; }
.gate-hero .icon-btn { background: rgb(255 255 255 / 0.14); color: inherit; border-color: transparent; }

.cta-stack { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.cta-stack .primary, .cta-stack .ghost { width: 100%; }
.cta-stack .link-btn { align-self: center; color: var(--muted); padding: 10px; }
.cta-check { justify-content: center; margin-top: 4px; color: var(--muted); font-size: 0.88rem; }
.dialog.gate > .gate-cta { margin-bottom: 22px; }

/* Palaute */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
#fbCount { align-self: flex-end; font-size: 0.78rem; }

/* ---------- Kartta */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.88) contrast(0.9) saturate(0.6); }
}
:root[data-theme="dark"] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.88) contrast(0.9) saturate(0.6); }
.leaflet-container { font: inherit; background: var(--surface-3); }
.leaflet-bar { border: 0 !important; box-shadow: var(--shadow) !important; border-radius: var(--radius-md) !important; overflow: hidden; }
.leaflet-bar a { width: 38px !important; height: 38px !important; line-height: 38px !important; background: var(--surface) !important; color: var(--text) !important; border-color: var(--border) !important; font-weight: 500; }
.leaflet-bar a:hover { background: var(--surface-2) !important; }
.leaflet-top.leaflet-left { margin: 4px; }
.leaflet-popup-content-wrapper { border-radius: var(--radius-md); box-shadow: var(--shadow-lg); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); }
.leaflet-popup-content { margin: 14px 16px; font-size: 0.9rem; line-height: 1.45; }
.leaflet-popup-content h4 { margin: 0 0 4px; font-size: 0.98rem; }
.leaflet-popup-content p { margin: 2px 0; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-control-attribution { background: color-mix(in srgb, var(--surface) 88%, transparent) !important; color: var(--muted); border-radius: 8px 0 0 0; font-size: 0.72rem !important; }
.leaflet-control-attribution a { color: var(--accent); }
.pin {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text);
  border: 2px solid var(--surface);
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.35);
  font: 700 13px/1 var(--font);
}
.pin.start, .pin.end { background: var(--surface); color: var(--text); border: 3px solid var(--accent); }
.pin.via { background: var(--surface); color: var(--text); border: 3px solid var(--muted); width: 26px; height: 26px; font-size: 12px; }

/* ---------- Esittely ja UKK */
.about { border-top: 1px solid var(--border); background: var(--surface); margin-top: 8px; }
.about-inner { max-width: 1180px; margin: 0 auto; padding: 40px 20px 28px; display: grid; gap: 16px 56px; grid-template-columns: minmax(0, 1fr); color: var(--text-2); font-size: 0.96rem; line-height: 1.65; }
@media (min-width: 900px) { .about-inner { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.about h2 { font-size: 1.2rem; margin: 0 0 10px; color: var(--text); }
.about ul { padding-left: 0; list-style: none; margin: 12px 0 16px; display: flex; flex-direction: column; gap: 8px; }
.about li { position: relative; padding-left: 26px; }
.about li::before { content: ""; position: absolute; left: 0; top: 0.45em; width: 14px; height: 14px; border-radius: 50%; background: var(--accent-soft); box-shadow: inset 0 0 0 4px var(--accent-soft), inset 0 0 0 7px var(--accent); }
.about details { border-bottom: 1px solid var(--border); padding: 12px 0; }
.about details:first-of-type { border-top: 1px solid var(--border); }
.about summary { cursor: pointer; font-weight: 600; color: var(--text); list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.about summary::-webkit-details-marker { display: none; }
.about summary::after { content: "+"; flex: none; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); color: var(--accent); font-weight: 600; transition: transform 0.15s; }
.about details[open] summary::after { transform: rotate(45deg); }
.about details p { margin: 8px 0 2px; color: var(--muted); }

/* ---------- Alapalkki */
.foot {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 16px;
  padding: 16px 20px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  color: var(--muted); font-size: 0.78rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.foot-right { text-align: right; white-space: nowrap; margin-left: auto; }
.credits { line-height: 1.7; }
.credits a, .foot a { color: inherit; }
.foot a:hover { color: var(--accent); }
.version { font-variant-numeric: tabular-nums; }

/* ---------- Puhelin */
@media (max-width: 600px) {
  .top { padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); gap: 8px; min-height: 58px; }
  .brand { gap: 10px; }
  .brand img { width: 32px; height: 32px; }
  .brand .brand-name { font-size: 0.95rem; hyphens: auto; -webkit-hyphens: auto; }
  .brand small { font-size: 0.72rem; }
  .top-actions { gap: 2px; }
  .top-actions .ghost { min-height: 40px; width: 40px; padding: 0; justify-content: center; position: relative; }
  .top-actions .ghost > span:not(.badge), .saved-label { display: none; }
  .account-btn { max-width: 40px; border-color: transparent !important; }
  #savedCount { position: absolute; top: 2px; right: 0; min-width: 17px; height: 17px; font-size: 0.66rem; padding: 0 4px; box-shadow: 0 0 0 2px var(--surface); }
  .layout { padding: 12px; gap: 12px; }
  .card { padding: 16px; border-radius: 16px; }
  .timeline-card { padding: 4px 16px; }
  #map { height: 46vh; min-height: 280px; }
  .notice { margin: 10px 12px 0; }
  .foot { flex-direction: column; align-items: stretch; padding: 16px; }
  .foot-right { text-align: left; margin-left: 0; }
  .about-inner { padding: 28px 16px 20px; }
  .res-actions .ghost { font-size: 0.85rem; }
  .hero-main b { font-size: 1.7rem; }
  .hero-side { text-align: left; }
}
@media (max-width: 380px) {
  .grid2 { grid-template-columns: minmax(0, 1fr); }
}

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

/* ---------- Tekstisivut (tietosuojaseloste) */
.doc { max-width: 760px; margin: 24px auto 40px; padding: 28px 32px; line-height: 1.65; }
.doc h1 { margin-top: 0; font-size: 1.7rem; letter-spacing: -0.025em; }
.doc h2 { font-size: 1.1rem; margin: 26px 0 6px; }
.doc ul { padding-left: 20px; }
.doc li { margin: 6px 0; }
@media (max-width: 640px) { .doc { margin: 12px; padding: 20px; } }
.privacy-body { overflow-y: auto; line-height: 1.6; margin-top: 8px; }
.privacy-body h2 { font-size: 1.05rem; margin: 18px 0 6px; }
.privacy-body ul { padding-left: 20px; }
.privacy-body li { margin: 6px 0; }
/* Latausasemien selaus kartalla (4.10.2026) */
.browse-ctl { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; margin: 4px 4px 0 0 !important; }
.browse-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); color: var(--text-2); font: 600 0.85rem var(--font); box-shadow: var(--shadow); cursor: pointer; }
.browse-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.browse-btn:hover { filter: brightness(0.97); }
.browse-msg { margin: 0; max-width: 220px; padding: 4px 9px; border-radius: var(--radius-sm); background: var(--surface); color: var(--text-2); font-size: 0.78rem; line-height: 1.35; text-align: right; box-shadow: var(--shadow-sm); }
.browse-msg[hidden] { display: none; }

/* Fintrafficin reaaliaikainen tila ja latauspisteet tehoittain (public/afir.js) */
.live-badge { display: inline-block; margin: 4px 0 0 4px; padding: 1px 8px; border-radius: 999px; font-size: 0.76rem; font-weight: 650; white-space: nowrap; background: var(--surface-2); color: var(--text-2); }
.live-badge.free { background: var(--accent-soft); color: var(--accent-ink); }
.live-badge.busy { background: var(--warn-soft); color: var(--warn); }
.live-badge.down { background: var(--danger-soft); color: var(--danger); }
.along-main .live-badge, .dest-chargers .live-badge { margin: 0 0 0 2px; }
.leaflet-popup .live-badge { margin: 0 0 0 4px; }
.afir-box { margin: 2px 0; }
.afir-box p { margin: 2px 0 0; }
.st-free { color: var(--accent-ink); font-weight: 600; }
.st-busy { color: var(--warn); }
.st-down { color: var(--danger); }

/* Kirjautumista vaativat toiminnot (data-needs-login) ja kokeilureittien määrä */
.lock-ic { display: inline-flex; margin-right: 6px; vertical-align: -2px; }
.trial-note { margin-top: 10px; }
.trial-note .link-btn { padding: 0; min-height: 0; font-size: inherit; }

/* Arvioitu hinta (asemalle ei saatu hintaa luotettavasta lähteestä) */
.est-tag { display: inline-block; padding: 0 6px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); font-size: 0.72rem; font-weight: 650; vertical-align: 1px; }

/* Aseman tietoikkuna ABRP:n tapaan: latauspisteet numeroittain tiloineen (afirDetailsHtml, stationPopup) */
.st-pop h4 { margin: 0 0 2px; font-size: 1rem; }
.st-pop p { margin: 4px 0; }
.afir-group { margin: 8px 0 6px; }
.ag-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.ag-count { font-size: 0.8rem; font-weight: 650; color: var(--text-2); white-space: nowrap; }
.ag-count.free { color: var(--accent-ink); }
.ag-count.busy { color: var(--warn); }
.ag-count.down { color: var(--danger); }
.stalls { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.stall { min-width: 26px; height: 22px; padding: 0 5px; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; font-size: 0.72rem; font-weight: 650; border: 1px solid transparent; background: var(--surface-2); color: var(--text-2); }
.stall.free { background: var(--accent-soft); color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.stall.busy { background: var(--warn-soft); color: var(--warn); }
.stall.down { background: var(--danger-soft); color: var(--danger); text-decoration: line-through; }
.afir-total { font-weight: 600; margin: 6px 0 2px !important; }
.afir-info { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 6px 0; font-size: 0.86rem; }
.afir-info dt { color: var(--muted); }
.afir-info dd { margin: 0; }
.afir-links { font-size: 0.86rem; }
.sp-price b { font-size: 1rem; }
.sp-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px !important; }
.st-pop a.nav-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border-radius: 999px; background: var(--accent); color: var(--accent-text); font-size: 0.86rem; text-decoration: none; }
.leaflet-popup-content .st-pop a.nav-btn { color: var(--accent-text); }
.sp-stop { margin: 0 0 6px !important; padding: 6px 8px; border-radius: 8px; background: var(--accent-soft); color: var(--accent-ink); font-size: 0.84rem; }
.st-pop { max-height: var(--pop-max, 70vh); overflow-y: auto; overscroll-behavior: contain; padding-right: 2px; }

/* Kartan merkkien tekstit ”vapaat/paikat · kW” (stationLabel; näkyvät zoomitasolla ≥ LABEL_MIN_ZOOM) */
.leaflet-tooltip.st-label { padding: 0 4px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--text-2); box-shadow: none; font: 650 10.5px/15px Inter, system-ui, sans-serif; white-space: nowrap; }
.leaflet-tooltip.st-label::before { display: none; }
.leaflet-tooltip.st-label.free { color: var(--accent-ink); }
.leaflet-tooltip.st-label.busy { color: var(--warn); }
.leaflet-tooltip.st-label.down { color: var(--danger); }
.leaflet-container:not(.st-labels) .leaflet-tooltip.st-label { display: none; }
