:root {
  --accent: #2f5d9e;
  --ink: #16181d;
  --text: #1a1c20;
  --text-2: rgba(50, 54, 62, 0.72);
  --glass: rgba(255, 255, 255, 0.72);
  --glass-strong: rgba(255, 255, 255, 0.88);
  --glass-border: rgba(255, 255, 255, 0.65);
  --field-border: rgba(20, 25, 35, 0.12);
  --focus-ring: rgba(47, 93, 158, 0.25);
  --chip: rgba(240, 240, 242, 0.72);
  --track: #d8dbe0;
  --cta-bg: #16181d;
  --cta-fg: #ffffff;
  --field-bg: rgba(255, 255, 255, 0.6);
  --bad: #b3311f;
  --open: #2e7d4f;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.14), 0 1px 2px rgba(0, 0, 0, 0.07);
  --welcome-bg: #f6f5f2;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro", "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark; /* controlli nativi (select, input) coerenti col tema — modalità Auto: segue il sistema */
}

/* Con un tema forzato esplicitamente (toggle Chiaro/Scuro, non Auto), anche
   color-scheme deve seguire data-theme: altrimenti i popup dei controlli
   nativi (select) restano legati al tema di sistema invece che a quello
   scelto in app (bug osservato su Windows: select scuro su tema Chiaro
   forzato quando il sistema è in dark mode, e viceversa). */
:root[data-theme="light"] {
  color-scheme: light;
}

/* Tema scuro: due copie identiche degli stessi ~18 token, una guardata dalla
   media query (per l'automatismo di sistema, quando non c'è override manuale)
   e una guardata da [data-theme="dark"] (per l'override esplicito via toggle,
   indipendente dalle preferenze di sistema). Tenerle sincronizzate a mano. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #8ab2e0;
    --ink: #f2f2f4;
    --text: #f2f2f4;
    --text-2: rgba(235, 235, 240, 0.72);
    --glass: rgba(26, 27, 30, 0.7);
    --glass-strong: rgba(26, 27, 30, 0.88);
    --glass-border: rgba(255, 255, 255, 0.12);
    --field-border: rgba(255, 255, 255, 0.16);
    --focus-ring: rgba(138, 178, 224, 0.3);
    --chip: rgba(44, 45, 50, 0.6);
    --track: #3a3d44;
    --cta-bg: #f2f2f4;
    --cta-fg: #16181d;
    --field-bg: rgba(255, 255, 255, 0.10);
    --bad: #e08578;
    --open: #8fd0a8;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
    --welcome-bg: #16181d;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --accent: #8ab2e0;
  --ink: #f2f2f4;
  --text: #f2f2f4;
  --text-2: rgba(235, 235, 240, 0.72);
  --glass: rgba(26, 27, 30, 0.7);
  --glass-strong: rgba(26, 27, 30, 0.88);
  --glass-border: rgba(255, 255, 255, 0.12);
  --field-border: rgba(255, 255, 255, 0.16);
  --focus-ring: rgba(138, 178, 224, 0.3);
  --chip: rgba(44, 45, 50, 0.6);
  --track: #3a3d44;
  --cta-bg: #f2f2f4;
  --cta-fg: #16181d;
  --field-bg: rgba(255, 255, 255, 0.10);
  --bad: #e08578;
  --open: #8fd0a8;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
  --welcome-bg: #16181d;
}

/* -------------------------------------------------------------------- */
/* Riduzione animazioni (accessibilità): ogni transizione/animazione     */
/* diventa un cambio di stato istantaneo.                                */
/* -------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; overflow: hidden; }
body { color: var(--text); }

.hidden { display: none !important; }

button, a, input, select {
  font-family: inherit;
}

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

/* -------------------------------------------------------------------- */
/* Mappa                                                                */
/* -------------------------------------------------------------------- */
#map { position: fixed; inset: 0; z-index: 0; }

/* -------------------------------------------------------------------- */
/* Vetro comune                                                         */
/* -------------------------------------------------------------------- */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
}

/* -------------------------------------------------------------------- */
/* Schermata di benvenuto (prima esperienza, nessun recente salvato)    */
/* -------------------------------------------------------------------- */
body.welcome-active { background: var(--welcome-bg); }

body.welcome-active #map { opacity: 0; pointer-events: none; }

/* In benvenuto il link di supporto c'è già sotto la tagline: niente doppione nel form. */
body.welcome-active #savings-row { display: none; }

/* display:flex + justify-content:center su un contenitore scrollabile è una
   trappola nota: se il contenuto supera il viewport il centraggio lo fa
   traboccare in modo simmetrico sopra E sotto l'origine dello scroll, e
   inizio/fine restano irraggiungibili (bug segnalato: su mobile non si
   arriva in fondo al form). Fix "margin auto" (safe-centering senza CSS
   sperimentali): il contenitore scrolla normalmente dall'alto
   (justify-content: flex-start, che è anche il default), il wrapper unico
   dei figli (.welcome-inner) prende margin-block: auto — con spazio
   disponibile si centra come farebbe justify-content:center, ma se il
   contenuto eccede l'altezza il margine collassa a 0 e il contenuto parte
   dall'inizio, interamente scorribile. */
.welcome-screen {
  position: fixed; inset: 0; z-index: 25;
  display: flex; flex-direction: column; align-items: center;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  background: var(--welcome-bg);
  text-align: center;
  opacity: 1;
  overflow-y: auto;
  transition: opacity 0.35s ease;
}

.welcome-inner {
  display: flex; flex-direction: column; align-items: center;
  gap: 18px;
  width: 100%;
  margin-block: auto; /* trucco di centraggio "safe": vedi commento sopra */
}

.welcome-screen.welcome-exit { opacity: 0; }

.welcome-title {
  font-size: 3.4rem; font-weight: 800; letter-spacing: 0.02em; color: var(--text);
  text-transform: uppercase;
}

.welcome-savings {
  font-size: 0.92rem; font-weight: 650; color: var(--accent);
}

.welcome-donate {
  color: var(--accent); font-size: 0.82rem; font-weight: 600;
  text-decoration: none; border-radius: 8px;
}

.welcome-donate:hover { text-decoration: underline; }

.welcome-screen .search-box {
  position: static; width: 100%; max-width: 420px;
  margin-top: 8px;
}

/* -------------------------------------------------------------------- */
/* Barra di ricerca flottante (pillola <-> pannello form)               */
/* -------------------------------------------------------------------- */
.search-box {
  position: fixed; z-index: 20;
  top: max(12px, env(safe-area-inset-top));
  left: 12px; right: 12px;
  border-radius: 22px;
  overflow: hidden;
  transition: border-radius 0.15s ease;
}

.search-box.collapsed {
  border-radius: 999px;
}

.search-compact {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 8px 13px 20px;
  font-weight: 600; font-size: 0.95rem;
}

.search-compact .route { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-compact .route b { font-weight: 700; }
.search-compact .route span { color: var(--text-2); font-weight: 400; padding: 0 2px; }

.edit-btn {
  flex-shrink: 0; border: none; cursor: pointer;
  border-radius: 999px; padding: 8px 16px; min-height: 34px;
  background: var(--chip); color: var(--text);
  font-size: 0.8rem; font-weight: 600;
  transition: transform 0.1s ease;
}

.route-form {
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px 18px calc(16px + env(safe-area-inset-bottom, 0px));
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

.search-box.collapsed .route-form { display: none; }

/* Nella schermata di benvenuto il form non deve avere un suo scroll interno:
   su schermi bassi creerebbe un doppio scroll annidato (pagina + riquadro),
   con lo stesso effetto "non riesco ad arrivare in fondo" del bug del
   centraggio. Qui deve scorrere con la pagina (.welcome-screen). */
.search-box--welcome .route-form {
  max-height: none;
  overflow-y: visible;
}

/* -------------------------------------------------------------------- */
/* Selettore modalità (Percorso / Distributori)                         */
/* -------------------------------------------------------------------- */
.mode-switch {
  display: flex; gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--chip);
}

.mode-btn {
  flex: 1; border: none; cursor: pointer; font-family: inherit;
  padding: 9px 0; border-radius: 10px;
  background: transparent; color: var(--text-2);
  font-size: 0.85rem; font-weight: 650;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.mode-btn.active {
  background: var(--glass-strong); color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.mode-btn:active { transform: scale(0.98); }

/* -------------------------------------------------------------------- */
/* Toggle tema (Auto/Chiaro/Scuro): stessa struttura del mode-switch, in */
/* versione compatta, in fondo al form (entrambe le modalità).          */
/* -------------------------------------------------------------------- */
.theme-field { gap: 6px; }

.mode-switch--compact {
  padding: 3px;
  border-radius: 11px;
}

.mode-switch--compact .mode-btn {
  padding: 6px 0;
  border-radius: 8px;
  font-size: 0.76rem;
}

.mode-switch--compact .mode-btn.active {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.empty-state {
  color: var(--text-2);
  font-size: 0.84rem;
  line-height: 1.4;
}

.field {
  display: flex; flex-direction: column; gap: 6px;
  position: relative; flex: 1;
}

.field-row { display: flex; gap: 10px; }

/* Se un'etichetta va a capo, gli input dei campi affiancati restano allineati. */
.field-row .field { justify-content: flex-end; }

label {
  font-size: 0.72rem; font-weight: 650; color: var(--text-2);
  text-transform: uppercase; letter-spacing: 0.03em;
}

input[type="text"], input[type="number"], select {
  padding: 11px 12px; min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--field-border);
  font-size: 0.95rem;
  background: var(--field-bg);
  color: var(--text);
  outline: none; width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]:focus, input[type="number"]:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.autocomplete-field { position: relative; }

.suggestions {
  list-style: none; margin: 0; padding: 4px;
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-height: 220px; overflow-y: auto;
  z-index: 1000;
}

.suggestions.hidden { display: none; }

.suggestions li {
  padding: 11px 10px; min-height: 44px;
  display: flex; align-items: center;
  border-radius: 8px; cursor: pointer;
  font-size: 0.9rem;
}

.suggestions li:hover, .suggestions li.active {
  background: var(--chip);
}

.link-btn {
  align-self: flex-start;
  display: flex; align-items: center;
  min-height: 44px; padding: 0 2px;
  margin: -11px 0 -11px;
  border: none; background: none; cursor: pointer;
  color: var(--accent);
  font-size: 0.8rem; font-weight: 600;
}

.link-btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* -------------------------------------------------------------------- */
/* Ricerche recenti                                                     */
/* -------------------------------------------------------------------- */
.recents { display: flex; flex-direction: column; gap: 8px; }

.recents-label {
  font-size: 0.72rem; font-weight: 650; color: var(--text-2);
  text-transform: uppercase; letter-spacing: 0.03em;
}

.recents-list { display: flex; flex-direction: column; gap: 6px; }

.recent-item {
  display: flex; align-items: center;
  min-height: 44px; width: 100%;
  padding: 0 12px;
  border: none; border-radius: 12px; cursor: pointer;
  background: var(--chip); color: var(--text);
  font-size: 0.85rem; font-weight: 550;
  text-align: left;
  transition: transform 0.1s ease;
}

/* -------------------------------------------------------------------- */
/* Riga risparmio + donazione, in fondo al form espanso                 */
/* -------------------------------------------------------------------- */
.savings-row {
  font-size: 0.8rem; font-weight: 600; color: var(--text-2);
  padding-top: 2px; text-align: center;
}

.savings-row .dot { margin: 0 3px; opacity: 0.6; }

.savings-donate {
  color: var(--accent); font-weight: 650; text-decoration: none;
}

.savings-donate:hover { text-decoration: underline; }

.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 999px; min-height: 50px;
  background: var(--cta-bg); color: var(--cta-fg);
  font-size: 0.98rem; font-weight: 650; cursor: pointer;
  letter-spacing: 0.01em;
  transition: opacity 0.15s ease, transform 0.1s ease;
}

.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: currentColor;
  animation: spin 0.7s linear infinite;
}

.spinner.hidden { display: none; }

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

/* -------------------------------------------------------------------- */
/* Banner errore                                                        */
/* -------------------------------------------------------------------- */
.error-box {
  position: fixed; z-index: 20;
  top: 84px; left: 12px; right: 12px;
  border-radius: 16px;
  padding: 12px 16px;
  font-size: 0.85rem;
  color: var(--bad);
}

/* -------------------------------------------------------------------- */
/* Chip contestuali                                                     */
/* -------------------------------------------------------------------- */
/* left/right condivisi a filo con .search-box (stessa geometria orizzontale
   in ogni stato/breakpoint: la prima chip parte esattamente sotto il bordo
   sinistro della pillola, non rientrata). Il `top` è un fallback statico:
   il valore reale, che dipende dall'altezza corrente di .search-box (pillola
   collassata o form espanso, entrambi variabili), è impostato via JS
   (syncChipsPosition) subito sotto il bordo inferiore della search-box. */
.chips {
  position: fixed; z-index: 20; top: 76px; left: 12px; right: 12px;
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
}

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

.chip {
  flex-shrink: 0; border: none; cursor: pointer;
  border-radius: 999px; padding: 8px 14px;
  font-size: 0.78rem; font-weight: 550; color: var(--text-2);
  transition: transform 0.1s ease;
}

/* -------------------------------------------------------------------- */
/* Bottom sheet                                                         */
/* -------------------------------------------------------------------- */
.sheet {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
  border-radius: 22px 22px 0 0;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px;
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  backdrop-filter: blur(28px) saturate(160%);
  border-top: 1px solid var(--glass-border);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.16);
  transform: translateY(0);
  transition: transform 0.25s ease;
}

/* Durante il trascinamento niente transition: il pannello deve seguire il
   dito 1:1. Applicata/rimossa via JS su #sheet.dragging. */
.sheet.dragging { transition: none !important; }

/* Ingresso dello sheet al primo risultato (o skeleton) della sessione. */
@keyframes sheet-slide-up {
  from { transform: translateY(28px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet.sheet-enter { animation: sheet-slide-up 0.3s ease-out; }

/* Riga sopra l'hero: grabber centrato (area di presa del drag, insieme a
   tutta la riga hero sottostante) + bottone esplicito di contrai/espandi,
   per chi su mobile non scopre mai il gesto di trascinamento. */
.sheet-topbar {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  min-height: 26px;
  touch-action: none;
}

.grabber {
  width: 40px; height: 5px; border-radius: 3px; background: var(--text-2); opacity: 0.3; margin: 2px auto 0;
  touch-action: none;
}

.sheet-toggle-btn {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  border: none; cursor: pointer;
  width: 30px; height: 30px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  background: var(--chip); color: var(--text-2);
  font-size: 0.8rem; line-height: 1;
  transition: transform 0.15s ease, background 0.15s ease;
}

.sheet-toggle-btn:active { transform: translateY(-50%) scale(0.92); }

/* -------------------------------------------------------------------- */
/* Skeleton loading: placeholder mostrati nello sheet durante il calcolo */
/* -------------------------------------------------------------------- */
#sheet-skeleton { display: none; }
.sheet.loading #sheet-skeleton { display: flex; flex-direction: column; gap: 14px; padding: 4px 2px 2px; }
.sheet.loading #sheet-content { display: none; }

/* Il contenuto reale vive in un wrapper (per lo scambio con lo skeleton):
   deve replicare la colonna con gap dello sheet, altrimenti gli elementi
   si impilano senza respiro e lo slider tocca le card. */
#sheet-content { display: flex; flex-direction: column; gap: 14px; }

.skel {
  border-radius: 12px; background: var(--chip);
  position: relative; overflow: hidden;
}

.skel::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  transform: translateX(-100%);
  animation: skel-shimmer 1.3s ease-in-out infinite;
}

@media (prefers-color-scheme: dark) {
  .skel::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent); }
}

@keyframes skel-shimmer { to { transform: translateX(100%); } }

.skel-hero { height: 34px; width: 55%; }
.skel-tag { height: 22px; width: 40%; }
/* overflow-x: hidden — le skeleton-card non devono mai sbordare dal riquadro
   dello sheet: a differenza del carosello reale (.cards) non scrollano, si
   limitano a suggerire "qui arriveranno delle card". */
.skel-cards { display: flex; gap: 10px; overflow-x: hidden; }
.skel-card { flex: 0 0 132px; height: 78px; }

@media (prefers-reduced-motion: reduce) {
  .skel::after { display: none; }
}

.hero { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 0 2px; touch-action: none; }
.hero .time { font-size: 2.1rem; font-weight: 750; letter-spacing: -0.03em; }
.hero .cost { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }

/* Micro fade/slide dei numeri hero quando cambia la selezione. */
@keyframes hero-fade {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero.hero-anim .time, .hero.hero-anim .cost {
  animation: hero-fade 0.15s ease;
}

.hero-sub { display: flex; gap: 8px; flex-wrap: wrap; margin-top: -6px; align-items: center; }
.tag {
  border-radius: 999px; padding: 5px 12px; font-size: 0.76rem; font-weight: 550;
  background: var(--chip); color: var(--text-2);
}
.tag.rec { background: var(--cta-bg); color: var(--cta-fg); font-weight: 650; }

.tag-toll {
  border: none; font-family: inherit; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
}

.toll-breakdown {
  display: flex; flex-wrap: wrap; gap: 6px 14px;
  margin-top: -4px; padding: 0 2px;
}

.toll-item {
  font-size: 0.76rem; font-weight: 550; color: var(--text-2);
}

/* -------------------------------------------------------------------- */
/* Pannello distributori (tag "Distributori" nello sheet)               */
/* -------------------------------------------------------------------- */
.tag-fuel {
  border: none; font-family: inherit; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
}

.fuel-panel {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: -4px; padding: 10px 2px 2px;
}

/* -------------------------------------------------------------------- */
/* Piano rifornimenti (soste consigliate in base all'autonomia)         */
/* -------------------------------------------------------------------- */
.refuel-plan {
  display: flex; flex-direction: column; gap: 6px;
  padding-bottom: 10px; margin-bottom: 2px;
  border-bottom: 1px solid var(--glass-border);
}

.refuel-summary {
  font-size: 0.82rem; font-weight: 700; color: var(--text);
}

.refuel-stop {
  font-size: 0.8rem; font-weight: 600; color: var(--text);
  background: var(--chip); border-radius: 10px; padding: 7px 10px;
}

.refuel-gap {
  font-size: 0.76rem; font-weight: 550; color: var(--bad); opacity: 0.8;
  padding: 2px 2px;
}

.fuel-badge-stop {
  margin-left: 6px; padding: 2px 8px; font-size: 0.64rem;
  vertical-align: middle;
}

.refuel-stop { cursor: pointer; transition: background 0.15s ease; }
.refuel-stop:hover { background: var(--glass-strong); }

/* Toggle "Passa dalle soste consigliate": switch sobrio, coerente col resto
   dei controlli (nessuna icona/emoji, un solo accento). */
.refuel-toggle {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.78rem; font-weight: 600; color: var(--text);
  cursor: pointer; padding: 2px 2px 2px;
}

.refuel-toggle input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 34px; height: 20px; flex-shrink: 0;
  border-radius: 999px; background: var(--track);
  position: relative; cursor: pointer; outline: none;
  transition: background 0.15s ease;
}

.refuel-toggle input[type="checkbox"]::before {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease;
}

.refuel-toggle input[type="checkbox"]:checked { background: var(--accent); }
.refuel-toggle input[type="checkbox"]:checked::before { transform: translateX(14px); }

/* -------------------------------------------------------------------- */
/* Card dettaglio distributore (selezione da lista o marker)            */
/* -------------------------------------------------------------------- */
.station-detail-card {
  position: relative;
  border-radius: 16px;
  padding: 12px 36px 12px 14px;
  display: flex; flex-direction: column; gap: 4px;
  background: var(--chip);
  border: 1.5px solid var(--accent);
  margin-top: -4px;
}

.detail-close {
  position: absolute; top: 8px; right: 8px;
  border: none; background: none; cursor: pointer;
  color: var(--text-2); font-size: 0.72rem; font-weight: 650;
  padding: 5px 7px; border-radius: 8px;
}

.detail-close:hover { background: var(--glass-strong); }

.detail-row { font-size: 0.8rem; color: var(--text-2); }

.detail-top {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
}

.detail-name {
  font-weight: 750; font-size: 0.96rem; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.detail-price { font-weight: 750; font-size: 1.15rem; color: var(--text); white-space: nowrap; }

.detail-actions {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  margin-top: 6px;
}

.detail-cta {
  align-self: flex-start;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 999px; padding: 9px 18px; min-height: 36px;
  background: var(--cta-bg); color: var(--cta-fg);
  font-size: 0.82rem; font-weight: 650; text-decoration: none; cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease, color 0.15s ease;
}

.detail-cta:active { transform: scale(0.98); }

/* Variante secondaria del bottone dettaglio ("Aggiungi/Rimuovi dal
   tragitto"): stesso ingombro di "Portami qui" ma discreta, solo bordo, mai
   piena — coerente con .cta-secondary usata altrove per le azioni non
   primarie. */
.detail-cta-secondary {
  border: 1.5px solid var(--glass-border);
  background: transparent; color: var(--text-2);
  font-family: inherit;
}

.detail-limit-msg {
  flex-basis: 100%; margin: 0;
  font-size: 0.76rem; font-weight: 550; color: var(--bad);
}

/* Riga "N tappe aggiunte al tragitto · Rimuovi tutte" nel pannello
   distributori, sopra il piano rifornimenti. */
.manual-stops-row {
  font-size: 0.78rem; font-weight: 550; color: var(--text-2);
  margin: 0;
}

.manual-stops-clear {
  border: none; background: none; cursor: pointer; padding: 0;
  color: var(--text); font-weight: 650; font-size: 0.78rem;
  text-decoration: underline; font-family: inherit;
}

.fuel-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  flex-wrap: wrap;
}

.fuel-updated {
  font-size: 0.72rem; font-weight: 550; color: var(--text-2);
}

.fuel-sort { display: flex; gap: 4px; }

.fuel-sort-btn {
  border: none; cursor: pointer; font-family: inherit;
  border-radius: 999px; padding: 4px 10px; min-height: 26px;
  background: transparent; color: var(--text-2);
  font-size: 0.72rem; font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
}

.fuel-sort-btn.active { background: var(--chip); color: var(--text); }

.fuel-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column;
  max-height: 200px; overflow-y: auto;
  border-radius: 12px;
}

.fuel-item {
  padding: 8px 8px;
  border-bottom: 1px solid var(--glass-border);
  cursor: pointer;
  transition: background 0.4s ease;
}

.fuel-item:last-child { border-bottom: none; }

.fuel-item:hover { background: var(--chip); }

/* Voce selezionata (persistente, non un flash): stessa card usata sia nel
   pannello lungo il percorso sia in quello per punto, così la selezione ha
   lo stesso aspetto in entrambe le modalità. */
.fuel-item.fuel-item-hl {
  background: var(--chip);
  border-left: 3px solid var(--accent);
  padding-left: 5px;
}

.fuel-item-main {
  font-size: 0.86rem; font-weight: 650; color: var(--text);
}

.fuel-item-sub {
  font-size: 0.74rem; font-weight: 500; color: var(--text-2);
  margin-top: 1px;
}

.fuel-open { color: var(--open); font-weight: 650; }
.fuel-closed { color: var(--bad); font-weight: 650; }

.fuel-msg {
  font-size: 0.8rem; color: var(--text-2); padding: 4px 2px;
}

.fuel-skel { display: flex; flex-direction: column; gap: 8px; }
.fuel-skel-row { height: 36px; }

/* slider */
.trade { display: flex; flex-direction: column; gap: 6px; }
.trade-labels { display: flex; justify-content: space-between; font-size: 0.74rem; font-weight: 600; color: var(--text-2); }

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 5px; border-radius: 3px;
  background: var(--track); outline: none; cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 28px; height: 28px; border-radius: 50%;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25); cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25); cursor: pointer;
}

/* carosello card */
/* snap "proximity", non "mandatory": il mandatory ri-aggancia lo scroll alla
   prima card a ogni relayout (tile mappa, animazioni) annullando il centraggio
   programmatico sulla card selezionata. */
.cards { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; padding: 2px 16px; margin: 0 -16px; }
.cards::-webkit-scrollbar { display: none; }
.card {
  flex: 0 0 132px; scroll-snap-align: center;
  border-radius: 16px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 3px;
  background: var(--chip);
  border: 1.5px solid transparent;
  cursor: pointer;
  text-align: left;
  color: var(--text); /* i <button> non ereditano il colore del testo */
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}
.card.sel { border-color: var(--ink); background: var(--glass-strong); }
.card .c-label { font-size: 0.7rem; font-weight: 650; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.04em; }
.card .c-time { font-size: 1.12rem; font-weight: 750; letter-spacing: -0.02em; }
.card .c-cost { font-size: 0.9rem; font-weight: 550; color: var(--text-2); }

/* CTA */
.cta {
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 999px; min-height: 54px;
  background: var(--cta-bg); color: var(--cta-fg);
  font-size: 1rem; font-weight: 650; cursor: pointer;
  letter-spacing: 0.01em;
  text-decoration: none;
  transition: transform 0.1s ease;
}

/* CTA secondaria (Condividi): discreta, solo bordo, mai piena come la CTA */
.cta-secondary {
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--glass-border); border-radius: 999px; min-height: 44px;
  background: transparent; color: var(--text-2);
  font-size: 0.88rem; font-weight: 600; cursor: pointer;
  letter-spacing: 0.01em;
  transition: transform 0.1s ease;
}

/* -------------------------------------------------------------------- */
/* Feedback attivo (tap/click) coerente su tutti i controlli principali */
/* -------------------------------------------------------------------- */
.btn-primary:active,
.cta:active,
.cta-secondary:active,
.edit-btn:active,
.chip:active,
.recent-item:active,
.card:active {
  transform: scale(0.98);
}

/* -------------------------------------------------------------------- */
/* Desktop (>= 860px): colonna flottante a sinistra sopra la mappa      */
/* -------------------------------------------------------------------- */
@media (min-width: 860px) {
  .search-box {
    left: 16px; right: auto; width: 420px; max-width: 420px;
  }

  .error-box {
    left: 16px; right: auto; width: 420px; max-width: 420px;
  }

  .chips { left: 16px; right: auto; max-width: 420px; }

  .sheet {
    left: 16px; right: auto; bottom: 16px;
    width: 420px; max-width: 420px;
    border-radius: 22px;
    max-height: calc(100vh - 32px);
  }
}
