:root {
  --bg: #f4f5f2; --card: #fff; --ink: #1f2a24; --muted: #6b7570; --line: #e3e6e1;
  --brand: #b5121b; --brand-2: #fdf6d6; --giallo: #f5c400; --pos: #15803d; --neg: #b42318; --warn: #b45309;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 28px 0 10px; }
h3 { margin: 0 0 12px; font-size: 16px; }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
.pos { color: var(--pos); } .neg { color: var(--neg); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; padding: 8px 24px; background: #fff; color: var(--ink); flex-wrap: wrap; border-bottom: 3px solid var(--brand); box-shadow: 0 1px 6px rgba(0,0,0,.06); }
.brand { display: flex; align-items: center; gap: 10px; font-size: 15px; white-space: nowrap; color: var(--muted); }
.brand img { height: 40px; display: block; }
.brand .sep { width: 1px; height: 26px; background: var(--line); }
nav { display: flex; gap: 2px; flex: 1; flex-wrap: nowrap; overflow-x: auto; min-width: 0; }
nav a { white-space: nowrap; }
nav a { color: var(--ink); text-decoration: none; padding: 7px 12px; border-radius: 8px; }
nav a:hover { background: #f4f5f2; }
nav a.active { background: var(--brand-2); color: var(--brand); font-weight: 600; }
main { max-width: 1280px; margin: 0 auto; padding: 20px 24px 60px; }
.view { display: none; } .view.active { display: block; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card.nopad { padding: 0; overflow: hidden; }
.scroll { overflow-x: auto !important; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #f7f8f6; }
.btn.primary { background: #f0b429; border-color: #e0a31a; color: #2b2100; font-weight: 600; }
.btn.primary:hover { background: #f5c04a; }
.btn.danger { color: var(--neg); border-color: #f2c9c5; }
.btn.danger:hover { background: #fdf0ef; }

.hero { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; background: linear-gradient(135deg, #fff, var(--brand-2)); }
.big { font-size: 38px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin: 2px 0; }
.hero-side { min-width: 240px; }
.kv { display: flex; justify-content: space-between; gap: 20px; padding: 3px 0; font-variant-numeric: tabular-nums; }

.grid-casse { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.cassa { position: relative; cursor: pointer; padding: 14px 16px 14px 20px; transition: transform .1s; }
.cassa:hover { transform: translateY(-1px); border-color: #cfd5cd; }
.cassa::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; border-radius: var(--radius) 0 0 var(--radius); background: var(--c); }
.cassa .nome { font-weight: 600; }
.cassa .saldo { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 4px 0; }
.cassa .mini { display: flex; gap: 12px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.filtri { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; margin-bottom: 12px; }
.filtri label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 3px; }
.filtri .grow { flex: 1; min-width: 180px; }
input, select { font: inherit; color: inherit; padding: 7px 9px; border: 1px solid #cfd5cd; border-radius: 7px; background: #fff; min-width: 0; }
input:focus, select:focus { outline: 2px solid #f0c94a; outline-offset: -1px; border-color: #e0b52a; }

.totali { display: flex; gap: 18px; flex-wrap: wrap; margin: 4px 2px 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.totali b { color: var(--ink); }

.tab { width: 100%; border-collapse: collapse; }
.tab th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #fafbf9; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tab td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tab tbody tr:hover { background: #fafcfa; }
.tab tr.click { cursor: pointer; }
.tab .vuoto { text-align: center; color: var(--muted); padding: 40px; }
.desc { font-weight: 500; }
.sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-flex; gap: 5px; align-items: center; font-size: 11.5px; padding: 2px 8px; border-radius: 99px; background: color-mix(in srgb, var(--c) 13%, #fff); color: color-mix(in srgb, var(--c) 75%, #000); white-space: nowrap; }
.chip i { font-style: normal; font-variant-numeric: tabular-nums; opacity: .85; }
.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 5px; background: #eef0ec; color: var(--muted); margin-right: 4px; }
.badge.stripe { background: #ede9fe; color: #5b21b6; }
.badge.bonifico { background: #e0f2fe; color: #075985; }
.badge.giro { background: #fef3c7; color: #92400e; }
.ver { width: 18px; height: 18px; cursor: pointer; accent-color: var(--pos); }

.rendiconto td, .rendiconto th { font-size: 13px; }
.rendiconto th.cassa-h { text-align: right; border-top: 3px solid var(--c); }
.rendiconto tr.sez td { background: #f4f6f3; font-weight: 700; text-transform: uppercase; font-size: 12px; letter-spacing: .04em; }
.rendiconto tr.tot td { font-weight: 700; border-top: 2px solid #cfd5cd; }
.rendiconto tr.saldo td { font-weight: 700; background: var(--brand-2); }
.rendiconto td:first-child { white-space: nowrap; }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.lista-cat { list-style: none; padding: 0; margin: 0 0 14px; }
.lista-cat li { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.lista-cat button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; }
.lista-cat button:hover { color: var(--neg); }
.inline { display: flex; gap: 8px; flex-wrap: wrap; } .inline input { flex: 1; }
.help dt { font-weight: 600; margin-top: 10px; } .help dd { margin: 2px 0 0; color: var(--muted); }

/* dialog */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 20px 60px rgba(0,0,0,.25); color: var(--ink); }
dialog::backdrop { background: rgba(20,30,25,.45); }
#form-mov { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; }
.dlg-head h3 { margin: 0; }
.x { border: 0; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); }
.seg { display: flex; background: #eef0ec; border-radius: 9px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button { flex: 1; border: 0; background: none; padding: 7px 10px; border-radius: 7px; font: inherit; cursor: pointer; color: var(--muted); white-space: nowrap; }
.seg button.on { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg button.on[data-tipo=entrata] { color: var(--pos); } .seg button.on[data-tipo=uscita] { color: var(--neg); }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.form-grid .span2 { grid-column: span 2; }
.form-grid label.check { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); grid-column: span 3; }
.ripart { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: #fafbf9; }
.ripart-head { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.presets { display: flex; flex-wrap: wrap; gap: 5px; }
.presets button { font: inherit; font-size: 12px; padding: 4px 9px; border: 1px solid #cfd5cd; background: #fff; border-radius: 99px; cursor: pointer; }
.presets button:hover { background: var(--brand-2); }
.presets button.strong { border-color: var(--brand); color: var(--brand); font-weight: 600; }
.logo-ripiego { font-size: 30px; line-height: 1; }
.rip-riga { display: grid; grid-template-columns: 22px 1fr 120px 110px; align-items: center; gap: 8px; padding: 3px 0; }
.rip-riga .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); justify-self: center; }
.rip-riga label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.rip-riga input[type=text] { text-align: right; padding: 5px 8px; }
.rip-riga .netto { font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.rip-riga.off input[type=text] { opacity: .45; }
.residuo { margin-top: 8px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.residuo.ok { color: var(--pos); } .residuo.ko { color: var(--warn); }
.errore { color: var(--neg); font-weight: 500; min-height: 1em; }
.errore:empty { display: none; }
.dlg-foot { display: flex; gap: 8px; } .grow { flex: 1; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(80px); background: #1f2a24; color: #fff; padding: 10px 18px; border-radius: 8px; transition: transform .25s; z-index: 50; }
#toast.show { transform: translateX(-50%) translateY(0); }

.onlyprint { display: none; }
@media print {
  .topbar, .noprint, #toast { display: none !important; }
  .onlyprint { display: block; color: var(--ink); text-transform: none; letter-spacing: 0; font-size: 16px; }
  body { background: #fff; } main { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; }
  .rendiconto td, .rendiconto th { font-size: 10px; padding: 4px 6px; }
}
@media (max-width: 760px) {
  .topbar { padding: 10px 16px; gap: 10px; }
  main { padding: 16px 16px 60px; }
  .cols, .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2, .form-grid label.check { grid-column: auto; }
  .rip-riga { grid-template-columns: 22px 1fr 100px; }
  .rip-riga .netto { grid-column: 2 / 4; }
  .tab .hide-m { display: none; }
  .big { font-size: 30px; }
}

/* accesso e ruoli */
body.anon > header, body.anon > main { display: none; }
#login { display: none; min-height: 100vh; align-items: center; justify-content: center; padding: 16px; background: linear-gradient(150deg, var(--giallo) 0%, #f7d84a 45%, var(--brand) 100%); }
body.anon #login { display: flex; }
#form-login { width: min(360px, 100%); display: flex; flex-direction: column; gap: 12px; padding: 28px; }
#form-login h1 { margin: 0 0 6px; font-size: 20px; text-align: center; }
#form-login label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
#form-login .btn { justify-content: center; padding: 10px; }
.login-logo { text-align: center; }
.login-logo img { width: 110px; height: auto; }
body:not(.puo-scrivere) .solo-scrive { display: none !important; }
body:not(.admin) .solo-admin { display: none !important; }
.utente-menu { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.link { background: none; border: 0; color: var(--brand); text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }
.stack { display: flex; flex-direction: column; gap: 8px; max-width: 360px; }
.spazio { margin-top: 24px; } .spazio-top { margin-top: 16px; }
.registro { max-height: 420px; overflow-y: auto; }
.tab select { padding: 4px 6px; }
.tag-off { color: var(--muted); text-decoration: line-through; }

@media (max-width: 760px) {
  .brand .sep, .brand > span:last-child { display: none; }
  .brand img { height: 34px; }
  .topbar { justify-content: space-between; }
  nav { order: 3; flex-basis: 100%; }
  nav a { padding: 6px 10px; }
}

/* menu: sottomenu contabilità */
.subnav { display: none; gap: 4px; padding: 6px 24px; background: #fff; border-bottom: 1px solid var(--line); overflow-x: auto; }
body.in-contabilita .subnav { display: flex; }
body:not(.in-contabilita) .solo-contab { display: none !important; }
.subnav a { color: var(--muted); text-decoration: none; padding: 5px 12px; border-radius: 7px; font-size: 13px; white-space: nowrap; }
.subnav a:hover { background: #f4f5f2; }
.subnav a.active { color: var(--ink); font-weight: 600; background: #f0f1ee; }
.pill { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 4px; border-radius: 99px; background: var(--brand); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.pill[hidden] { display: none; }

/* anagrafiche */
.avviso { background: #fff8e1; border: 1px solid #f3d27a; color: #6b4e00; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; }
.avviso .link { color: var(--brand); }
.stato { display: inline-block; font-size: 11.5px; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.stato.attivo { background: #e7f5ec; color: #166534; }
.stato.richiesta { background: #fff4d6; color: #92400e; }
.stato.archiviato { background: #eef0ec; color: var(--muted); }
.badge.warn { background: #fde8e7; color: var(--neg); }
.badge.salute { background: #e8f1fd; color: #1e4f91; }
.badge.censimento { background: #e0f2fe; color: #075985; }
.badge.campo { background: #e7f5ec; color: #166534; }
.badge.attivita { background: #f3e8ff; color: #6b21a8; }
.nowrap { white-space: nowrap; }
.maiuscolo { text-transform: uppercase; }
textarea { font: inherit; color: inherit; padding: 7px 9px; border: 1px solid #cfd5cd; border-radius: 7px; background: #fff; resize: vertical; width: 100%; }
textarea:focus { outline: 2px solid #f0c94a; outline-offset: -1px; border-color: #e0b52a; }
.dlg-form { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.form-grid .span3 { grid-column: span 3; }
.gruppo-campi { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 12px; margin: 0; }
.gruppo-campi legend { font-size: 12px; color: var(--muted); padding: 0 6px; }
.gruppo-campi[hidden] { display: none; }
.storico { border-top: 1px solid var(--line); padding-top: 8px; font-size: 13px; }
.storico-riga { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.check-riga { display: flex; align-items: center; gap: 8px; margin: 8px 0; cursor: pointer; }
.stack-label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); margin: 8px 0 12px; }

/* iscrizioni */
.grid-eventi { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin-bottom: 18px; }
.evento { position: relative; cursor: pointer; padding: 14px 16px 14px 20px; transition: transform .1s; }
.evento:hover { transform: translateY(-1px); }
.evento::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; border-radius: var(--radius) 0 0 var(--radius); background: var(--c); }
.evento.sel { outline: 2px solid var(--brand); }
.evento .nome { font-weight: 700; font-size: 15px; margin: 4px 0; }
.evento .mini { display: flex; gap: 12px; font-size: 12.5px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.dettaglio-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 6px 0 10px; }
.dettaglio-head h2 { margin: 0; color: var(--ink); text-transform: none; letter-spacing: 0; font-size: 18px; }
.lista-scelta { max-height: 50vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.scelta { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.scelta span:first-of-type { flex: 1; }
.scelta:hover { background: #fafbf9; }
#dlg-persona, #dlg-aggiungi { width: min(820px, calc(100vw - 24px)); }
@media (max-width: 760px) {
  .form-grid .span3 { grid-column: auto; }
  .subnav { padding: 6px 16px; }
}

/* pagina pubblica di iscrizione */
body.pubblico { background: linear-gradient(180deg, #fdf6d6 0, var(--bg) 260px); }
.pub-head { display: flex; justify-content: center; padding: 22px 16px 6px; }
.pub-head img { height: 64px; }
.pub-main { max-width: 820px; margin: 0 auto; padding: 8px 16px 60px; }
.pub-main h1 { font-size: 24px; text-align: center; margin: 10px 0 18px; }
.pub-main h2 { font-size: 13px; margin: 22px 0 10px; color: var(--brand); }
.pub-main form h2:first-of-type { margin-top: 6px; }
.trappola { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.informativa { background: #fafbf9; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font-size: 13px; margin-bottom: 8px; }
.informativa summary { cursor: pointer; font-weight: 600; }
.informativa p { margin: 8px 0; color: #3c4640; }
.btn.grande { width: 100%; justify-content: center; padding: 12px; font-size: 16px; margin-top: 10px; }
