/* ============================================================
   Numio — dashboard
   Register: product. Colore = semantica, mai decorazione.
   ============================================================ */

/* ── Transizione tra pagine ───────────────────────────────
   L'app è multi-pagina: ogni link carica un documento nuovo. Senza
   questo, fra una pagina e l'altra si vede il lampo bianco del
   ricaricamento — il "saltino". Con la View Transition il browser
   trattiene i pixel della pagina uscente e dissolve verso la nuova.
   Sidebar, topbar e barra inferiore hanno un nome stabile: restano
   ferme mentre solo il contenuto cambia, come in una vera app. */
@view-transition { navigation: auto; }

.sidebar    { view-transition-name: ff-sidebar; }
.topbar     { view-transition-name: ff-topbar; }
.shell-tabs { view-transition-name: ff-tabs; }

::view-transition-group(root)  { animation-duration: 180ms; }
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 180ms;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Chi ha chiesto meno movimento non deve vedere dissolvenze. */
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}

/* ── Tokens ─────────────────────────────────────────────── */
:root {
  --primary:        oklch(0.620 0.190 272);
  --primary-hover:  oklch(0.672 0.190 272);
  --primary-ink:    oklch(0.145 0.030 272);
  --primary-soft:   oklch(0.620 0.190 272 / 0.14);
  --primary-line:   oklch(0.620 0.190 272 / 0.34);

  --pos:      oklch(0.760 0.150 162);
  --pos-soft: oklch(0.760 0.150 162 / 0.14);
  --neg:      oklch(0.700 0.160 22);
  --neg-soft: oklch(0.700 0.160 22 / 0.14);
  /* --warn dipinge (anello, barre, punti); --warn-ink scrive.
     Sul chiaro i due valori divergono: l'ambra leggibile come testo
     è troppo scura per restare ambra come grafica. */
  --warn:     oklch(0.800 0.140 76);
  --warn-ink: oklch(0.800 0.140 76);
  --warn-soft:oklch(0.800 0.140 76 / 0.14);

  /* type */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --t-xs:   0.6875rem;  /* 11 */
  --t-sm:   0.75rem;    /* 12 */
  --t-base: 0.8125rem;  /* 13 */
  --t-md:   0.875rem;   /* 14 */
  --t-lg:   1rem;       /* 16 */
  --t-xl:   1.375rem;   /* 22 */
  --t-2xl:  1.75rem;    /* 28 */
  --t-3xl:  2.5rem;     /* 40 */

  /* space */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-7: 32px; --s-8: 40px;

  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 20px;

  --sidebar-w: 264px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);          /* out-quart */
  --ease-soft: cubic-bezier(0.33, 1, 0.68, 1);
  --dur: 200ms;

  --z-sticky: 100;
  --z-tooltip: 400;
}

/* dark = default */
:root, [data-theme="dark"] {
  --bg:        oklch(0.118 0.008 272);
  --surface:   oklch(0.158 0.010 272);
  --surface-2: oklch(0.205 0.012 272);
  --surface-3: oklch(0.250 0.013 272);
  --sidebar:   oklch(0.098 0.007 272);
  --ink:       oklch(0.970 0.004 272);
  --ink-2:     oklch(0.780 0.010 272);
  --muted:     oklch(0.640 0.012 272);
  --rule:      oklch(0.265 0.010 272);
  --rule-soft: oklch(0.225 0.010 272);
  --shadow:    0 1px 2px oklch(0 0 0 / 0.4), 0 8px 24px -12px oklch(0 0 0 / 0.5);
  --shadow-lg: 0 24px 60px -20px oklch(0 0 0 / 0.7);
  --grid-line: oklch(1 0 0 / 0.055);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg:        oklch(0.968 0.009 272);
  --surface:   oklch(1 0 0);
  --surface-2: oklch(0.972 0.007 272);
  --surface-3: oklch(0.945 0.010 272);
  --sidebar:   oklch(0.988 0.005 272);
  --ink:       oklch(0.215 0.020 272);
  --ink-2:     oklch(0.380 0.018 272);
  --muted:     oklch(0.475 0.020 272);
  --rule:      oklch(0.905 0.008 272);
  --rule-soft: oklch(0.938 0.007 272);
  --shadow:    0 1px 2px oklch(0.30 0.03 272 / 0.05), 0 10px 24px -14px oklch(0.30 0.05 272 / 0.16);
  --shadow-lg: 0 24px 60px -20px oklch(0.30 0.05 272 / 0.22);
  --grid-line: oklch(0.30 0.03 272 / 0.07);

  /* 0.545 portava la voce di menu attiva a 4,42:1 sul proprio sfondo
     tinto, sotto il minimo. Scurirlo alza anche il contrasto del testo
     bianco sui pulsanti pieni. */
  --primary:       oklch(0.505 0.205 272);
  --primary-hover: oklch(0.455 0.205 272);
  --primary-ink:   oklch(1 0 0);
  --primary-soft:  oklch(0.545 0.205 272 / 0.10);
  --primary-line:  oklch(0.545 0.205 272 / 0.28);

  /* Sul verde tenue dei badge il testo a 0.545 restava a 3,83:1;
     0.485 arrivava a 4,44 sulla pastiglia mobile, ancora sotto. */
  --pos:      oklch(0.455 0.140 162);
  --pos-soft: oklch(0.545 0.140 162 / 0.12);
  /* Su fondo rosso tenue il testo a 0.560 restava a 4,36:1. */
  --neg:      oklch(0.505 0.185 22);
  --neg-soft: oklch(0.560 0.180 22 / 0.11);
  --warn:     oklch(0.720 0.150 68);
  --warn-ink: oklch(0.480 0.125 60);   /* sull'ambra tenue 0.545 dava 4,33:1 */
  --warn-soft:oklch(0.660 0.145 66 / 0.16);
  color-scheme: light;
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; }

/* `display` dichiarato su una classe batte il `display:none` che lo user
   agent applica a [hidden]: senza questa regola nascondere un .btn o una
   .card non funziona. */
[hidden] { display: none !important; }

body {
  font-family: var(--font);
  font-size: var(--t-base);
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 260ms var(--ease), color 260ms var(--ease);
}

h1, h2, h3 { font-size: inherit; font-weight: 600; line-height: 1.25; text-wrap: balance; }
button, input { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; padding: 0; }

/* Cifre tabulari ovunque compaia un numero. */
.num, input[type="search"], table {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

.ico {
  width: 18px; height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Shell ──────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
  padding: var(--s-5) var(--s-4);
  background: var(--sidebar);
  border-right: 1px solid var(--rule-soft);
  transition: background-color 260ms var(--ease), border-color 260ms var(--ease);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: var(--s-2) var(--s-2) var(--s-1);
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: 9px;
  background: var(--primary);
  color: var(--primary-ink);
  box-shadow: 0 4px 14px -4px var(--primary-line);
}
.brand-mark svg { width: 26px; height: 26px; }
.brand-name { font-weight: 600; font-size: var(--t-lg); letter-spacing: -0.02em; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-label {
  font-size: var(--t-xs);
  font-weight: 600;
  color: var(--muted);
  padding: var(--s-4) var(--s-3) var(--s-2);
}
.nav-label:first-child { padding-top: var(--s-2); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px var(--s-3);
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-weight: 500;
  transition: background-color 140ms var(--ease), color 140ms var(--ease);
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item .ico { width: 17px; height: 17px; opacity: 0.75; }
.nav-item.is-active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}
[data-theme="dark"] .nav-item.is-active { color: oklch(0.82 0.12 272); }
.nav-item.is-active .ico { opacity: 1; }

.nav-tag {
  margin-left: auto;
  font-size: var(--t-xs);
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 20px;
  padding: 1px 7px;
}
.nav-dot {
  margin-left: auto;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--warn);
}

.sidebar-foot { display: flex; flex-direction: column; gap: var(--s-3); }

.regime {
  border: 1px solid var(--rule-soft);
  border-radius: var(--r-md);
  padding: var(--s-3);
  background: var(--surface);
}
.regime-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-2); }
.regime-badge {
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 6px;
  padding: 3px 8px;
}
[data-theme="dark"] .regime-badge { color: oklch(0.82 0.12 272); }
.regime-line {
  display: flex; justify-content: space-between;
  font-size: var(--t-sm);
  color: var(--muted);
  padding: 2px 0;
}
.regime-line b { color: var(--ink-2); font-weight: 600; }

.theme-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--rule-soft);
}
.theme-opt {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px;
  border-radius: 7px;
  font-size: var(--t-sm);
  font-weight: 500;
  color: var(--muted);
  transition: background-color 160ms var(--ease), color 160ms var(--ease);
}
.theme-opt .ico { width: 14px; height: 14px; }
.theme-opt i { font-style: normal; }
[data-theme="dark"] .theme-opt[data-theme-opt="dark"],
[data-theme="light"] .theme-opt[data-theme-opt="light"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

/* ── Main / topbar ──────────────────────────────────────── */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-5);
  padding: var(--s-5) var(--s-7);
  background: color-mix(in oklab, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--rule-soft);
}
.topbar-lead h1 { font-size: var(--t-xl); letter-spacing: -0.022em; }
.topbar-lead p { font-size: var(--t-base); color: var(--muted); margin-top: 2px; }
.topbar-lead p b { color: var(--warn-ink); font-weight: 600; }

.topbar-tools { display: flex; align-items: center; gap: var(--s-2); }

.search {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  width: clamp(200px, 26vw, 340px);
  padding: 0 10px;
  height: 38px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--rule-soft);
  color: var(--muted);
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}
.search:focus-within { border-color: var(--primary-line); box-shadow: 0 0 0 3px var(--primary-soft); }
.search input {
  flex: 1; min-width: 0;
  background: none; border: 0; outline: none;
  color: var(--ink);
  font-size: var(--t-base);
}
.search input::placeholder { color: var(--muted); }
.search kbd {
  font: 500 var(--t-xs)/1 var(--font);
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--rule-soft);
  border-radius: 5px;
  padding: 4px 5px;
}

.icon-btn {
  position: relative;
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--rule-soft);
  color: var(--ink-2);
  transition: background-color 160ms var(--ease), color 160ms var(--ease), border-color 160ms var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn-sm {
  width: 24px; height: 24px;
  border: 0; background: none;
  color: var(--muted);
  border-radius: 6px;
}
.icon-btn-sm .ico { width: 15px; height: 15px; }
.icon-btn-sm:hover { background: var(--surface-2); color: var(--ink); }
.badge-dot {
  position: absolute; top: 8px; right: 9px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--neg);
  border: 2px solid var(--surface);
}

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: var(--t-base);
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 160ms var(--ease), transform 160ms var(--ease), box-shadow 160ms var(--ease);
}
.btn .ico { width: 16px; height: 16px; stroke-width: 2; }
.btn-primary {
  background: var(--primary);
  color: var(--primary-ink);
  box-shadow: 0 6px 18px -8px var(--primary-line);
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: translateY(1px); }

.avatar {
  display: grid; place-items: center;
  position: relative;
  width: 38px; height: 38px;
  border-radius: 50%;
  overflow: hidden;
  font-size: var(--t-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--primary-ink);
  background: var(--primary);
  transition: box-shadow 160ms var(--ease);
}
.avatar:hover { box-shadow: 0 0 0 3px var(--primary-soft); }

/* ── Content grid ───────────────────────────────────────── */
.content {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  padding: var(--s-6) var(--s-7) var(--s-8);
}

.row { display: grid; gap: var(--s-4); }
.row-metrics { grid-template-columns: 1.55fr 1fr 1fr 1fr; }
.row-main    { grid-template-columns: minmax(0, 1.85fr) minmax(0, 1fr); }
.row-triple  { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row-bottom  { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }

.col-stack { display: flex; flex-direction: column; gap: var(--s-4); }
/* L'ultima card riempie la colonna: il bordo inferiore della riga resta dritto. */
.col-stack > .card:last-child { flex: 1; }

/* ── Card ───────────────────────────────────────────────── */
.card {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-5);
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--rule-soft);
  box-shadow: var(--shadow);
  transition: background-color 260ms var(--ease), border-color 260ms var(--ease);
}

.card-head { display: flex; align-items: center; gap: var(--s-2); }
.card-head-split { justify-content: space-between; align-items: flex-start; }
.card-head h2 { font-size: var(--t-md); letter-spacing: -0.01em; }
.card-sub { font-size: var(--t-sm); color: var(--muted); margin-top: 2px; }

.card-foot {
  margin-top: auto;
  padding-top: var(--s-3);
  border-top: 1px solid var(--rule-soft);
  font-size: var(--t-sm);
  color: var(--muted);
}
.card-foot b { color: var(--ink-2); }

.link {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--t-sm);
  font-weight: 500;
  color: var(--muted);
  transition: color 160ms var(--ease);
}
.link .ico { width: 14px; height: 14px; transition: transform 200ms var(--ease); }
.link:hover { color: var(--primary); }
[data-theme="dark"] .link:hover { color: oklch(0.82 0.12 272); }
.link:hover .ico { transform: translateX(2px); }

.pill {
  font-size: var(--t-xs);
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
}
.pill-warn { color: var(--warn-ink); background: var(--warn-soft); }
.pill-neg  { color: var(--neg);  background: var(--neg-soft); }

/* ── Metriche ───────────────────────────────────────────── */
.metric-value {
  font-size: var(--t-2xl);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.1;
  white-space: nowrap;   /* un importo non va mai spezzato su due righe */
}
.metric-value small { font-size: var(--t-md); font-weight: 500; color: var(--muted); letter-spacing: 0; }

.metric-delta {
  display: flex; align-items: center; gap: 5px;
  font-size: var(--t-sm);
  color: var(--muted);
  white-space: nowrap;
}
.metric-delta .ico { width: 13px; height: 13px; stroke-width: 2.4; }
.metric-delta span { font-weight: 600; }
.metric-delta.is-pos { color: var(--muted); }
.metric-delta.is-pos span, .metric-delta.is-pos .ico { color: var(--pos); }
.metric-delta.is-neg span, .metric-delta.is-neg .ico { color: var(--neg); }

.metric-foot { font-size: var(--t-sm); color: var(--muted); margin-top: auto; }
.metric-foot b { color: var(--ink-2); font-weight: 600; }

.is-pos { color: var(--pos); }
.is-neg { color: var(--neg); }
.is-warn { color: var(--warn-ink); }

/* hero */
.card-hero { gap: var(--s-4); }
.hero-body { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); }
.hero-figure .metric-value { font-size: var(--t-3xl); }
.hero-figure .metric-delta { margin-top: 6px; }
.hero-spark { width: 148px; height: 52px; flex: none; }
.spark { width: 100%; height: 100%; overflow: visible; }
/* Stato di riposo = visibile. L'animazione parte da nascosto, non ci
   arriva: se non scatta mai, il grafico si vede lo stesso. */
.spark-line { stroke-dasharray: var(--len, 400); stroke-dashoffset: 0; animation: draw 1000ms var(--ease); }
.spark-area { animation: fade 700ms var(--ease); }

.hero-breakdown {
  display: flex; align-items: center; gap: var(--s-4);
  margin-top: auto;
  padding-top: var(--s-4);
  border-top: 1px solid var(--rule-soft);
}
.bd-item { display: flex; flex-direction: column; gap: 1px; }
.bd-item span { font-size: var(--t-sm); color: var(--muted); }
.bd-item b { font-size: var(--t-lg); font-weight: 600; letter-spacing: -0.02em; }
.bd-op { font-size: var(--t-lg); color: var(--muted); }

/* soglia 85k */
.threshold { margin-top: auto; display: flex; flex-direction: column; gap: 7px; }
.threshold-bar { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.threshold-fill {
  display: block; height: 100%;
  width: var(--pct);
  border-radius: 3px;
  background: var(--warn);
  transform-origin: left;
  animation: grow 900ms var(--ease);
}
.threshold-note { font-size: var(--t-sm); color: var(--muted); }
.threshold-note b { color: var(--ink-2); }

/* ── Grafico ────────────────────────────────────────────── */
.card-chart { gap: var(--s-4); }
.seg {
  display: flex; gap: 2px;
  padding: 3px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--rule-soft);
}
.seg-btn {
  padding: 5px 11px;
  border-radius: 6px;
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--muted);
  transition: background-color 160ms var(--ease), color 160ms var(--ease);
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.chart-legend { display: flex; gap: var(--s-4); }
.lg {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--t-sm);
  color: var(--muted);
}
.lg::before { content: ""; width: 8px; height: 8px; border-radius: 3px; }
.lg-primary::before { background: var(--primary); }
.lg-pos::before { background: var(--pos); }
.lg-neg::before { background: var(--neg); }

.chart { position: relative; height: 268px; }
.chart-svg { display: block; width: 100%; height: 100%; overflow: visible; }

.chart-tip {
  position: absolute;
  top: 0; left: 0;
  min-width: 168px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  z-index: 5;
  transition: opacity 140ms var(--ease);
}
.chart-tip[hidden] { display: none; }
.tip-date { font-size: var(--t-sm); font-weight: 600; margin-bottom: 6px; }
.tip-row {
  display: flex; align-items: center; gap: 7px;
  font-size: var(--t-sm);
  color: var(--muted);
  padding: 1px 0;
}
.tip-row b { margin-left: auto; color: var(--ink); font-weight: 600; }
.dot { width: 7px; height: 7px; border-radius: 2px; flex: none; }
.dot-primary { background: var(--primary); }
.dot-pos { background: var(--pos); }
.dot-neg { background: var(--neg); }

/* ── Accantonamento tasse ───────────────────────────────── */
.card-tax { gap: var(--s-4); }
.ring-wrap { position: relative; display: grid; place-items: center; padding: var(--s-2) 0; }
.ring { width: 168px; height: 168px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 12; stroke-linecap: round; }
.ring-track { stroke: var(--surface-3); }
.ring-fill {
  stroke: var(--warn);
  stroke-dasharray: 377;
  stroke-dashoffset: calc(377 - 377 * var(--pct) / 100);
  animation: ring 1100ms var(--ease);
}
@keyframes ring { from { stroke-dashoffset: 377; } }

.ring-center {
  position: absolute;
  text-align: center;
}
.ring-pct { font-size: var(--t-2xl); font-weight: 600; letter-spacing: -0.03em; }
.ring-label { font-size: var(--t-sm); color: var(--muted); }

.tax-figures {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: var(--s-3);
  padding: var(--s-3) 0;
  border-block: 1px solid var(--rule-soft);
}
.tax-figures div { display: flex; flex-direction: column; gap: 2px; }
.tax-figures span { font-size: var(--t-sm); color: var(--muted); }
.tax-figures b { font-size: var(--t-lg); font-weight: 600; letter-spacing: -0.02em; }

.tax-breakdown { display: flex; flex-direction: column; gap: var(--s-2); }
.tax-breakdown li { display: flex; justify-content: space-between; gap: var(--s-3); font-size: var(--t-base); color: var(--muted); }
.tax-breakdown small { font-size: var(--t-xs); opacity: 0.7; }
.tax-breakdown b { color: var(--ink-2); font-weight: 600; }
.tax-breakdown .is-total { padding-top: var(--s-2); border-top: 1px solid var(--rule-soft); color: var(--ink-2); font-weight: 600; }
.tax-breakdown .is-total b { color: var(--ink); }

.disclaimer {
  display: flex; gap: 7px;
  font-size: var(--t-xs);
  line-height: 1.45;
  color: var(--muted);
}
.disclaimer .ico { width: 14px; height: 14px; margin-top: 1px; }

/* ── Movimenti ──────────────────────────────────────────── */
.tx { display: flex; flex-direction: column; }
.tx-row {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 10px var(--s-2);
  margin-inline: calc(var(--s-2) * -1);
  border-radius: var(--r-sm);
  transition: background-color 140ms var(--ease);
}
.tx-row:hover { background: var(--surface-2); }
.tx-row + .tx-row { box-shadow: inset 0 1px 0 var(--rule-soft); }

.tx-logo {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  flex: none;
  border-radius: 10px;
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: 0.02em;
  background: var(--surface-3);
  color: var(--ink-2);
}
/* Il colore della sigla deriva dal nome (hash → seed), così ogni
   controparte resta riconoscibile senza mappare marchi a mano. */
.tx-logo[data-seed], .who-mark[data-seed] { background: var(--seed-bg); color: var(--seed-ink); }
[data-seed="0"] { --seed-bg: oklch(0.62 0.17 272 / 0.16); --seed-ink: oklch(0.76 0.14 272); }
[data-seed="1"] { --seed-bg: oklch(0.72 0.15 60 / 0.16);  --seed-ink: oklch(0.79 0.13 60); }
[data-seed="2"] { --seed-bg: oklch(0.62 0.16 250 / 0.16); --seed-ink: oklch(0.76 0.13 250); }
[data-seed="3"] { --seed-bg: oklch(0.62 0.19 20 / 0.16);  --seed-ink: oklch(0.76 0.15 20); }
[data-seed="4"] { --seed-bg: oklch(0.66 0.14 175 / 0.16); --seed-ink: oklch(0.78 0.12 175); }
[data-seed="5"] { --seed-bg: oklch(0.66 0.16 320 / 0.16); --seed-ink: oklch(0.78 0.13 320); }
[data-theme="light"] [data-seed="0"] { --seed-ink: oklch(0.48 0.19 272); }
[data-theme="light"] [data-seed="1"] { --seed-ink: oklch(0.50 0.13 60); }
[data-theme="light"] [data-seed="2"] { --seed-ink: oklch(0.48 0.16 250); }
[data-theme="light"] [data-seed="3"] { --seed-ink: oklch(0.50 0.19 20); }
[data-theme="light"] [data-seed="4"] { --seed-ink: oklch(0.45 0.12 175); }
[data-theme="light"] [data-seed="5"] { --seed-ink: oklch(0.49 0.17 320); }

.tx-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.tx-body b { font-weight: 600; font-size: var(--t-base); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-body small { font-size: var(--t-sm); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-amt { font-size: var(--t-base); font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.tx-amt.is-pos { color: var(--pos); }

/* ── AI ─────────────────────────────────────────────────── */
.ai-more[hidden] { display: none; }
.ai-more .ico { width: 14px; height: 14px; }
.ai-title { display: flex; gap: 10px; align-items: flex-start; }
.ai-mark {
  display: grid; place-items: center;
  width: 30px; height: 30px;
  flex: none;
  border-radius: 9px;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid var(--primary-line);
}
[data-theme="dark"] .ai-mark { color: oklch(0.82 0.12 272); }
.ai-mark .ico { width: 16px; height: 16px; stroke-width: 1.5; }

.tabs {
  display: flex;
  gap: var(--s-1);
  padding-bottom: var(--s-2);
  border-bottom: 1px solid var(--rule-soft);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 9px;
  border-radius: 7px;
  font-size: var(--t-sm);
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}
.tab:hover { background: var(--surface-2); color: var(--ink); }
.tab.is-active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
[data-theme="dark"] .tab.is-active { color: oklch(0.82 0.12 272); }
.tab-n {
  font-size: var(--t-xs);
  font-weight: 600;
  padding: 0 5px;
  border-radius: 20px;
  background: var(--surface-3);
  color: var(--muted);
}
.tab.is-active .tab-n { background: var(--primary-soft); color: inherit; }

.ai-list { display: flex; flex-direction: column; }
.ai-item {
  display: flex; gap: 10px;
  padding: 11px var(--s-2);
  margin-inline: calc(var(--s-2) * -1);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background-color 140ms var(--ease);
  animation: rise 320ms var(--ease);
}
.ai-item:hover { background: var(--surface-2); }
.ai-item + .ai-item { box-shadow: inset 0 1px 0 var(--rule-soft); }
/* Riflettore: un consiglio alla volta si accende, a turno — la card
   sembra viva anche senza toccarla. */
.ai-item.is-live { background: linear-gradient(135deg, var(--primary-soft), transparent 60%), var(--surface);
  box-shadow: inset 0 0 0 1px var(--primary-line), 0 10px 26px -16px var(--primary); }
.ai-item.is-live + .ai-item { box-shadow: none; }

.ai-ico {
  display: grid; place-items: center;
  width: 26px; height: 26px;
  flex: none;
  border-radius: 8px;
  margin-top: 1px;
}
.ai-ico .ico { width: 14px; height: 14px; }
.ai-ico[data-kind="warn"] { background: var(--warn-soft); color: var(--warn-ink); }
.ai-ico[data-kind="neg"]  { background: var(--neg-soft);  color: var(--neg); }
.ai-ico[data-kind="pos"]  { background: var(--pos-soft);  color: var(--pos); }
.ai-ico[data-kind="info"] { background: var(--primary-soft); color: var(--primary); }
[data-theme="dark"] .ai-ico[data-kind="info"] { color: oklch(0.82 0.12 272); }

.ai-text { min-width: 0; flex: 1; }
.ai-text b { display: block; font-size: var(--t-base); font-weight: 600; margin-bottom: 2px; text-wrap: pretty; }
.ai-text p { font-size: var(--t-sm); color: var(--muted); line-height: 1.45; text-wrap: pretty; }
.ai-act {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 7px;
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--primary);
}
[data-theme="dark"] .ai-act { color: oklch(0.82 0.12 272); }
.ai-act .ico { width: 13px; height: 13px; transition: transform 200ms var(--ease); }
.ai-item:hover .ai-act .ico { transform: translateX(3px); }

/* ── Scadenze ───────────────────────────────────────────── */
.due { display: flex; flex-direction: column; }
.due-row {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 10px var(--s-2);
  margin-inline: calc(var(--s-2) * -1);
  border-radius: var(--r-sm);
  transition: background-color 140ms var(--ease), opacity 220ms var(--ease);
}
.due-row:hover { background: var(--surface-2); }
.due-row + .due-row { box-shadow: inset 0 1px 0 var(--rule-soft); }
.due-row.is-done { opacity: 0.5; }
.due-row.is-done .due-body b { text-decoration: line-through; text-decoration-thickness: 1px; }

.check { position: relative; display: grid; place-items: center; flex: none; cursor: pointer; }
.check input { position: absolute; opacity: 0; width: 20px; height: 20px; margin: 0; cursor: pointer; }
.check-box {
  display: grid; place-items: center;
  width: 20px; height: 20px;
  border-radius: 6px;
  border: 1.5px solid var(--rule);
  color: transparent;
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease), color 160ms var(--ease);
}
.check-box .ico { width: 13px; height: 13px; stroke-width: 2.6; }
.check input:hover + .check-box { border-color: var(--primary-line); }
.check input:focus-visible + .check-box { outline: 2px solid var(--primary); outline-offset: 2px; }
.check input:checked + .check-box { background: var(--pos); border-color: var(--pos); color: var(--bg); }
[data-theme="light"] .check input:checked + .check-box { color: #fff; }

.due-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.due-body b { font-size: var(--t-base); font-weight: 600; }
.due-body small { font-size: var(--t-sm); color: var(--muted); }
.due-flag { font-style: normal; color: var(--warn-ink); font-weight: 600; }
.due-flag.is-late { color: var(--neg); }
.due-amt { font-size: var(--t-base); font-weight: 600; color: var(--ink-2); white-space: nowrap; }

.due-row.is-urgent:not(.is-done) .due-amt { color: var(--warn-ink); }
.due-row.is-late:not(.is-done) .due-amt { color: var(--neg); }

/* ── Abbonamenti ────────────────────────────────────────── */
.subs { display: flex; flex-direction: column; }
.subs li {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 9px var(--s-2);
  margin-inline: calc(var(--s-2) * -1);
  border-radius: var(--r-sm);
  font-weight: 600;
  color: var(--ink-2);
  transition: background-color 140ms var(--ease);
}
.subs li:hover { background: var(--surface-2); }
.subs li + li { box-shadow: inset 0 1px 0 var(--rule-soft); }
.subs .tx-logo { width: 30px; height: 30px; border-radius: 9px; }
.idle-flag { color: var(--warn-ink); font-weight: 500; }

/* ── Clienti ────────────────────────────────────────────── */
.clients { display: flex; flex-direction: column; gap: var(--s-3); margin-top: var(--s-1); }
.clients li {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr) 42px 82px;
  align-items: center;
  gap: var(--s-3);
  font-size: var(--t-base);
}
.cl-name { color: var(--ink-2); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cl-bar { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.cl-bar i {
  display: block; height: 100%;
  width: var(--pct);
  border-radius: 4px;
  background: var(--primary);
  transform-origin: left;
  animation: grow 900ms var(--ease);
}
.cl-bar i.is-risk { background: var(--warn); }
.cl-val { font-weight: 600; text-align: right; }
.cl-eur { color: var(--muted); text-align: right; }

/* ── Previsione ─────────────────────────────────────────── */
.card-forecast { gap: var(--s-4); }
.forecast-fig .metric-value { color: var(--warn-ink); }
.fc-scale { display: flex; flex-direction: column; gap: 7px; }
.fc-track { position: relative; height: 10px; border-radius: 5px; background: var(--surface-3); overflow: hidden; }
.fc-actual, .fc-proj {
  position: absolute; inset-block: 0; left: 0;
  width: var(--pct);
  border-radius: 5px;
  transform-origin: left;
  animation: grow 900ms var(--ease);
}
.fc-proj { background: var(--warn-soft); }
.fc-actual { background: var(--primary); z-index: 1; }
.fc-limit {
  position: absolute; inset-block: -3px;
  left: var(--pct);
  width: 2px;
  border-radius: 1px;
  background: var(--ink);
  z-index: 2;
}
.fc-marks { display: flex; justify-content: space-between; font-size: var(--t-sm); color: var(--muted); }
.fc-limit-mark { color: var(--ink-2); font-weight: 600; }
.forecast-note { font-size: var(--t-sm); color: var(--muted); line-height: 1.5; text-wrap: pretty; margin-top: auto; }

.page-disclaimer {
  font-size: var(--t-sm);
  color: var(--muted);
  text-align: center;
  max-width: 70ch;
  margin: var(--s-3) auto 0;
  text-wrap: pretty;
}

/* ═══════════════════════════════════════════════════════════
   Pagine movimenti — Entrate / Uscite
   ═══════════════════════════════════════════════════════════ */

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

.row-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* ── Controlli ──────────────────────────────────────────── */
.btn-ghost {
  background: var(--surface-2);
  border: 1px solid var(--rule-soft);
  color: var(--ink-2);
}
.btn-ghost:hover { background: var(--surface-3); color: var(--ink); }

.select {
  height: 38px;
  padding: 0 30px 0 11px;
  border-radius: 10px;
  background: var(--surface) no-repeat right 10px center;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-size: 5px 5px, 5px 5px;
  background-position: right 14px center, right 9px center;
  border: 1px solid var(--rule-soft);
  color: var(--ink);
  font-size: var(--t-base);
  font-weight: 500;
  appearance: none;
  cursor: pointer;
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}
.select:hover { border-color: var(--rule); }
.select:focus-visible { border-color: var(--primary-line); box-shadow: 0 0 0 3px var(--primary-soft); outline: none; }

/* ── Barra filtri ───────────────────────────────────────── */
.card-table { gap: var(--s-4); padding: var(--s-5) var(--s-5) var(--s-4); }

.filters { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.search-inline { flex: 1 1 240px; min-width: 200px; }

/* ── Tabella ────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin-inline: calc(var(--s-5) * -1); padding-inline: var(--s-5); }
.table-wrap[hidden] { display: none; }

.table { width: 100%; border-collapse: collapse; font-size: var(--t-base); }

.table th {
  text-align: left;
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--muted);
  padding: 0 var(--s-3) var(--s-2);
  white-space: nowrap;
  border-bottom: 1px solid var(--rule-soft);
}
.table th:first-child { padding-left: var(--s-2); }
.table th:last-child  { padding-right: var(--s-2); }
.th-right { text-align: right; }

.th-sort { cursor: pointer; user-select: none; transition: color 140ms var(--ease); }
.th-sort:hover { color: var(--ink); }
.th-sort::after {
  content: "";
  display: inline-block;
  width: 0; height: 0;
  margin-left: 5px;
  vertical-align: middle;
  border-inline: 3.5px solid transparent;
  opacity: 0;
  transition: opacity 140ms var(--ease);
}
.th-sort[data-dir="asc"]::after  { border-bottom: 5px solid currentColor; opacity: 1; }
.th-sort[data-dir="desc"]::after { border-top: 5px solid currentColor; opacity: 1; }
.th-sort.is-sorted { color: var(--ink); }

.table td {
  padding: 11px var(--s-3);
  border-bottom: 1px solid var(--rule-soft);
  vertical-align: middle;
}
.table td:first-child { padding-left: var(--s-2); }
.table td:last-child  { padding-right: var(--s-2); }
.table tbody tr { transition: background-color 140ms var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }

.td-date { color: var(--muted); white-space: nowrap; }
.td-inv  { color: var(--muted); white-space: nowrap; }
.td-acc  { color: var(--muted); white-space: nowrap; }
.td-muted { color: var(--muted); }
.td-amt  { text-align: right; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.td-amt.is-pos { color: var(--pos); }

/* Il flex sta su un wrapper interno: applicarlo alla cella romperebbe
   l'allineamento verticale della riga. */
.td-who { min-width: 190px; }
.who-wrap { display: flex; align-items: center; gap: 10px; }
.who-mark {
  display: grid; place-items: center;
  width: 30px; height: 30px;
  flex: none;
  border-radius: 9px;
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: 0.02em;
}
.who-text { display: flex; flex-direction: column; min-width: 0; }
.who-text b { font-weight: 600; }
.who-text small { font-size: var(--t-sm); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.td-act { text-align: right; white-space: nowrap; }
.td-act .icon-btn { opacity: 0; transition: opacity 140ms var(--ease); }
.table tbody tr:hover .td-act .icon-btn,
.td-act .icon-btn:focus-visible { opacity: 1; }
@media (hover: none) { .td-act .icon-btn { opacity: 1; } }

.chip {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: var(--t-sm);
  font-weight: 500;
  color: var(--ink-2);
  background: var(--surface-2);
  white-space: nowrap;
}

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: var(--t-xs);
  font-weight: 600;
  white-space: nowrap;
}
.badge .ico { width: 12px; height: 12px; }
.badge-ok   { color: var(--pos);      background: var(--pos-soft); }
.badge-wait { color: var(--warn-ink); background: var(--warn-soft); }
.badge-rec  { color: var(--primary);  background: var(--primary-soft); }
[data-theme="dark"] .badge-rec { color: oklch(0.82 0.12 272); }

.pill-pos { color: var(--pos); background: var(--pos-soft); }

/* ── Stato vuoto ────────────────────────────────────────── */
.empty {
  display: flex; flex-direction: column; align-items: center;
  gap: var(--s-3);
  padding: var(--s-8) var(--s-5);
  text-align: center;
}
.empty[hidden] { display: none; }
.empty-mark {
  display: grid; place-items: center;
  width: 46px; height: 46px;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--muted);
}
.empty-mark .ico { width: 22px; height: 22px; }
.empty h3 { font-size: var(--t-lg); }
.empty p { font-size: var(--t-base); color: var(--muted); max-width: 46ch; text-wrap: pretty; }
.empty .btn { margin-top: var(--s-1); }

/* ── Callout informativo ────────────────────────────────── */
.callout {
  display: flex; gap: var(--s-3);
  padding: var(--s-4);
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--rule-soft);
}
.callout-mark {
  display: grid; place-items: center;
  width: 28px; height: 28px;
  flex: none;
  border-radius: 9px;
  background: var(--primary-soft);
  color: var(--primary);
}
[data-theme="dark"] .callout-mark { color: oklch(0.82 0.12 272); }
.callout-mark .ico { width: 16px; height: 16px; }
.callout p { font-size: var(--t-base); color: var(--muted); line-height: 1.5; text-wrap: pretty; }
.callout p b { color: var(--ink); font-weight: 600; }

/* ── Pannello form (dialog laterale) ────────────────────── */
.sheet {
  width: min(460px, 100%);
  max-width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--rule-soft);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  overflow-x: hidden;
}
.sheet::backdrop { background: oklch(0.10 0.01 272 / 0.55); backdrop-filter: blur(2px); }

.sheet[open] { animation: sheetIn 260ms var(--ease); }
.sheet[open]::backdrop { animation: fade 200ms var(--ease); }
@keyframes sheetIn { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }

.sheet-inner { display: flex; flex-direction: column; height: 100%; }

.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-5);
  border-bottom: 1px solid var(--rule-soft);
}
.sheet-head h2 { font-size: var(--t-lg); letter-spacing: -0.015em; }

.sheet-body {
  flex: 1;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--s-4);
  padding: var(--s-5);
}

.sheet-foot {
  display: flex; justify-content: flex-end; gap: var(--s-2);
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--rule-soft);
  background: var(--surface);
}

.sheet-hint {
  display: flex; gap: 8px;
  padding: var(--s-3);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: var(--t-sm);
  line-height: 1.45;
  color: var(--muted);
  text-wrap: pretty;
}
.sheet-hint .ico { width: 15px; height: 15px; flex: none; margin-top: 1px; }
/* Il testo sta in un solo contenitore: senza wrapper, ogni <b> diventerebbe
   un flex item a sé e la frase si spezzerebbe in colonne. */
.sheet-hint span { flex: 1; }
.sheet-hint b { color: var(--ink-2); font-weight: 600; }

/* ── Campi ──────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }

.field label {
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--ink-2);
}
.field-opt { font-weight: 400; color: var(--muted); }

/* Tutti i campi testuali, non solo type="text": email, password e number
   restavano con lo stile di default del browser. */
.field input:not([type="checkbox"]):not([type="radio"]),
.field .select {
  width: 100%;
  height: 40px;
  padding: 0 11px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--rule);
  color: var(--ink);
  font-size: var(--t-md);
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}
.field input::placeholder { color: var(--muted); }
.field input:focus-visible,
.field .select:focus-visible {
  outline: none;
  border-color: var(--primary-line);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.field .is-invalid { border-color: var(--neg); }
.field .is-invalid:focus-visible { box-shadow: 0 0 0 3px var(--neg-soft); }

.input-affix { position: relative; display: flex; align-items: center; }
.input-affix span {
  position: absolute; left: 11px;
  font-size: var(--t-md);
  color: var(--muted);
  pointer-events: none;
}
.input-affix input { padding-left: 28px !important; }

.field-error { font-size: var(--t-sm); color: var(--neg); min-height: 0; }
.field-error:empty { display: none; }

/* ── Importo in evidenza ────────────────────────────────────
   È il dato che l'utente sta registrando: grande, isolato, con la
   valuta discreta a sinistra. */
.field-amount { gap: 8px; }
.amount-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--bg);
  border: 1px solid var(--rule);
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}
.amount-box:focus-within { border-color: var(--primary-line); box-shadow: 0 0 0 3px var(--primary-soft); }
.amount-box.is-out:focus-within { border-color: var(--neg); box-shadow: 0 0 0 3px var(--neg-soft); }
.amount-box > span {
  font-size: var(--t-xl);
  font-weight: 500;
  color: var(--muted);
}
.amount-box input {
  flex: 1; min-width: 0;
  border: 0; background: none; outline: none;
  font-size: var(--t-2xl);
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.amount-box input::placeholder { color: var(--muted); font-weight: 500; }
.field-amount.is-invalid .amount-box,
.amount-box:has(.is-invalid) { border-color: var(--neg); }

/* ── Chip a scelta singola ──────────────────────────────── */
.chips-field { display: flex; flex-wrap: wrap; gap: 7px; }
.chip-opt {
  padding: 9px 14px;
  min-height: 40px;
  border-radius: 11px;
  font-size: var(--t-base);
  font-weight: 500;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid transparent;
  transition: background-color 140ms var(--ease), color 140ms var(--ease), border-color 140ms var(--ease);
}
.chip-opt:hover { background: var(--surface-3); }
.chip-opt.is-on {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary-line);
  font-weight: 600;
}
[data-theme="dark"] .chip-opt.is-on { color: oklch(0.82 0.12 272); }

/* ── Autocompletamento ──────────────────────────────────── */
.suggest {
  position: fixed;
  z-index: calc(var(--z-tooltip) + 10);
  max-height: 232px;
  overflow-y: auto;
  padding: 5px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow-lg);
}
.suggest[hidden] { display: none; }
.suggest-opt {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 11px;
  min-height: 42px;
  border-radius: 8px;
  font-size: var(--t-base);
  color: var(--ink);
  transition: background-color 120ms var(--ease);
}
.suggest-opt:hover, .suggest-opt.is-active { background: var(--surface-2); }

/* ── Scorciatoie di data ────────────────────────────────── */
.date-quick { display: flex; gap: 6px; margin-top: 7px; }
.date-chip {
  padding: 7px 13px;
  min-height: 36px;
  border-radius: 9px;
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
  transition: background-color 140ms var(--ease), color 140ms var(--ease);
}
.date-chip:hover { color: var(--ink); }
.date-chip.is-on { background: var(--primary-soft); color: var(--primary); }
[data-theme="dark"] .date-chip.is-on { color: oklch(0.82 0.12 272); }

/* ── Interruttore ricorrenza ────────────────────────────── */
.switch {
  display: flex; align-items: flex-start; gap: 10px;
  padding: var(--s-3);
  border-radius: var(--r-sm);
  border: 1px solid var(--rule-soft);
  cursor: pointer;
  transition: border-color 160ms var(--ease), background-color 160ms var(--ease);
}
.switch:hover { background: var(--surface-2); }
.switch input { position: absolute; opacity: 0; width: 20px; height: 20px; margin: 0; cursor: pointer; }
.switch-box {
  display: grid; place-items: center;
  width: 20px; height: 20px;
  flex: none;
  margin-top: 1px;
  border-radius: 6px;
  border: 1.5px solid var(--rule);
  color: transparent;
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease), color 160ms var(--ease);
}
.switch-box .ico { width: 13px; height: 13px; stroke-width: 2.6; }
.switch input:checked + .switch-box { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.switch input:focus-visible + .switch-box { outline: 2px solid var(--primary); outline-offset: 2px; }
.switch-text { display: flex; flex-direction: column; gap: 2px; }
.switch-text b { font-size: var(--t-base); font-weight: 600; }
.switch-text small { font-size: var(--t-sm); color: var(--muted); line-height: 1.4; text-wrap: pretty; }

/* ── Toast ──────────────────────────────────────────────── */
.toasts {
  position: fixed;
  left: 50%; bottom: var(--s-6);
  transform: translateX(-50%);
  z-index: var(--z-tooltip);
  display: flex; flex-direction: column; gap: var(--s-2);
  align-items: center;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 10px var(--s-3) 10px var(--s-4);
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow-lg);
  font-size: var(--t-base);
  pointer-events: auto;
  animation: toastIn 240ms var(--ease);
  transition: opacity 200ms var(--ease), transform 200ms var(--ease);
}
.toast.is-out { opacity: 0; transform: translateY(8px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.toast-act {
  padding: 4px 9px;
  border-radius: 7px;
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  transition: background-color 140ms var(--ease);
}
[data-theme="dark"] .toast-act { color: oklch(0.82 0.12 272); }
.toast-act:hover { background: var(--primary-line); }

/* ═══════════════════════════════════════════════════════════
   Accesso e configurazione iniziale
   ═══════════════════════════════════════════════════════════ */

.page-auth, .page-setup { min-height: 100dvh; }

.btn-block { width: 100%; justify-content: center; height: 42px; }

.link-btn {
  font-size: inherit;
  font-weight: 600;
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 140ms var(--ease);
}
[data-theme="dark"] .link-btn { color: oklch(0.82 0.12 272); }
.link-btn:hover { color: var(--ink); }

.brand-auth { padding: 0; }

/* ── Accesso ────────────────────────────────────────────── */
.auth {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 100dvh;
}

.auth-panel {
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
  justify-content: center;
  padding: var(--s-8) clamp(var(--s-5), 6vw, 88px);
  max-width: 560px;
  width: 100%;
  margin-inline: auto;
}

.auth-head h1 { font-size: var(--t-2xl); letter-spacing: -0.025em; }
.auth-head p { font-size: var(--t-md); color: var(--muted); margin-top: 6px; text-wrap: pretty; }

.auth-form { display: flex; flex-direction: column; gap: var(--s-4); }

.field-hint { font-size: var(--t-sm); color: var(--muted); text-wrap: pretty; }

.input-reveal { position: relative; display: flex; align-items: center; }
.input-reveal input { flex: 1; min-width: 0; padding-right: 84px !important; }
.reveal-btn {
  position: absolute; right: 6px;
  padding: 5px 9px;
  border-radius: 7px;
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--muted);
  transition: background-color 140ms var(--ease), color 140ms var(--ease);
}
.reveal-btn:hover { background: var(--surface-2); color: var(--ink); }

.auth-error {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--neg-soft);
  color: var(--neg);
  font-size: var(--t-base);
  font-weight: 500;
}
.auth-error[hidden] { display: none; }

.auth-switch { font-size: var(--t-base); color: var(--muted); }

.auth-note {
  display: flex; gap: 9px;
  padding: var(--s-3);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--rule-soft);
  font-size: var(--t-sm);
  line-height: 1.5;
  color: var(--muted);
  text-wrap: pretty;
}
.auth-note .ico { width: 15px; height: 15px; flex: none; margin-top: 2px; }
.auth-note span { flex: 1; }
.auth-note b { color: var(--ink-2); font-weight: 600; }

/* Colonna destra: argomento, non decorazione. */
.auth-aside {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--s-7);
  padding: var(--s-8) clamp(var(--s-5), 5vw, 72px);
  background: var(--surface);
  border-left: 1px solid var(--rule-soft);
}
.auth-kicker { font-size: var(--t-sm); font-weight: 600; color: var(--muted); }
.auth-big {
  font-size: clamp(2.5rem, 5vw, 3.75rem);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1;
  margin-top: var(--s-2);
}
.auth-cap {
  font-size: var(--t-md);
  color: var(--muted);
  line-height: 1.55;
  max-width: 38ch;
  margin-top: var(--s-3);
  text-wrap: pretty;
}
.auth-points { display: flex; flex-direction: column; gap: var(--s-3); }
.auth-points li {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: var(--t-base);
  color: var(--ink-2);
  text-wrap: pretty;
}
.auth-points .ico { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--pos); stroke-width: 2.4; }

/* ── Configurazione ─────────────────────────────────────── */
.setup {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 780px;
  margin-inline: auto;
  padding: var(--s-6) var(--s-5) 0;
}

.setup-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); }

.setup-progress { margin-top: var(--s-6); }
.steps { display: flex; gap: var(--s-4); flex-wrap: wrap; }
.step-dot {
  display: flex; align-items: center; gap: 7px;
  font-size: var(--t-sm);
  color: var(--muted);
  transition: color 200ms var(--ease);
}
.step-n {
  display: grid; place-items: center;
  width: 20px; height: 20px;
  border-radius: 50%;
  font-size: var(--t-xs);
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--rule-soft);
  transition: background-color 200ms var(--ease), color 200ms var(--ease), border-color 200ms var(--ease);
}
.step-dot.is-active { color: var(--ink); font-weight: 600; }
.step-dot.is-active .step-n { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.step-dot.is-done .step-n { background: var(--pos-soft); color: var(--pos); border-color: transparent; }

.steps-bar {
  height: 3px;
  border-radius: 2px;
  background: var(--surface-3);
  margin-top: var(--s-3);
  overflow: hidden;
}
.steps-bar span {
  display: block; height: 100%;
  border-radius: 2px;
  background: var(--primary);
  transition: width 320ms var(--ease);
}

.setup-main { flex: 1; padding: var(--s-7) 0 var(--s-6); }
.step { display: flex; flex-direction: column; gap: var(--s-5); }
.step[hidden] { display: none; }

.step-head h1 { font-size: var(--t-2xl); letter-spacing: -0.025em; }
.step-head p {
  font-size: var(--t-md);
  color: var(--muted);
  margin-top: 8px;
  max-width: 62ch;
  line-height: 1.55;
  text-wrap: pretty;
}
.step-head p b { color: var(--ink-2); font-weight: 600; }

.field-narrow { max-width: 220px; }

.choice-set { border: 0; padding: 0; margin: 0; min-width: 0; }
.choice-set legend {
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--ink-2);
  padding: 0 0 var(--s-2);
}
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--s-2); }
.choices-wide { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

.choice {
  position: relative;
  display: flex;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  border: 1px solid var(--rule-soft);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 160ms var(--ease), background-color 160ms var(--ease);
}
.choice:hover { border-color: var(--rule); }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.choice:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }

.choice-body { display: flex; flex-direction: column; gap: 3px; }
.choice-body b { font-size: var(--t-base); font-weight: 600; }
.choice-body small { font-size: var(--t-sm); color: var(--muted); line-height: 1.45; text-wrap: pretty; }
.choice-meta { font-size: var(--t-xs); color: var(--muted); margin-top: 3px; }
.choice-meta b { font-size: var(--t-xs); color: var(--ink-2); }

.callout-warn .callout-mark { background: var(--warn-soft); color: var(--warn-ink); }
.callout[hidden] { display: none; }

.input-affix-end input { padding-left: 11px !important; padding-right: 30px !important; }
.input-affix-end span { left: auto; right: 11px; }

.summary-card {
  display: flex; flex-direction: column;
  border-radius: var(--r-md);
  border: 1px solid var(--rule-soft);
  background: var(--surface);
  overflow: hidden;
}
.summary-row {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--s-4);
  padding: 12px var(--s-4);
  font-size: var(--t-base);
}
.summary-row + .summary-row { border-top: 1px solid var(--rule-soft); }
.summary-row span { color: var(--muted); }
.summary-row b { font-weight: 600; text-align: right; }

.setup-foot {
  position: sticky;
  bottom: 0;
  display: flex; justify-content: flex-end; gap: var(--s-2);
  padding: var(--s-4) 0;
  background: linear-gradient(to top, var(--bg) 68%, transparent);
}
.setup-foot .btn { height: 42px; padding-inline: var(--s-5); }

@media (max-width: 900px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-aside { display: none; }
  .auth-panel { max-width: 480px; }
}

/* ── Menu account ───────────────────────────────────────── */
.account { position: relative; }
.account-menu {
  position: absolute;
  top: calc(100% + 8px); right: 0;
  z-index: var(--z-tooltip);
  min-width: 226px;
  padding: var(--s-2);
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow-lg);
}
.account-menu[hidden] { display: none; }
.account-who {
  display: flex; flex-direction: column; gap: 1px;
  padding: var(--s-2) var(--s-3) var(--s-3);
  border-bottom: 1px solid var(--rule-soft);
  margin-bottom: var(--s-2);
}
.account-who b { font-size: var(--t-base); font-weight: 600; }
.account-who small { font-size: var(--t-sm); color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.account-item {
  display: block; width: 100%;
  padding: 8px var(--s-3);
  border-radius: var(--r-sm);
  text-align: left;
  font-size: var(--t-base);
  color: var(--ink-2);
  transition: background-color 140ms var(--ease), color 140ms var(--ease);
}
.account-item:hover { background: var(--surface-2); color: var(--ink); }

/* ═══════════════════════════════════════════════════════════
   Tasse
   ═══════════════════════════════════════════════════════════ */
.calc { display: flex; flex-direction: column; }
.calc-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: baseline;
  gap: var(--s-3);
  padding: 12px 0;
}
.calc-row + .calc-row { border-top: 1px solid var(--rule-soft); }
.calc-op { font-size: var(--t-md); color: var(--muted); text-align: center; }
.calc-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.calc-body b { font-size: var(--t-base); font-weight: 600; }
.calc-body small { font-size: var(--t-sm); color: var(--muted); line-height: 1.45; text-wrap: pretty; }
.calc-val { font-size: var(--t-lg); font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; }

.calc-row.is-total { padding-top: var(--s-4); border-top-width: 1px; border-top-color: var(--rule); }
.calc-row.is-total .calc-val { font-size: var(--t-xl); }

.calc-note {
  margin-top: var(--s-3);
  padding: var(--s-3);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: var(--t-base);
  color: var(--muted);
  line-height: 1.5;
  text-wrap: pretty;
}
.calc-note b { color: var(--ink); font-weight: 600; }

.sim-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-3); }
.sim-cell {
  display: flex; flex-direction: column; gap: 3px;
  padding: var(--s-3);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.sim-cell span { font-size: var(--t-sm); color: var(--muted); }
.sim-cell b { font-size: var(--t-lg); font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; }
.sim-cell.is-lead { background: var(--pos-soft); }
.sim-cell.is-lead b { font-size: var(--t-xl); }

.sim-note {
  margin-top: var(--s-3);
  font-size: var(--t-sm);
  color: var(--muted);
  line-height: 1.5;
  text-wrap: pretty;
}
.sim-note b { color: var(--ink-2); font-weight: 600; }
.sim-empty { font-size: var(--t-base); color: var(--muted); }

/* Nelle card a colonna un bottone si allargherebbe come un campo. */
.card > .btn { align-self: flex-start; }

@media (max-width: 720px) {
  .sim-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ═══════════════════════════════════════════════════════════
   Clienti · Conti · Obiettivi · Impostazioni
   ═══════════════════════════════════════════════════════════ */

.content-narrow { max-width: 860px; width: 100%; }

/* ── Quota in tabella ───────────────────────────────────── */
.quota { display: flex; align-items: center; gap: var(--s-2); min-width: 120px; }
.quota-bar { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.quota-bar i {
  display: block; height: 100%; width: var(--pct);
  border-radius: 3px; background: var(--primary);
  transform-origin: left;
  animation: grow 700ms var(--ease);
}
.quota-bar i.is-risk { background: var(--warn); }
.quota b { font-weight: 600; min-width: 34px; text-align: right; }

/* ── Conti ──────────────────────────────────────────────── */
.accounts { display: flex; flex-direction: column; }
.account-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto 20px;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) 0;
  cursor: pointer;
  transition: background-color 140ms var(--ease);
}
.account-row + .account-row { border-top: 1px solid var(--rule-soft); }
.account-row:hover { background: var(--surface-2); }
.account-row:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: var(--r-sm); }
.account-chev { width: 16px; height: 16px; color: var(--muted); }

.account-icon {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--ink-2);
}
.account-icon[data-tipo="salvadanaio"] { background: var(--warn-soft); color: var(--warn-ink); }
.account-icon[data-tipo="banca"] { background: var(--primary-soft); color: var(--primary); }
[data-theme="dark"] .account-icon[data-tipo="banca"] { color: oklch(0.82 0.12 272); }

.account-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.account-main b { font-size: var(--t-base); font-weight: 600; }
.account-main small { font-size: var(--t-sm); color: var(--muted); }
.account-bar { height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; margin-top: 4px; max-width: 260px; }
.account-bar i {
  display: block; height: 100%; width: var(--pct);
  border-radius: 2px; background: var(--primary);
  transform-origin: left;
  animation: grow 700ms var(--ease);
}

.account-figures { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.account-figures b { font-size: var(--t-lg); font-weight: 600; letter-spacing: -0.02em; }
.account-figures small { font-size: var(--t-sm); color: var(--muted); }

/* Da quanto il conto è allineato al saldo vero della banca. */
.account-verifica {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 3px;
  font-size: var(--t-xs); color: var(--muted);
}
.account-verifica .ico { width: 12px; height: 12px; color: var(--pos); }
.account-verifica.is-stale { color: var(--warn-ink); }
.account-verifica.is-stale .ico { color: var(--warn-ink); }

.card-head-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* ── Allinea (riconciliazione) ──────────────────────────── */
.reconcile {
  margin-top: var(--s-4);
  padding-top: var(--s-4);
  border-top: 1px solid var(--rule-soft);
  display: flex; flex-direction: column; gap: var(--s-3);
}
.reconcile-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-2); }
.reconcile-head h3 { font-size: var(--t-md); font-weight: 600; }
.reconcile-when { font-size: var(--t-xs); color: var(--muted); white-space: nowrap; }
.reconcile-when.is-stale { color: var(--warn-ink); }
.reconcile-now { font-size: var(--t-sm); color: var(--ink-2); line-height: 1.45; }
.reconcile-now b { color: var(--ink); font-weight: 600; }
.reconcile-esito { font-size: var(--t-sm); border-radius: var(--r-sm); padding: var(--s-2) var(--s-3); line-height: 1.4; }
.reconcile-esito.is-ok  { background: var(--pos-soft); color: var(--ink); }
.reconcile-esito.is-err { background: var(--neg-soft); color: var(--ink); }
.reconcile-storico-label {
  font-size: var(--t-xs); color: var(--muted);
  margin-bottom: var(--s-2); text-transform: uppercase; letter-spacing: 0.04em;
}
.reconcile-storico ul { display: flex; flex-direction: column; }
.storico-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); padding: var(--s-2) 0; }
.storico-row + .storico-row { border-top: 1px solid var(--rule-soft); }
.storico-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.storico-main b { font-size: var(--t-base); font-weight: 600; }
.storico-main small { font-size: var(--t-xs); color: var(--muted); }

/* ── Giroconti ──────────────────────────────────────────── */
.giro-list { display: flex; flex-direction: column; }
.giro-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto auto;
  align-items: center; gap: var(--s-3);
  padding: var(--s-3) 0;
}
.giro-row + .giro-row { border-top: 1px solid var(--rule-soft); }
.giro-ico {
  display: grid; place-items: center; width: 36px; height: 36px;
  border-radius: 10px; background: var(--surface-2); color: var(--ink-2);
}
.giro-ico .ico { width: 16px; height: 16px; }
.giro-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.giro-main b { font-size: var(--t-base); font-weight: 600; }
.giro-main b .giro-to { color: var(--muted); font-weight: 400; margin: 0 2px; }
.giro-main small { font-size: var(--t-sm); color: var(--muted); }
.giro-amt { font-size: var(--t-md); font-weight: 600; white-space: nowrap; }
.giro-del .ico { width: 15px; height: 15px; }

/* Dialog giroconto: i due conti con la freccia in mezzo. */
.giro-fields { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: var(--s-3); }
.giro-arrow { display: grid; place-items: center; width: 30px; height: 40px; color: var(--muted); }
.giro-arrow .ico { width: 16px; height: 16px; transform: rotate(90deg); }

.sheet-lead { font-size: var(--t-sm); color: var(--ink-2); line-height: 1.5; margin-bottom: var(--s-2); }
.label-opt { color: var(--muted); font-weight: 400; }

@media (max-width: 520px) {
  .giro-fields { grid-template-columns: 1fr; align-items: stretch; }
  .giro-arrow { width: auto; height: auto; justify-self: start; padding: 2px 0; }
}

/* ── Obiettivi ──────────────────────────────────────────── */
.goals { display: flex; flex-direction: column; gap: var(--s-5); }
.goal { display: flex; flex-direction: column; gap: var(--s-2); }
.goal + .goal { padding-top: var(--s-5); border-top: 1px solid var(--rule-soft); }

.goal-head { display: grid; grid-template-columns: minmax(0, 1fr) auto 28px; align-items: baseline; gap: var(--s-3); }
.goal-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.goal-name b { font-size: var(--t-md); font-weight: 600; }
.goal-name small { font-size: var(--t-sm); color: var(--muted); }
.goal-figs { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.goal-figs b { font-size: var(--t-lg); font-weight: 600; letter-spacing: -0.02em; }
.goal-figs small { font-size: var(--t-sm); color: var(--muted); }

.goal-bar { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.goal-bar i {
  display: block; height: 100%; width: var(--pct);
  border-radius: 4px;
  transform-origin: left;
  animation: grow 700ms var(--ease);
}
.goal-bar i.is-pos  { background: var(--pos); }
.goal-bar i.is-warn { background: var(--warn); }
.goal-bar i.is-neg  { background: var(--neg); }

.goal-verdict { font-size: var(--t-sm); line-height: 1.5; text-wrap: pretty; }
.goal-verdict.is-pos  { color: var(--pos); }
.goal-verdict.is-warn { color: var(--warn-ink); }
.goal-verdict.is-neg  { color: var(--neg); }

/* ── Clienti ricorrenti ─────────────────────────────────── */
.ric-list { display: flex; flex-direction: column; gap: var(--s-3); }
.ric {
  display: flex; flex-direction: column; gap: var(--s-3);
  padding: var(--s-4);
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--rule-soft);
}
.ric-main { display: flex; align-items: center; gap: var(--s-3); }
.ric-main .who-mark { width: 40px; height: 40px; border-radius: 12px; flex: none; }
.ric-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ric-text b { font-size: var(--t-base); font-weight: 600; }
.ric-text small { font-size: var(--t-sm); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ric-stato {
  font-size: var(--t-xs); font-weight: 600;
  padding: 4px 9px;
  border-radius: 20px;
  white-space: nowrap;
  flex: none;
}
.ric-stato.is-ok   { color: var(--pos); background: var(--pos-soft); }
.ric-stato.is-late { color: var(--neg); background: var(--neg-soft); }
.ric-stato.is-due  { color: var(--warn-ink); background: var(--warn-soft); }
.ric-stato.is-wait { color: var(--muted); background: var(--surface-3); }

.ric-actions { display: flex; gap: var(--s-2); padding-left: calc(40px + var(--s-3)); }
.ric-actions .btn { flex: 0 1 auto; }

/* ── Scenari ────────────────────────────────────────────── */
.scenari { display: flex; flex-direction: column; }
.scenario {
  display: flex; flex-direction: column; gap: var(--s-2);
  padding: var(--s-3) 0;
}
.scenario + .scenario { border-top: 1px solid var(--rule-soft); }
.scenario-head { display: flex; flex-direction: column; gap: 2px; }
.scenario-head b { font-size: var(--t-base); font-weight: 600; }
.scenario-head small { font-size: var(--t-sm); color: var(--muted); }
.scenario-figs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-3); }
.scenario-figs span { display: flex; flex-direction: column; gap: 1px; }
.scenario-figs small { font-size: var(--t-sm); color: var(--muted); }
.scenario-figs b { font-size: var(--t-base); font-weight: 600; white-space: nowrap; }

.lg-dashed::before {
  background: repeating-linear-gradient(90deg, var(--muted) 0 3px, transparent 3px 6px);
  border-radius: 0;
}

/* ── Righe impostazione ─────────────────────────────────── */
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-3) 0;
}
.setting-row + .setting-row { border-top: 1px solid var(--rule-soft); }
.setting-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.setting-text b { font-size: var(--t-base); font-weight: 600; }
.setting-text small { font-size: var(--t-sm); color: var(--muted); line-height: 1.45; text-wrap: pretty; }

.seg-wide { display: inline-flex; align-self: flex-start; }
.seg-wide .seg-btn { padding: 7px 18px; }

.card-danger { border-color: var(--neg-soft); }
.btn-danger {
  background: var(--neg-soft);
  color: var(--neg);
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn-danger:hover { background: var(--neg); color: var(--bg); }
[data-theme="light"] .btn-danger:hover { color: #fff; }

/* ── Conferma distruttiva ───────────────────────────────── */
.confirm {
  max-width: 460px; width: calc(100% - 32px);
  padding: 0; border: 0;
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}
.confirm::backdrop { background: oklch(0.10 0.01 272 / 0.6); backdrop-filter: blur(2px); }
.confirm-inner { display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-5); }
.confirm-inner h2 { font-size: var(--t-lg); }
.confirm-inner > p { font-size: var(--t-base); color: var(--muted); line-height: 1.5; text-wrap: pretty; }
.confirm-inner > p b { color: var(--ink); font-weight: 600; }
.confirm-foot { display: flex; justify-content: flex-end; gap: var(--s-2); margin-top: var(--s-2); }
.btn:disabled { opacity: 0.45; pointer-events: none; }

@media (max-width: 720px) {
  /* Ogni conto è una scheda a sé, come i debiti: icona a sinistra,
     nome e tipo al centro, saldo grande a destra sulla stessa riga.
     Niente più saldo che va a capo da solo sotto l'icona. */
  .accounts { gap: var(--s-2); }
  .account-row {
    grid-template-columns: 40px minmax(0, 1fr) auto;
    column-gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    border-radius: 14px;
    background: var(--surface-2);
    border: 1px solid var(--rule-soft);
  }
  .account-row + .account-row { border-top: 1px solid var(--rule-soft); }
  .account-main .account-bar { display: none; }   /* indicatore decorativo: fuori su mobile */
  .account-figures { align-items: flex-end; }
  .account-figures b { font-size: var(--t-md); white-space: nowrap; }
  .account-figures small { white-space: nowrap; }
  .account-chev { display: none; }                /* la scheda intera è tappabile */

  .scenario-figs { grid-template-columns: minmax(0, 1fr); gap: var(--s-2); }
  .setting-row { flex-direction: column; align-items: flex-start; }
  .goal-head { grid-template-columns: minmax(0, 1fr) 28px; }
  .goal-figs { grid-column: 1; }
}

/* ═══════════════════════════════════════════════════════════
   Logo · Verifica email · Personale
   ═══════════════════════════════════════════════════════════ */

/* Avatar con immagine al posto delle iniziali. */
.avatar.has-image { padding: 0; overflow: hidden; background: var(--surface-2); }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }

.avatar-edit { display: flex; align-items: flex-start; gap: var(--s-4); flex-wrap: wrap; }
.avatar-preview {
  display: grid; place-items: center;
  width: 72px; height: 72px;
  flex: none;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-ink);
  font-size: var(--t-xl);
  font-weight: 600;
  letter-spacing: 0.02em;
  overflow: hidden;
}
.avatar-preview.has-image { background: var(--surface-2); }
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); flex: 1; min-width: 220px; }
.avatar-actions .field-hint, .avatar-actions .field-error { flex: 1 1 100%; }
/* label.btn: senza questo il cursore resta quello del testo. */
label.btn { cursor: pointer; }

/* ── Barra di verifica ──────────────────────────────────── */
.btn-sm { height: 30px; padding: 0 11px; font-size: var(--t-sm); }

/* ── Personale ──────────────────────────────────────────── */
.fc-actual.is-over { background: var(--neg); }
tr.is-past { opacity: 0.55; }
tr.is-past .td-amt { font-weight: 500; }


/* Errore in fondo alla configurazione: sta a sinistra dei pulsanti
   e li spinge a destra, senza spostarli in verticale. */
.setup-error { flex: 1; margin: 0; text-align: left; }
.setup-error:empty { display: none; }

/* ═══════════════════════════════════════════════════════════
   Presentazione guidata
   ═══════════════════════════════════════════════════════════ */

/* Il velo cattura i clic: durante il tour l'app resta inerte.
   L'oscuramento invece lo disegna il buco, con un'ombra enorme:
   così il ritaglio segue l'elemento senza maschere né clip-path. */
.tour-veil {
  position: fixed;
  inset: 0;
  z-index: 500;
  cursor: default;
}

.tour-hole {
  position: fixed;
  z-index: 501;
  border-radius: var(--r-md);
  pointer-events: none;
  box-shadow: 0 0 0 9999px oklch(0.08 0.01 272 / 0.72);
  outline: 2px solid var(--primary-line);
  outline-offset: 0;
  transition: top 260ms var(--ease), left 260ms var(--ease),
              width 260ms var(--ease), height 260ms var(--ease);
}

.tour-card {
  position: fixed;
  z-index: 502;
  width: min(360px, calc(100% - 24px));
  padding: var(--s-5);
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow-lg);
  transition: top 260ms var(--ease), left 260ms var(--ease);
}
.tour-card:focus { outline: none; }

.tour-conta {
  font-size: var(--t-xs);
  font-weight: 600;
  color: var(--muted);
  margin-bottom: var(--s-2);
}
.tour-card h2 {
  font-size: var(--t-lg);
  letter-spacing: -0.015em;
  margin-bottom: var(--s-2);
  text-wrap: balance;
}
.tour-testo {
  font-size: var(--t-base);
  line-height: 1.55;
  color: var(--ink-2);
  text-wrap: pretty;
}
.tour-testo b { color: var(--ink); font-weight: 600; }

.tour-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-top: var(--s-4);
}
.tour-nav { display: flex; gap: var(--s-2); }
.tour-skip {
  font-size: var(--t-sm);
  font-weight: 500;
  color: var(--muted);
  transition: color 140ms var(--ease);
}
.tour-skip:hover { color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  .tour-hole, .tour-card { transition: none; }
}

@media (max-width: 720px) {
  /* Su schermo stretto il riquadro sta in basso, fisso: inseguire
     l'elemento lo farebbe saltare fuori dallo schermo. */
  .tour-card { left: 12px !important; right: 12px; width: auto; top: auto !important; bottom: 12px; }
}

/* ═══════════════════════════════════════════════════════════
   Importazione
   ═══════════════════════════════════════════════════════════ */
.import-tabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--rule-soft); padding-bottom: var(--s-2); }

.import-area {
  width: 100%;
  padding: var(--s-3);
  border-radius: var(--r-md);
  background: var(--bg);
  border: 1px solid var(--rule);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--t-sm);
  line-height: 1.6;
  resize: vertical;
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}
.import-area::placeholder { color: var(--muted); }
.import-area:focus-visible {
  outline: none;
  border-color: var(--primary-line);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.import-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* Conto + "cosa stai incollando" affiancati, poi vanno a capo su schermo
   stretto. */
.import-setup { display: flex; flex-wrap: wrap; gap: var(--s-5); align-items: flex-start; margin-bottom: var(--s-4); }
.seg-dir { display: inline-flex; width: fit-content; }

/* Correzione in blocco, spinta a destra della barra dei filtri. */
.import-bulk { display: inline-flex; align-items: center; gap: var(--s-2); margin-left: auto; }
.import-bulk-label { font-size: var(--t-sm); color: var(--muted); }
@media (max-width: 560px) {
  .import-bulk { margin-left: 0; width: 100%; }
}

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: var(--s-8) var(--s-5);
  border-radius: var(--r-md);
  border: 1.5px dashed var(--rule);
  background: var(--surface-2);
  text-align: center;
  cursor: pointer;
  transition: border-color 160ms var(--ease), background-color 160ms var(--ease);
}
.dropzone:hover, .dropzone.is-over { border-color: var(--primary-line); background: var(--primary-soft); }
.dropzone-mark {
  display: grid; place-items: center;
  width: 44px; height: 44px;
  border-radius: 14px;
  background: var(--surface);
  color: var(--muted);
  margin-bottom: var(--s-1);
}
.dropzone b { font-size: var(--t-md); }
.dropzone small { font-size: var(--t-sm); color: var(--muted); max-width: 46ch; line-height: 1.5; text-wrap: pretty; }

/* ── Riepilogo dell'import ──────────────────────────────── */
.import-riepilogo { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-3); }
.riep-cella {
  display: flex; flex-direction: column; gap: 3px;
  padding: var(--s-3);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.riep-cella span { font-size: var(--t-sm); color: var(--muted); }
.riep-cella b { font-size: var(--t-lg); font-weight: 600; letter-spacing: -0.02em; }

/* ── Tabella di revisione ───────────────────────────────── */
.table-import td { vertical-align: top; padding-block: 9px; }
.table-import .td-amt { vertical-align: middle; }

.cella, .select-cella {
  width: 100%;
  height: 34px;
  padding: 0 9px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--rule-soft);
  color: var(--ink);
  font-size: var(--t-base);
  transition: border-color 140ms var(--ease);
}
.cella:focus-visible, .select-cella:focus-visible {
  outline: none; border-color: var(--primary-line); box-shadow: 0 0 0 3px var(--primary-soft);
}
.select-cella { min-width: 150px; }

.riga-nota {
  display: block;
  font-size: var(--t-xs);
  margin-top: 4px;
  line-height: 1.4;
}
.riga-nota.is-dup { color: var(--warn-ink); }
.riga-nota.is-incerta { color: var(--neg); }
.riga-nota.is-ok { color: var(--pos); }
.riga-nota.is-giro { color: var(--primary); }
[data-theme="dark"] .riga-nota.is-giro { color: oklch(0.82 0.12 272); }

tr.is-dup { background: var(--warn-soft); }
tr.is-incerta { background: var(--neg-soft); }
/* Il giroconto non è un errore né un rischio: è neutro. Colore del
   brand, non warn né neg, così non allarma. Se è anche duplicato o
   incerto, quei fondi hanno la precedenza. */
tr.is-giro:not(.is-dup):not(.is-incerta) { background: var(--primary-soft); }
tr.is-giro .td-amt { opacity: 0.7; }

/* Collega-come-giroconto: un interruttore inline nella riga riconosciuta. */
.riga-giro {
  display: flex; align-items: flex-start; gap: 6px;
  margin-top: 5px;
  font-size: var(--t-xs); line-height: 1.4;
  color: var(--ink-2); cursor: pointer;
}
.riga-giro input { margin-top: 1px; flex: none; accent-color: var(--primary); }
.riga-giro b { color: var(--ink); font-weight: 600; }

.seg-mini { padding: 2px; }
.seg-mini .seg-btn { padding: 4px 9px; font-size: var(--t-xs); }

.check-inline { flex-direction: row; align-items: center; gap: 8px; }
.check-etichetta { font-size: var(--t-base); font-weight: 500; color: var(--ink-2); }

.import-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-4); flex-wrap: wrap;
  padding-top: var(--s-3);
  border-top: 1px solid var(--rule-soft);
}

@media (max-width: 900px) {
  .import-riepilogo { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ═══════════════════════════════════════════════════════════
   Debiti
   ═══════════════════════════════════════════════════════════ */

.impegno {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s-4);
  padding: var(--s-2) 0 var(--s-4);
}
.impegno-fig { display: flex; flex-direction: column; gap: 2px; }
.impegno-fig span { font-size: var(--t-sm); color: var(--muted); }
.impegno-fig b { font-size: var(--t-lg); font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; }
.impegno-fig.is-lead b { font-size: var(--t-xl); }
.impegno-op { font-size: var(--t-lg); color: var(--muted); }

.prossima { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) 0; }
.prossima-mark {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  flex: none;
  border-radius: 12px;
  font-size: var(--t-xs);
  font-weight: 700;
  background: var(--seed-bg, var(--surface-3));
  color: var(--seed-ink, var(--ink-2));
}
.prossima-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.prossima-text b { font-size: var(--t-base); font-weight: 600; }
.prossima-text small { font-size: var(--t-sm); color: var(--muted); }
.prossima-fig { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.prossima-fig b { font-size: var(--t-lg); font-weight: 600; letter-spacing: -0.02em; }
.prossima-fig small { font-size: var(--t-sm); color: var(--muted); white-space: nowrap; }

.debts { display: flex; flex-direction: column; gap: var(--s-3); }
/* Ogni debito è una scheda cliccabile a sé: niente matita da centrare,
   il tap sull'intera scheda apre la modifica. */
.debt {
  display: flex; flex-direction: column; gap: var(--s-2);
  padding: var(--s-4);
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--rule-soft);
  cursor: pointer;
  transition: background-color 140ms var(--ease), border-color 140ms var(--ease);
}
.debt:hover { background: var(--surface-3); border-color: var(--rule); }
.debt:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.debt.is-done { opacity: 0.6; cursor: default; }

/* Flex, non grid: l'avatar, il testo che cresce, le cifre e il chevron
   si dispongono da soli senential lasciare orfano nessun elemento. */
.debt-head { display: flex; align-items: center; gap: var(--s-3); }
.debt-head .who-mark { width: 40px; height: 40px; border-radius: 12px; flex: none; }
.debt-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.debt-name b { font-size: var(--t-base); font-weight: 600; }
.debt-name small { font-size: var(--t-sm); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.debt-figs { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; flex: none; }
.debt-figs b { font-size: var(--t-lg); font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; }
.debt-figs small { font-size: var(--t-sm); color: var(--muted); white-space: nowrap; }
.debt-chev { width: 16px; height: 16px; color: var(--muted); flex: none; }

.debt-bar { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.debt-bar i {
  display: block; height: 100%; width: var(--pct);
  border-radius: 3px;
  background: var(--pos);
  transform-origin: left;
  animation: grow 700ms var(--ease);
}
.debt-note { font-size: var(--t-sm); color: var(--muted); text-wrap: pretty; }

/* Chip con tasso, interessi e more sotto ogni debito. */
.debt-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.debt-chip {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 999px;
  font-size: var(--t-xs); font-weight: 600;
  background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--rule-soft);
}
.debt-chip.is-neg  { color: var(--neg); border-color: var(--neg-soft); }
.debt-chip.is-warn { color: var(--warn-ink); border-color: var(--warn-soft); }

/* ── Form debito: dettagli tasso, box fiscale, analisi ───── */
.debt-extra { border-top: 1px solid var(--rule-soft); padding-top: var(--s-3); }
.debt-extra > summary {
  cursor: pointer; font-size: var(--t-sm); font-weight: 600; color: var(--ink-2);
  list-style: none; display: flex; align-items: center; gap: 6px;
}
.debt-extra > summary::-webkit-details-marker { display: none; }
.debt-extra > summary::before { content: '＋'; color: var(--muted); font-weight: 400; }
.debt-extra[open] > summary::before { content: '−'; }
.debt-extra[open] > summary { margin-bottom: var(--s-3); }
.input-affix-end input { padding-left: 11px !important; padding-right: 30px !important; }
.input-affix-end span { left: auto; right: 11px; }

.fisco-box { border-top: 1px solid var(--rule-soft); padding-top: var(--s-3); display: flex; flex-direction: column; gap: var(--s-3); }

.mora-out { border-radius: var(--r-md); border: 1px solid var(--warn-soft); background: var(--warn-soft); padding: var(--s-3); }
.mora-head { display: flex; align-items: center; gap: 6px; font-size: var(--t-sm); font-weight: 600; color: var(--warn-ink); margin-bottom: var(--s-2); }
.mora-head .ico { width: 15px; height: 15px; }
.mora-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2) var(--s-3); }
.mora-grid > div { display: flex; flex-direction: column; gap: 1px; }
.mora-grid span { font-size: var(--t-xs); color: var(--ink-2); }
.mora-grid b { font-size: var(--t-md); font-weight: 600; }
.mora-grid .is-lead { grid-column: 1 / -1; padding-top: var(--s-2); border-top: 1px dashed var(--warn-soft); }
.mora-grid .is-lead b { font-size: var(--t-lg); }
.mora-nota, .mora-disclaimer { font-size: var(--t-xs); color: var(--ink-2); line-height: 1.45; margin-top: var(--s-2); text-wrap: pretty; }
.mora-disclaimer { color: var(--muted); }

.debt-analisi { border-radius: var(--r-md); background: var(--primary-soft); padding: var(--s-3); }
.an-head { display: flex; align-items: center; gap: 6px; font-size: var(--t-sm); font-weight: 600; color: var(--ink); margin-bottom: var(--s-2); }
.an-head .ico { width: 15px; height: 15px; color: var(--primary); }
[data-theme="dark"] .an-head .ico { color: oklch(0.82 0.12 272); }
.an-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--s-2); padding: 3px 0; font-size: var(--t-sm); }
.an-row span { color: var(--ink-2); }
.an-row b { font-weight: 600; color: var(--ink); margin-left: auto; }
.an-row b.is-neg { color: var(--neg); }
.an-row em { font-size: var(--t-xs); color: var(--muted); font-style: normal; flex-basis: 100%; text-align: right; margin-top: -2px; }
.an-nota { font-size: var(--t-xs); color: var(--ink-2); line-height: 1.45; margin-top: var(--s-2); text-wrap: pretty; }

/* ── Recap debiti in home ───────────────────────────────── */
.hd-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-4); margin-bottom: var(--s-4); }
.hd-fig { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.hd-fig span { font-size: var(--t-xs); color: var(--muted); }
.hd-fig b { font-size: var(--t-xl); font-weight: 600; letter-spacing: -0.02em; }
.hd-mixwrap { display: flex; flex-direction: column; gap: var(--s-3); }
.hd-mix { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--surface-3); gap: 2px; }
.hd-seg { width: var(--w); min-width: 3px; }
.hd-legend { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); }
.hd-legend li { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-sm); color: var(--ink-2); }
.hd-legend b { color: var(--ink); font-weight: 600; margin-left: 2px; }
.hd-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.hd-next { margin-top: var(--s-3); font-size: var(--t-sm); color: var(--muted); text-wrap: pretty; }
.hd-next b { color: var(--ink); font-weight: 600; }

.hd-seg[data-tipo="finanziamento"], .hd-dot[data-tipo="finanziamento"] { background: oklch(0.62 0.19 272); }
.hd-seg[data-tipo="leasing"],       .hd-dot[data-tipo="leasing"]       { background: oklch(0.70 0.13 195); }
.hd-seg[data-tipo="rateizzazione"], .hd-dot[data-tipo="rateizzazione"] { background: oklch(0.76 0.14 76); }
.hd-seg[data-tipo="fido"],          .hd-dot[data-tipo="fido"]          { background: oklch(0.68 0.17 22); }
.hd-seg[data-tipo="fornitore"],     .hd-dot[data-tipo="fornitore"]     { background: oklch(0.62 0.16 330); }
.hd-seg[data-tipo="altro"],         .hd-dot[data-tipo="altro"]         { background: oklch(0.60 0.02 272); }

@media (max-width: 720px) {
  .hd-grid { grid-template-columns: 1fr 1fr; gap: var(--s-3); }
  .hd-fig b { font-size: var(--t-lg); }
}

/* ── Assistente (tasto fisso + pannello) ────────────────── */
.assist-fab {
  position: fixed; right: var(--s-5); bottom: var(--s-5);
  z-index: var(--z-tooltip);
  display: inline-flex; align-items: center; gap: 7px;
  padding: 11px 16px; border: 0; border-radius: 999px;
  background: var(--primary); color: var(--primary-ink);
  font-weight: 600; font-size: var(--t-sm); cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: transform 140ms var(--ease), box-shadow 140ms var(--ease);
}
.assist-fab:hover { transform: translateY(-2px); }
.assist-fab .ico { width: 16px; height: 16px; }

.assist-sheet {
  margin: auto auto 0; padding: 0;
  width: 100%; max-width: 470px;
  border: 0; border-radius: 20px 20px 0 0;
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-lg);
}
.assist-sheet::backdrop { background: oklch(0 0 0 / 0.45); backdrop-filter: blur(2px); }
.assist-in { padding: var(--s-3) var(--s-5) var(--s-5); max-height: 78vh; overflow-y: auto; }
.assist-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s-2); margin-bottom: var(--s-3); }
.assist-head b { font-size: var(--t-lg); font-weight: 600; display: block; }
.assist-head small { font-size: var(--t-sm); color: var(--muted); }
.assist-empty { font-size: var(--t-sm); color: var(--muted); padding: var(--s-4) 0; text-align: center; }
.assist-nota { margin-top: var(--s-3); padding-top: var(--s-3); border-top: 1px solid var(--rule-soft); font-size: var(--t-xs); color: var(--muted); text-wrap: pretty; }

@media (min-width: 721px) {
  .assist-sheet { margin: auto var(--s-5) var(--s-5) auto; border-radius: 18px; }
  .assist-in .m-grab { display: none; }
}
@media (max-width: 720px) {
  /* Ben SOPRA la dock staccata (che arriva a ~70px + safe-area) e sopra il
     "+" centrale rialzato: 66px la faceva finire sulla barra. */
  .assist-fab { right: var(--s-3); bottom: calc(94px + env(safe-area-inset-bottom, 0px)); padding: 10px; }
  .assist-fab span { display: none; }
  .assist-fab .ico { width: 20px; height: 20px; }

  /* Topbar mobile: "Altro" prende il posto del microfono (l'assistente ora
     si apre dal "+" centrale della dock, come nella home). */
  .topbar-tools #shellAssist { display: none; }
  .topbar-tools .shell-altro { display: grid; place-items: center; }
}
/* "Altro" in topbar serve solo sul telefono: su desktop la sidebar ha tutto.
   min-width (non regola nuda) per non sovrascrivere il mobile per ordine sorgente. */
@media (min-width: 721px) { .topbar-tools .shell-altro { display: none; } }

/* ── Simulatore di estinzione ───────────────────────────── */
.accelera-out { margin-top: var(--s-2); }
.accelera-lead { font-size: var(--t-base); color: var(--ink-2); line-height: 1.5; text-wrap: pretty; }
.accelera-lead b { color: var(--ink); font-weight: 600; }
.accelera-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); margin-top: var(--s-3); }
.accelera-cell {
  display: flex; flex-direction: column; gap: 3px;
  padding: var(--s-3);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.accelera-cell.is-lead { background: var(--pos-soft); }
.accelera-cell span { font-size: var(--t-sm); color: var(--muted); }
.accelera-cell b { font-size: var(--t-lg); font-weight: 600; letter-spacing: -0.02em; }
.accelera-cell em { font-size: var(--t-xs); font-style: normal; color: var(--muted); }
.accelera-note { margin-top: var(--s-3); font-size: var(--t-sm); color: var(--muted); line-height: 1.5; text-wrap: pretty; }
.accelera-note b { color: var(--ink-2); font-weight: 600; }

@media (max-width: 720px) {
  .impegno { gap: var(--s-3); }
  .impegno-op { display: none; }
  .impegno-fig { flex: 1 1 100%; flex-direction: row; align-items: baseline; justify-content: space-between; }
  .accelera-grid { grid-template-columns: 1fr; }
}

/* ── Guasto bloccante ───────────────────────────────────── */
.fatal { display: grid; place-items: center; min-height: 100dvh; padding: var(--s-6); }
.fatal-box {
  display: flex; flex-direction: column; align-items: flex-start;
  gap: var(--s-3);
  max-width: 56ch;
  padding: var(--s-6);
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--rule-soft);
  box-shadow: var(--shadow);
}
.fatal-mark {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--warn-soft);
  color: var(--warn-ink);
}
.fatal-box h1 { font-size: var(--t-xl); letter-spacing: -0.02em; }
.fatal-box p { font-size: var(--t-md); color: var(--muted); line-height: 1.55; text-wrap: pretty; }
.fatal-box code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
  padding: 2px 5px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--ink-2);
}
.fatal-detail {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--t-sm) !important;
  padding: var(--s-3);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  width: 100%;
  overflow-wrap: anywhere;
}
.fatal-box .btn { margin-top: var(--s-2); }

/* ── Stato sincronizzazione ─────────────────────────────── */
.sync-badge {
  position: fixed;
  left: var(--s-4); bottom: var(--s-4);
  z-index: var(--z-tooltip);
  padding: 7px 12px;
  border-radius: 20px;
  font-size: var(--t-sm);
  font-weight: 500;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow-lg);
}
.sync-badge.is-offline { color: var(--warn-ink); border-color: var(--warn-soft); }

/* ═══════════════════════════════════════════════════════════
   Notifiche
   ═══════════════════════════════════════════════════════════ */
.notif { position: relative; }
.badge-count {
  position: absolute; top: 4px; right: 4px;
  min-width: 17px; height: 17px;
  padding: 0 4px;
  display: grid; place-items: center;
  border-radius: 20px;
  background: var(--neg);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  border: 2px solid var(--bg);
}
.badge-count[hidden] { display: none; }

.notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: var(--z-tooltip);
  width: min(360px, calc(100% - 24px));
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.notif-panel[hidden] { display: none; }

.notif-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--rule-soft);
}
.notif-head b { font-size: var(--t-md); }
.notif-clear {
  font-size: var(--t-sm); font-weight: 600;
  color: var(--muted);
  transition: color 140ms var(--ease);
}
.notif-clear:hover { color: var(--primary); }
[data-theme="dark"] .notif-clear:hover { color: oklch(0.82 0.12 272); }

.notif-list { overflow-y: auto; }
.notif-empty { padding: var(--s-6) var(--s-4); text-align: center; font-size: var(--t-sm); color: var(--muted); }

.notif-item a {
  display: flex; gap: 11px;
  padding: 11px var(--s-4);
  transition: background-color 140ms var(--ease);
}
.notif-item + .notif-item a { border-top: 1px solid var(--rule-soft); }
.notif-item a:hover { background: var(--surface-2); }
.notif-item.is-unread a { background: var(--primary-soft); }
.notif-item.is-unread a:hover { background: var(--primary-line); }

.notif-ico {
  width: 32px; height: 32px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
}
.notif-ico .ico { width: 16px; height: 16px; }
.notif-ico[data-k="neg"]  { background: var(--neg-soft);  color: var(--neg); }
.notif-ico[data-k="warn"] { background: var(--warn-soft); color: var(--warn-ink); }
.notif-ico[data-k="info"] { background: var(--primary-soft); color: var(--primary); }
.notif-ico[data-k="pos"]  { background: var(--pos-soft);  color: var(--pos); }
[data-theme="dark"] .notif-ico[data-k="info"] { color: oklch(0.82 0.12 272); }

.notif-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.notif-text b { font-size: var(--t-base); font-weight: 600; line-height: 1.3; }
.notif-text small { font-size: var(--t-sm); color: var(--muted); line-height: 1.4; text-wrap: pretty; }
.notif-text em { font-size: var(--t-xs); font-style: normal; color: var(--muted); margin-top: 1px; }

/* ── Tooltip ────────────────────────────────────────────── */
.tip {
  position: fixed;
  z-index: var(--z-tooltip);
  max-width: 270px;
  padding: 9px 11px;
  border-radius: 10px;
  font-size: var(--t-sm);
  line-height: 1.45;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 140ms var(--ease), transform 140ms var(--ease);
}
.tip.is-open { opacity: 1; transform: translateY(0); }
.tip[hidden] { display: none; }

/* ── Animazioni ─────────────────────────────────────────── */
/* Tutte le entrate partono da uno stato nascosto e tornano al valore
   naturale dell'elemento: nessuna usa fill-mode per *restare* visibile. */
@keyframes draw { from { stroke-dashoffset: var(--len, 400); } }
@keyframes fade { from { opacity: 0; } }
@keyframes grow { from { transform: scaleX(0); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ── Responsive (strutturale) ───────────────────────────── */
/* Sotto i 1440 la sparkline passa sotto la cifra invece di comprimerla. */
@media (max-width: 1440px) {
  .hero-body { flex-direction: column; align-items: stretch; gap: var(--s-3); }
  .hero-spark { width: 100%; height: 44px; }
}

/* Nessuna metrica viene nascosta: sotto i 1180 si impagina 2×2 pieno.
   La hero resta dominante per dimensione della cifra, non per larghezza. */
@media (max-width: 1180px) {
  .row-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row-main, .row-bottom { grid-template-columns: minmax(0, 1fr); }
  .row-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .row-triple { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .col-stack { grid-column: span 2; flex-direction: row; }
  .col-stack > .card { flex: 1; }
}

@media (max-width: 1000px) {
  :root { --sidebar-w: 72px; }
  .sidebar { padding: var(--s-4) 10px; align-items: center; }
  .brand-name, .nav-item span:not(.nav-tag):not(.nav-dot), .nav-label, .regime, .theme-opt i { display: none; }
  .nav-item { justify-content: center; padding: 10px; }
  .nav-tag, .nav-dot { display: none; }
  .theme-toggle { grid-template-columns: 1fr; }
  .theme-opt { padding: 8px; }
  [data-theme="dark"] .theme-opt[data-theme-opt="light"],
  [data-theme="light"] .theme-opt[data-theme-opt="dark"] { display: none; }
  .topbar { padding: var(--s-4) var(--s-5); flex-direction: column; align-items: stretch; gap: var(--s-3); }
  .content { padding: var(--s-5) var(--s-5) var(--s-7); }
  .topbar-tools { width: 100%; }
  .search { flex: 1; width: auto; }
}

@media (max-width: 720px) {
  .row-metrics, .row-triple { grid-template-columns: minmax(0, 1fr); }
  .card-hero { grid-column: auto; }
  .col-stack { grid-column: auto; flex-direction: column; }
  .hero-figure .metric-value { font-size: var(--t-2xl); }
  .hero-spark { display: none; }
  .topbar-lead h1 { font-size: var(--t-lg); }
  .btn-primary span, .btn-primary { font-size: var(--t-sm); }
  .clients li { grid-template-columns: 96px minmax(0, 1fr) 38px; }
  .cl-eur { display: none; }
  .chart { height: 220px; }

  /* Intestazione e comandi vanno a capo invece di comprimere il titolo. */
  .card-head-split { flex-wrap: wrap; row-gap: var(--s-3); }
  .card-head-split > div { flex: 1 1 100%; }
  .topbar-tools { flex-wrap: wrap; row-gap: var(--s-2); }
  .search { flex: 1 1 100%; order: -1; }

  /* Movimenti */
  .row-summary { grid-template-columns: minmax(0, 1fr); }
  .filters > .select, .filters > .btn { flex: 1 1 auto; }
  .field-row { grid-template-columns: minmax(0, 1fr); }
  /* Pannello a tutta larghezza reale (no 100%: su iOS eccede il viewport
     e fa "ballare" la pagina). Slide dal basso: zero sforamento orizzontale. */
  .sheet { width: 100%; margin: 0; }
  .sheet[open] { animation: sheetInMobile 260ms var(--ease); }
}
@keyframes sheetInMobile { from { transform: translateY(18px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 560px) {
  .btn-primary { padding: 0 11px; }
  .btn-label { display: none; }
}

/* ── Stato finale senza animazione ──────────────────────────
   Vale sia per prefers-reduced-motion sia per .ff-no-anim (scheda
   aperta in background: le animazioni non partono mai, quindi lo
   stato di partenza nascosto non deve essere applicato). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.ff-no-anim .spark-line, .ff-no-anim .spark-area,
.ff-no-anim .ring-fill, .ff-no-anim .threshold-fill,
.ff-no-anim .cl-bar i, .ff-no-anim .fc-actual,
.ff-no-anim .fc-proj, .ff-no-anim .ai-item,
.ff-no-anim .toast, .ff-no-anim .sheet[open] {
  animation: none !important;
}

.ff-no-anim .spark-line { stroke-dashoffset: 0; }
.ff-no-anim .spark-area { opacity: 1; }
.ff-no-anim .ring-fill  { stroke-dashoffset: calc(377 - 377 * var(--pct) / 100); }

@media (prefers-reduced-motion: reduce) {
  .spark-line { stroke-dashoffset: 0; }
  .spark-area { opacity: 1; }
  .ring-fill  { stroke-dashoffset: calc(377 - 377 * var(--pct) / 100); }
}

/* ── No auto-zoom su iOS ─────────────────────────────────────
   Safari mobile ingrandisce (e sposta) la pagina quando un campo
   ha font < 16px e prende il focus. Portiamo i campi testuali a 16px
   SOLO su touch: la densità desktop resta invariata. L'importo resta
   grande. Evita anche lo scroll orizzontale post-zoom. */
@media (pointer: coarse), (max-width: 640px) {
  .field input:not([type="checkbox"]):not([type="radio"]),
  .field .select,
  .select, .select-cella, .cella,
  .search input,
  input[type="text"], input[type="email"], input[type="password"],
  input[type="tel"], input[type="number"], input[type="search"],
  input[type="date"], textarea {
    font-size: 16px;
  }
  /* l'importo grande non deve rimpicciolirsi */
  .amount-box input { font-size: var(--t-2xl); }
}

/* Nessuna pagina deve scrollare in orizzontale (niente “balletto” dx/sx). */
html, body { overflow-x: hidden; max-width: 100%; }

/* ── Andamento incassi (Revenue Flow) ─────────────────────── */
.flow-body { display: grid; grid-template-columns: 320px 1fr; gap: 26px; align-items: stretch; }
.flow-left { display: flex; flex-direction: column; }
.flow-total { font-size: 40px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.flow-sub { font-size: var(--t-sm); color: var(--muted); margin-top: 8px; }
.flow-insight { margin-top: auto; border: 1px solid var(--rule-soft); border-radius: var(--r-md); background: var(--surface-2); padding: 15px 16px; }
.fi-card b { font-size: var(--t-md); font-weight: 700; display: block; letter-spacing: -0.01em; }
.fi-card p { font-size: var(--t-sm); color: var(--muted); line-height: 1.5; margin-top: 5px; min-height: 42px; }
.fi-nav { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.fi-arrow { width: 26px; height: 26px; flex: none; display: grid; place-items: center; border: 1px solid var(--rule-soft); border-radius: 8px; background: var(--surface); color: var(--muted); cursor: pointer; transition: color 140ms, border-color 140ms; }
.fi-arrow:hover { color: var(--ink); border-color: var(--rule); }
.fi-arrow svg { width: 15px; height: 15px; }
.fi-dots { display: flex; gap: 6px; flex: 1; }
.fi-dots .d { flex: 1; height: 4px; border-radius: 999px; background: var(--surface-3); overflow: hidden; position: relative; }
.fi-dots .d i { position: absolute; inset: 0; width: 0; background: var(--primary); border-radius: 999px; }
.fi-dots .d.done i { width: 100%; }

.flow-chart { position: relative; min-width: 0; }
.flow-chart #flowSvg { width: 100%; height: 220px; display: block; }
.flow-xax { display: flex; justify-content: space-between; margin-top: 6px; }
.flow-xax span { font-size: 11px; color: var(--muted); }
.flow-tip { position: absolute; z-index: 5; pointer-events: none; background: var(--surface-2); border: 1px solid var(--rule); border-radius: 10px; padding: 8px 11px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; white-space: nowrap; }
.flow-tip .ft-date { font-size: 11px; color: var(--muted); }
.flow-tip .ft-val { font-size: var(--t-md); font-weight: 700; }
.flow-tip .ft-delta { font-size: 11px; font-weight: 600; color: var(--pos); }
@media (max-width: 860px) {
  .flow-body { grid-template-columns: 1fr; gap: 18px; }
  .flow-total { font-size: 34px; }
  .flow-chart #flowSvg { height: 180px; }
}

/* Nastro "demo": pill in basso al centro, sopra la nav mobile. */
.demo-ribbon {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  z-index: 480; max-width: calc(100% - 24px);
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 8px 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--rule); box-shadow: var(--shadow-lg);
  font-size: var(--t-sm); color: var(--muted);
}
.demo-ribbon .dr-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--pos); flex: none; }
.demo-ribbon b { color: var(--ink); font-weight: 700; }
.demo-ribbon .dr-txt { white-space: nowrap; }
/* CTA "Crea il tuo account": gradient animato che si illumina + bagliore
   pulsante + passata di luce, per invitare al click. Il testo è bianco:
   la sheen (bianca) non lo tocca, scivola solo sullo sfondo colorato. */
.demo-ribbon .dr-cta { flex: none; text-decoration: none; font-weight: 700;
  color: #fff; padding: 7px 15px; border-radius: 999px;
  position: relative; overflow: hidden; isolation: isolate;
  background: linear-gradient(110deg,
    oklch(0.60 0.20 272), oklch(0.66 0.19 292), oklch(0.72 0.16 262), oklch(0.60 0.20 272));
  background-size: 220% 100%;
  box-shadow: 0 3px 12px -3px oklch(0.60 0.20 272 / 0.5);
  animation: drCtaGrad 4.2s ease-in-out infinite, drCtaGlow 2.6s ease-in-out infinite;
}
.demo-ribbon .dr-cta::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: 0; width: 45%;
  background: linear-gradient(100deg, transparent, oklch(1 0 0 / 0.55), transparent);
  transform: translateX(-160%) skewX(-18deg); pointer-events: none;
  animation: drCtaSheen 3.6s ease-in-out infinite;
}
.demo-ribbon .dr-cta:hover { filter: brightness(1.08); }
.demo-ribbon .dr-cta:active { transform: scale(0.96); }
@keyframes drCtaGrad { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
@keyframes drCtaGlow {
  0%, 100% { box-shadow: 0 3px 12px -3px oklch(0.60 0.20 272 / 0.45); }
  50%      { box-shadow: 0 5px 22px -2px oklch(0.64 0.21 285 / 0.8); }
}
@keyframes drCtaSheen { 0% { transform: translateX(-160%) skewX(-18deg); } 55%, 100% { transform: translateX(320%) skewX(-18deg); } }
@media (prefers-reduced-motion: reduce) {
  .demo-ribbon .dr-cta { animation: none; background-position: 0 50%; }
  .demo-ribbon .dr-cta::after { display: none; }
}
.demo-ribbon .dr-x { flex: none; border: 0; background: none; color: var(--muted); cursor: pointer;
  font-size: 18px; line-height: 1; padding: 0 6px; }
.demo-ribbon .dr-x:hover { color: var(--ink); }
@media (max-width: 760px) {
  /* Sopra la dock liquid-glass staccata (bottom 14px + ~56px) e sopra il
     "+" centrale rialzato (sporge ~14px): serve più aria del vecchio 68px. */
  .demo-ribbon { bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
  .demo-ribbon .dr-txt { display: none; }
}

/* Avviso di rete non distruttivo: la pagina resta coi dati in cache. */
.net-warn {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  z-index: 500; max-width: calc(100% - 24px);
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 12px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--rule); box-shadow: var(--shadow-lg);
  font-size: var(--t-sm);
}
.net-warn button {
  flex: none; border: 0; cursor: pointer;
  padding: 6px 12px; border-radius: 8px;
  background: var(--primary); color: var(--primary-ink);
  font: 600 var(--t-sm)/1 var(--font);
}

/* ── Tasse: grafico andamento + previsioni ─────────────────── */
.select-wrap { display: inline-flex; }
.tax-chart { margin-top: 6px; }
.tax-bars { display: flex; align-items: flex-end; gap: 6px; height: 180px; }
.tax-bar {
  flex: 1; height: 100%; display: flex; align-items: flex-end;
  padding: 0; border: 0; background: none; cursor: pointer;
  border-radius: 6px 6px 0 0; position: relative;
  transition: background 140ms var(--ease);
}
.tax-bar:hover { background: var(--surface-2); }
.tb-fill {
  display: block; width: 100%; box-sizing: border-box; min-height: 3px;
  border-radius: 6px 6px 0 0; background: var(--warn);
  transition: height 500ms var(--ease);
}
.tax-bar.is-est .tb-fill { background: var(--warn-soft); border: 1px dashed var(--warn); }
.tax-bar:focus { outline: none; }
.tax-bar.is-sel .tb-fill { background: var(--warn); border-style: solid; outline: 2px solid var(--ink); outline-offset: 2px; }
.tax-bar:focus-visible .tb-fill { outline: 2px solid var(--primary); outline-offset: 2px; }
.tax-bar.is-now::before {
  content: ''; position: absolute; top: -9px; left: 50%; transform: translateX(-50%);
  width: 5px; height: 5px; border-radius: 50%; background: var(--warn);
}
.tax-xaxis { display: flex; gap: 6px; margin-top: 8px; }
.tax-xaxis span { flex: 1; text-align: center; font-size: 10px; color: var(--muted); }
.tax-xaxis span.is-now { color: var(--warn-ink); font-weight: 700; }

.tax-legend { display: flex; align-items: center; gap: 16px; margin-top: 14px; font-size: var(--t-sm); color: var(--muted); }
.tl-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; margin-right: 5px; }
.tl-real { background: var(--warn); }
.tl-est { background: var(--warn-soft); border: 1px dashed var(--warn); }
.tax-legend-hint { margin-left: auto; font-size: var(--t-xs); }

.tax-forecast { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 12px; margin-top: 18px; }
.tax-stat { border: 1px solid var(--rule-soft); border-radius: var(--r-md); padding: 14px; }
.tax-stat > span { font-size: var(--t-sm); color: var(--muted); display: block; }
.tax-stat b { font-size: var(--t-xl); font-weight: 700; letter-spacing: -0.02em; display: block; margin-top: 4px; }
.tax-stat b small { font-size: var(--t-md); color: var(--muted); font-weight: 500; }
.tax-stat > small { font-size: var(--t-xs); color: var(--muted); display: block; margin-top: 4px; }
.tax-stat.is-lead { background: var(--warn-soft); border-color: transparent; }
.tax-stat.is-warn b { color: var(--warn-ink); }

@media (max-width: 640px) {
  .tax-bars { height: 140px; }
  .tax-legend-hint { display: none; }
}

/* Variante indaco per la dashboard Debiti (riusa la struttura .tax-*). */
.is-debt .tb-fill,
.is-debt .tl-real { background: var(--primary); }
.is-debt .tax-bar.is-est .tb-fill { background: var(--primary-soft); border: 1px dashed var(--primary); }
.is-debt .tl-est { background: var(--primary-soft); border: 1px dashed var(--primary); }
.is-debt .tax-bar.is-sel .tb-fill { background: var(--primary); border-style: solid; }
.is-debt .tax-bar.is-now::before { background: var(--primary); }
.is-debt .tax-xaxis span.is-now { color: var(--primary); }
.is-debt.tax-forecast .tax-stat.is-lead,
.is-debt .tax-stat.is-lead { background: var(--primary-soft); }
.is-debt .tax-stat.is-warn b { color: var(--primary); }

/* Entrate (menta) e Uscite (rosa) — stessa struttura .tax-*. */
.is-in .tb-fill, .is-in .tl-real { background: var(--pos); }
.is-in .tax-bar.is-est .tb-fill, .is-in .tl-est { background: var(--pos-soft); border: 1px dashed var(--pos); }
.is-in .tax-bar.is-sel .tb-fill { background: var(--pos); border-style: solid; }
.is-in .tax-bar.is-now::before { background: var(--pos); }
.is-in .tax-xaxis span.is-now { color: var(--pos); }
.is-in.tax-forecast .tax-stat.is-lead, .is-in .tax-stat.is-lead { background: var(--pos-soft); }

.is-out .tb-fill, .is-out .tl-real { background: var(--neg); }
.is-out .tax-bar.is-est .tb-fill, .is-out .tl-est { background: var(--neg-soft); border: 1px dashed var(--neg); }
.is-out .tax-bar.is-sel .tb-fill { background: var(--neg); border-style: solid; }
.is-out .tax-bar.is-now::before { background: var(--neg); }
.is-out .tax-xaxis span.is-now { color: var(--neg); }
.is-out.tax-forecast .tax-stat.is-lead, .is-out .tax-stat.is-lead { background: var(--neg-soft); }
