/* ============================================================
   Numio — schermata mobile

   Riprogettata attorno a tre domande, non a un elenco di dati:
   quanto ho davvero · cosa devo · come sto andando.

   La versione precedente impilava sei indicatori a scorrimento e
   tre caroselli, tutti sulla stessa superficie: nessuno scorre
   lateralmente per cercare un numero, e se ogni riquadro ha lo
   stesso peso visivo non ne ha nessuno.

   Qui il colore fa da struttura. Due blocchi tematici con superfici
   tinte diverse — ambra per ciò che devi, indaco per come stai
   andando — così il pollice sa dove guardare prima di leggere.
   ============================================================ */

.m {
  background: var(--bg);
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}

/* Nessun movimento orizzontale, mai: né scorrimento né rimbalzo. `clip`
   non crea un contenitore scrollabile come `hidden`, quindi non intrappola
   i pannelli in top layer. */
@media (max-width: 720px) {
  html, body { overflow-x: clip; max-width: 100%; }
  /* Con un pannello aperto lo sfondo resta immobile: la tastiera non lo
     fa più scorrere o spostare lateralmente. */
  html.ff-modal-open, html.ff-modal-open body { overflow: hidden; }
}

.m-app {
  max-width: 560px;
  margin-inline: auto;
  padding: 0 var(--s-4) calc(104px + env(safe-area-inset-bottom));
}
.m-app[hidden] { display: none; }

/* ── Avvio ──────────────────────────────────────────────── */
.m-boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 900; }
.m-boot[hidden] { display: none; }
.m-boot-dot {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2.5px solid var(--rule);
  border-top-color: var(--primary);
  animation: mSpin 700ms linear infinite;
}
@keyframes mSpin { to { transform: rotate(360deg); } }

/* ── Intestazione ───────────────────────────────────────── */
.m-top {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: calc(var(--s-4) + env(safe-area-inset-top)) 0 var(--s-2);
}
.m-avatar {
  width: 38px; height: 38px;
  flex: none;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-ink);
  font-size: var(--t-sm);
  font-weight: 700;
  display: grid; place-items: center;
  overflow: hidden;
  position: relative;
}
/* Assoluto + inset:0: riempie SEMPRE il cerchio. Con width/height:100% dentro
   una grid centrata la height% non trovava un genitore definito e l'img
   ricadeva sull'aspect-ratio (non riempiva). */
.m-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.m-top-text { flex: 1; min-width: 0; }
.m-hello { font-size: var(--t-md); font-weight: 600; letter-spacing: -0.01em; }
.m-date { font-size: var(--t-sm); color: var(--muted); }

.m-bell {
  position: relative;
  width: 38px; height: 38px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--rule-soft);
  color: var(--ink-2);
}
.m-bell-dot {
  position: absolute; top: 8px; right: 9px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--warn);
  border: 2px solid var(--surface);
}
.m-bell-dot[hidden] { display: none; }

/* ══ 1. QUANTO HO DAVVERO ═══════════════════════════════════
   Occupa mezzo schermo perché è la domanda per cui si apre l'app. */
.m-hero {
  padding-top: var(--s-5); text-align: center;
  /* Alone morbido dietro la cifra: dà profondità senza pesare. */
  background: radial-gradient(58% 42% at 50% 24%, oklch(0.62 0.19 272 / 0.16), transparent 72%);
}

.m-hero-label { font-size: var(--t-sm); font-weight: 500; color: var(--muted); letter-spacing: 0.01em; }
.m-hero-value {
  margin-top: 8px;
  font-size: 3.15rem;
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 1;
  white-space: nowrap;
  /* Durante il trascinamento la cifra cambia a ogni frame: senza
     larghezza fissa delle cifre ballerebbe di continuo. */
  font-variant-numeric: tabular-nums;
}
.m-hero-delta {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  padding: 4px 11px;
  border-radius: 20px;
  font-size: var(--t-sm);
  font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
}
.m-hero-delta.is-up { color: var(--pos); background: var(--pos-soft); }
.m-hero-delta.is-down { color: var(--neg); background: var(--neg-soft); }

.m-hero-sub {
  margin-top: var(--s-3);
  font-size: var(--t-sm);
  color: var(--muted);
  text-wrap: pretty;
}

/* ── Grafico ────────────────────────────────────────────── */
.m-chart {
  position: relative;
  height: 172px;
  margin: var(--s-4) calc(var(--s-4) * -1) 0;
  touch-action: pan-y;
}
.m-chart-svg { display: block; width: 100%; height: 100%; filter: drop-shadow(0 4px 12px oklch(0.62 0.19 272 / 0.30)); }

.m-scrub { position: absolute; inset: 0; pointer-events: none; }
.m-scrub[hidden] { display: none; }
.m-scrub-line {
  position: absolute; top: 0; bottom: 0;
  width: 1px;
  background: linear-gradient(to bottom, transparent, var(--primary-line) 18%, var(--primary-line) 82%, transparent);
  transform: translateX(-0.5px);
}
.m-scrub-dot {
  position: absolute;
  width: 13px; height: 13px;
  margin: -6.5px 0 0 -6.5px;
  border-radius: 50%;
  background: var(--primary);
  border: 2.5px solid var(--bg);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.m-ranges {
  display: inline-flex;
  gap: 2px;
  margin-top: var(--s-4);
  padding: 3px;
  border-radius: 12px;
  background: var(--surface-2);
}
.m-range {
  min-height: 32px;
  padding: 0 14px;
  border-radius: 9px;
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--muted);
  transition: background-color 160ms var(--ease), color 160ms var(--ease);
}
.m-range.is-on { background: var(--surface); color: var(--ink); }

/* ── Azioni ─────────────────────────────────────────────── */
.m-quick {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-2);
  margin-top: var(--s-5);
}
.m-quick-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 54px;
  border-radius: 16px;
  background: var(--surface-2);
  border: 1px solid transparent;
  font-size: var(--t-base);
  font-weight: 600;
  color: var(--ink);
  transition: transform 140ms var(--ease), filter 140ms var(--ease);
}
.m-quick-btn:active { transform: scale(0.96); filter: brightness(1.08); }
.m-quick-btn .ico { width: 18px; height: 18px; stroke-width: 2.3; color: var(--muted); }
.m-quick-btn.is-in  { background: var(--pos-soft); }
.m-quick-btn.is-in  .ico { color: var(--pos); }
.m-quick-btn.is-out { background: var(--neg-soft); }
.m-quick-btn.is-out .ico { color: var(--neg); }

/* ── Avviso ─────────────────────────────────────────────────
   Uno solo alla volta: due avvisi contemporanei si annullano. */
.m-alert {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-top: var(--s-4);
  padding: var(--s-3) var(--s-4);
  border-radius: 16px;
  background: var(--warn-soft);
  border: 1px solid oklch(from var(--warn) l c h / 0.22);
}
.m-alert[hidden] { display: none; }
.m-alert-ico {
  width: 34px; height: 34px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 11px;
  background: oklch(from var(--warn) l c h / 0.18);
  color: var(--warn-ink);
}
.m-alert-ico .ico { width: 17px; height: 17px; }
.m-alert-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.m-alert-text b { font-size: var(--t-base); font-weight: 600; line-height: 1.3; }
.m-alert-text small { font-size: var(--t-sm); color: var(--ink-2); line-height: 1.4; }

/* ══ BLOCCHI TEMATICI ════════════════════════════════════════
   La tinta di sfondo raggruppa: guardando lo schermo si capisce
   cosa appartiene a cosa prima ancora di leggere le parole. */
.m-block {
  margin-top: var(--s-5);
  padding: var(--s-4);
  border-radius: 20px;
  border: 1px solid var(--rule-soft);
}
.m-block.is-devi {
  background: linear-gradient(160deg,
    oklch(from var(--warn) l c h / 0.10) 0%,
    oklch(from var(--warn) l c h / 0.03) 55%,
    transparent 100%), var(--surface);
}
.m-block.is-vai {
  background: linear-gradient(160deg,
    oklch(from var(--primary) l c h / 0.12) 0%,
    oklch(from var(--primary) l c h / 0.04) 55%,
    transparent 100%), var(--surface);
}

.m-block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-3);
}
.m-block-head h2 { font-size: var(--t-lg); font-weight: 700; letter-spacing: -0.02em; }
.m-block-tot {
  font-size: var(--t-lg);
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.is-devi .m-block-tot { color: var(--warn-ink); }
.is-vai  .m-block-tot { color: var(--pos); }

/* ── Riga cliccabile dentro un blocco ───────────────────── */
.m-line {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 11px 0;
  min-height: 54px;
}
.m-line[hidden] { display: none; }
.m-line + .m-line { border-top: 1px solid var(--rule-soft); }
.m-line:active { opacity: 0.6; }

.m-line-ico {
  width: 38px; height: 38px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--muted);
}
.m-line-ico .ico { width: 17px; height: 17px; }
.m-line-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.m-line-text b { font-size: var(--t-base); font-weight: 600; }
.m-line-text small { font-size: var(--t-sm); color: var(--muted); }
.m-line-val { font-size: var(--t-md); font-weight: 600; white-space: nowrap; }

/* Anello compatto: la percentuale sta dentro, non accanto. */
.m-ring { position: relative; width: 38px; height: 38px; flex: none; display: grid; place-items: center; }
.m-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.m-ring circle { fill: none; stroke-width: 5; stroke-linecap: round; }
.m-ring-bg { stroke: var(--surface-3); }
.m-ring-fg {
  stroke: var(--warn);
  stroke-dasharray: 113;
  stroke-dashoffset: calc(113 - 113 * var(--pct, 0) / 100);
  transition: stroke-dashoffset 700ms var(--ease);
}
.m-ring i {
  position: absolute;
  font-size: 10px;
  font-weight: 700;
  font-style: normal;
  letter-spacing: -0.02em;
}

/* ── Soglia ─────────────────────────────────────────────── */
.m-soglia { display: block; padding: var(--s-2) 0 var(--s-3); }
.m-soglia:active { opacity: 0.6; }
.m-soglia-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); }
.m-soglia-row small { font-size: var(--t-sm); color: var(--muted); }
.m-soglia-row b { font-size: var(--t-md); font-weight: 600; }
.m-soglia-note { display: block; margin-top: 7px; font-size: var(--t-sm); color: var(--muted); text-wrap: pretty; }

.m-bar {
  position: relative;
  display: block;
  height: 8px;
  margin-top: 9px;
  border-radius: 4px;
  background: var(--surface-3);
  overflow: hidden;
}
.m-bar em {
  position: absolute; inset-block: 0; left: 0;
  border-radius: 4px;
  background: var(--primary);
  z-index: 1;
  transition: width 700ms var(--ease);
}
.m-bar i {
  position: absolute; inset-block: 0; left: 0;
  border-radius: 4px;
  background: oklch(from var(--warn) l c h / 0.30);
  transition: width 700ms var(--ease);
}

/* ── Due celle affiancate ───────────────────────────────── */
.m-duo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-2);
  margin-top: var(--s-3);
}
.m-duo-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: var(--s-3);
  border-radius: 14px;
  background: var(--surface-2);
}
.m-duo-cell:active { opacity: 0.65; }
.m-duo-cell small { font-size: var(--t-sm); color: var(--muted); }
.m-duo-cell b { font-size: var(--t-lg); font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; }
.m-duo-cell em { font-size: var(--t-xs); font-style: normal; color: var(--muted); }

/* ── Consigli a carosello ───────────────────────────────── */
.m-tips {
  display: flex;
  gap: var(--s-3);
  margin-inline: calc(var(--s-4) * -1);
  padding: 2px var(--s-4) 0;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.m-tips::-webkit-scrollbar { display: none; }
.m-tip {
  display: block;
  flex: 0 0 84%;
  scroll-snap-align: center;
  padding: var(--s-4);
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--rule-soft);
}
.m-tip:active { background: var(--surface-2); }
.m-tip-head { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; }
.m-tip-ico {
  width: 30px; height: 30px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
}
.m-tip-ico .ico { width: 16px; height: 16px; }
.m-tip-ico[data-k="warn"] { background: var(--warn-soft); color: var(--warn-ink); }
.m-tip-ico[data-k="neg"]  { background: var(--neg-soft);  color: var(--neg); }
.m-tip-ico[data-k="pos"]  { background: var(--pos-soft);  color: var(--pos); }
.m-tip-ico[data-k="info"] { background: var(--primary-soft); color: var(--primary); }
[data-theme="dark"] .m-tip-ico[data-k="info"] { color: oklch(0.82 0.12 272); }
.m-tip-title { font-size: var(--t-base); font-weight: 600; line-height: 1.35; text-wrap: pretty; }
.m-tip-body { font-size: var(--t-sm); color: var(--muted); line-height: 1.5; margin-top: 6px; text-wrap: pretty; }
.m-tip-act {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 10px;
  font-size: var(--t-sm); font-weight: 600;
  color: var(--primary);
}
[data-theme="dark"] .m-tip-act { color: oklch(0.82 0.12 272); }
.m-tip-act .ico { width: 13px; height: 13px; }

.m-count { font-size: var(--t-sm); color: var(--muted); }

/* ── Sezioni semplici ───────────────────────────────────── */
.m-section { margin-top: var(--s-6); }
.m-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-2);
}
.m-section-head h2 { font-size: var(--t-lg); font-weight: 700; letter-spacing: -0.02em; }
.m-more { font-size: var(--t-sm); font-weight: 600; color: var(--primary); }
[data-theme="dark"] .m-more { color: oklch(0.82 0.12 272); }

/* ── Conti: carte affiancate ────────────────────────────── */
.m-cardacc-row {
  display: flex;
  gap: var(--s-3);
  margin-inline: calc(var(--s-4) * -1);
  padding: 2px var(--s-4) 0;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.m-cardacc-row::-webkit-scrollbar { display: none; }

.m-cardacc {
  flex: 0 0 62%;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 128px;
  padding: var(--s-4);
  border-radius: 18px;
  /* La tinta del conto, dal nome: due strati per dare profondità da carta. */
  background:
    radial-gradient(120% 90% at 100% 0%, var(--seed-bg, var(--surface-2)) 0%, transparent 70%),
    var(--surface);
  border: 1px solid var(--rule-soft);
  transition: transform 140ms var(--ease);
}
.m-cardacc:active { transform: scale(0.98); }
.m-cardacc-top {
  display: flex; align-items: center; justify-content: space-between;
  color: var(--seed-ink, var(--muted));
}
.m-cardacc-tipo { font-size: var(--t-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.m-cardacc-top .ico { width: 18px; height: 18px; }
.m-cardacc-name {
  margin-top: auto;
  font-size: var(--t-sm); color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.m-cardacc-val { font-size: var(--t-xl); font-weight: 600; letter-spacing: -0.03em; white-space: nowrap; }
.m-cardacc-val.is-neg { color: var(--neg); }

/* Ultima carta: aggiungi/gestisci, tratteggiata e neutra. */
.m-cardacc.is-add {
  flex-basis: 44%;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: none;
  border-style: dashed;
  color: var(--muted);
  font-size: var(--t-sm);
  font-weight: 600;
  text-align: center;
}
.m-cardacc.is-add .ico { width: 22px; height: 22px; }

/* ── Movimenti ──────────────────────────────────────────── */
.m-moves { display: flex; flex-direction: column; }
.m-move { display: flex; align-items: center; gap: var(--s-3); padding: 11px 0; min-height: 54px; }
.m-move + .m-move { border-top: 1px solid var(--rule-soft); }
.m-move-mark {
  width: 38px; height: 38px;
  flex: none;
  display: grid; place-items: center;
  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));
}
.m-move-text { flex: 1; min-width: 0; }
.m-move-text b { display: block; font-size: var(--t-base); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-move-text small { font-size: var(--t-sm); color: var(--muted); }
.m-move-amt { font-size: var(--t-base); font-weight: 600; white-space: nowrap; }
.m-move-amt.is-in { color: var(--pos); }

.m-chev { width: 15px; height: 15px; color: var(--muted); flex: none; }

.m-legal {
  margin-top: var(--s-6);
  font-size: var(--t-xs);
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
  text-wrap: pretty;
}

/* ── Barra inferiore ────────────────────────────────────── */
/* Dock "liquid glass": staccata dalla base, vetro semitrasparente. */
.m-tabs {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom));
  width: calc(100% - 28px); max-width: 528px;
  z-index: 300;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  padding: 8px;
  border-radius: 28px;
  background: color-mix(in oklab, var(--surface) 55%, transparent);
  -webkit-backdrop-filter: blur(26px) saturate(1.8);
  backdrop-filter: blur(26px) saturate(1.8);
  border: 1px solid oklch(1 0 0 / 0.10);
  box-shadow: 0 16px 44px -10px oklch(0 0 0 / 0.55), inset 0 1px 0 oklch(1 0 0 / 0.10);
}
[data-theme="light"] .m-tabs {
  background: color-mix(in oklab, #fff 62%, transparent);
  border-color: oklch(0 0 0 / 0.06);
  box-shadow: 0 16px 40px -12px oklch(0 0 0 / 0.22), inset 0 1px 0 oklch(1 0 0 / 0.7);
}

/* Pulsante "+" al centro della dock, rialzato: movimenti rapidi. */
.m-fab {
  justify-self: center; align-self: center;
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  color: #fff;
  background: linear-gradient(150deg, oklch(0.70 0.17 272), oklch(0.55 0.19 272));
  box-shadow: 0 10px 24px -6px oklch(0.55 0.19 272 / 0.72), inset 0 1px 0 oklch(1 0 0 / 0.35);
  transform: translateY(-9px);
  transition: transform 220ms var(--ease);
}
.m-fab svg { width: 23px; height: 23px; transition: transform 220ms var(--ease); }
.m-fab:active { transform: translateY(-9px) scale(0.92); }
.m-fab.is-open svg { transform: rotate(45deg); }

.m-fab-backdrop {
  position: fixed; inset: 0; z-index: 301;
  background: oklch(0.08 0.01 272 / 0.4);
  opacity: 0; visibility: hidden; transition: opacity 200ms, visibility 200ms;
}
.m-fab-backdrop.is-open { opacity: 1; visibility: visible; }

.m-fab-menu {
  position: fixed; left: 50%; bottom: calc(146px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(10px) scale(0.96);
  transform-origin: bottom center;
  z-index: 302;
  display: flex; flex-direction: column; gap: 4px;
  padding: 8px; border-radius: 20px;
  min-width: 190px;
  background: color-mix(in oklab, var(--surface) 90%, transparent);
  -webkit-backdrop-filter: blur(24px) saturate(1.6);
  backdrop-filter: blur(24px) saturate(1.6);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow-lg);
  opacity: 0; visibility: hidden;
  transition: opacity 200ms var(--ease), transform 200ms var(--ease), visibility 200ms;
}
.m-fab-menu.is-open { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0) scale(1); }
.m-fab-menu a {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 20px 12px 13px; border-radius: 13px;
  font-size: var(--t-base); font-weight: 600; color: var(--ink); white-space: nowrap;
}
.m-fab-menu a:active { background: var(--surface-2); }
.m-fab-menu a .ico { width: 19px; height: 19px; color: var(--muted); }
.m-fab-menu a.in  .ico { color: var(--pos); }
.m-fab-menu a.out .ico { color: var(--neg); }

/* ── Assistente vocale ──────────────────────────────────── */
.m-voice .m-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.m-voice .m-sheet-head h2 { font-size: var(--t-lg); font-weight: 700; letter-spacing: -0.02em; }
.m-voice .m-sheet-close { width: auto; min-height: 0; padding: 8px 14px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); font-size: var(--t-sm); font-weight: 600; }
.mv-body { display: flex; flex-direction: column; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-5) var(--s-6); }
.mv-mic {
  width: 84px; height: 84px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(150deg, oklch(0.70 0.17 272), oklch(0.55 0.19 272));
  box-shadow: 0 14px 34px -8px oklch(0.55 0.19 272 / 0.6), inset 0 1px 0 oklch(1 0 0 / 0.3);
  transition: transform 160ms var(--ease);
  margin-top: var(--s-2);
}
.mv-mic svg { width: 34px; height: 34px; }
.mv-mic:active { transform: scale(0.94); }
.mv-mic.is-live { animation: mvPulse 1.4s ease-out infinite; }
@keyframes mvPulse {
  0%   { box-shadow: 0 14px 34px -8px oklch(0.55 0.19 272 / 0.6), 0 0 0 0 oklch(0.62 0.19 272 / 0.5); }
  70%  { box-shadow: 0 14px 34px -8px oklch(0.55 0.19 272 / 0.6), 0 0 0 22px oklch(0.62 0.19 272 / 0); }
  100% { box-shadow: 0 14px 34px -8px oklch(0.55 0.19 272 / 0.6), 0 0 0 0 oklch(0.62 0.19 272 / 0); }
}
.mv-status { font-size: var(--t-sm); color: var(--muted); text-align: center; text-wrap: pretty; }
.mv-status.is-err { color: var(--neg); }
.mv-transcript { font-size: var(--t-lg); font-weight: 600; letter-spacing: -0.01em; text-align: center; min-height: 1px; text-wrap: pretty; }
.mv-transcript:empty { display: none; }

.mv-result { width: 100%; }
.mv-result[hidden] { display: none; }
.mv-card {
  display: flex; flex-direction: column; gap: 3px;
  padding: var(--s-4); border-radius: var(--r-md);
  background: var(--primary-soft); border: 1px solid var(--primary-line);
  text-align: center;
}
.mv-card b { font-size: var(--t-lg); font-weight: 700; letter-spacing: -0.02em; }
.mv-card span { font-size: var(--t-sm); color: var(--ink-2); }
.mv-actions { display: flex; gap: var(--s-2); margin-top: var(--s-3); }
.mv-btn { flex: 1; min-height: 48px; border-radius: 13px; font-size: var(--t-md); font-weight: 600; }
.mv-btn.primary { background: var(--primary); color: var(--primary-ink); }
.mv-btn.primary:active { filter: brightness(1.08); }
.mv-btn.ghost { background: var(--surface-2); color: var(--ink); }

.mv-hints { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; margin-top: var(--s-2); }
.mv-hint {
  font-size: var(--t-sm); font-weight: 500; color: var(--ink-2);
  padding: 8px 13px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--rule-soft);
}
.mv-hint:active { background: var(--surface-3); }

.mv-manual { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-2); width: 100%; margin-top: var(--s-3); padding-top: var(--s-4); border-top: 1px solid var(--rule-soft); }
.mv-manual a { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 12px 0; border-radius: 14px; background: var(--surface-2); font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); }
.mv-manual a .ico { width: 18px; height: 18px; color: var(--muted); }
.mv-manual a.in .ico { color: var(--pos); }
.mv-manual a.out .ico { color: var(--neg); }

/* ── Assistente (dialog condiviso mobile + desktop) ───────── */
.nm-assist { position: fixed; inset: auto 0 0 0; margin: 0 auto; width: 100%; max-width: 620px;
  padding: 0; border: 0; background: transparent; max-height: 92dvh; }
.nm-assist::backdrop { background: oklch(0.08 0.01 272 / 0.5); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.nm-assist[open] { animation: nmAssistIn 260ms var(--ease); }
@keyframes nmAssistIn { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }
.nm-assist-in { background: var(--surface); color: var(--ink); border-radius: 26px 26px 0 0; padding: 12px 0 calc(18px + env(safe-area-inset-bottom)); overflow: hidden; }
.nm-assist .m-grab { width: 40px; height: 4px; border-radius: 999px; background: var(--rule); margin: 4px auto 8px; }
.nm-assist-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 20px 0; }
.nm-assist-head h2 { font-size: var(--t-lg); font-weight: 700; letter-spacing: -0.02em; }
.nm-assist-head-r { display: flex; align-items: center; gap: 8px; }
.nm-assist-help { width: 30px; height: 30px; flex: none; border-radius: 50%; background: var(--surface-2); color: var(--ink-2); font-weight: 700; font-size: 15px; }
.nm-assist-x { padding: 8px 14px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); font-size: var(--t-sm); font-weight: 600; }
.nm-assist-body { display: flex; flex-direction: column; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-5) var(--s-2); }
.nm-assist-body[hidden] { display: none; }
.nm-assist-tutlink { margin-top: var(--s-2); font-size: var(--t-sm); font-weight: 600; color: var(--primary); }
[data-theme="dark"] .nm-assist-tutlink { color: oklch(0.82 0.12 272); }

.nm-assist-tut { padding: var(--s-3) var(--s-5) var(--s-2); display: flex; flex-direction: column; gap: var(--s-3); }
.nm-assist-tut[hidden] { display: none; }
.nm-tut-lead { font-size: var(--t-sm); color: var(--ink-2); line-height: 1.55; text-wrap: pretty; }
.nm-tut-lead b { color: var(--ink); }
.nm-tut-row { display: flex; align-items: flex-start; gap: 12px; }
.nm-tut-ic { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 11px; background: var(--primary-soft); color: var(--primary); }
[data-theme="dark"] .nm-tut-ic { color: oklch(0.82 0.12 272); }
.nm-tut-ic .ico { width: 18px; height: 18px; }
.nm-tut-row b { font-size: var(--t-base); font-weight: 700; display: block; }
.nm-tut-row small { font-size: var(--t-sm); color: var(--muted); line-height: 1.5; }
.nm-tut-row small b { font-weight: 600; color: var(--ink-2); font-size: inherit; }
.nm-assist-tut .mv-btn { margin-top: var(--s-2); }

@media (min-width: 721px) {
  .nm-assist { inset: 0; margin: auto; width: min(440px, 92vw); height: max-content; max-height: 88vh; }
  .nm-assist-in { border-radius: 22px; box-shadow: var(--shadow-lg); }
  .nm-assist .m-grab { display: none; }
}
.m-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 0;
  min-height: 46px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
}
.m-tab .ico { width: 20px; height: 20px; transition: transform 200ms var(--ease); }
.m-tab.is-on { color: var(--primary); background: color-mix(in oklab, var(--primary) 11%, transparent); }
.m-tab.is-on .ico { transform: translateY(-1px); }
[data-theme="dark"] .m-tab.is-on { color: oklch(0.82 0.12 272); }
.m-tab:active { background: var(--surface-2); }

/* Tab "Personale": accento TEAL (vita privata, non business). L'icona è
   sempre teal così si distingue nella dock; da attiva prende la pillola teal. */
.m-tab-pers .ico { color: oklch(0.72 0.115 185); }
.m-tab-pers.is-on { color: oklch(0.74 0.12 185); background: color-mix(in oklab, oklch(0.72 0.115 185) 14%, transparent); }
[data-theme="dark"] .m-tab-pers.is-on { color: oklch(0.82 0.10 185); }

/* ── Pannello "Altro" ───────────────────────────────────── */
.m-sheet {
  width: 100%;
  max-width: 560px;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 24px 24px 0 0;
  background: var(--surface);
  color: var(--ink);
}
.m-sheet::backdrop { background: oklch(0.06 0.01 272 / 0.6); }
.m-sheet[open] { animation: mUp 280ms var(--ease); }
@keyframes mUp { from { transform: translateY(100%); } }

.m-sheet-in { padding: var(--s-3) var(--s-4) calc(var(--s-5) + env(safe-area-inset-bottom)); }
.m-grab { width: 38px; height: 4px; margin: 0 auto var(--s-4); border-radius: 2px; background: var(--rule); }
.m-menu-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-2); }
.m-menu-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: var(--s-4) var(--s-2);
  border-radius: 14px;
  background: var(--surface-2);
  font-size: var(--t-xs);
  font-weight: 600;
  color: var(--ink-2);
  text-align: center;
}
.m-menu-item .ico { width: 20px; height: 20px; color: var(--muted); }
.m-menu-item:active { background: var(--surface-3); }
.m-sheet-close {
  width: 100%;
  margin-top: var(--s-4);
  padding: 14px;
  border-radius: 14px;
  background: var(--surface-2);
  font-size: var(--t-md);
  font-weight: 600;
  color: var(--ink);
}

/* ── Foglio notifiche ───────────────────────────────────── */
.m-sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-3); }
.m-sheet-head h2 { font-size: var(--t-lg); }
.m-notif-clear { font-size: var(--t-sm); font-weight: 600; color: var(--primary); }
[data-theme="dark"] .m-notif-clear { color: oklch(0.82 0.12 272); }

.m-notif-list { display: flex; flex-direction: column; max-height: 60dvh; overflow-y: auto; margin-inline: calc(var(--s-4) * -1); }
.m-notif-empty { padding: var(--s-6); text-align: center; font-size: var(--t-sm); color: var(--muted); }
.m-notif a { display: flex; gap: 11px; padding: 12px var(--s-4); min-height: 56px; }
.m-notif + .m-notif a { border-top: 1px solid var(--rule-soft); }
.m-notif.is-unread a { background: var(--primary-soft); }
.m-notif-ico { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 11px; }
.m-notif-ico .ico { width: 16px; height: 16px; }
.m-notif-ico[data-k="neg"]  { background: var(--neg-soft);  color: var(--neg); }
.m-notif-ico[data-k="warn"] { background: var(--warn-soft); color: var(--warn-ink); }
.m-notif-ico[data-k="info"] { background: var(--primary-soft); color: var(--primary); }
.m-notif-ico[data-k="pos"]  { background: var(--pos-soft);  color: var(--pos); }
[data-theme="dark"] .m-notif-ico[data-k="info"] { color: oklch(0.82 0.12 272); }
.m-notif-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.m-notif-text b { font-size: var(--t-base); font-weight: 600; line-height: 1.3; }
.m-notif-text small { font-size: var(--t-sm); color: var(--muted); line-height: 1.4; text-wrap: pretty; }
.m-notif-text em { font-size: var(--t-xs); font-style: normal; color: var(--muted); }

@media (min-width: 620px) {
  .m-tabs { width: 500px; }
}

/* ══════════════════════════════════════════════════════════
   LE ALTRE PAGINE SU TELEFONO

   Le pagine interne nascono per il desktop: sidebar, tabelle a
   sette colonne, pannelli laterali. Su 390px vanno ripensate,
   non compresse.
   ══════════════════════════════════════════════════════════ */
.shell-tabs { display: none; }

@media (max-width: 720px) {
  .shell-tabs { display: grid; }

  /* La sidebar sparisce: 72px di icone su 390 sono un quinto
     dello schermo speso in navigazione. Resta la barra in basso. */
  .app > .sidebar { display: none; }
  .app { grid-template-columns: minmax(0, 1fr); }

  .main { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }

  /* Intestazione su UNA riga: titolo a sinistra, controlli a destra.
     La versione impilata (titolo, sottotitolo, fila di bottoni sotto)
     spendeva tre righe per dire una cosa sola. Il sottotitolo sparisce:
     su 390px è decorazione che spinge i contenuti in basso. */
  .topbar {
    flex-direction: row;
    align-items: center;
    padding: calc(var(--s-3) + env(safe-area-inset-top)) var(--s-4) var(--s-3);
    gap: var(--s-3);
  }
  .topbar-lead { flex: 1; min-width: 0; }
  .topbar-lead h1 {
    font-size: var(--t-lg);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .topbar-lead p { display: none; }
  .topbar .search { display: none; }        /* la ricerca vive nei filtri di pagina */
  .topbar-tools { width: auto; gap: 6px; flex: none; flex-wrap: nowrap; }
  .topbar .icon-btn, .topbar .btn, .topbar .avatar { width: 42px; height: 42px; min-height: 42px; }

  .content { padding: var(--s-4) var(--s-4) var(--s-6); gap: var(--s-3); }

  /* ── Tabelle → schede ────────────────────────────────────
     Sette colonne su 390px significano scorrimento laterale, cioè
     dati che non si trovano. Ogni riga diventa una scheda con le
     etichette accanto ai valori. */
  .table-wrap { overflow: visible; margin-inline: 0; padding-inline: 0; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table thead { display: none; }

  /* Colonna, così l'ordine di lettura si può ricomporre: la controparte
     fa da titolo e l'importo la segue, indipendentemente da come sono
     disposte le colonne sul desktop. */
  .table tbody tr {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: var(--s-3);
    margin-bottom: var(--s-2);
    border-radius: 16px;
    background: var(--surface-2);
    border: 1px solid var(--rule-soft);
  }
  .table td.td-who { order: -2; }
  .table td.td-amt { order: -1; }
  .table td.td-act { order: 9; }
  .table tbody tr:hover { background: var(--surface-2); }
  .table tbody tr:last-child td { border-bottom: 0; }

  .table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    padding: 3px 0;
    border-bottom: 0;
    text-align: left;
    min-height: 26px;
  }
  /* Le celle senza etichetta sono pastiglie (categoria, stato):
     stanno bene addossate, senza occupare una riga intera ciascuna. */
  .table td:not([data-label]):not(.td-who):not(.td-amt):not(.td-act) {
    justify-content: flex-start;
    padding: 2px 0;
  }
  .table td:first-child, .table td:last-child { padding-inline: 0; }

  /* L'etichetta della colonna compare a sinistra del valore. */
  .table td[data-label]::before {
    content: attr(data-label);
    font-size: var(--t-sm);
    color: var(--muted);
    flex: none;
  }

  /* Celle vuote (es. "da incassare" a zero): via dalla scheda, non
     lasciano un trattino sospeso. Sul desktop restano per la colonna. */
  .table td.td-vuoto-mobile { display: none; }

  /* La controparte fa da titolo della scheda: niente etichetta,
     larghezza piena, in cima. */
  .table td.td-who {
    display: block;
    padding-bottom: var(--s-2);
    margin-bottom: 4px;
    border-bottom: 1px solid var(--rule-soft);
  }
  .table td.td-who::before { display: none; }

  /* L'importo è il dato che si cerca per primo: va evidenziato. */
  .table td.td-amt { font-size: var(--t-md); }
  .table td.td-amt::before { font-weight: 500; }

  /* Le azioni scendono in fondo, a tutta larghezza e toccabili. */
  .table td.td-act {
    justify-content: flex-end;
    gap: var(--s-2);
    padding-top: var(--s-2);
    margin-top: 4px;
    border-top: 1px solid var(--rule-soft);
  }
  .table td.td-act::before { display: none; }
  /* Modifica ed elimina sono le azioni principali di un elenco:
     44px pieni, senza il margine negativo usato altrove. */
  .table td.td-act .icon-btn { opacity: 1; width: 44px; height: 44px; margin: 0; }

  .quota { min-width: 0; flex: 1; }

  /* ── Filtri ─────────────────────────────────────────────── */
  .filters { gap: var(--s-2); }
  .search-inline { flex: 1 1 100%; }
  .filters .select, .filters .btn { flex: 1 1 auto; min-height: 42px; }

  /* ── Pannelli laterali → fogli dal basso ───────────────── */
  .sheet {
    width: 100%;
    max-width: none;
    height: auto;
    max-height: 92dvh;
    margin: auto 0 0;
    border-radius: 24px 24px 0 0;
    border: 0;
    border-top: 1px solid var(--rule-soft);
  }
  .sheet[open] { animation: mUp 280ms var(--ease); }
  .sheet-head { padding: var(--s-4); }
  .sheet-body { padding: var(--s-4); gap: var(--s-3); }
  .sheet-foot {
    padding: var(--s-3) var(--s-4) calc(var(--s-4) + env(safe-area-inset-bottom));
    flex-wrap: wrap;
  }
  .sheet-foot .btn { flex: 1 1 auto; min-height: 46px; }
  .field-row { grid-template-columns: 1fr; gap: var(--s-3); }
  .field input, .field .select { min-height: 46px; }

  /* Sotto i 16px iOS zooma la pagina a ogni focus su un campo: è il
     "salto" che si vede aprendo i moduli. 16px lo disattiva alla radice. */
  .field input, .field .select, .field textarea,
  .filters .select, .filters input, textarea, select,
  input[type="text"], input[type="search"], input[type="date"] {
    font-size: 16px;
  }

  /* Conferme distruttive: stesso trattamento. */
  .confirm { width: calc(100% - 24px); }

  /* ── Riquadri e griglie ─────────────────────────────────── */
  .card { padding: var(--s-4); border-radius: 16px; }
  .row-metrics, .row-main, .row-triple, .row-bottom {
    grid-template-columns: minmax(0, 1fr);
  }
  .col-stack { flex-direction: column; }

  /* Le tre card di riepilogo, a tutta altezza, occupavano due schermate
     prima di far vedere i dati. Qui diventano righe compatte: stesso
     contenuto, un terzo dello spazio. */
  .row-summary { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .row-summary .card-metric {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: baseline;
    gap: var(--s-2) var(--s-3);
    padding: var(--s-3) var(--s-4);
    border-radius: 0;
    border-bottom: 0;
  }
  .row-summary .card-metric:first-child { border-radius: 16px 16px 0 0; }
  .row-summary .card-metric:last-child { border-radius: 0 0 16px 16px; border-bottom: 1px solid var(--rule-soft); }
  .row-summary .card-head { grid-column: 1; margin: 0; }
  .row-summary .card-head h2 { font-size: var(--t-base); font-weight: 500; color: var(--muted); }
  .row-summary .metric-value { grid-column: 2; grid-row: 1; font-size: var(--t-xl); text-align: right; }
  .row-summary .metric-foot,
  .row-summary .metric-delta { grid-column: 1 / -1; grid-row: 2; margin: 0; font-size: var(--t-sm); }
  .row-summary .threshold { grid-column: 1 / -1; margin-top: 2px; }

  /* Bottoni pieni dove la mano se li aspetta. */
  .card-head-split .btn { width: 100%; min-height: 46px; justify-content: center; }
  .empty .btn { width: 100%; min-height: 46px; justify-content: center; }

  /* Grafici: più bassi, restano leggibili. */
  .chart { height: 200px; }
  .ring { width: 132px; height: 132px; }

  /* Elenchi: righe toccabili da 44px in su. */
  .tx-row, .due-row, .subs li, .account-row, .m-line { min-height: 48px; }

  /* I pulsanti icona da 24px sono comodi col mouse e impossibili col
     pollice. Qui l'area toccabile cresce a 40 senza ingrandire il segno
     disegnato: si allarga il bersaglio, non l'icona. */
  .icon-btn-sm {
    width: 40px; height: 40px;
    margin: -8px;                 /* non sposta ciò che sta accanto */
  }
  .card-head .icon-btn-sm, .m-line .icon-btn-sm { margin: -8px -8px -8px 0; }
  .icon-btn-sm .ico { width: 17px; height: 17px; }
  /* Controlli segmentati e schede: larghi ma bassi. In altezza vanno
     portati a 40, altrimenti si sbaglia bersaglio scorrendo. */
  .seg-btn, .tab, .m-range, .date-chip { min-height: 40px; }
  .chip-opt { min-height: 44px; padding: 11px 15px; }
  .tabs { gap: 6px; }

  .check, .check-box { min-width: 24px; }
  .check input { width: 44px; height: 44px; left: -10px; top: -10px; position: absolute; }

  .page-disclaimer { margin-top: var(--s-4); }
}

@media (max-width: 400px) {
  .m-tab span { font-size: 9px; }
  .topbar-lead h1 { font-size: var(--t-md); }
}

@media (prefers-reduced-motion: reduce) {
  .m-ring-fg, .m-bar em, .m-bar i { transition: none; }
  .m-sheet[open] { animation: none; }
}

/* ═══ La marcia in più (home mobile): aurora, cascata, respiro ═══ */
/* Aurora indaco sul fondo, che si muove piano: la pagina non è mai ferma. */
[data-page="mobile"]::before { content: ''; position: fixed; inset: -12%; z-index: 0; pointer-events: none;
  background:
    radial-gradient(46% 32% at 80% 4%, oklch(0.62 0.19 272 / 0.13), transparent 70%),
    radial-gradient(38% 30% at 6% 96%, oklch(0.70 0.15 300 / 0.07), transparent 70%);
  animation: mAurora 20s ease-in-out infinite alternate; }
[data-page="mobile"] .m-app { position: relative; z-index: 1; }
@keyframes mAurora { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(-2.5%, -2%, 0) scale(1.08); } }

/* Le sezioni entrano a cascata all'apertura. La dock resta fuori:
   vive del suo translateX(-50%), un'animazione con fill la romperebbe. */
.m-app > *:not(.m-tabs) { animation: mRise .55s var(--ease) both; }
.m-app > *:nth-child(2) { animation-delay: .05s; }
.m-app > *:nth-child(3) { animation-delay: .10s; }
.m-app > *:nth-child(4) { animation-delay: .15s; }
.m-app > *:nth-child(5) { animation-delay: .20s; }
.m-app > *:nth-child(6) { animation-delay: .26s; }
.m-app > *:nth-child(7) { animation-delay: .32s; }
.m-app > *:nth-child(8) { animation-delay: .38s; }
.m-app > *:nth-child(9) { animation-delay: .44s; }
@keyframes mRise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* L'alone dietro la cifra grande respira, appena percettibile. */
.m-hero { position: relative; }
.m-hero::before { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(58% 42% at 50% 24%, oklch(0.62 0.19 272 / 0.13), transparent 72%);
  animation: mBreathe 6s ease-in-out infinite alternate; }
@keyframes mBreathe { from { opacity: 0.4; transform: scale(1); } to { opacity: 1; transform: scale(1.12); } }

@media (prefers-reduced-motion: reduce) {
  [data-page="mobile"]::before, .m-app > *:not(.m-tabs), .m-hero::before { animation: none !important; }
}
