/* Risparmione: un solo foglio di stile, senza framework.
   Ordine: token → base → struttura dell'app → componenti → pagine.
   I colori stanno SOLO nei token; il tema scuro ridefinisce i token. */

/* ─── Token ─────────────────────────────────────────────────────────────────── */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f7f8fa;          /* testate di tabella, righe al passaggio del mouse */
  --border: #e2e6ec;
  --border-strong: #cdd3dc;      /* bordi dei campi */
  --text: #111827;
  --muted: #5a6474;              /* 5,9:1 su bianco */
  --subtle: #8a93a1;             /* solo icone e dettagli non testuali */
  --accent: #2459d6;
  --accent-hover: #1c47ad;
  --accent-soft: color-mix(in srgb, var(--accent) 10%, transparent);
  --on-accent: #ffffff;
  --danger: #c0392b;
  --ok: #1e7f46;
  --good-text: #006300;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, .05);
  --shadow: 0 1px 3px rgba(17, 24, 39, .06), 0 1px 2px rgba(17, 24, 39, .04);
  --shadow-lg: 0 12px 32px rgba(17, 24, 39, .14);
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 12px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  /* Grafici: palette categoriale validata (8 slot), grigi recessivi per griglia e assi */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
  --viz-grid: #e1e0d9;
  --viz-axis: #c3c2b7;
  --viz-muted: #6b6a65;
  --segmented-on: var(--surface);
  color-scheme: light;
}
/* Tema scuro: segue il sistema (Automatico) o la scelta fatta dal pulsante nel menu,
   salvata come data-theme su <html>. I due blocchi devono restare identici. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116;
    --surface: #161a21;
    --surface-2: #1c222a;
    --border: #2a313b;
    --border-strong: #3a4350;
    --text: #e8ebf0;
    --muted: #9aa4b2;
    --subtle: #6f7a88;
    --accent: #6b9cf5;
    --accent-hover: #8db3f8;
    --accent-soft: color-mix(in srgb, var(--accent) 16%, transparent);
    --on-accent: #0e1116;
    --danger: #ef7a6d;
    --ok: #58c285;
    --good-text: #3fbf5f;
    --shadow-sm: none;
    --shadow: none;
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
    --viz-grid: #2c3440;
    --viz-axis: #3a4350;
    --viz-muted: #9aa6b5;
    --segmented-on: var(--border);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1116;
  --surface: #161a21;
  --surface-2: #1c222a;
  --border: #2a313b;
  --border-strong: #3a4350;
  --text: #e8ebf0;
  --muted: #9aa4b2;
  --subtle: #6f7a88;
  --accent: #6b9cf5;
  --accent-hover: #8db3f8;
  --accent-soft: color-mix(in srgb, var(--accent) 16%, transparent);
  --on-accent: #0e1116;
  --danger: #ef7a6d;
  --ok: #58c285;
  --good-text: #3fbf5f;
  --shadow-sm: none;
  --shadow: none;
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --viz-grid: #2c3440;
  --viz-axis: #3a4350;
  --viz-muted: #9aa6b5;
  --segmented-on: var(--border);
  color-scheme: dark;
}

/* ─── Base ──────────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.55 var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
h1 { font-size: 1.55rem; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; margin: 0 0 6px; }
h2 { font-size: 1.05rem; line-height: 1.35; font-weight: 600; margin: 0 0 10px; }
h3 { font-size: .95rem; font-weight: 600; margin: 0 0 8px; }
p { margin: 0 0 10px; }
a { color: var(--accent); text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-hover); }
strong { font-weight: 600; }
code { font: .86em var(--mono); background: var(--surface-2); border: 1px solid var(--border); padding: 1px 5px; border-radius: 4px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--muted); }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.salta { position: absolute; left: 12px; top: 12px; z-index: 50; background: var(--surface); padding: 8px 12px;
  border-radius: var(--r-sm); transform: translateY(-200%); }
.salta:focus { transform: none; box-shadow: var(--shadow-lg); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ─── Struttura dell'app: barra laterale + contenuto ────────────────────────── */
body.app { display: grid; grid-template-columns: 244px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
  padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; color: var(--text);
  text-decoration: none; font-weight: 650; font-size: 1.02rem; letter-spacing: -.01em; }
.brand:hover { color: var(--text); }
.marchio { width: 28px; height: 28px; flex: none; }
.marchio rect { fill: var(--accent); }
.marchio path { stroke: var(--on-accent); stroke-width: 2.4; stroke-linecap: round; fill: none; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-gruppo { margin: 14px 10px 4px; font-size: .7rem; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--subtle); }
.nav-gruppo:first-child { margin-top: 0; }
.icona { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }
.nav a, .pulsante-nav {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px 10px; border-radius: 8px; border: 0; background: none;
  color: var(--muted); text-decoration: none; font: 500 .93rem var(--font); text-align: left; cursor: pointer;
  justify-content: flex-start; min-height: 0;
}
.nav a .icona, .pulsante-nav .icona { color: var(--subtle); }
.nav a:hover, .pulsante-nav:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a[aria-current="page"] .icona { color: var(--accent); }
.sidebar-piede { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); display: grid; gap: 4px; }
.sidebar-piede .utente { padding: 0 10px; font-size: .82rem; }
.tema { display: flex; align-items: center; gap: 10px; padding: 2px 10px 6px; }
.tema > .icona { color: var(--subtle); }
.tema .segmented { flex: 1; }
.tema .segmented button { flex: 1; min-height: 0; padding: 3px 6px; border: 0; border-radius: 7px; background: none;
  color: var(--muted); font: 500 .8rem var(--font); cursor: pointer; }
.tema .segmented button:hover { background: none; color: var(--text); }
.tema .segmented button[aria-pressed="true"]:hover { background: var(--segmented-on); }
.tema .segmented button[aria-pressed="true"] { background: var(--segmented-on); color: var(--text); font-weight: 600;
  box-shadow: var(--shadow); }
main { min-width: 0; outline: none; }
.pagina { max-width: 1200px; margin: 0 auto; padding: 28px 32px 56px; }
.barra-mobile, .velo { display: none; }

/* Schermi stretti: barra in alto con il pulsante Menu, barra laterale a scomparsa. */
@media (max-width: 960px) {
  body.app { display: block; }
  .barra-mobile {
    display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 20;
    padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--border);
  }
  .barra-mobile .brand { padding: 0; }
  .sidebar {
    position: fixed; z-index: 40; top: 0; left: 0; width: 268px; max-width: 85vw;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg);
  }
  .nav-aperta .sidebar { transform: none; }
  .velo { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .35); }
  .nav-aperta .velo { display: block; }
  .pagina { padding: 20px 16px 48px; }
}
@media (max-width: 600px) { .pagina { padding: 16px 12px 40px; } }

/* Pagina di accesso */
body.pubblica .pagina { max-width: 400px; padding-top: 12vh; }
.brand-pubblica { justify-content: center; font-size: 1.2rem; padding-bottom: 20px; }

/* ─── Componenti ────────────────────────────────────────────────────────────── */

/* Intestazione di pagina: il primo riquadro con il titolo perde l'aspetto di riquadro. */
.page-head, .card:not(.login):has(> h1) {
  background: none; border: 0; box-shadow: none; padding: 0; margin: 0 0 22px; border-radius: 0;
}
.page-head > p, .card:not(.login):has(> h1) > p { max-width: 78ch; }
.card:not(.login):has(> h1) > button, .card:not(.login):has(> h1) > .azioni { margin-top: 6px; }
.card:not(.login):has(> h1) + .card, .page-head + .card { margin-top: 0; }

/* Riquadri */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 20px 22px; box-shadow: var(--shadow-sm); min-width: 0;
}
.card + .card, .card + div, div + .card, .kpi + .card, .card + .kpi { margin-top: 16px; }
#risultati > .card + .card { margin-top: 16px; }
.card > h2:first-child { margin-bottom: 12px; }
@media (max-width: 600px) { .card { padding: 16px; border-radius: var(--r); } }

/* Campi */
label { display: grid; gap: 5px; font-size: .82rem; font-weight: 500; color: var(--muted); }
input, select, textarea {
  font: .93rem var(--font); color: var(--text); background: var(--surface);
  padding: 7px 10px; min-height: 36px; border: 1px solid var(--border-strong); border-radius: 8px;
  max-width: 100%; transition: border-color .12s, box-shadow .12s;
}
input:hover, select:hover, textarea:hover { border-color: var(--subtle); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox], input[type=radio] { min-height: 0; width: 16px; height: 16px; accent-color: var(--accent); }
input[type=file] { padding: 6px; background: var(--surface-2); }
input.corto { width: 7em; }

/* Pulsanti: principale (default), secondario, link, icona */
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 600 .9rem var(--font); padding: 8px 14px; min-height: 36px;
  border: 1px solid var(--accent); border-radius: 8px; background: var(--accent); color: var(--on-accent);
  cursor: pointer; transition: background .12s, border-color .12s, box-shadow .12s;
}
button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button:disabled { opacity: .55; cursor: default; }
button.secondario { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
button.secondario:hover { background: var(--surface-2); border-color: var(--subtle); }
button.link { background: none; border: 0; color: var(--accent); padding: 0; min-height: 0; font-weight: 500; box-shadow: none; }
button.link:hover { color: var(--accent-hover); text-decoration: underline; }
.pulsante-icona { background: none; border: 0; color: var(--text); padding: 6px; min-height: 0; }
.pulsante-icona:hover { background: var(--surface-2); }
.azioni { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.azioni button { padding: 6px 12px; min-height: 32px; font-size: .86rem; }

/* Tabelle */
.tabella-scroll, .tabella-grafico { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
thead th {
  font-size: .72rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted); background: var(--surface-2); white-space: nowrap; border-bottom-color: var(--border);
}
thead th:first-child { border-top-left-radius: 8px; }
thead th:last-child { border-top-right-radius: 8px; }
tbody tr:hover > td { background: var(--surface-2); }
tfoot th, tfoot td { font-weight: 600; color: var(--text); border-top: 1px solid var(--border-strong); border-bottom: 0; }
tr.riga-errore td { background: color-mix(in srgb, var(--danger) 6%, transparent); }
td.file { color: var(--muted); word-break: break-all; font-size: .85rem; }

/* Etichette di stato */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px;
  font-size: .74rem; font-weight: 600; line-height: 1.6; white-space: nowrap;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.badge.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); border-color: transparent; }
.badge.errore { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); border-color: transparent; }
.badge.auto { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* Avvisi */
.avviso {
  margin: 0 0 16px; padding: 10px 14px; border-radius: var(--r);
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent); color: var(--text);
}
.avviso.errore { background: color-mix(in srgb, var(--danger) 9%, transparent);
  border-color: color-mix(in srgb, var(--danger) 35%, transparent); color: var(--text); }
.avviso.errore strong { color: var(--danger); }
.errore { color: var(--danger); margin: 0; }
.nota { margin: 0 0 16px; font-size: .88rem; }
.conteggio { color: var(--muted); font-weight: 400; font-size: .85rem; margin-left: 6px; font-variant-numeric: tabular-nums; }
.etichetta { display: block; font-size: .7rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }
details > summary { cursor: pointer; }
summary { color: var(--muted); font-size: .88rem; font-weight: 500; }
summary:hover { color: var(--text); }

/* Scelta a pulsanti affiancati */
.segmented { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; }
.segmented a { padding: 4px 12px; border-radius: 7px; text-decoration: none; color: var(--muted); font-size: .86rem; font-weight: 500; }
.segmented a:hover { color: var(--text); }
.segmented a.attivo { background: var(--segmented-on); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.segmented.grande a { padding: 6px 16px; font-size: .92rem; }

/* Elenchi di movimenti e importi */
.elenco { list-style: none; margin: 0; padding: 0; }
.elenco > li { border-top: 1px solid var(--border); padding: 14px 0; display: grid; gap: 8px; }
.elenco > li:first-child { border-top: 0; padding-top: 4px; }
.elenco.compatto > li { padding: 8px 0; }
.importo { font-weight: 600; font-variant-numeric: tabular-nums; display: inline-flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.importo .muted { font-weight: 400; font-size: .85rem; }
.importo.negativo, .num.negativo { color: var(--danger); }
.importo.positivo, .num.positivo { color: var(--ok); }
.mov { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: .9rem; }
.movimenti .movimento { display: grid; gap: 4px; }
.mov-testa { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.mov-testa .importo { margin-left: auto; }
.mov-conto { font-weight: 500; font-size: .88rem; }
.mov-data { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .88rem; white-space: nowrap; }
.mov-esercente { font-weight: 600; word-break: break-word; }
.mov-desc { flex-basis: 100%; color: var(--muted); font-size: .8rem; word-break: break-word; }
.mov-cat { font-size: .88rem; }
.mov-categoria { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 4px; }
.mov-categoria select { flex: 1 1 220px; }
.mov-categoria button { padding: 5px 12px; min-height: 32px; font-size: .85rem; }
.lati { display: grid; gap: 6px; grid-template-columns: 1fr 1fr; }
@media (max-width: 700px) { .lati { grid-template-columns: 1fr; } }
.origine { display: inline-flex; gap: 8px; align-items: center; }
.paginazione { display: flex; justify-content: space-between; margin-top: 14px; }

/* Barre di filtri */
.filtri-dashboard, .filtri, .classifica { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.filtri-dashboard {
  margin-bottom: 18px; padding: 14px 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
}
.filtri { margin-top: 14px; }
.classifica { margin-top: 10px; }
.filtri-dashboard label, .filtri label, .classifica label { flex: 1 1 150px; min-width: 0; }
.filtri-dashboard label > select, .filtri label > select, .classifica label > select { width: 100%; }
.filtri > input[type=search] { flex: 2 1 260px; }
.filtri > select { flex: 1 1 190px; min-width: 0; }
.filtri > input[type=date] { flex: 0 1 160px; }
/* Filtri dentro l'intestazione di pagina: stessa barra delle altre pagine. */
.card:not(.login):has(> h1) > .filtri {
  margin-top: 16px; padding: 12px 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
}
.card:not(.login):has(> h1) > .nota { margin: 10px 0 0; }
.filtri-dashboard label:first-of-type { flex: 1 1 210px; }
.filtri-dashboard label:has(input[type=date]) { flex: 0 1 160px; }
.filtri-dashboard > button, .classifica .spunta, .classifica button { flex: 0 0 auto; }
.filtri-dashboard .campo { display: grid; gap: 5px; font-size: .82rem; font-weight: 500; color: var(--muted); flex: 0 0 auto; }
.classifica .largo { flex: 1 1 100%; }
.classifica .largo input { width: 100%; font-family: var(--mono); font-size: .88rem; }
.spunta { display: flex; flex-direction: row; align-items: center; gap: 7px; color: var(--text); font-weight: 400; font-size: .9rem; }

/* Indicatori */
.kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 14px; margin: 0 0 18px; }
.kpi > * { min-width: 0; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow-sm);
}
.tile-label { color: var(--muted); font-size: .8rem; font-weight: 500; }
.tile-valore { font-size: 1.6rem; font-weight: 650; letter-spacing: -.015em; font-variant-numeric: tabular-nums; white-space: nowrap; line-height: 1.25; }
.tile-nota { font-size: .76rem; color: var(--muted); }
.tile-delta { font-size: .8rem; font-weight: 600; display: flex; gap: 6px; flex-wrap: wrap; align-items: baseline; margin-top: auto; padding-top: 6px; }
.tile-delta.buono { color: var(--good-text); }
.tile-delta.cattivo { color: var(--danger); }
.tile-delta .muted { font-size: .76rem; font-weight: 400; }
@media (max-width: 600px) {
  .kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { padding: 12px 14px; }
  .tile-valore { font-size: 1.15rem; }
}

/* Grafici */
.grafico { margin-top: 16px; }
.grafico .vega { width: 100%; min-height: 80px; overflow: hidden; }
.grafico .vega svg { max-width: 100%; }
.griglia-grafici { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 16px; }
.griglia-grafici > * { min-width: 0; }
.testa-grafico { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.testa-grafico h2 { margin: 0; }
.nota-grafico { font-size: .82rem; color: var(--muted); margin: 4px 0 12px; }
.nota-grafico button.link { display: inline; font: inherit; text-align: left; white-space: normal; }
.tabella-grafico { margin-top: 10px; font-size: .88rem; }
.tabella-grafico > summary { display: inline-block; padding: 2px 0; }
#vg-tooltip-element.vg-tooltip.custom-theme {
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow-lg); font: 13px var(--font); padding: 8px 10px;
}
#vg-tooltip-element.custom-theme td.key { color: var(--muted); }
#vg-tooltip-element.custom-theme td.value { font-weight: 600; }
.htmx-request #cruscotto, #cruscotto.htmx-request, .htmx-request#pagina, .htmx-request #pagina,
#dettaglio-fetta.htmx-request { opacity: .55; transition: opacity .15s; }

/* Campioni di colore e barre di quota (legende-tabella) */
.campione { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 7px; vertical-align: baseline; flex: none; }
.campione.s1, .sotto-barra .s1 { background: var(--series-1); }
.campione.s2, .sotto-barra .s2 { background: var(--series-2); }
.campione.s3, .sotto-barra .s3 { background: var(--series-3); }
.campione.s4, .sotto-barra .s4 { background: var(--series-4); }
.campione.s5, .sotto-barra .s5 { background: var(--series-5); }
.campione.s6, .sotto-barra .s6 { background: var(--series-6); }
.campione.s7, .sotto-barra .s7 { background: var(--series-7); }
.campione.s8, .sotto-barra .s8 { background: var(--series-8); }
.campione.altro, .sotto-barra .altro { background: var(--viz-muted); }
.sotto-barra { height: 4px; border-radius: 2px; background: var(--border); margin-top: 4px; max-width: 240px; }
.sotto-barra span { display: block; height: 100%; border-radius: 2px; }

/* ─── Pagine ────────────────────────────────────────────────────────────────── */

/* Accesso */
.login { display: grid; gap: 14px; padding: 28px; box-shadow: var(--shadow); }
.login h1 { font-size: 1.25rem; margin: 0; }
.login button { width: 100%; margin-top: 4px; }

/* Panoramica */
.esclusi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 10px 16px; font-size: .9rem; box-shadow: var(--shadow-sm); }
.esclusi[open] summary { margin-bottom: 8px; }

/* Ripartizione */
.torta { display: grid; grid-template-columns: minmax(0, 330px) minmax(0, 1fr); gap: 16px 28px; align-items: start; }
.torta.piccola { grid-template-columns: minmax(0, 270px) minmax(0, 1fr); }
.torta-grafico { max-width: 330px; margin: 0 auto; }
.torta.piccola .torta-grafico { max-width: 270px; }
@media (min-width: 761px) { .torta-grafico { position: sticky; top: 16px; } }
@media (max-width: 760px) { .torta, .torta.piccola { grid-template-columns: minmax(0, 1fr); } }
.torta-legenda td { vertical-align: middle; }
.torta-legenda tr.selezionata td, .torta-legenda tbody.attiva td { background: var(--accent-soft); font-weight: 600; }
.torta-legenda .espandi { background: none; border: 0; padding: 0 4px 0 0; min-height: 0; color: var(--subtle);
  font: 1rem/1 var(--font); width: 1.3em; justify-content: flex-start; }
.torta-legenda .espandi:hover { color: var(--accent); background: none; }
.torta-legenda .espandi span { display: inline-block; transition: transform .15s; }
.torta-legenda tbody.attiva .espandi span { transform: rotate(90deg); color: var(--accent); }
.torta-legenda .espandi-vuoto { display: inline-block; width: 1.3em; }
.dettaglio-fetta h2 { display: flex; align-items: center; }
.dettaglio-fetta h2 .campione { width: 12px; height: 12px; margin-right: 9px; }
.briciole a { font-weight: 500; }
.dettaglio-movimenti td { vertical-align: top; }
.dettaglio-movimenti .mov-desc { max-width: 46ch; }

/* Estratti conto */
.carica { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }
.esiti { margin: 0; padding-left: 18px; }
.esito-errore { color: var(--danger); }
.esito-gia_importato { color: var(--muted); }
.dettaglio { color: var(--danger); font-size: .82rem; margin-top: 4px; }

/* Revisione, categorie, regole */
.gruppo-testa { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.gruppo-testa h2 { margin: 0; word-break: break-word; }
.gruppo details, .area, .voci details { margin: 8px 0; }
.mini { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; font-size: .88rem; }
.mini .mov-desc { display: block; }
.proposta { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; margin: 8px 0 0; }
.proposta .motivo { flex-basis: 100%; font-size: .85rem; }
.proposta-regola input { flex: 1 1 200px; font-family: var(--mono); font-size: .86rem; }
.voci { list-style: none; padding-left: 14px; margin: 6px 0; border-left: 2px solid var(--border); }
.voci > li { padding: 3px 0; }
.aggiungi { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 4px; }
.aggiungi input { flex: 1 1 200px; }
.rinomina { padding-top: 10px; border-top: 1px dashed var(--border); }
.uso { font-size: .8rem; margin-left: 6px; }
.regola-riga { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; }
.regola-riga button { margin-left: auto; padding: 4px 10px; min-height: 30px; font-size: .84rem; }
.regole code { word-break: break-all; }
.priorita { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 2.5em; }
.regole .disattiva .regola-riga { opacity: .55; }

/* Movimenti manuali */
.modulo-manuale .tipo { align-self: stretch; }
.modulo-manuale .tipo label { display: flex; align-items: center; gap: 6px; padding: 8px 14px; color: var(--text); cursor: pointer; }
.modulo-manuale .tipo label:has(input:checked) { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.modulo-manuale input[name=importo] { font-size: 1.2rem; width: 8em; }
@media (max-width: 600px) { .modulo-manuale label, .modulo-manuale select, .modulo-manuale input { width: 100%; } }
