:root {
  --brand: #1b6b3a;
  --brand-dark: #14522b;
  --accent: #f5a623;
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #6b7280;
  --border: #e2e6ea;
  --danger: #c0392b;
  --ok: #2e7d32;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 0.9rem 1.5rem; background: var(--brand); color: #fff; }
.brand-wrap { display: inline-flex; align-items: center; gap: .55rem; }
.brand-logo { height: 2.3rem; width: auto; display: block; border-radius: 4px; }
.topbar .brand { color: #fff; font-size: 1.25rem; font-weight: 700; }
.topbar nav a { color: #fff; margin-left: 1rem; opacity: 0.95; }
.topbar nav a:hover { opacity: 1; }
.topbar .linkbtn { background: none; border: none; color: #fff; cursor: pointer; font: inherit; margin-left: 1rem; padding: 0; }

.container { max-width: 1080px; margin: 0 auto; padding: 1.5rem; }
.hero { padding: 1.5rem 0; }
.hero h1 { margin: 0 0 .5rem; color: var(--brand-dark); }
.muted { color: var(--muted); font-size: .9rem; }

.btn { display: inline-block; background: var(--brand); color: #fff; border: none; padding: .55rem 1.1rem; border-radius: 6px; cursor: pointer; font-size: 1rem; text-decoration: none; }
.btn:hover { background: var(--brand-dark); text-decoration: none; color: #fff; }
.btn-secondary { background: #6b7280; }
.btn-danger { background: var(--danger); }
.btn-small { padding: .3rem .6rem; font-size: .85rem; }

.flash { padding: .8rem 1rem; border-radius: 6px; margin: 1rem 0; }
.flash-successo { background: #e6f4ea; color: var(--ok); border: 1px solid #b7dfbe; }
.flash-errore { background: #fdecea; color: var(--danger); border: 1px solid #f5c6cb; }
.flash ul { margin: .3rem 0 0 1.2rem; }

.form { display: grid; gap: 1rem; }
.form fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 1rem; background: var(--card); }
.form legend { font-weight: 600; color: var(--brand-dark); }
.form label { display: block; margin: .5rem 0; font-size: .95rem; }
.form input, .form select, .form textarea { width: 100%; padding: .5rem; border: 1px solid var(--border); border-radius: 4px; font: inherit; margin-top: .25rem; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.hint { font-size: .8rem; color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.grid.two { grid-template-columns: 1fr 1fr; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; }
.card h3 { margin-top: 0; }
.kv { list-style: none; padding: 0; margin: 0; }
.kv li { padding: .25rem 0; border-bottom: 1px dashed var(--border); }
.kv li:last-child { border-bottom: none; }

.table { width: 100%; border-collapse: collapse; background: var(--card); }
.table th, .table td { padding: .6rem .75rem; border-bottom: 1px solid var(--border); text-align: left; }
.table th { background: #f0f2f5; font-size: .85rem; text-transform: uppercase; color: var(--muted); }
.badge { display: inline-block; padding: .2rem .5rem; border-radius: 4px; font-size: .75rem; font-weight: 600; }
.badge-in_verifica { background: #fff3cd; color: #856404; }
.badge-attiva { background: #d4edda; color: #155724; }
.badge-rifiutata { background: #f8d7da; color: #721c24; }
.badge-sospesa { background: #e2e3e5; color: #383d41; }
.badge-in_deposito { background: #d1ecf1; color: #0c5460; }
.badge-rilasciata { background: #e2e3e5; color: #383d41; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .75rem; margin: 1rem 0; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: .75rem; text-align: center; }
.stat strong { display: block; font-size: 1.6rem; color: var(--brand); }
.stat span { font-size: .8rem; color: var(--muted); }

.map { height: 420px; border-radius: 8px; border: 1px solid var(--border); margin: 1rem 0; }
.map.small { height: 260px; }

/* Pagina di registrazione: scelta tipo proprietario */
.scelta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.scelta {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .6rem;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  cursor: pointer;
  color: inherit;
  text-decoration: none;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.scelta:hover { border-color: var(--brand); transform: translateY(-2px); text-decoration: none; }
.scelta:focus-visible { box-shadow: 0 0 0 3px rgba(27, 107, 58, .25); outline: none; }
.scelta-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: #e6f4ea;
  font-size: 1.9rem;
  line-height: 1;
}
.scelta-icone {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.scelta-num {
  position: absolute;
  top: 1.25rem;
  right: 1.5rem;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: .9rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.scelta-testo strong { display: block; font-size: 1.15rem; color: var(--brand-dark); margin-bottom: .35rem; }
.scelta-desc { display: block; color: var(--muted); font-size: .92rem; line-height: 1.5; }
.scelta-cta {
  margin-top: .25rem;
  padding: .3rem .75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .8rem;
  color: var(--muted);
  background: #f8f9fa;
}
.scelta.attiva { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(27, 107, 58, .2); transform: none; }
.scelta.attiva .scelta-icon { background: var(--brand); }
.scelta.attiva .scelta-cta { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.scelta.attiva .scelta-cta::after { content: " ✓"; }
.scelta-attesa { margin: 1.25rem 0 0; min-height: 1.2em; }
.scelta-attesa.scelto { font-weight: 600; color: var(--brand-dark); }

/* Riepilogo tipo di proprietario nel form account */.sintesi-owner {
  display: flex;
  align-items: center;
  gap: .9rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .9rem 1rem;
  margin-bottom: 1.25rem;
}
.sintesi-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: #e6f4ea;
  font-size: 1.5rem;
  flex: none;
}
.sintesi-testo { display: flex; flex-direction: column; gap: .15rem; flex: 1; }
.sintesi-testo strong { color: var(--brand-dark); }

/* Schermata di login (primo ingresso) */
.accesso { max-width: 430px; margin: 0 auto; text-align: center; }
.accesso-logo { display: block; width: 120px; height: auto; margin: 1.5rem auto 1rem; border-radius: 12px; }
.accesso-titolo { color: var(--brand-dark); margin: 0 0 1.25rem; }
.accesso .flash { text-align: left; }
.accesso-form { text-align: left; }
.accesso-form .btn { width: 100%; text-align: center; }
.accesso-messaggio {
  display: block;
  margin-top: 1.5rem;
  padding: .9rem 1rem;
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.55;
}
.accesso-messaggio strong { color: var(--brand-dark); }
.accesso-messaggio:hover { border-color: var(--brand); border-style: solid; color: var(--brand-dark); text-decoration: none; }

@media (max-width: 700px) {
  .scelta-grid { grid-template-columns: 1fr; }
}

.filters { display: flex; gap: .5rem; margin: 1rem 0; }
.filters a { padding: .35rem .7rem; border-radius: 4px; background: #e9ecef; color: var(--text); }
.filters a.active { background: var(--brand); color: #fff; }

.contract { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 1.5rem; max-width: 800px; }
.contract h2 { color: var(--brand-dark); border-bottom: 1px solid var(--border); padding-bottom: .3rem; }
.ok { color: var(--ok); font-weight: 600; }
code { background: #f0f2f5; padding: .1rem .35rem; border-radius: 3px; }
.checkbox { display: flex; align-items: center; gap: .5rem; }
.checkbox input { width: auto; }

@media print {
  .topbar, footer, .no-print, .flash { display: none !important; }
  body { background: #fff; }
  .contract { border: none; box-shadow: none; }
}

.footer { text-align: center; color: var(--muted); padding: 1.5rem; font-size: .85rem; }

/* ---------- Aiuto: pulsante in nav (sempre visibile) + finestra istruzioni ---------- */
.topbar nav { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.nav-aiuto {
  margin-left: 1rem;
  width: 2.05rem; height: 2.05rem; padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .6);
  background: rgba(255, 255, 255, .16);
  color: #fff; font-size: 1rem; font-weight: 700; line-height: 1;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.nav-aiuto:hover, .nav-aiuto:focus { background: #fff; color: var(--brand); outline: none; }

.aiuto-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(17, 24, 39, .55);
  padding: 4vh 1rem;
  overflow-y: auto;
  display: flex; align-items: flex-start; justify-content: center;
}
.aiuto-overlay[hidden] { display: none; }
body.aiuto-aperto { overflow: hidden; }

.aiuto-modal {
  position: relative;
  width: 100%; max-width: 760px;
  background: var(--card);
  border-radius: 12px;
  padding: 1.3rem 1.5rem 1.5rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.aiuto-modal h2 { margin: 0 0 .4rem; color: var(--brand-dark); font-size: 1.3rem; }

.aiuto-chiudi {
  position: absolute; top: .7rem; right: .8rem;
  width: 2rem; height: 2rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #fff; color: var(--muted);
  cursor: pointer; font-size: 1rem; line-height: 1;
}
.aiuto-chiudi:hover { background: var(--brand); border-color: var(--brand); color: #fff; }

.aiuto-lista { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: .6rem; }
.aiuto-lista li {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .65rem .85rem;
  background: #fff;
  font-size: .95rem; line-height: 1.55;
}
.aiuto-lista li .tit { display: block; font-weight: 700; color: var(--brand-dark); margin-bottom: .1rem; }
.aiuto-lista li .perc {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .76rem; color: var(--muted);
  background: #f0f2f5; border-radius: 4px; padding: .05rem .4rem; margin-bottom: .3rem;
}
.aiuto-lista li.attuale { border-color: var(--brand); background: #eef7f1; box-shadow: 0 0 0 2px rgba(27, 107, 58, .18); }
.aiuto-lista li.attuale .tit::after { content: "  ← sei qui"; color: var(--brand); font-weight: 600; }
.aiuto-nota {
  margin: 1rem 0 0; padding-top: .8rem;
  border-top: 1px dashed var(--border);
  font-size: .9rem; color: var(--muted);
}

/* ---------- Prenotazioni: badge di stato, scelta mezzo, flusso e token ---------- */
.badge-richiesta { background: #fff3cd; color: #856404; }
.badge-approvata { background: #cce5ff; color: #004085; }
.badge-arrivo { background: #e8d9ff; color: #5b2d8e; }
.badge-parcheggiata { background: #d4edda; color: #155724; }
.badge-rilascio { background: #ffe0b2; color: #8a4b00; }
.badge-annullata { background: #fde2e2; color: #922b21; }

.scelta-mezzo {
  display: flex; align-items: center; gap: .6rem;
  border: 1px solid var(--border); border-radius: 6px;
  padding: .6rem .8rem; margin: .4rem 0; cursor: pointer; background: #fff;
}
.scelta-mezzo input { width: auto; margin: 0; }
.scelta-mezzo:has(input:checked) {
  border-color: var(--brand); background: #eef7f1;
  box-shadow: 0 0 0 2px rgba(27, 107, 58, .15);
}

.flusso { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; margin: .4rem 0 0; padding: 0; }
.flusso li {
  padding: .35rem .75rem; border-radius: 999px;
  background: #f0f2f5; border: 1px solid var(--border);
  color: var(--muted); font-size: .85rem;
}
.flusso li.fatto { background: #d4edda; border-color: #a9d5b5; color: #155724; }
.flusso li.attuale { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.flusso li.stop { background: var(--danger); border-color: var(--danger); }

.token-card .token {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.7rem; font-weight: 700; letter-spacing: .25rem;
  color: var(--brand-dark); background: #eef7f1;
  border: 1px dashed var(--brand); border-radius: 8px;
  padding: .5rem .8rem; text-align: center; margin: .4rem 0;
}

.azioni-card .azione-form { border-top: 1px dashed var(--border); padding-top: .7rem; }
.azioni-card .azione-form:first-of-type { border-top: none; padding-top: 0; }

@media print {
  .aiuto-overlay { display: none !important; }
}