:root {
  --bg: #f6f1ea;
  --surface: #ffffff;
  --ink: #1f2a2e;
  --muted: #5d6b70;
  --line: #e3dbd0;
  --brand: #c02835;
  --brand-ink: #ffffff;
  --brand-soft: #f9e2e4;
  --accent: #1f6f6b;
  --danger: #b42318;
  --ok: #1f7a4d;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(31, 42, 46, .08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141a1c; --surface: #1d2528; --ink: #eef1f0; --muted: #9fb0b3;
    --line: #2f3a3e; --brand: #e8606b; --brand-soft: #3d1f24; --accent: #5fb7ae;
    --danger: #f97066; --ok: #4ade80; --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 Inter, system-ui, sans-serif;
}
a { color: var(--accent); }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px clamp(16px, 4vw, 48px);
}
.logo { display: inline-flex; align-items: center; line-height: 0; text-decoration: none; }
.logo img { height: 36px; width: auto; display: block; }
@media (max-width: 560px) { .logo img { height: 28px; } }
.topbar-note { color: var(--muted); font-size: .9rem; }

.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: clamp(24px, 4vw, 64px);
  max-width: 1180px; margin: 0 auto; padding: 24px clamp(16px, 4vw, 48px) 64px;
  align-items: start;
}
.intro { position: sticky; top: 24px; padding-top: 24px; }
.eyebrow { color: var(--brand); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; font-size: .8rem; margin: 0 0 12px; }
h1 { font: 700 clamp(2rem, 4vw, 3rem)/1.1 Fraunces, serif; margin: 0 0 16px; text-wrap: balance; }
.lead { color: var(--muted); font-size: 1.05rem; max-width: 42ch; }
.benefits { list-style: none; padding: 0; margin: 32px 0 0; display: grid; gap: 14px; }
.benefits li { display: flex; gap: 14px; align-items: center; }
.benefits span { font: 600 .8rem Inter; color: var(--accent); border: 1px solid var(--line); border-radius: 999px; padding: 4px 9px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow); padding: clamp(20px, 3vw, 36px);
}

.stepper { list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 0; margin: 0 0 28px; counter-reset: s; }
.stepper li {
  counter-increment: s; font-size: .8rem; color: var(--muted);
  border-top: 3px solid var(--line); padding-top: 8px;
}
.stepper li::before { content: counter(s) ". "; font-weight: 600; }
.stepper li.active { color: var(--ink); border-color: var(--brand); font-weight: 600; }
.stepper li.done { border-color: var(--accent); color: var(--accent); }

fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { font: 600 1.5rem Fraunces, serif; margin-bottom: 18px; padding: 0; }
.step { display: none; }
.step.active { display: block; animation: in .25s ease; }
@keyframes in { from { opacity: 0; transform: translateY(6px); } }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.span-2 { grid-column: span 2; }
.field { margin-bottom: 18px; position: relative; }
label, .label { display: block; font-weight: 500; font-size: .9rem; margin-bottom: 6px; }
.opt { color: var(--muted); font-weight: 400; }
.hint { color: var(--muted); font-size: .85rem; margin: 0 0 16px; }
small.hint { display: block; margin: 6px 0 0; }

input, select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus, .tags:focus-within {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.upper { text-transform: uppercase; }
textarea { resize: vertical; }
.counter { position: absolute; right: 4px; bottom: -20px; color: var(--muted); font-size: .75rem; }

.invalid input, .invalid select, .invalid textarea, .invalid .tags, .invalid .chips { border-color: var(--danger); }
.err { color: var(--danger); font-size: .8rem; margin-top: 4px; min-height: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; border: 1px solid transparent; border-radius: 10px; }
.chip {
  font: 500 .85rem Inter; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 7px 14px; cursor: pointer; transition: all .15s;
}
.chip:hover { border-color: var(--brand); }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

.tags {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  border: 1px solid var(--line); border-radius: 10px; padding: 6px;
}
.tags input { flex: 1; min-width: 160px; border: 0; padding: 6px; box-shadow: none !important; }
.tag { background: var(--brand-soft); color: var(--ink); border-radius: 999px; padding: 4px 6px 4px 12px; font-size: .85rem; display: inline-flex; align-items: center; gap: 4px; }
.tag button { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 1rem; line-height: 1; padding: 0 4px; }

.pw { position: relative; }
.pw input { padding-right: 80px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--accent); font: 500 .85rem Inter; cursor: pointer; padding: 6px 8px; }
.meter { height: 5px; background: var(--line); border-radius: 99px; margin-top: 8px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--danger); transition: width .2s, background .2s; }

.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 12px 0 0; }
.check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--brand); flex: none; }

.riepilogo { background: var(--bg); border-radius: var(--radius); padding: 16px 18px; margin: 8px 0 12px; font-size: .9rem; }
.riepilogo h3 { margin: 0 0 8px; font: 600 1rem Fraunces, serif; }
.riepilogo dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; }
.riepilogo dt { color: var(--muted); }
.riepilogo dd { margin: 0; overflow-wrap: anywhere; }

.form-error { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); border-radius: 10px; padding: 10px 14px; margin-top: 16px; font-size: .9rem; }

.actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 28px; }
.btn {
  font: 600 1rem Inter; border: 0; border-radius: 999px; padding: 12px 26px; cursor: pointer;
  background: var(--brand); color: var(--brand-ink); transition: transform .1s, opacity .15s;
}
.btn:hover { opacity: .92; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); margin-right: auto; }

.success { text-align: center; padding: 32px 8px; }
.success-icon { width: 64px; height: 64px; border-radius: 50%; background: var(--ok); color: #fff; font-size: 2rem; display: grid; place-items: center; margin: 0 auto 16px; }
.success h2 { font: 700 1.8rem Fraunces, serif; margin: 0 0 8px; }
.success p { color: var(--muted); max-width: 46ch; margin: 0 auto 18px; }
.badge { display: inline-block; background: var(--brand-soft); color: var(--brand); border-radius: 999px; padding: 6px 14px; font-weight: 600; font-size: .85rem; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .intro { position: static; padding-top: 0; }
  .benefits { display: none; }
}
@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .stepper li { font-size: 0; }
  .stepper li::before { font-size: .8rem; }
  .stepper li.active { font-size: .75rem; }
}

/* ---------- Accesso ---------- */
a.topbar-note { text-decoration: none; }
a.btn { display: inline-block; text-decoration: none; }
.btn-block { width: 100%; margin-top: 8px; }
.login-wrap { display: grid; place-items: center; padding: 40px 16px 80px; }
.login-card { width: 100%; max-width: 420px; }
.login-title { font-size: 2rem; margin-bottom: 8px; }

/* ---------- App installabile (PWA) ---------- */
html { -webkit-tap-highlight-color: transparent; }
body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.topbar { padding-top: max(18px, env(safe-area-inset-top)); }
.barra-installa {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-h, 0px) + 12px + env(safe-area-inset-bottom));
  z-index: 20; max-width: 520px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .18); padding: 10px 10px 10px 12px; animation: in .25s ease;
}
.barra-installa img { border-radius: 10px; flex: none; }
.bi-testo { flex: 1; min-width: 0; font-size: .82rem; line-height: 1.3; }
.bi-testo b { display: block; font-size: .92rem; }
.bi-testo span { color: var(--muted); }
.bi-chiudi { border: 0; background: none; color: var(--muted); font-size: 1.4rem; line-height: 1; padding: 4px 8px; cursor: pointer; }
.barra-installa .btn-sm { padding: 8px 14px; font-size: .85rem; }

/* ---------- Pagina iniziale (accesso unico) ---------- */
.home-wrap {
  max-width: 1080px; margin: 0 auto; padding: 24px clamp(16px, 4vw, 48px) 64px;
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: clamp(24px, 5vw, 72px); align-items: center;
}
.home-icona { border-radius: 16px; box-shadow: 0 8px 24px rgba(192, 40, 53, .25); }
.home-intro h1 { margin-top: 20px; }
.ruoli { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; }
.ruoli li { border-left: 3px solid var(--brand); padding: 4px 0 4px 14px; }
.ruoli b { display: block; }
.ruoli span { color: var(--muted); font-size: .92rem; }
.home .login-card { max-width: none; }
.separatore { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .82rem; margin: 18px 0; }
.separatore::before, .separatore::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.btn.ghost.btn-block { margin-right: 0; text-align: center; }
.banner-primo { background: var(--brand-soft); border-radius: 12px; padding: 10px 14px; font-size: .9rem; margin-bottom: 16px; }
@media (max-width: 760px) {
  .home-wrap { grid-template-columns: 1fr; padding-top: 0; }
  .home-intro h1 { font-size: 1.9rem; }
  .ruoli { display: none; }
}

/* ---------- Intestazione comune: ruolo dell'utente ---------- */
.ruolo-badge {
  font: 600 .7rem Inter; text-transform: uppercase; letter-spacing: .06em;
  background: var(--ink); color: var(--surface); border-radius: 6px; padding: 4px 8px;
}
body[data-ruolo="guida"] .ruolo-badge { background: var(--accent); }
.home .login-title { margin-top: 0; font: 600 1.7rem Fraunces, serif; }

/* ---------- Modalità prova ---------- */

/* ---------- Iscrizione: residenza ---------- */
.sottotitolo { font: 600 1.1rem Fraunces, serif; margin: 10px 0 4px; }
.grid-residenza { grid-template-columns: 120px 1fr 120px; }
.grid-residenza .span-2 { grid-column: 1 / -1; }
@media (max-width: 560px) { .grid-residenza { grid-template-columns: 1fr 1fr; } .grid-residenza .field:nth-child(3) { grid-column: 1 / -1; } }

/* ---------- Iscrizione: altre lingue ---------- */
.lingua-altra { display: flex; gap: 8px; margin-top: 10px; }
.lingua-altra input { flex: 1; min-width: 0; }
.lingua-altra .btn.ghost { margin-right: 0; flex: none; }
#lingua-msg.err { color: var(--danger); }
/* Campo password con pulsante "Mostra" */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 92px; }
.pw-mostra { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--accent); font: 600 .85rem Inter, sans-serif; padding: 8px 10px; cursor: pointer; border-radius: 8px; }
.pw-mostra:hover { background: var(--bg); }

/* Voto medio dei clienti alla guida (1-10): stesso aspetto in tutto il sito */
.voto { display: inline-flex; align-items: baseline; gap: 1px; font: 500 .78rem Inter, sans-serif; color: #7a5200; background: #fdf1d6;
  border: 1px solid #f0d28f; border-radius: 99px; padding: 1px 8px; white-space: nowrap; vertical-align: middle; }
.voto b { font-size: .9rem; font-weight: 700; color: #6b4600; }
.voto::before { content: '★'; color: #e0a106; margin-right: 3px; font-size: .8rem; }
.voto small { color: #8f6b2a; font-size: .74rem; }
.voto.voto-nuovo { color: var(--muted); background: transparent; border-color: var(--line); }
.voto.voto-nuovo::before { color: var(--muted); }
@media (prefers-color-scheme: dark) {
  .voto { background: #3a2e12; border-color: #6b5420; color: #f2d48a; }
  .voto b { color: #ffe3a1; } .voto small { color: #d9bb78; }
}
