/* ==========================================================================
   CRM Consulente - aspetto «app» per il telefono (v40)
   Caricato da layout.html solo con schermo stretto:
     media="screen and (max-width: 767.98px)"
   Sul computer non viene nemmeno letto: la versione desktop resta com'era.

   Stile: blu profondo, superfici in leggero rilievo (neumorfismo morbido),
   verde acqua per cifre, pulsanti e voce attiva. Testi secondari quasi bianchi
   per avere contrasto sufficiente anche all'aperto (≥ 4,5:1).
   ========================================================================== */

:root {
  color-scheme: dark;

  --m-bg: #24529f;        /* fondo e superfici */
  --m-deep: #1e4689;      /* barre, campi, zone incavate */
  --m-hi: #3068c6;        /* ombra chiara del rilievo */
  --m-lo: #173b78;        /* ombra scura del rilievo */
  --m-mint: #6bf2d4;      /* accento */
  --m-mint-2: #a8fae6;
  --m-navy: #14306a;      /* testo sopra il verde acqua */
  --m-sep: #3a6bc0;       /* separatori */

  --canvas: var(--m-bg);
  --raised: var(--m-bg);
  --sunken: var(--m-deep);
  --ink: #ffffff;
  --ink-2: #e4edff;
  --ink-3: #d6e4ff;
  --line: rgba(255, 255, 255, 0.14);
  --line-strong: rgba(255, 255, 255, 0.26);

  --accent: var(--m-mint);
  --accent-hover: var(--m-mint-2);
  --accent-soft: rgba(107, 242, 212, 0.16);
  --on-accent: var(--m-navy);
  --brand-1: var(--m-mint);
  --brand-2: var(--m-mint);

  --teal: var(--m-mint);
  --amber: #ffc59e;
  --violet: #c9b8ff;

  /* guadagni in verde acqua, perdite ed errori in corallo chiaro: si distinguono anche per luminosità e segno */
  --ok: var(--m-mint);
  --perf-su: #9cf5b4;        /* v71: 5,8:1 sul fondo #24529f, 7:1 sulle righe incavate */
  --perf-giu: #fecaca;       /* 5,2:1 sul fondo, 6,3:1 sulle righe incavate */
  --perf-su-soft: rgba(156, 245, 180, 0.16);
  --perf-giu-soft: rgba(254, 202, 202, 0.16);
  --ok-soft: rgba(107, 242, 212, 0.16);
  --danger: #ffb4a3;
  --danger-soft: rgba(255, 150, 130, 0.18);
  --warn: #ffd98f;
  --warn-soft: rgba(255, 217, 143, 0.16);
  --info: #b9d2ff;
  --info-soft: rgba(185, 210, 255, 0.16);

  --shadow-soft: 6px 6px 14px var(--m-lo), -4px -4px 12px var(--m-hi);
  --shadow-lift: 8px 8px 18px var(--m-lo), -5px -5px 14px var(--m-hi);
  --m-shadow-sm: 4px 4px 10px var(--m-lo), -3px -3px 8px var(--m-hi);
  --m-inset: inset 4px 4px 10px var(--m-lo), inset -3px -3px 8px var(--m-hi);

  --seg-0: #6bf2d4;
  --seg-1: #ffffff;
  --seg-2: #9dbdf5;
  --seg-3: #ffc59e;
  --seg-4: #e9a8ff;
  --seg-5: #5c7fc4;

  --radius: 14px;
  --radius-lg: 22px;

  --m-topbar: 64px;
  --m-tabbar: 68px;
}

body { background: var(--m-bg); color: var(--ink); }
h1, h2, h3, h4 { color: var(--ink); }
a { color: var(--m-mint); }
a:hover { color: var(--m-mint-2); }
:focus-visible { outline-color: var(--m-mint); }
code { color: var(--m-mint-2); }

.solo-mobile { display: revert; }
.solo-desktop { display: none !important; }

/* ---------- barra superiore ---------- */

.topbar {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px 44px 44px; align-items: center; gap: var(--space-2);
  min-height: calc(var(--m-topbar) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) max(var(--space-4), env(safe-area-inset-right, 0px)) 0 max(var(--space-4), env(safe-area-inset-left, 0px));
  background: var(--m-bg); box-shadow: none; color: #ffffff;
}
.topbar .icon-btn, .topbar-back, .topbar-me {
  width: 44px; height: 44px; border-radius: 14px; background: var(--m-bg); color: #ffffff;
  box-shadow: var(--m-shadow-sm); display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
}
.topbar .icon-btn:hover, .topbar-back:hover { background: var(--m-bg); color: var(--m-mint); }
.topbar .icon-btn:active, .topbar-back:active { box-shadow: var(--m-inset); }
.topbar-me { border-radius: 50%; background: var(--m-mint); color: var(--m-navy); font-weight: 700; font-size: 0.95rem; }
.topbar-me:hover { color: var(--m-navy); }
.topbar-title {
  display: block; margin: 0; text-align: center; font-size: 1rem; font-weight: 600; color: #ffffff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar .brand { justify-self: center; color: #ffffff; font-size: 1rem; }
.topbar .brand-mark { display: none; }
.topbar #menu-btn { grid-column: 5; }
.topbar .topbar-cerca { grid-column: 4; }
.topbar .topbar-notifiche { grid-column: 3; }                     /* v51 */
.topbar .topbar-notifiche[aria-current="page"] { color: var(--m-mint); box-shadow: var(--m-inset); }
.nt-pallino { background: #ffb4a3; color: #4a1208; }
.topbar .nt-pallino { box-shadow: 0 0 0 2px var(--m-bg); }
.topbar .topbar-cerca[aria-current="page"] { color: var(--m-mint); box-shadow: var(--m-inset); }

/* ---------- menu completo: si apre da destra ---------- */

.sidebar {
  left: auto; right: 0; transform: translateX(100%);
  background: var(--m-deep); box-shadow: -10px 0 30px rgba(10, 25, 60, 0.45);
  border-radius: 24px 0 0 24px;
}
.nav a { color: #e4edff; border-radius: 14px; min-height: 50px; }
.nav a:hover { background: rgba(255, 255, 255, 0.08); color: #ffffff; }
.nav a[aria-current="page"] { background: var(--m-mint); color: var(--m-navy); box-shadow: none; }
.ai-card { display: none; }
.sidebar-foot { margin-top: auto; border-top-color: var(--m-sep); }
.sidebar-foot .meta { color: var(--ink-3); }
.foot-link { color: var(--ink-2); }
body.nav-open .scrim { background: rgba(8, 20, 50, 0.55); }

/* ---------- barra di navigazione in basso ---------- */

.tabbar {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 22;
  padding: 6px max(var(--space-2), env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) max(var(--space-2), env(safe-area-inset-left, 0px));
  /* v62: stesso colore del fondo, della barra di stato e della barra dei tasti di Android: nessuno stacco */
  background: var(--m-bg); border-top: 0; box-shadow: none;
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 52px; border-radius: 14px; color: #e4edff; text-decoration: none;
  font-size: 0.7rem; font-weight: 500; letter-spacing: 0.01em;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.tb-fo { white-space: nowrap; font-size: 0.64rem; letter-spacing: -0.01em; }   /* v98: «Family Office» su una riga */
.tabbar a[aria-current="page"] { color: var(--m-mint); font-weight: 700; }
.tabbar a:active { background: rgba(255, 255, 255, 0.06); }
body.nav-open .tabbar { visibility: hidden; }

.page {
  padding: var(--space-2) max(var(--space-4), env(safe-area-inset-left, 0px)) calc(var(--m-tabbar) + var(--space-8) + env(safe-area-inset-bottom, 0px));
}

/* ---------- intestazioni ---------- */

.page-head { margin-bottom: var(--space-6); }
.page-head h1 { font-size: 1.5rem; }
.sub, .meta, .hint, .hint-block, .empty, .empty p { color: var(--ink-3); }
.lead, .note-text, .testo-ia { color: var(--ink-2); }
h2 { font-size: 1.1rem; }
.section-head { margin-top: var(--space-6); }

/* ---------- superfici in rilievo ---------- */

.panel, .figures > div, .table-wrap table.is-stack tr, .news-col, .bank-block, .totale-banche,
.cat-card, .filters, .segnale-area, .ia-card, .cal-month, .cal-scroll, .banca-opzione, .narrow-panel {
  background: var(--m-bg); border: 0; box-shadow: var(--shadow-soft);
}
.panel { border-radius: var(--radius-lg); padding: var(--space-4); }
.panel.flush { padding: 0; }
.panel.inset, .panel.inset.flush { background: var(--m-deep); box-shadow: var(--m-inset); }
.figures > div::before { display: none; }

/* cifre: due per riga, valore in evidenza */
.figures { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); margin-bottom: var(--space-6); }
.figures > div { padding: var(--space-4); border-radius: 20px; }
.figures > div:only-child, .figures > div:last-child:nth-child(odd) { grid-column: 1 / -1; }
.figures > .solo-desktop:first-child ~ div:last-child:nth-child(odd) { grid-column: auto; }
.figures > .solo-desktop:first-child ~ div:last-child:nth-child(even) { grid-column: 1 / -1; }
.fig-label { color: var(--ink-3); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; }
.fig-value { font-size: 1.3rem; color: #ffffff; }
.fig-pl.is-gain .fig-value, .fig-pl.is-gain .pl-amount, .txt-ok { color: var(--ok); }
.fig-pl.is-loss .fig-value, .fig-pl.is-loss .pl-amount, .txt-ko { color: var(--danger); }

/* elenchi */
.list > li { border-bottom-color: var(--m-sep); }
.row-link:hover { background: rgba(255, 255, 255, 0.05); }
.item-title { color: #ffffff; }
a.item-title:hover { color: var(--m-mint); }

/* tabelle diventate schede */
table.is-stack tr { border-radius: 20px; margin-bottom: var(--space-4); }
table.is-stack tbody tr:hover { background: var(--m-bg); }
table.is-stack td { border-bottom-color: var(--line); }
table.is-stack td::before { color: var(--ink-3); }
table.is-stack td:first-child, table.is-stack tbody tr td:first-child { border-bottom-color: var(--m-sep); }
table.is-stack tfoot tr { background: var(--m-deep); box-shadow: var(--m-inset); }
tbody tr.bank-row td { background: transparent; color: var(--m-mint); }
.opera-table tr.is-attiva { background: rgba(107, 242, 212, 0.08); }
thead th, .cal-head span, .tg-head { background: var(--m-deep); color: var(--ink-3); }
tbody tr:hover { background: rgba(255, 255, 255, 0.04); }
tfoot td { background: var(--m-deep); color: #ffffff; }

/* ---------- campi ---------- */

input, select, textarea {
  background: var(--m-deep); color: #ffffff; border: 1px solid transparent;
  box-shadow: var(--m-inset); border-radius: 14px; min-height: 48px;
}
input::placeholder, textarea::placeholder { color: #b9cdf3; }
input:focus, select:focus, textarea:focus { border-color: var(--m-mint); box-shadow: var(--m-inset), 0 0 0 3px rgba(107, 242, 212, 0.25); }
input[type="checkbox"], input[type="radio"] { box-shadow: none; accent-color: var(--m-mint); min-height: 0; }
select option { background: var(--m-deep); color: #ffffff; }
.field label, .label-like, .check label { color: var(--ink-2); }
.req { color: var(--danger); }

/* ---------- pulsanti ---------- */

.btn {
  background: var(--m-mint); color: var(--m-navy); border: 0; border-radius: 16px; min-height: 48px;
  box-shadow: var(--m-shadow-sm); font-weight: 700;
}
.btn:hover { background: var(--m-mint-2); color: var(--m-navy); box-shadow: var(--m-shadow-sm); }
.btn:active { box-shadow: var(--m-inset); transform: none; }
.btn-secondary { background: var(--m-bg); color: #ffffff; border: 0; box-shadow: var(--m-shadow-sm); }
.btn-secondary:hover { background: var(--m-bg); color: var(--m-mint); }
.btn-danger-outline { background: transparent; color: var(--danger); border: 1px solid var(--danger); box-shadow: none; }
.btn-danger-outline:hover { background: var(--danger-soft); color: var(--danger); }
.link-btn { color: var(--m-mint); }
.link-btn.is-danger { color: var(--danger); }

/* ---------- schede (tab) come interruttore a pillole ---------- */

.tabs {
  gap: 4px; padding: 5px; border: 0; border-radius: 18px;
  background: var(--m-deep); box-shadow: var(--m-inset); margin-bottom: var(--space-4);
}
.tab {
  border: 0; border-radius: 13px; min-height: 40px; padding: 0 var(--space-3);
  color: var(--ink-2); background: transparent; white-space: nowrap;
}
.tab:hover { background: rgba(255, 255, 255, 0.06); color: #ffffff; }
.tab[aria-selected="true"], .tab[aria-current="page"] { background: var(--m-mint); color: var(--m-navy); border: 0; font-weight: 700; }
.tab[aria-selected="true"] .badge, .tab[aria-current="page"] .badge { background: var(--m-navy); color: var(--m-mint); }
.tab-alert { background: var(--danger); }

.seg-control, .seg-radio { background: var(--m-deep); border: 0; box-shadow: var(--m-inset); border-radius: 16px; padding: 4px; gap: 4px; }
.seg-control a, .seg-radio label { border: 0; border-radius: 12px; color: var(--ink-2); }
.seg-control a:hover { background: rgba(255, 255, 255, 0.06); color: #ffffff; }
.seg-control a[aria-current="true"] { background: var(--m-mint); color: var(--m-navy); }
.seg-radio input:checked + .l-nessuna { background: var(--m-bg); color: #ffffff; }
.seg-radio input:checked + .l-acquisto { background: var(--m-mint); color: var(--m-navy); }
.seg-radio input:checked + .l-vendita { background: #ffc59e; color: #3b2500; }

/* ---------- etichette, avvisi ---------- */

.badge, .chip, .badge-ok { background: var(--accent-soft); color: var(--m-mint); }
.chip-generico { background: rgba(255, 255, 255, 0.1); color: var(--ink-2); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-ko { background: var(--danger-soft); color: var(--danger); }
.badge-off { background: rgba(255, 255, 255, 0.08); color: var(--ink-3); }
.flashes { margin-bottom: var(--space-6); }
.flash { border: 0; border-radius: 18px; box-shadow: var(--m-shadow-sm); }
.flash-success { background: var(--m-deep); color: var(--m-mint); }
.flash-info { background: var(--m-deep); color: var(--info); }
.flash-danger { background: var(--m-deep); color: var(--danger); }
.is-overdue, .is-overdue.meta { color: var(--danger); }
.is-soon, .is-soon.meta { color: var(--warn); }
.opera-avviso { background: var(--warn-soft); color: var(--warn); }

/* ---------- grafici ---------- */

.alloc { background: var(--m-deep); }
.chart-line { stroke: var(--m-mint); stroke-width: 2.6; }
.chart-area { fill: var(--m-mint); opacity: 0.16; }
.chart-grid { stroke: rgba(255, 255, 255, 0.12); }
.chart-zero { stroke: var(--ink-3); }
.chart-axis { fill: var(--ink-3); }
.chart-dot { fill: var(--m-mint); stroke: var(--m-bg); }
.peso-bar { background: var(--m-deep); }
.peso-bar .dopo { mix-blend-mode: normal; opacity: 0.8; }

/* ciambella costruita da app.js a partire dalle barre .alloc */
.donut-box { display: flex; justify-content: center; margin: var(--space-2) 0 var(--space-6); }
.donut {
  position: relative; flex: none; width: 11rem; height: 11rem; border-radius: 50%;
  box-shadow: var(--shadow-soft);
}
.donut::after {
  content: ""; position: absolute; inset: 1.15rem; border-radius: 50%;
  background: var(--m-bg); box-shadow: var(--m-inset);
}
.donut-centro {
  position: absolute; inset: 1.15rem; z-index: 1; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 0.4rem;
}
.donut-centro small { font-size: 0.72rem; color: var(--ink-3); line-height: 1.2; }
.donut-centro b { font-size: 0.95rem; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.alloc.has-donut { display: none; }
.alloc.has-donut + .legend { margin-top: 0; }
.legend-val { color: var(--ink-2); }

/* ---------- blocchi specifici ---------- */

.news-col { border-top: 0; border-radius: var(--radius-lg); }
.news-mondo .news-head, .news-portafogli .news-head { background: transparent; border-bottom-color: var(--m-sep); }
.news-mondo .news-ico, .news-portafogli .news-ico { background: var(--m-mint); color: var(--m-navy); }
.news-item { border-bottom-color: var(--m-sep); }
.news-item::before { color: var(--m-mint); }
.news-titolo a { color: #ffffff; }

.totale-banche { border-left: 0; }
.totale-titolo { color: var(--m-mint); }
.bank-block { border-top: 0; }
.bank-block.is-esterno { box-shadow: var(--shadow-soft), inset 0 3px 0 #ffc59e; }
.bank-ico { background: var(--m-deep); color: var(--m-mint); box-shadow: var(--m-inset); }
.bank-figures { border-bottom-color: var(--m-sep); }
.cat-card:hover { transform: none; box-shadow: var(--shadow-soft); }

.ai-badge { background: var(--m-mint); color: var(--m-navy); box-shadow: none; }
.ia-card.is-attiva { box-shadow: var(--shadow-soft), 0 0 0 2px var(--m-mint); }
.ia-simbolo.has-icona { background: #ffffff; }
.ia-attiva { background: var(--m-deep); box-shadow: var(--m-inset); }

/* calendario */
.cal-day { border-color: var(--m-sep); }
.cal-day.is-out { background: rgba(0, 0, 0, 0.08); }
.cal-day.is-today { background: var(--accent-soft); }
.cal-day.is-today .cal-daynum, .tg-dayhead.is-today b, .cal-count { background: var(--m-mint); color: var(--m-navy); }
.cal-chip, .tg-event { color: #ffffff; }
.t-call { --ev-bg: rgba(185, 210, 255, 0.18); --ev-bar: #b9d2ff; }
.t-meet { --ev-bg: rgba(107, 242, 212, 0.16); --ev-bar: var(--m-mint); }
.t-video { --ev-bg: rgba(255, 217, 143, 0.16); --ev-bar: #ffd98f; }
.t-none { --ev-bg: rgba(255, 255, 255, 0.08); --ev-bar: var(--ink-3); }
.tg-col { border-left-color: var(--m-sep); }

/* anteprima dei file Excel: resta una tabella leggibile */
.sheet-preview { background: var(--m-deep); border-color: var(--m-sep); }
.sheet-preview thead th, .sheet-preview .rn { background: var(--m-bg); }

/* ---------- pagina di accesso ---------- */

.center-wrap { background: var(--m-bg); }
.brand-login { color: #ffffff; }
.brand-login .brand-mark { background: var(--m-mint); color: var(--m-navy); box-shadow: var(--m-shadow-sm); }

/* ---------- dashboard: testata da app ---------- */

.m-hero { display: flex; flex-direction: column; gap: var(--space-6); margin: var(--space-2) 0 var(--space-6); }
.m-saluto p { margin: 0; }
.m-data { font-size: 0.9rem; color: var(--ink-3); }
.m-nome { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; }
.m-totale { border-radius: var(--radius-lg); padding: var(--space-6) var(--space-4); background: var(--m-bg); box-shadow: var(--shadow-soft); text-align: center; }
.m-totale p { margin: 0; }
.m-totale-label { font-size: 0.75rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em; }
.m-totale-valore { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin: var(--space-1) 0 !important; overflow-wrap: anywhere; }
.m-totale-meta { font-size: 0.85rem; color: var(--ink-3); }
.m-totale-meta b.is-gain { color: var(--ok); }
.m-totale-meta b.is-loss { color: var(--danger); }
.m-azioni { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); }
.m-azioni a {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-2);
  color: #ffffff; text-decoration: none; font-size: 0.75rem; font-weight: 500; text-align: center; line-height: 1.2;
}
.m-azioni a span {
  display: flex; align-items: center; justify-content: center; width: 62px; height: 62px; border-radius: 18px;
  background: var(--m-bg); color: var(--m-mint); box-shadow: var(--m-shadow-sm);
}
.m-azioni a:active span { box-shadow: var(--m-inset); }

/* ---------- scheda cliente: avatar con le iniziali ---------- */

.m-avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 64px; height: 64px; border-radius: 50%; background: var(--m-bg); color: var(--m-mint);
  font-size: 1.35rem; font-weight: 700; box-shadow: var(--shadow-soft);
}
.page-head:has(.m-avatar) > div:first-child { display: flex; align-items: center; gap: var(--space-4); }

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}

/* ==========================================================================
   v42 - Animazioni (solo telefono). Con «riduci animazioni» attivo nel
   telefono restano fermi: tutto il movimento è dentro
   @media (prefers-reduced-motion: no-preference).
   Durate: 140 ms pressione · 260-420 ms passaggi · 500-1300 ms ingressi e grafici.
   ========================================================================== */

@property --m-p { syntax: "<number>"; inherits: false; initial-value: 100; }

/* pillola che scivola sotto la scheda scelta (creata da app.js) */
.tabs { position: relative; }
.tab-pill {
  display: block; position: absolute; top: 5px; bottom: 5px; left: 0; width: 0; z-index: 0;
  border-radius: 13px; background: var(--m-mint); pointer-events: none;
}
.tabs .tab { position: relative; z-index: 1; }
.tabs.has-pill .tab[aria-selected="true"], .tabs.has-pill .tab[aria-current="page"] { background: transparent; }

/* trattino verde sopra la voce attiva della barra in basso: scorre da una voce all'altra cambiando pagina */
.tabbar a { position: relative; }
.tb-ind {
  display: block; position: absolute; top: -6px; left: 50%; width: 28px; height: 3px; margin-left: -14px;
  border-radius: 0 0 3px 3px; background: var(--m-mint); opacity: 0;
}
.tabbar a[aria-current="page"] .tb-ind { opacity: 1; view-transition-name: tabbar-ind; }

/* ciambella: il disegno sta in --donut (app.js), così si può «disegnare» */
.donut { background: none; }
.donut::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--donut, transparent);
  -webkit-mask: conic-gradient(#000 calc(var(--m-p) * 1%), transparent 0);
  mask: conic-gradient(#000 calc(var(--m-p) * 1%), transparent 0);
}

/* attesa delle analisi IA: righe «in caricamento» sotto il messaggio */
section.panel[role="status"]::after {
  content: ""; display: block; height: 46px; margin-top: var(--space-4);
  background: linear-gradient(90deg, #2c5fb4 0, #4a80dc 50%, #2c5fb4 100%) #2c5fb4; background-size: 260px 100%;
  -webkit-mask: linear-gradient(#000 0 0) 0 0 / 92% 10px no-repeat, linear-gradient(#000 0 0) 0 18px / 74% 10px no-repeat, linear-gradient(#000 0 0) 0 36px / 56% 10px no-repeat;
  mask: linear-gradient(#000 0 0) 0 0 / 92% 10px no-repeat, linear-gradient(#000 0 0) 0 18px / 74% 10px no-repeat, linear-gradient(#000 0 0) 0 36px / 56% 10px no-repeat;
}

/* barra sottile in alto mentre si carica la pagina successiva (app.js) */
body.is-leaving::after {
  content: ""; position: fixed; z-index: 60; top: env(safe-area-inset-top, 0px); left: 0;
  width: 35%; height: 3px; border-radius: 0 3px 3px 0;
  background: var(--m-mint); box-shadow: 0 0 10px rgba(107, 242, 212, 0.7);
}

@media (prefers-reduced-motion: no-preference) {

  /* ---------- passaggio tra le pagine (vedi transizioni.js) ---------- */
  @view-transition { navigation: auto; }
  .topbar { view-transition-name: topbar; }
  .tabbar { view-transition-name: tabbar; }

  ::view-transition-old(root), ::view-transition-new(root) {
    mix-blend-mode: normal; animation-duration: 0.42s; animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1); animation-fill-mode: both;
  }
  ::view-transition-old(root) { animation-name: m-vt-sotto; }
  ::view-transition-new(root) { animation-name: m-vt-entra; box-shadow: -14px 0 34px rgba(10, 25, 60, 0.38); }
  :root:active-view-transition-type(back)::view-transition-old(root) { animation-name: m-vt-esce; z-index: 1; box-shadow: -14px 0 34px rgba(10, 25, 60, 0.38); }
  :root:active-view-transition-type(back)::view-transition-new(root) { animation-name: m-vt-riemerge; box-shadow: none; }
  :root:active-view-transition-type(tab)::view-transition-old(root) { animation: m-svanisce 0.2s ease both; }
  :root:active-view-transition-type(tab)::view-transition-new(root) { animation: m-compare 0.3s ease both; box-shadow: none; }
  ::view-transition-old(topbar), ::view-transition-new(topbar) { animation-duration: 0.25s; }
  ::view-transition-group(tabbar-ind) { animation-duration: 0.42s; animation-timing-function: cubic-bezier(0.34, 1.45, 0.64, 1); }

  @keyframes m-vt-sotto { to { transform: translateX(-28%); filter: brightness(0.78); } }
  @keyframes m-vt-entra { from { transform: translateX(100%); } }
  @keyframes m-vt-esce { to { transform: translateX(100%); } }
  @keyframes m-vt-riemerge { from { transform: translateX(-28%); filter: brightness(0.78); } }
  @keyframes m-svanisce { to { opacity: 0; } }
  @keyframes m-compare { from { opacity: 0; } }

  /* ---------- ingresso della pagina: blocchi uno dopo l'altro ---------- */
  .page > *, .m-hero > * { animation: m-sale 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
  .page > :nth-child(2), .m-hero > :nth-child(2) { animation-delay: 0.06s; }
  .page > :nth-child(3), .m-hero > :nth-child(3) { animation-delay: 0.12s; }
  .page > :nth-child(4) { animation-delay: 0.18s; }
  .page > :nth-child(5) { animation-delay: 0.24s; }
  .page > :nth-child(6) { animation-delay: 0.3s; }
  .page > :nth-child(7) { animation-delay: 0.36s; }
  .page > :nth-child(n+8) { animation-delay: 0.4s; }
  .figures > div { animation: m-sale 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
  .figures > div:nth-child(2) { animation-delay: 0.08s; }
  .figures > div:nth-child(3) { animation-delay: 0.16s; }
  .figures > div:nth-child(n+4) { animation-delay: 0.24s; }

  /* dashboard: icone che «saltano fuori», percentuale che compare dopo il conteggio */
  .m-azioni a span { animation: m-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
  .m-azioni a:nth-child(1) span { animation-delay: 0.25s; }
  .m-azioni a:nth-child(2) span { animation-delay: 0.31s; }
  .m-azioni a:nth-child(3) span { animation-delay: 0.37s; }
  .m-azioni a:nth-child(4) span { animation-delay: 0.43s; }
  .m-totale-meta b { display: inline-block; animation: m-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.9s both; }
  .m-avatar { animation: m-pop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both; }

  /* ---------- schede: contenuto che entra dal lato giusto ---------- */
  .page .tab-panel, .tab-panel { animation: m-da-destra 0.36s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
  :root[data-tab-dir="back"] .page .tab-panel, :root[data-tab-dir="back"] .tab-panel { animation-name: m-da-sinistra; }
  .tabs.pill-ready .tab-pill { transition: transform 0.42s cubic-bezier(0.34, 1.45, 0.64, 1), width 0.42s cubic-bezier(0.34, 1.45, 0.64, 1); }
  .tabs .tab { transition: color 0.26s ease, background 0.2s ease; }

  /* ---------- grafici ---------- */
  .donut::before { animation: m-ciambella 1.1s cubic-bezier(0.4, 0, 0.2, 1) 0.25s both; }
  .chart-line[pathLength] { stroke-dasharray: 1; stroke-dashoffset: 1; animation: m-disegna 1.3s cubic-bezier(0.4, 0, 0.2, 1) 0.2s forwards; }
  .chart-area { animation: m-compare 0.7s ease 1.1s both; }
  .chart-dot { transform-box: fill-box; transform-origin: center; animation: m-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) 1.4s both; }
  .peso-bar .prima, .alloc span { transform-origin: left center; animation: m-cresce 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) 0.3s both; }

  /* ---------- tocco: la superficie affonda ---------- */
  .btn, .cat-card, .row-link, .m-azioni a span, .topbar .icon-btn, .topbar-back, .tabbar a svg {
    transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.15s ease, color 0.15s ease;
  }
  .btn:active, .cat-card:active, .row-link:active, .topbar .icon-btn:active, .topbar-back:active { transform: scale(0.96); }
  .m-azioni a:active span { transform: scale(0.93); }
  .tabbar a[aria-current="page"] svg { transform: translateY(-2px) scale(1.08); }
  .tabbar a:active svg { transform: scale(0.86); }

  /* ---------- menu, messaggi, attese ---------- */
  body.nav-open .scrim { animation: m-compare 0.22s ease both; }
  body.nav-open .nav a { animation: m-da-destra 0.38s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
  body.nav-open .nav a:nth-child(2) { animation-delay: 0.03s; }
  body.nav-open .nav a:nth-child(3) { animation-delay: 0.06s; }
  body.nav-open .nav a:nth-child(4) { animation-delay: 0.09s; }
  body.nav-open .nav a:nth-child(5) { animation-delay: 0.12s; }
  body.nav-open .nav a:nth-child(6) { animation-delay: 0.15s; }
  body.nav-open .nav a:nth-child(n+7) { animation-delay: 0.18s; }
  .flash { animation: m-cade 0.45s cubic-bezier(0.34, 1.4, 0.64, 1) both; }
  section.panel[role="status"]::after { animation: m-riflesso 1.4s linear infinite; }
  body.is-leaving::after { animation: m-carica 1.1s ease-in-out infinite; }

  @keyframes m-sale { from { opacity: 0; transform: translateY(18px) scale(0.985); } to { opacity: 1; transform: none; } }
  @keyframes m-pop { 0% { opacity: 0; transform: scale(0.4); } 70% { opacity: 1; transform: scale(1.12); } 100% { opacity: 1; transform: none; } }
  @keyframes m-da-destra { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
  @keyframes m-da-sinistra { from { opacity: 0; transform: translateX(-28px); } to { opacity: 1; transform: none; } }
  @keyframes m-cade { from { opacity: 0; transform: translateY(-14px) scale(0.97); } to { opacity: 1; transform: none; } }
  @keyframes m-ciambella { from { --m-p: 0; } to { --m-p: 100; } }
  @keyframes m-disegna { to { stroke-dashoffset: 0; } }
  @keyframes m-cresce { from { transform: scaleX(0); } to { transform: none; } }
  @keyframes m-riflesso { from { background-position: -260px 0; } to { background-position: 260px 0; } }
  @keyframes m-carica { from { transform: translateX(-100%); } to { transform: translateX(290%); } }
}

/* ---------- v53: filtri a pillole (Portafogli, Clienti, Notifiche) senza barra di scorrimento ---------- */
/* La fila arriva fino ai bordi dello schermo e sfuma a destra: si capisce che si scorre col dito. */
.rb-filtri {
  flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity; scroll-padding-inline: var(--space-4);
  margin-inline: calc(-1 * var(--space-4)); padding: 4px var(--space-4) 6px;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--space-4), #000 calc(100% - 36px), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 var(--space-4), #000 calc(100% - 36px), transparent 100%);
}
.rb-filtri::-webkit-scrollbar { display: none; }
.rb-filtri.is-fine { -webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--space-4)); mask-image: linear-gradient(to right, transparent 0, #000 var(--space-4)); }
.rb-filtri .rb-chip { scroll-snap-align: start; min-height: 40px; }


/* ---------- v62: barra della liquidità in «Opera sul portafoglio» ----------
   Era bianca con i testi chiari (illeggibile) e finiva sotto la barra di navigazione: ora ha i colori dell'app e
   resta appoggiata sopra la barra in basso. */
.opera-barra {
  bottom: calc(var(--m-tabbar) + env(safe-area-inset-bottom, 0px));
  background: var(--m-deep); backdrop-filter: none; -webkit-backdrop-filter: none;
  border: 1px solid var(--m-sep); border-bottom: 0; box-shadow: 0 -8px 20px rgba(10, 25, 60, 0.35);
  padding-bottom: var(--space-3); color: var(--ink);
}
.opera-numeri span { color: var(--ink-3); }
.opera-numeri b { color: #ffffff; }
.opera-numeri .dopo b { color: var(--m-mint); }
.opera-barra.is-negativa .dopo b { color: var(--danger); }

/* v71: performance in verde e rosso (prevalgono sul verde acqua dei riquadri profitto / perdita) */
.fig-pl.is-gain .fig-value, .fig-pl.is-gain .pl-amount { color: var(--perf-su); }
.fig-pl.is-loss .fig-value, .fig-pl.is-loss .pl-amount { color: var(--perf-giu); }
.m-totale-meta b.is-gain { color: var(--perf-su); }
.m-totale-meta b.is-loss { color: var(--perf-giu); }
