:root {
  --bg: #f4f4f1;
  --surface: #ffffff;
  --text: #15171b;
  --muted: #676c75;
  --line: #e2e3df;
  /* Colori verificati con la formula del contrasto WCAG (minimo 4,5:1 per il testo): vedi docs/REGISTRO-MODIFICHE.md */
  --accent: #187a50;        /* sfondo dei pulsanti principali, bordi, punti */
  --on-accent: #ffffff;     /* testo sopra il verde: 5,33:1 */
  --accent-text: #146c47;   /* testo verde su bianco, grigio e verde tenue: ≥ 4,85:1 */
  --accent-soft: rgba(24, 122, 80, 0.14);
  --danger: #c2412d;
  --danger-text: #a8351f;   /* testo rosso su rosso tenue */
  --warn-text: #875800;
  --info-text: #2558b3;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.16);
  --radius: 18px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101214;
    --surface: #1b1e22;
    --text: #f0f1f2;
    --muted: #9aa0a8;
    --line: #2b2f34;
    --accent: #34b37b;
    --on-accent: #0b1f15;   /* nel modo scuro il testo sul verde è scuro: 6,45:1 (il bianco era 2,66:1) */
    --accent-text: #34b37b;
    --accent-soft: rgba(52, 179, 123, 0.18);
    --danger: #e0664f;
    --danger-text: #ef8571;
    --warn-text: #f0b440;
    --info-text: #7fa8f0;
    --shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { margin: 0 0 6px; line-height: 1.2; }
h1 { font-size: 26px; }
h2 { font-size: 20px; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.eyebrow { color: var(--muted); font-size: 13px; margin-bottom: 4px; }

/* ---------- mappa e pannello ---------- */
#map { position: fixed; inset: 0; z-index: 0; }
.leaflet-container { background: var(--bg); font: inherit; }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 1000;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow);
  padding: 10px 16px calc(16px + env(safe-area-inset-bottom));
  max-height: 62vh;
  overflow-y: auto;
}
.sheet::before {
  content: "";
  display: block;
  width: 40px; height: 4px;
  border-radius: 2px;
  background: var(--line);
  margin: 0 auto 12px;
}
@media (min-width: 800px) {
  .sheet {
    top: 16px; left: 16px; right: auto; bottom: auto;
    width: 380px;
    max-height: calc(100vh - 32px);
    border-radius: var(--radius);
    padding: 20px;
  }
  .sheet::before { display: none; }
}

.brand {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.brand strong { font-size: 17px; letter-spacing: -0.01em; }
.brand strong span { color: var(--accent-text); }
.brand a, .brand button.link { color: var(--muted); font-size: 13px; text-decoration: none; width: auto; padding: 4px; }

/* ---------- campi ---------- */
.field {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg);
  border: 1.5px solid transparent;
  border-radius: 12px;
  padding: 2px 4px 2px 12px;
  margin-bottom: 8px;
}
.field.active { border-color: var(--accent); }
.field input {
  flex: 1; min-width: 0;
  border: 0; background: transparent; color: inherit; font: inherit;
  padding: 11px 0; outline: none;
}

form label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
form input[type="text"] {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: inherit;
  font: inherit;
}
form input[type="text"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.dot.green { background: var(--accent); }
.dot.red { background: var(--danger); border-radius: 2px; }

/* ---------- pulsanti ---------- */
button, .btn {
  font: inherit; font-weight: 600;
  border: 0; border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform 0.08s ease, opacity 0.15s ease;
}
button:active:not(:disabled), .btn:active { transform: scale(0.98); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.primary { background: var(--accent); color: var(--on-accent); }
.ghost { background: var(--bg); color: var(--text); }
.icon-btn { background: transparent; padding: 8px 10px; font-size: 18px; }
.link { background: none; color: var(--muted); width: 100%; padding: 10px; font-weight: 500; }
.danger { color: var(--danger); }
.block { width: 100%; margin-top: 12px; }
.row { display: flex; gap: 8px; margin-top: 10px; }
.row > * { flex: 1; }

.hint { color: var(--muted); font-size: 13px; margin: 2px 0 6px; }

/* ---------- stima ---------- */
.estimate {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 12px 0 0; margin-top: 8px;
  border-top: 1px solid var(--line);
}
.price { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }

/* ---------- corsa ---------- */
.driver-card {
  display: flex; gap: 12px; align-items: center;
  background: var(--bg);
  border-radius: 14px;
  padding: 12px;
  margin: 12px 0 4px;
}
.avatar {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center;
  font-weight: 700; font-size: 18px; flex-shrink: 0;
}
.plate {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 13px; font-weight: 600;
  margin-left: auto;
}

.searching {
  height: 4px; border-radius: 2px;
  background: var(--line);
  overflow: hidden; position: relative;
  margin: 14px 0;
}
.searching::after {
  content: ""; position: absolute; inset: 0; width: 40%;
  background: var(--accent);
  animation: slide 1.2s ease-in-out infinite;
}
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

.stop { display: flex; gap: 10px; align-items: center; margin: 6px 0; }
.stop em { color: var(--muted); font-style: normal; margin-left: auto; font-size: 13px; white-space: nowrap; }

/* ---------- autista ---------- */
.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px;
  background: var(--bg); color: var(--muted);
}
.status-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-pill.on { background: var(--accent-soft); color: var(--accent-text); }

.offer {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin-top: 10px;
  animation: pop 0.25s ease-out;
}
.offer-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.offer-top strong { font-size: 22px; }
@keyframes pop { from { transform: scale(0.96); opacity: 0; } to { transform: none; opacity: 1; } }

.switch { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); margin-top: 14px; cursor: pointer; }
.switch input { accent-color: var(--accent); width: 18px; height: 18px; }

.stats {
  display: flex; justify-content: space-between;
  font-size: 13px; color: var(--muted);
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--line);
}
.stats b { color: var(--text); }

.pulse { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 6px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }

/* ---------- marker ---------- */
.pin { background: none; border: 0; }
.pin span {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  font-size: 22px;
  background: var(--surface);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
}
.pin.car-idle span { width: 30px; height: 30px; font-size: 15px; margin: 5px; opacity: 0.9; }
.pin.me span, .pin.driver span { box-shadow: 0 0 0 3px var(--accent), 0 2px 8px rgba(0, 0, 0, 0.28); }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; top: 14px;
  transform: translate(-50%, -200%);
  opacity: 0;
  background: var(--text); color: var(--surface);
  padding: 10px 16px; border-radius: 12px;
  z-index: 2000;
  transition: transform 0.25s ease, opacity 0.25s ease;
  max-width: calc(100% - 32px);
  box-shadow: var(--shadow);
  pointer-events: none;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- home ---------- */
.landing {
  min-height: 100%;
  display: grid; place-items: center;
  padding: 24px 16px;
}
.landing .card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 22px;
}
.landing .logo { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 6px; }
.landing .logo span { color: var(--accent-text); }
.landing .choice {
  display: flex; align-items: center; gap: 14px;
  padding: 16px; margin-top: 12px;
  border-radius: 14px;
  background: var(--bg); color: var(--text);
  text-decoration: none;
}
.landing .choice:hover { outline: 2px solid var(--accent); }
.landing .choice .emoji { font-size: 30px; }
.landing .choice small { display: block; color: var(--muted); font-weight: 400; }
.landing .tip { font-size: 13px; color: var(--muted); margin-top: 18px; }
.landing .admin-link { display: inline-block; margin-top: 10px; font-size: 13px; color: var(--muted); }

/* ---------- elementi comuni ---------- */
h3 { font-size: 16px; margin: 14px 0 8px; }
h4 { font-size: 14px; margin: 16px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.small { font-size: 13px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.row-between h2, .row-between h3 { margin: 0; }
.menu { display: flex; gap: 2px; }
.menu .link, .link.narrow { width: auto; padding: 6px 8px; font-size: 13px; }
.form-error { color: var(--danger); font-size: 14px; margin: 8px 0 0; }
.login input[type="tel"], .login input[type="text"], form input[type="tel"] {
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: inherit; font: inherit; letter-spacing: 0.02em;
}
.login input:disabled { opacity: 0.7; }
.login .code-step .link { width: auto; padding: 6px 0; }
.dev-code { color: var(--accent-text); }
.note { background: var(--bg); border-left: 3px solid var(--danger); padding: 8px 12px; border-radius: 6px; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.doc { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.doc .actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.small-btn { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
label.btn { margin: 0; color: var(--text); display: inline-flex; }

.badge {
  display: inline-block; font-size: 12px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
  background: var(--bg); color: var(--muted); white-space: nowrap;
}
.badge.completed, .badge.approved { background: var(--accent-soft); color: var(--accent-text); }
.badge.requested, .badge.pending { background: rgba(214, 143, 0, 0.16); color: var(--warn-text); }
.badge.accepted, .badge.arrived, .badge.in_progress { background: rgba(49, 110, 214, 0.14); color: var(--info-text); }
.badge.cancelled, .badge.no_drivers, .badge.rejected, .badge.suspended { background: rgba(194, 65, 45, 0.13); color: var(--danger-text); }

.status-pill.wait { background: rgba(214, 143, 0, 0.16); color: var(--warn-text); }
.status-pill.bad { background: rgba(194, 65, 45, 0.13); color: var(--danger-text); }

.pin.free span { box-shadow: 0 0 0 3px var(--accent), 0 2px 8px rgba(0, 0, 0, 0.28); }
.pin.busy span { box-shadow: 0 0 0 3px #e0a100, 0 2px 8px rgba(0, 0, 0, 0.28); }
.pin.waiting span { box-shadow: 0 0 0 3px var(--danger), 0 2px 8px rgba(0, 0, 0, 0.28); }
.dot.amber { background: #e0a100; }

/* ---------- amministrazione ---------- */
body.admin { height: auto; min-height: 100%; }
.admin-header {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 20px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.admin-logo { font-size: 16px; }
.admin-logo span { color: var(--accent-text); }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tabs button { background: none; color: var(--muted); padding: 8px 12px; font-weight: 600; border-radius: 10px; white-space: nowrap; }
.tabs button.active { background: var(--bg); color: var(--text); }
.count { background: #b23a27; color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; margin-left: 4px; }
.admin-main { max-width: 1200px; margin: 0 auto; padding: 20px 16px 48px; }
.admin-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
}
.narrow-card { max-width: 420px; margin: 40px auto; }
.admin-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .admin-grid { grid-template-columns: 1fr 1fr; } }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
pre { background: var(--bg); padding: 10px 12px; border-radius: 8px; overflow-x: auto; }
select, input[type="search"] {
  font: inherit; color: inherit; background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; max-width: 100%;
}
input[type="search"] { min-width: 220px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.kpi-label { color: var(--muted); font-size: 13px; }

#live-map { height: 460px; border-radius: 12px; margin-top: 10px; position: relative; z-index: 0; }
.legend { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.legend .dot { margin-left: 8px; }

.table-wrap { overflow-x: auto; margin-top: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.active-row td { background: var(--accent-soft); }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 12px 0; }
.facts dt { color: var(--muted); font-size: 13px; }
.facts dd { margin: 0; }
.timeline { margin: 0; padding-left: 18px; }
.timeline li { margin: 6px 0; }
.doc-preview { margin: 12px 0; }
.doc-preview img { max-width: 100%; max-height: 480px; border-radius: 10px; border: 1px solid var(--line); }

/* ---------- passeggero: posizione, tragitto, ricerca, segnaposto ---------- */
.locate-hero {
  width: 64px; height: 64px; border-radius: 50%;
  display: grid; place-items: center; font-size: 30px;
  background: var(--accent-soft); margin: 4px 0 12px;
}
#view-locate .link { margin-top: 4px; }

.trip-box {
  border: 1px solid var(--line); border-radius: 14px;
  overflow: hidden; margin-top: 4px;
}
.trip-row {
  width: 100%; display: flex; align-items: center; gap: 12px;
  background: var(--surface); color: var(--text);
  border-radius: 0; padding: 12px 14px; text-align: left; font-weight: 400;
}
.trip-row + .trip-row { border-top: 1px solid var(--line); }
.trip-row:hover { background: var(--bg); }
.trip-row:active:not(:disabled) { transform: none; }
.trip-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.trip-text small { color: var(--muted); font-size: 12px; }
.trip-text strong { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trip-text .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trip-row.main.empty strong { font-size: 18px; color: var(--muted); }
.trip-edit { color: var(--accent-text); font-size: 13px; font-weight: 600; flex-shrink: 0; }

.hint.warn { color: var(--warn-text); }
.link.inline { width: auto; display: inline; padding: 0; color: var(--accent-text); font-weight: 600; text-decoration: underline; }

.search-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border-radius: 12px; padding: 2px 10px 2px 2px;
  border: 1.5px solid var(--accent);
}
.search-bar input {
  flex: 1; min-width: 0; border: 0; background: transparent; color: inherit;
  font: inherit; font-size: 16px; padding: 12px 0; outline: none;
}
.search-bar .icon-btn { font-size: 20px; padding: 8px 10px; color: var(--text); }

.suggestions { list-style: none; margin: 6px 0 0; padding: 0; }
.suggestions button {
  width: 100%; display: flex; align-items: center; gap: 12px;
  justify-content: flex-start; text-align: left;
  background: none; color: var(--text); font-weight: 400;
  padding: 10px 6px; border-radius: 10px;
}
.suggestions button:hover, .suggestions button:focus-visible { background: var(--bg); }
.suggestions button > span:nth-child(2) { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.suggestions strong { font-weight: 600; }
.suggestions .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sug-icon {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; background: var(--bg); font-size: 16px;
}
.sug-dist { color: var(--muted); font-size: 12px; flex-shrink: 0; }
#search-shortcuts { border-bottom: 1px solid var(--line); padding-bottom: 6px; }

.pick-address {
  display: flex; gap: 12px; align-items: center;
  background: var(--bg); border-radius: 12px; padding: 12px 14px; margin: 10px 0 2px;
  min-height: 62px;
}
.pick-address strong { font-size: 16px; }

.center-pin {
  position: fixed; z-index: 900; pointer-events: none;
  /* la punta dell'asta (non l'ombra) cade esattamente sul punto */
  transform: translate(-50%, calc(-100% + 3px));
  display: flex; flex-direction: column; align-items: center;
  transition: transform 0.15s ease;
}
.center-pin.moving { transform: translate(-50%, calc(-100% - 7px)); }
.pin-head {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; font-size: 22px;
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--text), 0 4px 12px rgba(0, 0, 0, 0.3);
}
.pin-stick { width: 3px; height: 16px; background: var(--text); border-radius: 0 0 2px 2px; position: relative; z-index: 1; }
.pin-shadow {
  width: 12px; height: 6px; margin-top: -3px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.35); transition: transform 0.15s ease, opacity 0.15s ease;
}
.center-pin.moving .pin-shadow { transform: translateY(10px) scale(1.4); opacity: 0.5; }

/* ---------- attesa, verifica dell'auto, luoghi salvati ---------- */
.search-line { font-size: 14px; color: var(--muted); margin: -4px 0 10px; }

.verify {
  border: 1.5px solid var(--line); border-radius: 14px;
  padding: 12px 14px; margin: 12px 0 4px;
}
.verify.urgent { border-color: var(--accent); background: var(--accent-soft); }
.verify-pin { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pin-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 28px; letter-spacing: 0.2em; font-weight: 700;
  padding-left: 0.2em; flex-shrink: 0;
}
.verify-plate { margin: 10px 0 0; font-size: 14px; }
.verify-pin[hidden] + .verify-plate { margin-top: 0; }
.verify-plate .plate { margin-left: 0; font-size: 14px; }

.suggestions mark { background: none; color: inherit; font-weight: 700; text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }
.suggestions strong mark { font-weight: 800; }
.sug-action {
  color: var(--accent-text); font-size: 13px; font-weight: 600; flex-shrink: 0;
  padding: 10px 6px; margin: -10px -6px -10px 0;
}

/* Tasti e link facili da toccare: almeno 44 px (WCAG 2.5.5, Apple HIG). */
.link, .menu .link, .link.narrow { min-height: 44px; }
.link.inline { min-height: 0; }
.icon-btn { min-width: 44px; min-height: 44px; }
#pick-note-wrap label { margin-top: 12px; }
#pick-note { width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: inherit; font: inherit; }

/* ---------- autista: nota del passeggero e codice ---------- */
.note-driver { background: var(--bg); border-radius: 10px; padding: 8px 12px; font-size: 14px; margin: 6px 0; }
.pin-input {
  width: 100%; padding: 12px; border-radius: 10px; border: 1.5px solid var(--accent);
  background: var(--bg); color: inherit;
  font: 600 24px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.3em; text-align: center;
}
#ride label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }

/* ---------- per chi è la corsa ---------- */
.chip {
  background: var(--bg); color: var(--text); font-weight: 600; font-size: 14px;
  padding: 8px 14px; border-radius: 999px; min-height: 40px; margin-bottom: 10px;
}
.choice-list { margin: 10px 0 4px; }
.choice-row {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px; border: 1.5px solid var(--line); border-radius: 12px; margin: 0 0 8px;
  color: var(--text); font-size: 15px; cursor: pointer;
}
form .choice-row, .choice-row { margin-top: 0; }
.choice-row:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice-row input { accent-color: var(--accent); width: 20px; height: 20px; margin: 1px 0 0; flex-shrink: 0; }
.choice-row > span { display: flex; flex-direction: column; gap: 2px; }
#guest-fields label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
#guest-fields input { width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: inherit; font: inherit; }
.guest-box { background: var(--bg); border-radius: 14px; padding: 12px 14px; margin: 10px 0 4px; font-size: 14px; }
.guest-box p { margin: 0 0 4px; }
.guest-box .row { margin-top: 8px; }
.call-link { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent-text); font-weight: 600; text-decoration: none; }
/* Le schermate con un modulo (per chi è la corsa, ricerca) usano quasi tutta l'altezza su telefono. */
@media (max-width: 799px) {
  .sheet:has(#view-passenger:not([hidden])),
  .sheet:has(#view-search:not([hidden])) { max-height: 88vh; }
}

/* ---------- annullamento e ritardi ---------- */
.danger-btn { background: var(--bg); color: var(--danger); }
.danger-btn.block { margin-top: 10px; }
#cancel-replace + .danger-btn { margin-top: 8px; }
#cancel-note-wrap label { display: block; font-size: 13px; color: var(--muted); margin: 6px 0 4px; }
#cancel-note { width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: inherit; font: inherit; }
.late-box {
  border: 1.5px solid #e0a100; background: rgba(214, 143, 0, 0.1);
  border-radius: 14px; padding: 12px 14px; margin: 10px 0 4px; font-size: 14px;
}
.late-box p { margin: 0 0 4px; font-weight: 600; }
.late-box .row { margin-top: 8px; }
.late-box .link { padding: 6px; }
@media (max-width: 799px) { .sheet:has(#view-cancel:not([hidden])) { max-height: 88vh; } }

/* ---------- creazione dell'account ---------- */
.welcome .block + .block { margin-top: 8px; }
.login input[type="email"], .account input[type="email"], .account input[type="text"] {
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: inherit; font: inherit;
}
.register .form-grid { gap: 0 10px; }
.register .hint { margin-top: 4px; }
form label.check-row, label.check-row {
  display: flex; gap: 10px; align-items: flex-start;
  margin: 14px 0 0; font-size: 14px; color: var(--text); cursor: pointer;
}
.check-row input { width: 22px; height: 22px; margin: 0; flex-shrink: 0; accent-color: var(--accent); }
.check-row a, .legal-links a { color: var(--accent-text); font-weight: 600; }
.legal-links { font-size: 13px; color: var(--muted); margin-top: 14px; }
.account dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 8px 0 4px; font-size: 14px; }
.account dt { color: var(--muted); }
.account dd { margin: 0; }
.danger-zone { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 12px; }
@media (max-width: 799px) { .sheet:has(#view-account:not([hidden])), .sheet:has(#view-login:not([hidden])) { max-height: 88vh; } }

/* ---------- home: "Dove vai?" ---------- */
.where-to {
  width: 100%; justify-content: flex-start; gap: 12px;
  background: var(--bg); color: var(--muted); font-weight: 600; font-size: 17px;
  padding: 14px 16px; border-radius: 14px; margin: 6px 0 4px; text-align: left;
}
.where-to .dot { width: 12px; height: 12px; }
.locate-dest { display: flex; gap: 10px; align-items: center; background: var(--bg); border-radius: 12px; padding: 10px 12px; margin: 8px 0 4px; }
.locate-dest strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.locate-dest > span:nth-child(2) { min-width: 0; flex: 1; }
.locate-dest .link { width: auto; padding: 6px; color: var(--accent-text); font-weight: 600; }
.unreachable-box {
  border: 1.5px solid #e0a100; background: rgba(214, 143, 0, 0.1);
  border-radius: 14px; padding: 12px 14px; margin: 10px 0 4px; font-size: 14px;
}
.unreachable-box p { margin: 0 0 8px; }
.unreachable-box strong { color: var(--text); }

/* ---------- termini e informativa ---------- */
body.legal { height: auto; }
.legal-page { max-width: 720px; margin: 0 auto; padding: 24px 16px 48px; }
.legal-page h2 { margin-top: 22px; font-size: 18px; }
.legal-page a { color: var(--accent-text); }
.legal-page table { margin: 8px 0; }
.legal-page .note { margin-bottom: 18px; }

/* ---------- corse programmate ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips .chip { margin-bottom: 10px; }
.when-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.when-fields label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.when-fields input, .account select, form select {
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: inherit; font: inherit; min-height: 46px;
}
.eta-line { font-size: 14px; margin: 8px 0 0; color: var(--text); }
.eta-line strong { color: var(--accent-text); }
.booking { display: grid; gap: 4px; }
.booking .row { margin-top: 6px; }
.booking-when { font-weight: 700; font-size: 16px; }
.booking-status { font-size: 13px; }
.booking-status.ok { color: var(--accent-text); }
.booking-status.wait { color: var(--warn-text); }
.menu .count { margin-left: 4px; }
@media (max-width: 799px) {
  .sheet:has(#view-when:not([hidden])), .sheet:has(#view-bookings:not([hidden])) { max-height: 88vh; }
}

/* ---------- autista: documenti, prenotazioni, guadagni ---------- */
.expiry-label { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; color: var(--muted); }
.expiry-label input { padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: inherit; font: inherit; }
#bookings { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 6px; }
.booking-card .row { margin-top: 8px; }
.earn-kpis { grid-template-columns: 1fr; gap: 8px; }
.earn-kpis .kpi { padding: 10px 14px; }
.earn-kpis .kpi-value { font-size: 20px; }
.small-link { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent-text); font-weight: 600; font-size: 13px; }
#view-profile h3 { margin-top: 18px; }
@media (max-width: 799px) { .sheet:has(#view-earnings:not([hidden])), .sheet:has(#view-profile:not([hidden])) { max-height: 88vh; } }

/* ---------- foglio di servizio, trasparenza, rendiconto ---------- */
.inline-field { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); margin: 8px 0; }
.inline-field input { padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: inherit; font: inherit; }
.sheet-doc h1 { margin-top: 18px; }
.sheet-table { margin: 14px 0; }
.sheet-table th { width: 38%; text-transform: none; letter-spacing: 0; font-size: 13px; vertical-align: top; }
@media print {
  .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .sheet-table th, .sheet-table td { border-bottom: 1px solid #999; color: #000; }
}
.booking-card { animation: none; }
.admin-card a { color: var(--accent-text); }

/* ---------- lato cliente: fermate, tipo di auto, pagamento, sicurezza, valutazione ---------- */
.dot.blue { background: var(--info-text); }
.pin.stop-marker span { width: 30px; height: 30px; margin: 5px; font: 700 14px/1 system-ui, sans-serif; background: var(--info-text); color: var(--surface); }
#stop-rows > .trip-row, #stop-rows + .trip-row { border-top: 1px solid var(--line); }
.stop-row { padding: 0 6px 0 0; }
.stop-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px;
  background: none; color: var(--text); padding: 12px 0 12px 14px; text-align: left; font-weight: 400; border-radius: 0;
}
.stop-row .icon-btn { color: var(--muted); }
.link.add-stop { width: auto; padding: 10px 2px; color: var(--accent-text); font-weight: 600; text-align: left; min-height: 44px; }

.estimate-box { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.estimate-head { margin-bottom: 6px; align-items: baseline; }
.estimate-head .eyebrow { margin: 0; }
.options { display: grid; gap: 8px; }
.option {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  background: var(--surface); color: var(--text); font-weight: 400;
  border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
.option.on { border-color: var(--accent); background: var(--accent-soft); }
.opt-icon { font-size: 24px; width: 32px; text-align: center; flex-shrink: 0; }
.opt-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.opt-price { font-size: 17px; white-space: nowrap; }
.options .hint { margin: 2px 0 0; }

.chip.warn { color: var(--warn-text); box-shadow: inset 0 0 0 1.5px #e0a100; }
.test-banner {
  border: 1.5px solid #e0a100; background: rgba(214, 143, 0, 0.1); color: var(--text);
  border-radius: 12px; padding: 10px 12px; font-size: 14px; margin: 6px 0 10px;
}
.cards .card-row { display: flex; align-items: center; gap: 6px; padding: 0; border: none; }
.cards .card-row .choice-row { flex: 1; margin: 0 0 8px; }
.cards .card-row .link { width: auto; }
#view-payment h3 { margin: 14px 0 0; font-size: 16px; }

.rating-pill { font-size: 13px; color: var(--muted); font-weight: 600; margin-left: 4px; }
.safety-row { display: flex; gap: 8px; margin: 10px 0 4px; }
.safety-row > * { flex: 1; min-height: 44px; font-size: 14px; }
.sos-btn { background: var(--bg); color: var(--danger-text); box-shadow: inset 0 0 0 1.5px var(--danger); }
.sos-call {
  display: flex; align-items: center; justify-content: center; min-height: 56px; margin: 12px 0;
  background: #b3261e; color: #fff; border-radius: 14px; font-size: 20px; font-weight: 700; text-decoration: none;
}
.sos-facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 6px 0 10px; font-size: 15px; }
.sos-facts dt { color: var(--muted); }
.sos-facts dd { margin: 0; font-weight: 600; }

.done-box { background: var(--bg); border-radius: 14px; padding: 12px 14px; margin: 10px 0 4px; }
.done-box p { margin: 0; }
.stars { display: flex; justify-content: center; gap: 6px; margin: 12px 0; }
.stars button {
  width: 52px; height: 52px; padding: 0; font-size: 34px; line-height: 1;
  background: none; color: #8c9097; border-radius: 50%; /* stella vuota: 3,3:1 sul bianco */
}
.stars button.on { color: #e0a100; }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 10px; }
.tag {
  background: var(--bg); color: var(--text); font-weight: 600; font-size: 14px;
  border-radius: 999px; padding: 8px 14px; min-height: 40px; border: 1.5px solid var(--line);
}
.tag.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
#view-rate textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: inherit; font: inherit; resize: vertical; margin-top: 4px;
}
.history-actions { display: flex; gap: 14px; align-items: center; margin-top: 2px; }
@media (max-width: 799px) {
  .sheet:has(#view-payment:not([hidden])), .sheet:has(#view-rate:not([hidden])), .sheet:has(#view-emergency:not([hidden])) { max-height: 88vh; }
}

/* ---------- ricevuta ---------- */
.receipt-total { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; margin: 6px 0 12px; }
.receipt-note { font-size: 13px; color: var(--muted); line-height: 1.5; }
.cat-tag { display: inline-block; font-size: 12px; font-weight: 700; color: var(--info-text); border: 1.5px solid var(--info-text); border-radius: 999px; padding: 1px 8px; vertical-align: middle; }
.rating-summary { margin: 4px 0 10px; }
.rating-summary .kpi { padding: 10px 14px; }
.rating-summary p { margin: 6px 2px 0; }
.emergency-card { border: 2px solid var(--danger); }
.emergency-card h3 { color: var(--danger-text); margin-top: 0; }

/* ---------- lato autista: turno, ditta, contatto, chat, incassi ---------- */
.contact-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin: 10px 0 4px; }
.contact-row > * { min-height: 44px; font-size: 14px; padding: 8px 10px; }
.contact-row .count, .menu .count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; border-radius: 10px; background: #b3261e; color: #fff; font-size: 12px; padding: 0 5px; }
.contact-row .count[hidden] { display: none; }
.wait-line { font-size: 14px; margin: 8px 0; padding: 10px 12px; border-radius: 12px; background: var(--bg); }
.wait-line.warn { color: var(--warn-text); box-shadow: inset 0 0 0 1.5px #e0a100; }
.shift-bar, .vehicle-box, .invites-box, .push-box, .payout-box { background: var(--bg); border-radius: 14px; padding: 10px 12px; margin: 10px 0; }
.shift-bar p { margin: 0; }
.shift-bar .row { margin-top: 8px; }
.shift-bar .row > * { min-height: 44px; font-size: 14px; padding: 8px; }
.vehicle-box label { display: block; font-size: 13px; color: var(--muted); }
.vehicle-box select, #view-shift select {
  width: 100%; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: inherit; font: inherit; min-height: 44px;
}
.invites-box { box-shadow: inset 0 0 0 1.5px var(--accent); }
.invites-box p { margin: 0 0 8px; }
.push-box p { margin: 0 0 8px; }
#view-shift h3 { margin: 18px 0 4px; font-size: 16px; }
#view-shift label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
#dest-input { width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: inherit; font: inherit; }
#release-note-wrap label { display: block; font-size: 13px; color: var(--muted); margin: 6px 0 4px; }
#release-note, .iban-form input { width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: inherit; font: inherit; }
.iban-form label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0 4px; }
.iban-form button { margin-top: 8px; }
.payout-kpi { background: var(--surface); padding: 10px 14px; margin-bottom: 8px; }
.payout-box details { margin-top: 6px; }
.warn-text { color: var(--warn-text); }
#view-rate-rider textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: inherit; font: inherit; resize: vertical; margin-top: 4px;
}
.menu a.link { display: inline-flex; align-items: center; }

.chat-list { list-style: none; margin: 8px 0; padding: 4px; display: flex; flex-direction: column; gap: 6px; max-height: 42vh; overflow-y: auto; }
.msg { max-width: 80%; padding: 8px 12px; border-radius: 16px; font-size: 15px; display: flex; flex-direction: column; }
.msg time { font-size: 11px; color: var(--muted); align-self: flex-end; }
.msg.mine { align-self: flex-end; background: var(--accent-soft); border-bottom-right-radius: 4px; }
.msg.theirs { align-self: flex-start; background: var(--bg); border-bottom-left-radius: 4px; }
.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; min-width: 0; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: inherit; font: inherit; }
.chat-form button { width: auto; }
#chat-quick { margin: 4px 0 8px; }
#chat-quick .tag { min-height: 36px; padding: 6px 12px; font-size: 13px; }
@media (max-width: 799px) {
  .sheet:has(#view-chat:not([hidden])), .sheet:has(#view-shift:not([hidden])), .sheet:has(#view-release:not([hidden])),
  .sheet:has(#view-rate-rider:not([hidden])) { max-height: 88vh; }
}
.fleet-page { max-width: 1000px; }
.fleet-page h2 { margin-top: 0; }
.fleet-page .admin-card { margin: 14px 0; }
.fleet-page label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.fleet-page input, .fleet-page select {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: inherit; font: inherit; min-height: 44px;
}
.fleet-page td input[type="date"] { width: auto; min-height: 36px; padding: 4px 6px; margin-top: 4px; font-size: 13px; }
.fleet-form { margin-top: 12px; }
.fleet-form .span-all { grid-column: 1 / -1; }
.fleet-page #invite-form { margin-top: 12px; }
.fleet-page #invite-form button { flex: 0 0 auto; width: auto; }
.fleet-card { border-top: 1px solid var(--line); padding: 12px 0; }
.fleet-card .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.contact-row { grid-template-columns: repeat(4, 1fr); }
.contact-row > * { font-size: 13px; padding: 8px 4px; }
.vehicle-box .row select { flex: 2; min-width: 0; }

/* ---------- chiamate dentro l'app, accesso con WhatsApp, Google e Apple ---------- */
.call-who { text-align: center; padding: 12px 0 6px; }
.call-avatar { width: 72px; height: 72px; font-size: 28px; margin: 0 auto 8px; }
.call-who h2 { margin: 0; }
.call-actions { display: flex; gap: 10px; justify-content: center; margin: 14px 0 6px; flex-wrap: wrap; }
.call-actions > * { flex: 1 1 120px; min-height: 52px; }
.call-actions .on { box-shadow: inset 0 0 0 1.5px var(--accent); }
.danger-fill { background: #b3261e; color: #fff; }
.call-view .hint { text-align: center; }
.wa-step { margin: 12px 0 4px; }
.wa-btn {
  display: flex; align-items: center; justify-content: center; min-height: 52px; border-radius: 14px;
  background: #1a7f4b; color: #fff; font-weight: 700; text-decoration: none; margin: 8px 0;
}
.wa-status { margin: 6px 0; }
.wa-status.warn { color: var(--warn-text); }
.wa-msg { margin: 4px 0; }
.social-box { margin-top: 12px; }
.social-btn { display: flex; align-items: center; justify-content: center; gap: 10px; }
.social-btn + .social-btn { margin-top: 8px; }
.social-logo { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-weight: 800; font-size: 14px; }
.social-logo.g { background: var(--surface); color: #1a57c9; box-shadow: inset 0 0 0 1.5px var(--line); }
.social-logo.a::before { content: ""; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 6px 0 10px; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.linked-note { margin: 4px 0 8px; }
.identities .row { margin-top: 6px; }
.small-wa { margin: 0; min-height: 44px; font-size: 14px; border-radius: 12px; }
.invite-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.invite-actions { display: flex; gap: 12px; align-items: center; }

/* ---------- cambio di destinazione durante la corsa ---------- */
.stop .change-dest { margin-left: auto; flex: none; }
.newdest-price {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 14px 0 6px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px;
}
.newdest-price > div { display: flex; flex-direction: column; gap: 2px; }
.newdest-price > div:last-child { text-align: right; }
.newdest-price strong { font-size: 22px; }
.newdest-price > div:last-child strong { color: var(--accent-text); }
.surcharge-hint { margin-top: 6px; }

/* ---------- assistenza: scheda della corsa ---------- */
.support-grid { margin-top: 12px; }
.track-map, .rule-map { height: 260px; border-radius: 12px; border: 1px solid var(--line); margin: 6px 0; }
.rule-map { height: 220px; }
.refund-form { margin-top: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.refund-form h4 { margin-top: 0; }
.chat-log li { white-space: pre-wrap; }
#note-form textarea { width: 100%; }
.r-zone-results { margin: 4px 0; }
.nowrap { white-space: nowrap; }
.warn-row td { color: var(--warn-text); font-weight: 600; }
.report-period { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* ---------- report: grafico delle corse per giorno ---------- */
/* Colori verificati per daltonismo e contrasto (validatore dataviz), uno per il chiaro e uno per lo scuro. */
.rep-chart { position: relative; --s1: #187a50; --s2: #2558b3; --s3: #c77700; }
@media (prefers-color-scheme: dark) { .rep-chart { --s1: #2e9e6b; --s2: #5a8be0; --s3: #b97c14; } }
.rep-chart svg { width: 100%; height: auto; display: block; }
.rep-chart .s1 { fill: var(--s1); background: var(--s1); }
.rep-chart .s2 { fill: var(--s2); background: var(--s2); }
.rep-chart .s3 { fill: var(--s3); background: var(--s3); }
.rep-chart .grid { stroke: var(--line); stroke-width: 1; }
.rep-chart text { fill: var(--muted); font-size: 11px; }
.rep-chart .hit { fill: transparent; }
.rep-chart .bar:hover .hit, .rep-chart .bar:focus .hit { fill: var(--accent-soft); }
.rep-chart .bar:focus { outline: none; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; margin-bottom: 6px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.chart-tip {
  position: absolute; width: 220px; padding: 8px 10px; font-size: 13px; line-height: 1.35;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
  pointer-events: none;
}
#note-form textarea {
  font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--text); resize: vertical; margin: 4px 0 8px;
}
/* Nota informativa (non un avviso): bordo verde invece che rosso. */
.note.info-note { border-left-color: var(--accent); }
