@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,700&family=Sora:wght@400;500;600&display=swap");

:root {
  --bg0: #0f1a17;
  --bg1: #163028;
  --ink: #f3f6f2;
  --muted: #a7b8b0;
  --accent: #c6f26d;
  --accent-ink: #142016;
  --warn: #f0c674;
  --err: #ff8f8f;
  --ok: #9be7b0;
  --line: rgba(255, 255, 255, 0.1);
  --panel: #152821;
  --field: #0f1c18;
  --radius: 18px;
  --font: "Sora", "Avenir Next", "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #2a5a45 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #3a4a20 0%, transparent 50%),
    linear-gradient(165deg, var(--bg0), var(--bg1) 45%, #0c1412);
  line-height: 1.45;
  overflow-x: hidden;
}

a { color: var(--accent); }
h1, h2 {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -0.02em;
}
h1 { font-size: clamp(1.8rem, 5vw, 2.4rem); margin: 0 0 0.35rem; }
h2 { font-size: 1.15rem; margin: 0 0 0.75rem; }

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}
.auth-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.brand, .brand-link {
  font-family: var(--display);
  font-size: 1.35rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}
.lede, .muted { color: var(--muted); }
.err { color: var(--err); }
.ok { color: var(--ok); }
.warn {
  color: var(--warn);
  background: rgba(240, 198, 116, 0.08);
  border: 1px solid rgba(240, 198, 116, 0.25);
  padding: 0.8rem 1rem;
  border-radius: 12px;
}

.topnav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: rgba(12, 20, 18, 0.92);
  z-index: 20;
}
.topnav-links {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.92rem;
}
.topnav-links a { color: var(--muted); text-decoration: none; }
.topnav-links a.is-active,
.topnav-links a:hover { color: var(--ink); }
.user { color: var(--muted); opacity: 0.8; }

.page {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}
.page-head { margin-bottom: 1.1rem; }

.form-card,
.option-card {
  display: block;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.grid-2,
.grid-3 {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
  width: 100%;
}
@media (min-width: 560px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
  min-width: 0;
  width: 100%;
}

input,
select,
textarea {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  font: inherit;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--ink);
  padding: 0.7rem 0.8rem;
  color-scheme: dark;
  appearance: none;
  -webkit-appearance: none;
}
input[type="number"] {
  /* evita larghezza intrinseca enorme dei number field */
  width: 100%;
  min-width: 0;
}
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 0.55rem;
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  border: none;
  padding: 0;
  margin: 0.35rem 0 0.15rem;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0f1a17;
  box-shadow: 0 0 0 1px rgba(198,242,109,.35);
}
input[type="range"]::-moz-range-thumb {
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0f1a17;
}
.slider-field {
  display: grid;
  gap: 0.15rem;
}
.slider-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  font-size: 0.92rem;
}
.slider-head strong {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.slider-ends {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
}
input::placeholder { color: #7f948a; }
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ink);
  -webkit-box-shadow: 0 0 0 1000px var(--field) inset;
  transition: background-color 9999s ease-in-out 0s;
}
input:focus,
select:focus {
  outline: 2px solid rgba(198, 242, 109, 0.35);
  border-color: transparent;
}

.row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  width: 100%;
}
.row .suggest-wrap { flex: 1; min-width: 0; }
.field-block {
  display: grid;
  gap: 0.4rem;
}
.field-label {
  font-size: 0.9rem;
  color: var(--muted);
}
.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;
}
.check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
  color: var(--ink);
}
.check input {
  width: 1.1rem;
  height: 1.1rem;
  flex: 0 0 auto;
}
.fuel-block {
  border-top: 1px solid var(--line);
  padding-top: 0.9rem;
  margin-top: 0.15rem;
  width: 100%;
}

.suggest-wrap { position: relative; width: 100%; }
.suggest-list {
  position: absolute;
  z-index: 30;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  max-height: 240px;
  overflow: auto;
}
.suggest-list[hidden] { display: none; }
.suggest-list button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 8px;
  padding: 0.65rem 0.7rem;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
}
.suggest-list button:hover,
.suggest-list button.is-active {
  background: rgba(198, 242, 109, 0.12);
}

.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
  width: auto;
  max-width: 100%;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  padding: 0.75rem 1rem;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
}
.form-card > .btn,
.form-card > a.btn {
  width: 100%;
}
.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.small { padding: 0.45rem 0.75rem; font-size: 0.85rem; width: auto; }

.plan-status {
  margin-top: 1rem;
  display: grid;
  gap: 0.45rem;
}
.plan-progress {
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  overflow: hidden;
  border: 1px solid var(--line);
}
.plan-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #8fbc5a, var(--accent));
  transition: width .25s ease;
}
.plan-progress-label {
  margin: 0;
  font-size: 0.88rem;
}
.results { display: grid; gap: 0.9rem; margin-top: 1rem; }
.planning-notes {
  background: rgba(240, 198, 116, 0.1);
  border: 1px solid rgba(240, 198, 116, 0.35);
  border-radius: var(--radius);
  padding: 0.95rem 1rem;
}
.planning-notes-title {
  margin: 0 0 0.55rem;
  font-size: 1rem;
  color: var(--warn);
}
.planning-notes ul {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.45rem;
  color: var(--ink);
  font-size: 0.88rem;
  line-height: 1.45;
}
.compare-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
}
.compare-title {
  margin: 0 0 0.7rem;
  font-size: 1.05rem;
}
.compare-wrap { overflow-x: auto; }
.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 520px;
}
.compare-table th,
.compare-table td {
  text-align: left;
  padding: 0.55rem 0.45rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.compare-table th {
  color: var(--muted);
  font-weight: 500;
}
.compare-table td strong { color: var(--accent); }
.cell-sub {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.15rem;
  white-space: nowrap;
}
.compare-note {
  margin: 0.65rem 0 0;
  font-size: 0.8rem;
  line-height: 1.35;
}
.option-card h3 { margin: 0; font-family: var(--display); font-size: 1.35rem; }
.option-head { display: grid; gap: 0.7rem; margin-bottom: 0.75rem; }
.option-facts {
  display: grid;
  gap: 0.45rem 1rem;
  margin: 0;
}
.option-facts > div {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 0.35rem 0.75rem;
  align-items: baseline;
}
.option-facts dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
}
.option-facts dd {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink);
}
@media (min-width: 640px) {
  .option-facts {
    grid-template-columns: 1fr 1fr;
  }
}
.option-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.18);
  color: var(--muted);
  font-size: 0.82rem;
}
.pill.strong {
  background: rgba(198,242,109,.16);
  color: var(--accent);
  border-color: transparent;
  font-weight: 600;
}
.pill.warn-pill {
  background: rgba(240, 170, 80, 0.2);
  color: #f0c674;
  border-color: rgba(240, 170, 80, 0.35);
}
.stops-accordion {
  margin-top: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0,0,0,.12);
  overflow: hidden;
}
.stops-accordion > summary {
  cursor: pointer;
  list-style: none;
  padding: 0.8rem 0.95rem;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.stops-accordion > summary::-webkit-details-marker { display: none; }
.stops-accordion > summary::after {
  content: '▾';
  color: var(--muted);
  transition: transform .15s ease;
}
.stops-accordion[open] > summary::after { transform: rotate(180deg); }
.stops-accordion .stops {
  padding: 0 0.7rem 0.7rem;
  margin: 0;
}
.warn.compact {
  padding: 0.55rem 0.75rem;
  margin: 0 0 0.7rem;
  font-size: 0.85rem;
}
.stops {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.65rem;
}
.stop {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.85rem 0.9rem;
  background: rgba(0, 0, 0, 0.16);
}
.stop-top {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
}
.stop-title {
  display: flex;
  gap: 0.65rem;
  min-width: 0;
}
.stop-num {
  flex: 0 0 auto;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.8rem;
  font-weight: 700;
}
.stop-title strong {
  display: block;
  line-height: 1.25;
  font-size: 0.98rem;
}
.stop-brand {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.15rem;
}
.stop-price {
  text-align: right;
  flex: 0 0 auto;
}
.stop-price strong {
  display: block;
  font-size: 1.15rem;
  color: var(--accent);
  line-height: 1;
}
.stop-price span {
  color: var(--muted);
  font-size: 0.75rem;
}
.stop-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.7rem;
  margin-top: 0.65rem;
  color: var(--muted);
  font-size: 0.82rem;
}
.stop-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-top: 0.55rem;
}
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge.ok {
  color: var(--ok);
  border-color: rgba(155,231,176,.35);
  background: rgba(155,231,176,.08);
}
.badge.warn {
  color: var(--warn);
  border-color: rgba(240,198,116,.35);
  background: rgba(240,198,116,.08);
}
.tiny { font-size: 0.72rem; }
.option-actions,
.stop-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.7rem;
}
.stop-actions { margin-top: 0.55rem; }
.option-summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}
.option-map {
  height: 220px;
  margin: 0.75rem 0 0.9rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  overflow: hidden;
  background: #0c1412;
}
.map {
  height: 320px;
  margin-top: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  overflow: hidden;
}
#plan-status { margin-top: 0.8rem; }
