:root {
  --blu: #17407a;
  --blu-2: #245bb0;
  --blu-chiaro: #e8f0fb;
  --testo: #1b1f24;
  --testo-2: #4a5360;
  --bordo: #b9c2cf;
  --sfondo: #f3f5f8;
  --card: #ffffff;
  --rosso: #b3261e;
  --rosso-chiaro: #fdecea;
  --verde: #1e7a3c;
  --verde-chiaro: #e7f5ec;
  --giallo-chiaro: #fff6d6;
  --radius: 12px;
  --font: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--sfondo);
  color: var(--testo);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.5;
}
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }

/* Intestazione */
.top { background: var(--blu); color: #fff; padding: 20px 0 22px; }
.top .org { margin: 0; font-size: 14px; letter-spacing: .08em; text-transform: uppercase; opacity: .85; }
.top h1 { margin: 4px 0 2px; font-size: 26px; line-height: 1.2; }
.top .anno { margin: 0; opacity: .9; font-size: 16px; }

/* Avanzamento */
.progress { margin: 18px 0 10px; }
.progress p { margin: 0 0 6px; font-weight: 700; color: var(--blu); font-size: 16px; }
.progress .bar { height: 10px; background: #dde3eb; border-radius: 99px; overflow: hidden; }
.progress .bar span { display: block; height: 100%; width: 0; background: var(--blu-2); border-radius: 99px; transition: width .3s; }

/* Card */
.card { background: var(--card); border-radius: var(--radius); padding: 22px 18px; box-shadow: 0 1px 3px rgba(0,0,0,.08); margin-bottom: 16px; }
.card h2 { margin: 0 0 8px; font-size: 24px; color: var(--blu); line-height: 1.25; }
.card h3 { margin: 26px 0 4px; font-size: 20px; }
.lead { margin: 0 0 18px; color: var(--testo-2); }
.lead:empty { display: none; }
.tip { background: var(--blu-chiaro); border-radius: 10px; padding: 12px 16px; margin: 0 0 22px; }
.tip p { margin: 6px 0; }
.tip ul { margin: 6px 0; padding-left: 22px; }

fieldset { border: 0; padding: 0; margin: 0 0 22px; }
legend { font-weight: 700; font-size: 19px; padding: 0; margin-bottom: 10px; color: var(--blu); border-bottom: 2px solid var(--blu-chiaro); width: 100%; padding-bottom: 4px; }

/* Campi */
.field { margin-bottom: 18px; }
.field label, .field .label { display: block; font-weight: 700; margin-bottom: 4px; }
.field .label { margin-bottom: 8px; font-size: 19px; }
.hint { margin: 6px 0 0; font-size: 15px; color: var(--testo-2); }
.opz { font-weight: 400; color: var(--testo-2); font-size: 15px; }
body:not(.minore) .opz-cond { display: none; }
body:not(.minore) .solo-minore { display: none; }

input[type=text], input:not([type]), input[type=tel], input[type=email], select {
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  font: inherit;
  font-size: 18px;
  color: var(--testo);
  background: #fff;
  border: 2px solid var(--bordo);
  border-radius: 10px;
  appearance: none;
  -webkit-appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' stroke='%2317407a' stroke-width='2.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}
input:focus, select:focus { outline: none; border-color: var(--blu-2); box-shadow: 0 0 0 4px rgba(36,91,176,.2); }
.field.cf input { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; letter-spacing: .08em; }
input::placeholder { color: #8a93a0; }

.field.has-err input, .field.has-err select { border-color: var(--rosso); background: var(--rosso-chiaro); }
.field .err { margin: 6px 0 0; color: var(--rosso); font-weight: 700; font-size: 16px; }
.field .err:empty { display: none; }
.field .err:not(:empty)::before { content: "⚠ "; }
.field.has-err .choice span { border-color: var(--rosso); }

.cf-ok, .ac-ok { margin: 6px 0 0; color: var(--verde); font-weight: 700; font-size: 15px; }
p[data-cfmsg] { margin: 6px 0 0; font-size: 15px; font-weight: 700; color: var(--verde); }
p[data-cfmsg].cf-count { color: var(--testo-2); font-weight: 400; }
p[data-cfmsg]:empty { display: none; }
.cf-conferma { margin: -8px 0 18px; background: var(--giallo-chiaro); padding: 10px 14px; border-radius: 10px; }

.row { display: grid; gap: 0 14px; grid-template-columns: 1fr; }
@media (min-width: 620px) {
  .row { grid-template-columns: 1fr 1fr; }
  .row:has(.grow) { grid-template-columns: 1fr 140px 120px; }
  .row:has(.grow):not(:has(.small + .small)) { grid-template-columns: 1fr 160px; }
}

/* Scelte grandi (radio a scheda) */
.choices { display: grid; gap: 10px; }
@media (min-width: 620px) { .choices { grid-template-columns: 1fr 1fr; } }
.choices.small { grid-template-columns: 1fr 1fr; }
.choices.small.two { grid-template-columns: 1fr 1fr; }
.choice { position: relative; display: block; cursor: pointer; margin: 0 !important; font-weight: 400 !important; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span {
  display: flex; flex-direction: column; justify-content: center;
  min-height: 56px; padding: 12px 14px 12px 48px;
  border: 2px solid var(--bordo); border-radius: 10px; background: #fff;
  position: relative; line-height: 1.3;
}
.choice span::before {
  content: ""; position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--bordo); background: #fff;
}
.choice small { color: var(--testo-2); font-size: 15px; margin-top: 2px; }
.choice input:checked + span { border-color: var(--blu-2); background: var(--blu-chiaro); }
.choice input:checked + span::before { border-color: var(--blu-2); background: var(--blu-2); box-shadow: inset 0 0 0 4px #fff; }
.choice input:focus-visible + span { box-shadow: 0 0 0 4px rgba(36,91,176,.3); }

/* Checkbox */
.check { display: flex; gap: 12px; align-items: flex-start; font-weight: 400 !important; cursor: pointer; margin: 4px 0 16px; }
.check input { width: 26px; height: 26px; flex: 0 0 26px; margin: 1px 0 0; accent-color: var(--blu-2); }
.check.big { background: #f7f9fc; border: 2px solid var(--bordo); border-radius: 10px; padding: 14px; margin: 0; }
.field.has-err .check.big { border-color: var(--rosso); background: var(--rosso-chiaro); }
.check.big:has(input:checked) { border-color: var(--blu-2); background: var(--blu-chiaro); }

/* Autocompletamento */
.ac-wrap { position: relative; }
.ac-list {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px);
  margin: 0; padding: 4px; list-style: none; background: #fff;
  border: 2px solid var(--blu-2); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.15);
  max-height: 320px; overflow-y: auto;
}
.ac-list li { padding: 12px; border-radius: 8px; cursor: pointer; min-height: 48px; }
.ac-list li span { color: var(--testo-2); font-size: 15px; }
.ac-list li:hover, .ac-list li.sel { background: var(--blu-chiaro); }
.ac-list li.vuoto { color: var(--testo-2); cursor: default; }

/* Consensi */
.quota { background: var(--blu-chiaro); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; font-size: 19px; }
.consenso { border-top: 1px solid #e3e7ee; padding-top: 14px; }
.consenso p:first-child { margin: 0 0 10px; }
.informativa { margin: 18px 0 14px; border: 2px solid var(--bordo); border-radius: 10px; padding: 0 14px; background: #fafbfd; }
.informativa summary { cursor: pointer; font-weight: 700; padding: 14px 0; color: var(--blu); }
.informativa p { font-size: 15px; color: var(--testo-2); margin: 0 0 10px; }

/* Riepilogo */
.riep { border: 2px solid #e3e7ee; border-radius: 10px; margin-bottom: 14px; overflow: hidden; }
.riep header { display: flex; justify-content: space-between; align-items: center; background: #f7f9fc; padding: 10px 14px; }
.riep h3 { margin: 0; font-size: 18px; }
.riep dl { margin: 0; padding: 6px 14px 10px; }
.riep .r { display: grid; grid-template-columns: 1fr; padding: 6px 0; border-bottom: 1px solid #f0f2f5; }
.riep .r:last-child { border-bottom: 0; }
@media (min-width: 620px) { .riep .r { grid-template-columns: 200px 1fr; gap: 12px; } }
.riep dt { color: var(--testo-2); font-size: 15px; }
.riep dd { margin: 0; font-weight: 700; word-break: break-word; }
.link { background: none; border: 0; color: var(--blu-2); font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; padding: 8px; min-height: 44px; }

/* Pulsanti */
.nav { display: flex; gap: 12px; justify-content: space-between; margin: 8px 0 12px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 12px 26px; border-radius: 10px; border: 2px solid var(--blu-2);
  background: var(--blu-2); color: #fff; font: inherit; font-weight: 700; font-size: 19px;
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--blu); border-color: var(--blu); }
.btn.ghost { background: #fff; color: var(--blu-2); }
.btn.ghost:hover { background: var(--blu-chiaro); }
.btn.invia { background: var(--verde); border-color: var(--verde); }
.btn[disabled] { opacity: .6; cursor: wait; }
.nav #btn-avanti { margin-left: auto; flex: 1 1 auto; max-width: 340px; }
.btn[hidden] { display: none; }

.err-summary { background: var(--rosso-chiaro); color: var(--rosso); font-weight: 700; padding: 12px 16px; border-radius: 10px; margin: 0 0 20px; }
.alert { padding: 14px 16px; border-radius: 10px; margin: 14px 0; }
.alert.err { background: var(--rosso-chiaro); color: var(--rosso); font-weight: 700; }
.alert.ok { background: var(--verde-chiaro); color: var(--verde); }

.banner { background: var(--giallo-chiaro); border: 2px solid #e8cf73; border-radius: var(--radius); padding: 14px 16px; margin: 18px 0 0; }
.banner.ok { background: var(--verde-chiaro); border-color: #9fd3b0; }
.banner p { margin: 0 0 10px; }
.banner.ok p { margin: 0; }
.banner .btn { min-height: 48px; font-size: 17px; padding: 8px 18px; }

.foot { color: var(--testo-2); font-size: 14px; padding-top: 10px; padding-bottom: 30px; }

/* Pagina finale */
.grazie h2 { color: var(--verde); }
.passi { counter-reset: p; list-style: none; padding: 0; margin: 18px 0; }
.passi > li { counter-increment: p; position: relative; padding: 4px 0 14px 50px; }
.passi > li::before {
  content: counter(p); position: absolute; left: 0; top: 0;
  width: 36px; height: 36px; border-radius: 50%; background: var(--blu-2); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.azioni { display: flex; flex-direction: column; gap: 12px; margin: 22px 0 6px; }
@media (min-width: 620px) { .azioni { flex-direction: row; flex-wrap: wrap; } }

[hidden] { display: none !important; }
.field.has-err p[data-cfmsg] { display: none; }
fieldset > .hint, h3 + .hint { margin: 0 0 12px; }
textarea { width: 100%; padding: 10px 14px; font: inherit; font-size: 18px; color: var(--testo); background: #fff; border: 2px solid var(--bordo); border-radius: 10px; resize: vertical; }
textarea:focus { outline: none; border-color: var(--blu-2); box-shadow: 0 0 0 4px rgba(36,91,176,.2); }
.doclink { display: inline-flex; align-items: center; gap: 6px; min-height: 48px; padding: 10px 16px; border: 2px solid var(--blu-2); border-radius: 10px; color: var(--blu-2); font-weight: 700; text-decoration: none; background: #fff; }
.doclink:hover { background: var(--blu-chiaro); }
.admin-link { display: inline-block; padding: 10px 14px; margin-top: 4px; border: 1px solid var(--bordo); border-radius: 8px; color: var(--testo-2); text-decoration: none; font-size: 15px; background: #fff; }
.admin-link:hover { color: var(--blu); border-color: var(--blu-2); }
.salute-note, .un-genitore { margin: -4px 0 18px; }
.firme { margin: 8px 0 0; padding-left: 20px; font-size: 16px; } .firme li { padding: 2px 0; }

/* Etichetta colorata che dice di chi sono i dati del passo */
.chi-banner { display: flex; gap: 14px; align-items: center; border-radius: 12px; padding: 14px 16px; margin: -4px 0 18px; font-size: 19px; line-height: 1.35; border: 2px solid; }
.chi-banner .ico { font-size: 34px; line-height: 1; flex: 0 0 auto; }
.chi-banner strong { letter-spacing: .01em; }
.chi-banner small { display: block; font-size: 15px; margin-top: 3px; opacity: .85; }
.chi-banner.figlio { background: #fff3dc; border-color: #f0b44c; color: #6b4200; }
.chi-banner.genitore { background: #e6f4ea; border-color: #7cc393; color: #155c2c; }
.chi-banner.altro { background: #eef0fb; border-color: #9aa5e6; color: #2c3a8c; }
.di-chi { color: #a35f00; }

/* Tabella di marcia nella prima schermata */
.roadmap { background: #f7f9fc; border: 2px dashed var(--bordo); border-radius: 12px; padding: 14px 18px; margin-top: 6px; }
.roadmap p { margin: 0 0 8px; }
.roadmap ol { margin: 0; padding-left: 24px; }
.roadmap li { padding: 3px 0; }

/* Codice iscrizione */
.codice-grande { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 38px; font-weight: 700; letter-spacing: .12em; text-align: center; color: var(--blu); background: var(--blu-chiaro); border: 2px dashed var(--blu-2); border-radius: 12px; padding: 14px 8px; margin: 14px 0; user-select: all; }
.btn.whatsapp { background: #1f8f4e; border-color: #1f8f4e; }
.btn.whatsapp:hover { background: #17733e; border-color: #17733e; }
.codice-input { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; letter-spacing: .12em; font-size: 22px !important; text-transform: uppercase; }
.link-recupera { display: inline-block; margin-top: 10px; font-weight: 700; color: var(--blu-2); }
