/* =========================================================
   CZ Cash Flow – stile (v1.5)
   Regole, prese dalle app di finanza migliori e dalle linee
   guida di Apple su Liquid Glass:
   - il contenuto (card, liste, numeri) sta su superfici PIENE;
   - il vetro è solo per la navigazione che galleggia sopra
     (barra in basso, barra in alto, finestre, avvisi);
   - un colore di marca (bronzo) usato poco: pulsante principale,
     sezione attiva, selezione. Verde e rosso solo per i soldi;
   - font di sistema (SF Pro su iPhone), cifre tabellari, gerarchia
     data da dimensione e peso, non da effetti.
   ========================================================= */
:root {
  color-scheme: light;
  --bg: #f2f0ed;
  --surface: #ffffff;
  --surface-2: #f4f2ef;
  --surface-3: #e8e4df;
  --surface-sticky: #ffffff;
  --bar: rgba(248, 246, 243, 0.78);
  --text: #141210;
  --text-2: rgba(20, 18, 16, 0.62);
  --muted: rgba(20, 18, 16, 0.42);
  --line: rgba(20, 18, 16, 0.08);
  --line-strong: rgba(20, 18, 16, 0.15);
  --accent: #8a5a2e;
  --accent-ink: #ffffff;
  --accent-soft: rgba(138, 90, 46, 0.1);
  --pos: #1e8a4c;
  --neg: #d0362c;
  --warn: #a86400;
  --warn-soft: rgba(240, 165, 58, 0.16);
  --neg-soft: rgba(208, 54, 44, 0.09);
  --pos-soft: rgba(30, 138, 76, 0.09);
  --shadow: 0 1px 2px rgba(20, 18, 16, 0.05);
  --overlay: rgba(20, 18, 16, 0.3);
  --radius: 16px;
  --radius-s: 12px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  /* Grafici */
  --s1: #8a5a2e; --s2: #1e8a4c; --s3: #d0362c; --s4: #c9a26b;
  --s5: #6f6a64; --s6: #6f8f3a; --s7: #d07a2c; --s8: #7a1f2b;
  --c-pos: #1e8a4c; --c-neg: #d0362c; --c-mute: rgba(20, 18, 16, 0.14);
  --grid: rgba(20, 18, 16, 0.06); --axis: rgba(20, 18, 16, 0.14);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0a09;
    --surface: #171513;
    --surface-2: #1f1c19;
    --surface-3: #2a2622;
    --surface-sticky: #171513;
    --bar: rgba(20, 18, 16, 0.72);
    --text: #f5f2ee;
    --text-2: rgba(245, 242, 238, 0.62);
    --muted: rgba(245, 242, 238, 0.4);
    --line: rgba(255, 255, 255, 0.07);
    --line-strong: rgba(255, 255, 255, 0.14);
    --accent: #d4a36a;
    --accent-ink: #1b1108;
    --accent-soft: rgba(212, 163, 106, 0.13);
    --pos: #34c77b;
    --neg: #ff6259;
    --warn: #f0a53a;
    --warn-soft: rgba(240, 165, 58, 0.13);
    --neg-soft: rgba(255, 98, 89, 0.12);
    --pos-soft: rgba(52, 199, 123, 0.12);
    --shadow: none;
    --overlay: rgba(0, 0, 0, 0.55);
    --s1: #d4a36a; --s2: #34c77b; --s3: #ff6259; --s4: #e9cfa6;
    --s5: #a8a29b; --s6: #9bbf5a; --s7: #f0964a; --s8: #c2485a;
    --c-pos: #34c77b; --c-neg: #ff6259; --c-mute: rgba(255, 255, 255, 0.12);
    --grid: rgba(255, 255, 255, 0.06); --axis: rgba(255, 255, 255, 0.12);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0a09;
  --surface: #171513;
  --surface-2: #1f1c19;
  --surface-3: #2a2622;
  --surface-sticky: #171513;
  --bar: rgba(20, 18, 16, 0.72);
  --text: #f5f2ee;
  --text-2: rgba(245, 242, 238, 0.62);
  --muted: rgba(245, 242, 238, 0.4);
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.14);
  --accent: #d4a36a;
  --accent-ink: #1b1108;
  --accent-soft: rgba(212, 163, 106, 0.13);
  --pos: #34c77b;
  --neg: #ff6259;
  --warn: #f0a53a;
  --warn-soft: rgba(240, 165, 58, 0.13);
  --neg-soft: rgba(255, 98, 89, 0.12);
  --pos-soft: rgba(52, 199, 123, 0.12);
  --shadow: none;
  --overlay: rgba(0, 0, 0, 0.55);
  --s1: #d4a36a; --s2: #34c77b; --s3: #ff6259; --s4: #e9cfa6;
  --s5: #a8a29b; --s6: #9bbf5a; --s7: #f0964a; --s8: #c2485a;
  --c-pos: #34c77b; --c-neg: #ff6259; --c-mute: rgba(255, 255, 255, 0.12);
  --grid: rgba(255, 255, 255, 0.06); --axis: rgba(255, 255, 255, 0.12);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI Variable Text", "Segoe UI", Roboto, sans-serif;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
svg { width: 20px; height: 20px; flex: 0 0 auto; }
button { cursor: pointer; }
[hidden] { display: none !important; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }
.num, td.n, .tab-nums { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.sfondo { display: none; }

/* Cifre grandi: euro interi grandi, decimali e simbolo più piccoli */
.cifra { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cifra .dec { font-size: 0.58em; font-weight: 600; letter-spacing: 0; margin-left: 1px; opacity: 0.85; }

/* ---------- Struttura ---------- */
.app {
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 30px);
}
/* Barra in alto: vetro (navigazione) */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(var(--safe-t) + 8px) 16px 8px;
  background: var(--bar);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 0.5px solid var(--line);
}
.topbar h1 { font-size: 22px; font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-logo { flex: 0 0 auto; display: grid; }
.topbar-logo img { width: 32px; height: 32px; border-radius: 8px; }
.view { padding: 12px 16px 24px; max-width: 1120px; margin: 0 auto; outline: none; }
.sidebar { display: none; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 0;
  display: inline-grid; place-items: center; flex: 0 0 auto;
  background: var(--surface-3); color: var(--text);
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn.plain { background: transparent; }
.sync-dot { position: relative; }
.sync-dot::after {
  content: ""; position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted); box-shadow: 0 0 0 2px var(--surface-3);
}
.sync-dot[data-stato="ok"]::after { background: var(--pos); }
.sync-dot[data-stato="attesa"]::after { background: var(--warn); }
.sync-dot[data-stato="errore"]::after { background: var(--neg); }
.sync-dot[data-stato="off"]::after { display: none; }

/* Selettore mese */
.month-switch { display: inline-flex; align-items: center; gap: 0; padding: 2px; border-radius: 999px; background: var(--surface-3); }
.month-switch button { border: 0; background: transparent; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: var(--text-2); }
.month-switch button svg { width: 17px; height: 17px; }
.month-switch .label { width: auto; min-width: 116px; text-align: center; font-weight: 600; font-size: 15px; background: transparent; border: 0; padding: 0 4px; white-space: nowrap; color: var(--text); }

/* Barra in basso: pillola di vetro sospesa (navigazione) */
.tabbar {
  position: fixed; z-index: 30;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-b) + 8px);
  width: min(520px, calc(100% - 24px));
  height: var(--tabbar-h);
  display: grid; grid-template-columns: repeat(5, 1fr); padding: 6px;
  border-radius: 32px;
  background: var(--bar);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  border: 0.5px solid var(--line-strong);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--text-2); text-decoration: none; font-size: 10px; font-weight: 600; border-radius: 26px;
}
.tabbar a svg { width: 23px; height: 23px; }
.tabbar a.on { color: var(--accent); background: var(--accent-soft); }

/* Pulsante "+" */
.fab {
  position: fixed; z-index: 31;
  right: 20px; bottom: calc(var(--tabbar-h) + var(--safe-b) + 20px);
  width: 56px; height: 56px; border-radius: 50%; border: 0;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  transition: transform 0.12s;
}
.fab:active { transform: scale(0.94); }
.fab svg { width: 26px; height: 26px; stroke-width: 2.2; }

/* ---------- Superfici e griglie ---------- */
.stack { display: grid; gap: 12px; }
.stack > *, .desk-2 > *, .desk-3 > *, .grid-2 > *, .grid-3 > *, .grid-4 > * { min-width: 0; }
.grid-2, .grid-3, .grid-4 { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.card, .kpi { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; position: relative; }
.card { padding: 16px; }
.card.tight { padding: 4px 0; }
.card.inset, .kpi.inset { background: var(--surface-2); box-shadow: none; }
.card-h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.card-h h2, .card-h h3 { font-size: 17px; font-weight: 650; display: flex; align-items: center; gap: 8px; letter-spacing: -0.015em; }
.card-h h3 svg { width: 18px; height: 18px; color: var(--text-2); }
.card-h .link { font-size: 15px; font-weight: 500; color: var(--accent); background: none; border: 0; padding: 4px 0; text-decoration: none; }
.card.tight .card-h { padding: 12px 16px 4px; }
.section-title { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.02em; margin: 14px 16px 2px; }
.muted { color: var(--muted); }
.t2 { color: var(--text-2); }
.small { font-size: 14px; }
.xs { font-size: 12.5px; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.right { text-align: right; }
.center { text-align: center; }
.row-flex { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* Numero principale di una sezione */
.hero { padding: 18px 16px 16px; }
.hero .label { font-size: 14px; color: var(--text-2); font-weight: 500; }
.hero .value { font-size: 40px; font-weight: 700; letter-spacing: -0.035em; line-height: 1.1; margin: 4px 0 6px; }
.hero .sub { font-size: 14px; color: var(--text-2); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.hero .value-row { display: flex; align-items: center; gap: 10px; }
.hero .value-row .value { min-width: 0; }
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hero-top .link { font-size: 15px; font-weight: 500; color: var(--accent); text-decoration: none; }

/* Patrimonio: saldo nascondibile, sezione protetta */
.eye-btn { width: 34px; height: 34px; border-radius: 50%; border: 0; flex: 0 0 auto; display: inline-grid; place-items: center; color: var(--text-2); background: var(--surface-3); }
.eye-btn svg { width: 18px; height: 18px; }
.oscurato { letter-spacing: 0.04em; cursor: pointer; color: var(--text-2); white-space: nowrap; }
.tastierino { display: grid; justify-items: center; gap: 18px; padding: 8px 0; }
.gate { display: grid; justify-items: center; gap: 10px; text-align: center; padding: 28px 16px; max-width: 440px; margin: 8px auto 0; }
.gate h2 { font-size: 22px; }
.gate-ic { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.gate-ic svg { width: 26px; height: 26px; }

/* Grafico del patrimonio con selezione del mese */
.pt-chart { position: relative; height: 170px; margin-top: 12px; }
.pt-legenda { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); margin-top: 8px; }
.pt-legenda i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.gruppo-h { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 16px 6px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.02em; }
.gruppo-h b { color: var(--text-2); font-weight: 600; text-transform: none; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.quota { height: 4px; border-radius: 99px; background: var(--surface-3); margin-top: 6px; overflow: hidden; }
.quota i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.prev-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.prev-strip div { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.prev-strip b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.prev-strip span { font-size: 12.5px; color: var(--text-2); }

/* Schedine */
.sel-card { display: grid; gap: 8px; padding: 10px; border-radius: 14px; background: var(--surface-2); }
.sel-card .input { min-height: 42px; padding: 8px 12px; background: var(--surface); }
.cerca { display: grid; gap: 8px; margin-top: 8px; }
.risultati { display: grid; gap: 0; max-height: 320px; overflow-y: auto; border-radius: 12px; background: var(--surface-2); }
.ris-h { padding: 10px 12px 4px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; }
.ris-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left; border: 0; border-top: 0.5px solid var(--line); background: transparent; padding: 10px 12px; }
.ris-item svg { color: var(--accent); }
.stake-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stake-grid .chip { display: grid; justify-items: center; gap: 0; padding: 6px 2px; border-radius: 10px; }
.stake-grid .chip b { font-size: 14px; font-weight: 600; }
.stake-grid .chip span { font-size: 11.5px; opacity: 0.8; }
.stake-grid .chip.usato:not(.on) { box-shadow: inset 0 0 0 1px var(--accent); }
.sch-aperta { border-top: 0.5px solid var(--line); }
.list > .sch-aperta:first-child { border-top: 0; }
.sch-aperta .item { border-top: 0; }
.sch-azioni { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 16px 12px 66px; }
.sch-azioni .btn { min-height: 38px; font-size: 14.5px; }
.sch-azioni .esito-v { background: var(--pos-soft); color: var(--pos); }
.sch-azioni .esito-p { background: var(--neg-soft); color: var(--neg); }
.sch-azioni .xs { font-weight: 500; opacity: 0.85; }

/* Flusso di cassa in Home */
.flusso { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 15px; }
.flusso td { padding: 10px 0; border-top: 0.5px solid var(--line); }
.flusso td.n { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.flusso td .xs { display: block; color: var(--text-2); }
.flusso tr:active { opacity: 0.6; }

/* KPI */
.kpi { padding: 12px 14px; }
.kpi .k { font-size: 13px; color: var(--text-2); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .v { font-size: 21px; font-weight: 650; margin-top: 2px; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.kpi .d { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.delta { font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 2px; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--pos); }
.delta.down { color: var(--neg); }
.delta.flat { color: var(--text-2); }

/* Liste (stile elenchi raggruppati iOS) */
.list { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-height: 56px;
  border: 0; border-top: 0.5px solid var(--line); width: 100%; background: none; text-align: left;
}
.list > li:first-child > .item, .list > .item:first-child { border-top: 0; }
button.item:active { background: var(--surface-2); }
.item .ic {
  width: 36px; height: 36px; border-radius: 10px; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
  background: var(--surface-3); color: var(--text-2);
}
.item .ic svg { width: 19px; height: 19px; }
.item .main { flex: 1; min-width: 0; }
.item .t { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .amt { font-weight: 600; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.item .amt .s { font-weight: 400; text-align: right; }
.item > svg:last-child { color: var(--muted); width: 16px; height: 16px; }
.empty { padding: 22px 16px; text-align: center; color: var(--muted); font-size: 15px; }
.day-h { padding: 14px 16px 4px; font-size: 13px; font-weight: 600; color: var(--muted); display: flex; justify-content: space-between; }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }

/* Etichette piccole: poche e sobrie */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 2px 7px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.neg { background: var(--neg-soft); color: var(--neg); }
.badge.pos { background: var(--pos-soft); color: var(--pos); }
.badge.acc { background: var(--accent-soft); color: var(--accent); }

/* Avvisi */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--text); }
.alert svg { width: 19px; height: 19px; flex: 0 0 auto; color: var(--warn); margin-top: 1px; }
.alert.info { background: var(--surface-2); }
.alert.info svg { color: var(--text-2); }
.alert .t { font-weight: 600; }
.alert .s { font-size: 14px; color: var(--text-2); }
.alert button { margin-top: 8px; }

/* "Da sistemare" */
.todo { display: flex; align-items: center; border-top: 0.5px solid var(--line); }
.todo:first-child { border-top: 0; }
.todo .item { border-top: 0; flex: 1; min-width: 0; min-height: 52px; }
.item .ic.warn { background: var(--warn-soft); color: var(--warn); }
.item .ic.info { background: var(--surface-3); color: var(--text-2); }
.todo-x { width: 36px; height: 36px; border: 0; background: none; color: var(--muted); display: grid; place-items: center; margin-right: 6px; flex: 0 0 auto; border-radius: 50%; }
.todo-x svg { width: 15px; height: 15px; }

/* Barre (budget) */
.bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.bar.warn > i { background: var(--warn); }
.bar.over > i { background: var(--neg); }

/* Barra divisa */
.split { display: flex; height: 8px; border-radius: 99px; overflow: hidden; gap: 2px; margin: 12px 0 8px; }
.split > i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* Pulsanti */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 46px; padding: 0 16px; border-radius: 12px; border: 0;
  background: var(--surface-3); color: var(--text); font-weight: 600; font-size: 16px;
  text-decoration: none; white-space: nowrap; transition: opacity 0.12s, transform 0.12s;
}
.btn:active { opacity: 0.7; }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--neg-soft); color: var(--neg); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 14.5px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.45; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* Chip / segmented */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; border: 0; background: var(--surface-3); color: var(--text);
  border-radius: 999px; padding: 7px 13px; font-size: 14.5px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px;
}
.chip.on { background: var(--text); color: var(--bg); }
.chip.on .dot { box-shadow: 0 0 0 1.5px var(--bg); }
.seg { display: flex; background: var(--surface-3); border-radius: 10px; padding: 2px; gap: 2px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 8px; padding: 7px 6px; font-weight: 500; font-size: 14px; color: var(--text); white-space: nowrap; }
.seg button.on { background: var(--surface); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

/* Form */
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .field > .lab { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12.5px; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 48px; padding: 11px 14px; border-radius: 12px;
  border: 0; background: var(--surface-2);
  font-size: 17px; /* evita lo zoom su iPhone */
  outline: none; -webkit-appearance: none; appearance: none;
}
.sheet .input, .sheet select.input { background: var(--surface-3); }
textarea.input { min-height: 80px; resize: vertical; }
select.input { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 21px, calc(100% - 15px) 21px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
select.input option { background: var(--surface); color: var(--text); }
.input:focus { box-shadow: 0 0 0 2px var(--accent); }
.input::placeholder { color: var(--muted); }
.input.big { font-size: 32px; font-weight: 700; min-height: 64px; text-align: center; letter-spacing: -0.02em; }
.input-euro { position: relative; }
.input-euro::before { content: "€"; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 500; pointer-events: none; }
.input-euro .input { padding-left: 32px; }
.input-euro.big::before { font-size: 22px; left: 18px; }
.input-pct { position: relative; }
.input-pct::after { content: "%"; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 500; pointer-events: none; }
.form-row { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.form-row.three { grid-template-columns: 1fr 1fr 1fr; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; min-height: 44px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }

/* Stepper ore */
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button { width: 52px; height: 52px; border-radius: 12px; border: 0; background: var(--surface-3); font-size: 24px; font-weight: 500; flex: 0 0 auto; }
.stepper button:active { opacity: 0.6; }
.stepper .input { text-align: center; font-size: 24px; font-weight: 650; }

/* Totale in fondo a un modulo */
.totale-box { border-radius: 14px; padding: 14px; text-align: center; background: var(--surface-2); }
.sheet .totale-box { background: var(--surface-3); }
.totale-box .v { font-size: 36px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.totale-box .s { font-size: 13.5px; color: var(--text-2); }

/* Tabelle */
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table.t { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.t th { text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 0.5px solid var(--line-strong); white-space: nowrap; }
table.t td { padding: 9px 10px; border-bottom: 0.5px solid var(--line); white-space: nowrap; }
table.t td.n, table.t th.n { text-align: right; font-variant-numeric: tabular-nums; }
table.t tr.tot td { font-weight: 650; border-bottom: 0; }
table.t tr.fut td { color: var(--text-2); }
table.t td.sticky, table.t th.sticky { position: sticky; left: 0; background: var(--surface-sticky); z-index: 1; }

/* Grafici */
.chart-box { position: relative; height: 220px; }
.chart-box.tall { height: 290px; }
.chart-box.short { height: 170px; }
.chart-empty { height: 100%; display: grid; place-items: center; color: var(--muted); font-size: 15px; }

/* Finestre: dal basso su telefono, al centro su PC (navigazione: vetro) */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 60; background: var(--overlay);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade 0.18s ease-out;
}
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  padding: 8px 18px calc(18px + var(--safe-b));
  animation: slide-up 0.26s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.sheet .grab { width: 36px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 4px auto 10px; }
.sheet-h { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.sheet-h h2 { font-size: 20px; font-weight: 700; flex: 1; }
.sheet-actions {
  display: flex; gap: 10px; margin-top: 18px; position: sticky; bottom: calc(-18px - var(--safe-b));
  padding: 12px 0 calc(6px + var(--safe-b)); margin-bottom: calc(-18px - var(--safe-b));
  background: var(--surface);
}
.sheet-actions .btn { flex: 1; }
@keyframes slide-up { from { transform: translateY(50px); opacity: 0.4; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* Menu "+" */
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quick-grid button { border: 0; border-radius: 14px; background: var(--surface-2); padding: 14px; text-align: left; display: grid; gap: 6px; min-height: 92px; }
.quick-grid button:active { opacity: 0.7; }
.quick-grid button svg { width: 24px; height: 24px; color: var(--accent); }
.quick-grid button b { font-size: 16px; font-weight: 600; }
.quick-grid button span { font-size: 13px; color: var(--text-2); }

/* Avviso in basso (navigazione: vetro) */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 90px); transform: translateX(-50%) translateY(20px);
  background: var(--bar); color: var(--text);
  -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%);
  border: 0.5px solid var(--line-strong); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  padding: 12px 16px; border-radius: 16px; font-weight: 500; font-size: 15px;
  opacity: 0; pointer-events: none; transition: 0.2s; z-index: 90; max-width: calc(100vw - 32px); display: flex; gap: 12px; align-items: center;
}
.toast.on { opacity: 1; transform: translateX(-50%); pointer-events: auto; }
.toast button { background: none; border: 0; color: var(--accent); font-weight: 600; padding: 0; }

/* Blocco */
.lock {
  position: fixed; inset: 0; z-index: 100; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  padding: calc(var(--safe-t) + 20px) 24px calc(var(--safe-b) + 20px);
}
.lock .logo { width: 72px; height: 72px; border-radius: 17px; }
.lock h2 { font-size: 20px; font-weight: 600; }
.pin-dots { display: flex; gap: 16px; height: 16px; }
.pin-dots i { width: 13px; height: 13px; border-radius: 50%; border: 1.5px solid var(--text); }
.pin-dots i.on { background: var(--text); }
.pin-dots.err { animation: shake 0.35s; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 16px 22px; }
.pin-pad button { width: 76px; height: 76px; border-radius: 50%; border: 0; background: var(--surface-3); font-size: 30px; font-weight: 400; display: grid; place-items: center; }
.pin-pad button:active { background: var(--line-strong); }
.pin-pad button.ghost { background: transparent; font-size: 15px; color: var(--accent); font-weight: 500; }
.pin-pad button svg { width: 26px; height: 26px; }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

pre.code { background: var(--surface-2); border-radius: 12px; padding: 12px; font-size: 12px; overflow-x: auto; white-space: pre; }
ol.steps { padding-left: 20px; margin: 0; display: grid; gap: 8px; font-size: 15px; }

* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
@media (hover: hover) {
  button.item:hover, a.item:hover { background: var(--surface-2); }
  .btn:hover { opacity: 0.88; }
  .chip:hover:not(.on) { background: var(--line-strong); }
  .quick-grid button:hover { background: var(--surface-3); }
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-transparency: reduce) {
  .topbar, .tabbar, .toast { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- Tablet e PC ---------- */
@media (min-width: 720px) {
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
  .view { padding: 16px 24px 32px; }
  .topbar { padding-left: 24px; padding-right: 24px; }
  .sheet-backdrop { align-items: center; padding: 20px; }
  .sheet { border-radius: 20px; padding-bottom: 18px; max-height: 88vh; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3); }
  .sheet .grab { display: none; }
  .sheet-actions { bottom: -18px; margin-bottom: -18px; padding-bottom: 12px; }
  .chart-box { height: 260px; }
  .chart-box.tall { height: 320px; }
  .pt-chart { height: 200px; }
  .hero .value { font-size: 44px; }
}
@media (min-width: 1024px) {
  .app { display: grid; grid-template-columns: 250px 1fr; grid-template-rows: auto 1fr; padding-bottom: 0; }
  .sidebar {
    display: flex; flex-direction: column; gap: 2px; grid-row: 1 / span 2;
    position: sticky; top: 0; height: 100vh; padding: 18px 12px;
    background: var(--surface); border-right: 0.5px solid var(--line);
  }
  .sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 600; font-size: 16px; }
  .sidebar .brand b { font-weight: 700; }
  .sidebar .brand img { width: 32px; height: 32px; border-radius: 8px; }
  .sidebar a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: var(--text); text-decoration: none; font-weight: 500; font-size: 15px; }
  .sidebar a svg { width: 19px; height: 19px; color: var(--text-2); }
  .sidebar a:hover { background: var(--surface-2); }
  .sidebar a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  .sidebar a.on svg { color: var(--accent); }
  .sidebar .sb-foot { margin-top: auto; display: grid; gap: 8px; }
  .topbar { grid-column: 2; padding-top: 14px; }
  .topbar-logo { display: none; }
  .view { grid-column: 2; width: 100%; }
  .tabbar { display: none; }
  .fab { bottom: 28px; right: 28px; }
  .toast { bottom: 32px; }
  .desk-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
  .desk-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; align-items: start; }
  .only-mobile { display: none !important; }
}
@media (max-width: 1023px) {
  .only-desk { display: none !important; }
}
@media (max-width: 520px) {
  .topbar.has-switch h1 { display: none; }
  .topbar.has-switch .month-switch { margin-right: auto; }
  .topbar { gap: 8px; }
  .month-switch .label { min-width: 104px; }
}
@media (max-width: 440px) {
  .topbar a.icon-btn[href="#report"] { display: none; }
}
@media (max-width: 350px) {
  .topbar-logo { display: none; }
  .card > table.t td { white-space: normal; }
}
@media (max-width: 380px) {
  .btn-row > .btn { padding: 0 8px; gap: 6px; font-size: 15px; }
  .hero .value { font-size: 34px; }
  .kpi .v { font-size: 18px; }
  .month-switch .label { min-width: 90px; font-size: 14px; }
  .pin-pad { grid-template-columns: repeat(3, 68px); }
  .pin-pad button { width: 68px; height: 68px; }
}
