:root {
  --bg: #f5f7fa; --fg: #1f2732; --muted: #5b6675; --card: #fff; --line: #dde3ea;
  --accent: #572979; --btn: #572979; --brand-blu: #00a4db; --barra: #1f2732;
  --error-bg: #fdecea; --error-fg: #8a1c12;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14181f; --fg: #e4e7eb; --muted: #9aa5b1; --card: #1f2732; --line: #323a45;
          --accent: #5cc8f0; --btn: #572979; --barra: #1f2732;
          --error-bg: #3b1714; --error-fg: #f8b4ab; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.5 system-ui, sans-serif; background: var(--bg); color: var(--fg); }
.barra { display: flex; justify-content: space-between; align-items: center; gap: 1rem;
         padding: .75rem 1rem; background: var(--barra); color: #fff; border-bottom: 3px solid var(--brand-blu); }
main { max-width: 1100px; margin: 1.5rem auto; padding: 0 1rem; }
.scheda { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 1.25rem; }
.stretta { max-width: 380px; margin: 3rem auto; }
h1 { font-size: 1.4rem; margin-top: 0; }
label { display: block; margin-bottom: .9rem; font-weight: 600; }
input { display: block; width: 100%; margin-top: .3rem; padding: .55rem; font: inherit;
        border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); }
button { padding: .55rem 1.1rem; font: inherit; border: 0; border-radius: 6px;
         background: var(--btn); color: #fff; cursor: pointer; }
.esci { display: flex; align-items: center; gap: .6rem; margin: 0; }
.esci button { padding: .3rem .8rem; background: var(--brand-blu); color: var(--barra); }
.errore { background: var(--error-bg); color: var(--error-fg); padding: .6rem .8rem; border-radius: 6px; }
.trappola { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.cf-turnstile { margin-bottom: .9rem; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; }
@media (max-width: 640px) { table { display: block; overflow-x: auto; } }

/* --- Navigazione e componenti delle pagine di progetto --- */
a { color: var(--accent); }
.marchio { font-weight: 700; color: #fff; text-decoration: none; }
.barra nav { display: flex; gap: 1rem; flex-wrap: wrap; }
.barra nav a { color: #fff; text-decoration: none; }
.barra { flex-wrap: wrap; }
.scheda + .scheda { margin-top: 1.25rem; }
h2 { font-size: 1.15rem; margin-top: 0; }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }
.nota { color: var(--muted); font-size: .92rem; }
.avviso-ok { background: #e6f4ea; color: #1e4620; padding: .6rem .8rem; border-radius: 6px; }
@media (prefers-color-scheme: dark) { .avviso-ok { background: #16301d; color: #a7d7b0; } }
select, textarea { display: block; width: 100%; margin-top: .3rem; padding: .5rem; font: inherit;
  border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); }
.griglia-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 1rem; }
.griglia-form .largo { grid-column: 1 / -1; }
.riga-form { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: flex-end; margin-top: 1rem; }
.riga-form label { margin: 0; }
.riga-form .cresce { flex: 1 1 200px; }
.riga-form input { width: auto; }
.riga-form .cresce input { width: 100%; }
label.check { display: flex; align-items: center; gap: .4rem; font-weight: 400; }
label.check input { width: auto; margin: 0; }
.bottone { display: inline-block; padding: .55rem 1.1rem; border-radius: 6px; background: var(--btn);
  color: #fff; text-decoration: none; }
button.secondario { background: transparent; color: var(--muted); border: 1px solid var(--line); padding: .25rem .6rem; }
.dati { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .5rem 1.5rem; margin: 0 0 1rem; }
.dati dt { color: var(--muted); font-size: .85rem; }
.dati dd { margin: 0; }
details { margin-top: .75rem; }
summary { cursor: pointer; color: var(--accent); }
.scorre { overflow-x: auto; }
table.griglia input { width: 6.5rem; margin: 0; padding: .35rem; text-align: right; }
td, th { vertical-align: top; }
table.dettaglio td { font-size: .85rem; min-width: 7.5rem; }
.escluso { text-decoration: line-through; opacity: .6; }
tr.spento td { color: var(--muted); }
tr.rif td, tr.rif th { background: color-mix(in srgb, var(--accent) 10%, transparent); }
tr.totale td { font-weight: 700; }
.etichetta { font-size: .72rem; padding: .05rem .35rem; border-radius: 4px; background: var(--btn); color: #fff; }
.kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin: 1rem 0; }
.kpi div { border: 1px solid var(--line); border-radius: 8px; padding: .75rem 1rem; }
.kpi span { display: block; color: var(--muted); font-size: .85rem; }
.kpi strong { font-size: 1.5rem; }
.grafici { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.5rem; }
.grafici figure { margin: 0; }
.grafici figcaption { font-weight: 600; margin-bottom: .5rem; }
.grafici canvas { height: 300px !important; }
.largo-100 { width: 100%; }
.zona-pericolo summary { color: var(--error-fg); }
