/* Portale associazioni - stile base. I colori del marchio arrivano da brand/theme.css */
:root {
  --brand: #1f4e8c;
  --brand-2: #c8102e;
  --brand-dark: #173b69;
  --brand-soft: #e9eef6;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1c1f24;
  --muted: #5b6270;
  --line: #d9dde3;
  --focus: #ffbf47;
  --ok: #1b7a3a;
  --ok-bg: #e5f4ea;
  --warn: #8a5a00;
  --warn-bg: #fff4d6;
  --err: #b3261e;
  --err-bg: #fbe9e7;
  --info: #0b5394;
  --info-bg: #e6f0fa;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  font-size: 16px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--text); background: var(--bg); line-height: 1.5; }
a { color: var(--brand); }
a:hover { color: var(--brand-dark); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1 { font-size: 1.6rem; margin: 0 0 .5rem; line-height: 1.25; }
h2 { font-size: 1.2rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1.2rem 0 .5rem; }
p { margin: 0 0 .75rem; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .92em; background: #f0f2f5; padding: .05em .35em; border-radius: 4px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.25rem 0; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 0; background: var(--text); color: #fff; padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: 1rem; top: .5rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small, small { font-size: .85rem; }
.pre { white-space: pre-wrap; }
.upper { text-transform: uppercase; }
.mt { margin-top: .75rem; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.icon { width: 1.15em; height: 1.15em; vertical-align: -0.2em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ---------- Layout area riservata ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem; background: var(--brand); color: #fff; padding: .5rem 1rem; min-height: 56px; }
.topbar a { color: #fff; }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; text-decoration: none; font-size: 1.05rem; }
.brand img { border-radius: 6px; background: #fff; object-fit: contain; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.user-link { display: flex; align-items: center; gap: .5rem; text-decoration: none; }
.user-link small { display: block; opacity: .85; font-size: .75rem; }
.menu-toggle { display: none; background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.4); border-radius: 8px; padding: .35rem .5rem; font-size: 1.2rem; }
.shell { display: flex; min-height: calc(100vh - 56px); }
.sidebar { width: 240px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--line); padding: 1rem .5rem; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar a { display: flex; gap: .65rem; align-items: center; padding: .6rem .8rem; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 500; }
.sidebar a:hover { background: var(--brand-soft); }
.sidebar a.active { background: var(--brand); color: #fff; }
.content { flex: 1; min-width: 0; padding: 1.5rem clamp(1rem, 3vw, 2.5rem); max-width: 1400px; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1rem; }
.crumbs { margin: 0; font-size: .9rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

@media (max-width: 900px) {
  .menu-toggle { display: inline-flex; }
  .sidebar { position: fixed; top: 56px; bottom: 0; left: 0; z-index: 15; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); overflow-y: auto; }
  .sidebar.open { transform: none; }
  .user-link span { display: none; }
}

/* ---------- Pubblico ---------- */
.public-header { background: var(--brand); color: #fff; padding: .9rem 0; }
.wrap { max-width: 960px; margin: 0 auto; padding: 0 1rem; }
.public-main { padding-top: 1.5rem; padding-bottom: 2rem; }
.public-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; padding: 1.25rem 0; background: var(--surface); }
.public-footer p { margin: .2rem 0; }

/* ---------- Componenti ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.card.narrow { max-width: 480px; margin: 1.5rem auto; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.tabs { display: flex; gap: .5rem; flex-wrap: wrap; }
/* Stacco fra un blocco di dati e il titolo che apre la sezione dopo */
.card .dl + h2, .card .dl + h3, .card table + h3, .card ul + h3 { margin-top: 1.5rem; }
.danger-zone { border-color: #f1c0bb; }
.grid-2, .grid-3 { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.span-2 { grid-column: span 2; }
/* La scelta del luogo ha tre elenchi affiancati: dentro una griglia prende tutta la riga,
   altrimenti i nomi dei comuni restano tagliati. */
.grid-2 > .luogo, .grid-3 > .luogo { grid-column: 1 / -1; }
@media (max-width: 600px) { .span-2 { grid-column: auto; } }
.alert { border-radius: 8px; padding: .75rem 1rem; margin-bottom: 1rem; border-left: 5px solid; }
.alert ul { margin: .25rem 0 0 1.2rem; padding: 0; }
.alert-success { background: var(--ok-bg); border-color: var(--ok); }
.alert-error { background: var(--err-bg); border-color: var(--err); }
.alert-info { background: var(--info-bg); border-color: var(--info); }
.alert-warning { background: var(--warn-bg); border-color: var(--warn); }
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.badge-verde { background: var(--ok-bg); color: var(--ok); border-color: #b7dfc3; }
.badge-giallo { background: var(--warn-bg); color: var(--warn); border-color: #f0dc9d; }
.badge-arancio { background: #ffe8d2; color: #8a3d00; border-color: #f5c79d; }
.badge-rosso { background: var(--err-bg); color: var(--err); border-color: #f1c0bb; }
.badge-grigio { background: #eceef1; color: #3d434d; border-color: #d4d8de; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 600; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: .55rem 1rem; cursor: pointer; text-decoration: none; min-height: 42px; }
.btn:hover { background: #f0f2f5; color: var(--text); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); color: #fff; }
.btn-danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn-danger:hover { background: #8e1d17; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.topbar .btn-ghost { color: #fff; }
.topbar .btn-ghost:hover { background: rgba(255,255,255,.15); }
.btn-sm { min-height: 34px; padding: .3rem .7rem; font-size: .9rem; }
.btn-lg { min-height: 50px; padding: .75rem 1.5rem; font-size: 1.05rem; }
.btn-block { width: 100%; }

/* ---------- Moduli ---------- */
.form fieldset { border: 0; padding: 0; margin: 0 0 1.25rem; }
.form fieldset.card { padding: 1.25rem; }
legend { font-weight: 700; font-size: 1.1rem; margin-bottom: .75rem; padding: 0; }
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .75rem; }
.field.grow { flex: 1 1 280px; }
label { font-weight: 600; font-size: .92rem; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=tel], input[type=date], input[type=number], input:not([type]), select, textarea {
  font: inherit; width: 100%; padding: .55rem .7rem; border: 1px solid #b9c0ca; border-radius: 8px; background: #fff; color: var(--text); min-height: 44px;
}
input[type=color] { width: 100%; min-height: 44px; border: 1px solid #b9c0ca; border-radius: 8px; background: #fff; }
textarea { min-height: 80px; resize: vertical; }
[aria-invalid="true"] { border-color: var(--err) !important; box-shadow: 0 0 0 1px var(--err); }
.field-error { color: var(--err); font-size: .88rem; margin: 0; font-weight: 600; }
.hint { color: var(--muted); font-size: .85rem; margin: 0; }
.req { color: var(--err); }
.checks { display: flex; flex-direction: column; gap: .45rem; margin: .5rem 0 1rem; }
/* Il testo dell'etichetta scorre come una frase, così i link ("leggi l'informativa")
   restano dentro il discorso invece di finire in una colonna a parte.
   Rientro sporgente: le righe successive si allineano sotto il testo, non sotto la casella. */
.checks label { font-weight: 400; display: block; padding-left: 1.6rem; text-indent: -1.6rem; }
.checks input { width: 1.1rem; height: 1.1rem; margin-right: .5rem; vertical-align: -.15rem; }
.field.check { justify-content: flex-end; }
.field.check label { font-weight: 400; display: flex; gap: .5rem; align-items: center; }
.form-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1rem; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .5rem; margin-bottom: .75rem; }
.inline-form input, .inline-form select { width: auto; min-width: 180px; }
.inline-form .field { margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.filters .field { margin: 0; min-width: 150px; }
.field.buttons { flex-direction: row; gap: .5rem; align-items: flex-end; }
details.subform { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .75rem; }
details > summary { cursor: pointer; font-weight: 600; color: var(--brand); padding: .25rem 0; }
details[open] > summary { margin-bottom: .75rem; }
.choices { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 1rem; }
.choice { display: flex; gap: .6rem; border: 2px solid var(--line); border-radius: var(--radius); padding: .8rem; cursor: pointer; font-weight: 400; background: #fff; }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.choice input { margin-top: .25rem; width: 1.1rem; height: 1.1rem; }
.choice-body { display: flex; flex-direction: column; gap: .15rem; }
.price { font-size: 1.15rem; font-weight: 700; color: var(--brand); }

/* Autocompletamento comuni */
.comune-field { position: relative; }
.comune-list { position: absolute; top: 100%; left: 0; right: 0; z-index: 30; list-style: none; margin: 2px 0 0; padding: .25rem 0; background: #fff; border: 1px solid #b9c0ca; border-radius: 8px; box-shadow: var(--shadow); max-height: 260px; overflow-y: auto; }
.comune-field label { order: -1; }
.comune-list li { padding: .5rem .75rem; cursor: pointer; }
.comune-list li[aria-selected="true"], .comune-list li:hover { background: var(--brand-soft); }

/* ---------- Tabelle e liste ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1rem; }
.card .table-wrap { border: 0; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .65rem .75rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #fafbfc; }
.table tbody tr:hover { background: #fafbfd; }
.table.compact th, .table.compact td { padding: .4rem .5rem; }
.table .num { text-align: right; white-space: nowrap; }
.subrow td { background: #fafbfc; }
.empty { padding: 2rem; text-align: center; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.pagination { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin: 1rem 0; }
.pagination a, .pagination span[aria-current] { padding: .35rem .7rem; border-radius: 6px; border: 1px solid var(--line); background: #fff; text-decoration: none; }
.pagination span[aria-current] { background: var(--brand); color: #fff; border-color: var(--brand); }
.pagination .muted { margin-left: .5rem; }
.dl { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: .35rem 1rem; margin: 0; }
.dl dt { color: var(--muted); font-size: .9rem; }
.dl dd { margin: 0; }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: .2rem 0; }
.timeline { list-style: none; padding: 0; margin: 0; border-left: 3px solid var(--line); }
.timeline li { padding: .25rem 0 .75rem 1rem; position: relative; }
.timeline li p { margin: 0; }
del { color: var(--err); }
ins { color: var(--ok); text-decoration: none; }
.note-riservate { background: var(--warn-bg); padding: .5rem .75rem; border-radius: 8px; }
.steps { padding-left: 1.2rem; }
.qr { background: #fff; padding: .5rem; border: 1px solid var(--line); border-radius: 8px; }
.secret { font-size: 1.05rem; letter-spacing: .05em; word-break: break-all; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; list-style: none; padding: 0; }
.codes code { display: block; text-align: center; font-size: 1.05rem; padding: .4rem; }
.logo-preview { object-fit: contain; border: 1px solid var(--line); border-radius: 6px; background: #fff; }

/* Struttura ad albero */
.tree { list-style: none; margin: 0 0 1rem; padding: 0; }
.tree li { border-bottom: 1px solid #eef0f3; padding: .2rem 0; }
/* i livelli rientrano perché l'albero è annidato: niente classi di profondità */
.tree .tree { margin: .25rem 0 .25rem 1.1rem; border-left: 1px solid #eef0f3; padding-left: .6rem; }
.tree .tree li:last-child { border-bottom: 0; }
.tree summary { color: var(--text); font-weight: 500; }
.tree .conta { display: inline-block; margin-left: .4rem; padding: 0 .4rem; border-radius: 999px;
  background: #eef0f3; color: var(--muted); font-size: .75rem; font-weight: 400; }
.tree .scheda { margin: .35rem 0 .5rem 1.1rem; padding-left: .6rem; border-left: 2px solid #eef0f3; }
.tree .scheda .dl { margin: 0 0 .4rem; font-size: .9rem; }
.tree .subform { margin: .35rem 0 .35rem 0; }
.tree .subform > summary { font-weight: 400; font-size: .85rem; color: var(--muted); }
.lvl { display: inline-block; min-width: 5.5rem; font-size: .75rem; text-transform: uppercase; color: var(--muted); }

/* Statistiche */
.stats { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; display: flex; flex-direction: column; text-decoration: none; color: var(--text); box-shadow: var(--shadow); }
a.stat:hover { border-color: var(--brand); color: var(--text); }
.stat-label { color: var(--muted); font-size: .88rem; }
.stat-value { font-size: 1.9rem; font-weight: 700; color: var(--brand); }
.bars { list-style: none; padding: 0; margin: 0; }
.bars li { display: grid; grid-template-columns: minmax(120px, 180px) 1fr 3rem; gap: .75rem; align-items: center; padding: .3rem 0; }
.bars strong { text-align: right; }
.bar meter { width: 100%; height: 14px; }

@media print {
  .topbar, .sidebar, .btn, form, .skip { display: none !important; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 0; }
}

/* Scelta guidata del luogo */
.luogo-righe { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
.luogo-righe select { width: 100%; }
@media (max-width: 720px) { .luogo-righe { grid-template-columns: 1fr; } }

code.break { word-break: break-all; }

/* Comunicazioni: testo del messaggio come è stato scritto, e il conteggio ben visibile */
.testo-messaggio { white-space: pre-wrap; word-wrap: break-word; font: inherit; margin: 0; }
.numerone { font-size: 2.5rem; font-weight: 700; line-height: 1.1; margin: .25rem 0 .5rem; }

/* Eventi: intestazione di mese e righe spente per chi si è ritirato */
h2.mese { margin: 1.5rem 0 .5rem; font-size: 1.05rem; color: var(--muted); text-transform: capitalize; }
.card.evento { margin-bottom: .6rem; padding: .85rem 1.1rem; }
.card.evento h3 { margin: 0 0 .15rem; font-size: 1.05rem; }
tr.spenta td { opacity: .55; text-decoration: line-through; }
.btn-small { padding: .25rem .6rem; font-size: .85rem; }
.evento-pub { border-top: 1px solid var(--line); padding: .9rem 0; }
.evento-pub:first-of-type { border-top: 0; }
.evento-pub h3 { margin: 0 0 .2rem; }

/* Cassa: barre proporzionali senza meter, e colonna importi più larga */
.bars li { grid-template-columns: minmax(120px, 200px) 1fr 6rem; }
.bars .bar { display: block; background: #eceef1; border-radius: 6px; height: 14px; overflow: hidden; }
.bars .bar > span { display: block; height: 100%; background: var(--brand); }

/* Porta d'ingresso pubblica: credenziali dello staff sopra, le due strade
   per i tesserati sotto. Chi arriva sul portale di solito non è dello staff. */
.card.scelte { margin-top: 1rem; }
.card.scelte h2 { margin: 0 0 .75rem; font-size: 1.05rem; }
.scelte-griglia { display: grid; gap: .6rem; }
@media (min-width: 540px) { .scelte-griglia { grid-template-columns: 1fr 1fr; } }
.scelta { display: block; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: 10px;
  text-decoration: none; color: var(--text); background: #fff; transition: border-color .15s, box-shadow .15s; }
.scelta:hover, .scelta:focus-visible { border-color: var(--brand); box-shadow: var(--shadow); }
.scelta strong { display: block; color: var(--brand); margin-bottom: .15rem; }
.scelta span { display: block; font-size: .85rem; color: var(--muted); line-height: 1.35; }
.card.scelte .hint { margin-top: .75rem; }

/* Filtri in linea (pagina Verifica e stato) */
.filtri { font-size: .92rem; color: var(--muted); margin-bottom: .75rem; }
.filtri a { text-decoration: none; }
.filtri a:hover { text-decoration: underline; }
.filtri a.attivo { font-weight: 600; color: var(--text); text-decoration: underline; }
.table td form { margin: 0; }

/* Estratto conto: un riquadro per movimento */
.movimento { margin-bottom: .75rem; }
.movimento .descrizione { word-break: break-word; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; }
.movimento .azioni { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
/* celle con i bottoni di riga: in fila sul computer, a capo sul telefono */
td.azioni { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
form.inline { display: inline-block; margin: 0; }
.movimento .azioni form { display: flex; gap: .4rem; align-items: center; margin: 0; }

/* Istogramma dell'andamento mensile */
.istogramma th { width: 3.5rem; font-weight: 600; text-transform: none; letter-spacing: 0; background: none; }
.istogramma td.num { width: 3.5rem; }
.istogramma td.barra { padding-right: 1rem; }
.istogramma td.barra span { display: block; height: .75rem; min-width: 2px; border-radius: 3px; background: var(--brand); }

/* Le righe concrete sotto un avviso di Verifica e stato */
.elenco-problema { margin: .5rem 0 0 1.1rem; padding: 0; }
.elenco-problema li { margin: .15rem 0; }
