/*
 * Finanze: stile ispirato alle Human Interface Guidelines di Apple.
 * Sfondo raggruppato, elenchi a gruppi con separatori sottili, titoli grandi,
 * barra laterale sul computer e barra delle schede sul telefono, fogli che
 * salgono dal basso. Colore d'accento: Viva Magenta di Resolve.
 */
:root {
  --sfondo: #f2f2f7;
  --carta: #ffffff;
  --carta-2: #f2f2f7;
  --riempimento: rgba(118, 118, 128, .12);
  --testo: #000000;
  --tenue: rgba(60, 60, 67, .6);
  --tenue-2: rgba(60, 60, 67, .3);
  --linea: rgba(60, 60, 67, .2);
  --accento: #bb2649;
  --accento-tenue: rgba(187, 38, 73, .1);
  --entrata: #248a3d;
  --uscita: #d70015;
  --attenzione: #c93400;
  --materiale: rgba(249, 249, 249, .78);
  --laterale: rgba(236, 236, 241, .92);
  --raggio: 12px;
  --tondo: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --molla: cubic-bezier(.32, .72, 0, 1);
  /* colori di sistema per le icone delle categorie */
  --rosso: #ff3b30; --arancio: #ff9500; --giallo: #ffcc00; --verde: #34c759; --menta: #00c7be;
  --azzurro: #32ade6; --blu: #007aff; --indaco: #5856d6; --viola: #af52de; --rosa: #ff2d55;
  --marrone: #a2845e; --grigio: #8e8e93;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --sfondo: #000000; --carta: #1c1c1e; --carta-2: #2c2c2e; --riempimento: rgba(118, 118, 128, .24);
    --testo: #ffffff; --tenue: rgba(235, 235, 245, .6); --tenue-2: rgba(235, 235, 245, .3); --linea: rgba(84, 84, 88, .65);
    --accento: #ff5c86; --accento-tenue: rgba(255, 92, 134, .16);
    --entrata: #30d158; --uscita: #ff453a; --attenzione: #ff9f0a;
    --materiale: rgba(22, 22, 24, .78); --laterale: rgba(28, 28, 30, .92);
    --rosso: #ff453a; --arancio: #ff9f0a; --giallo: #ffd60a; --verde: #30d158; --menta: #63e6e2;
    --azzurro: #64d2ff; --blu: #0a84ff; --indaco: #5e5ce6; --viola: #bf5af2; --rosa: #ff375f;
    --marrone: #ac8e68; --grigio: #98989d;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--sfondo); color: var(--testo); font-size: 16px; line-height: 1.4; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; }
p { margin: 0; }
a { color: var(--accento); text-decoration: none; }
.nascosto { display: none !important; }
.tenue { color: var(--tenue); }
.piccolo { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--entrata); }
.neg { color: var(--uscita); }
.icona { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* l'icona dell'app: quadrato arrotondato con una linea che sale */
.icona-app {
  width: 76px; height: 76px; border-radius: 18px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 16.5 9.5 11l3.5 3.5L20 7.5M15 7.5h5v5'/%3E%3C/svg%3E") center / 58% no-repeat, linear-gradient(160deg, #d8406a, #9c1838);
  box-shadow: 0 6px 18px rgba(187, 38, 73, .28);
}
.icona-app.piccola { width: 28px; height: 28px; border-radius: 7px; box-shadow: none; }

/* -------------------------------------------------------- ingresso */
#ingresso { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
#ingresso form { width: min(360px, 100%); display: grid; gap: 14px; justify-items: center; text-align: center; }
#ingresso h1 { font-size: 34px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; }
#ingresso input { width: 100%; text-align: center; font-size: 17px; }
#ingresso .largo { width: 100%; }

/* ----------------------------------------------------------- struttura */
#app { min-height: 100vh; }
.laterale { display: none; }
.contenuto { min-width: 0; }
main { max-width: 1040px; margin: 0 auto; padding: 8px 16px calc(96px + env(safe-area-inset-bottom)); display: grid; gap: 28px; animation: entra .28s var(--molla); }
@keyframes entra { from { opacity: 0; transform: translateY(6px); } }

/* barra delle schede (telefono) */
.barra-schede {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px calc(4px + env(safe-area-inset-bottom));
  background: var(--materiale); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: .5px solid var(--linea);
}
.barra-schede a { display: grid; justify-items: center; gap: 2px; padding: 2px 0; min-height: 44px; font-size: 10px; font-weight: 500; color: var(--tenue); letter-spacing: .01em; }
.barra-schede a .icona { width: 26px; height: 26px; }
.barra-schede a.attiva { color: var(--accento); }
.barra-schede a.attiva .icona { stroke-width: 2.2; }

/* barra in alto col titolo piccolo, compare quando il titolo grande esce dallo schermo */
.barra-piccola {
  position: sticky; top: 0; z-index: 9; height: calc(44px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top);
  display: grid; place-items: center; font-weight: 600; font-size: 17px;
  background: transparent; border-bottom: .5px solid transparent; transition: background .2s, border-color .2s;
}
.barra-piccola span { opacity: 0; transition: opacity .2s; }
.barra-piccola.piena { background: var(--materiale); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-color: var(--linea); }
.barra-piccola.piena span { opacity: 1; }

/* testata della pagina con il titolo grande */
.testata { display: grid; gap: 12px; margin-top: -36px; }
.riga-titolo { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; min-height: 52px; }
.testata h1 { font-size: 34px; font-weight: 700; letter-spacing: -.022em; line-height: 1.12; }
.testata .sottotitolo { color: var(--tenue); font-size: 15px; margin-top: -6px; }
.azioni { display: flex; gap: 8px; align-items: center; }

/* computer: barra laterale */
@media (min-width: 900px) {
  #app { display: grid; grid-template-columns: 252px minmax(0, 1fr); }
  .barra-schede, .barra-piccola, .solo-telefono { display: none !important; }
  .laterale {
    display: flex; flex-direction: column; gap: 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
    padding: 22px 12px 16px; background: var(--laterale); border-right: .5px solid var(--linea);
    backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  }
  .laterale .marchio { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; padding: 0 8px; }
  .laterale .segmenti { margin: 0 4px; }
  .voci-laterali { display: grid; gap: 2px; }
  .voci-laterali a, .voce-esci {
    display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--testo);
    font-size: 15px; font-weight: 500; min-height: 36px;
  }
  .voci-laterali a .icona, .voce-esci .icona { color: var(--accento); width: 20px; height: 20px; }
  .voci-laterali a:hover, .voce-esci:hover { background: var(--riempimento); }
  .voci-laterali a.attiva { background: var(--accento); color: #fff; }
  .voci-laterali a.attiva .icona { color: #fff; }
  .titoletto-laterale { font-size: 12px; font-weight: 600; color: var(--tenue); padding: 14px 10px 4px; margin: 0; }
  .voce-esci { margin-top: auto; border: 0; background: none; font: inherit; cursor: pointer; color: var(--tenue); }
  .voce-esci .icona { color: var(--tenue); }
  main { padding: 40px 40px 80px; gap: 32px; }
  .testata { margin-top: 0; }
}
@media (max-width: 899px) {
  .solo-computer { display: none !important; }
}

/* ------------------------------------------------------------ sezioni */
.sezione { display: grid; gap: 10px; min-width: 0; }
.sezione > .intestazione { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 0 4px; }
.sezione h2 { font-size: 22px; font-weight: 700; letter-spacing: -.012em; }
.sezione .nota-sezione { color: var(--tenue); font-size: 13px; padding: 0 4px; }
.colonne { display: grid; gap: 28px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); align-items: start; }

.scheda { background: var(--carta); border-radius: var(--raggio); padding: 16px; min-width: 0; }

/* elenco a gruppi: righe da 44 punti, separatore che parte dopo l'icona */
.gruppo { background: var(--carta); border-radius: var(--raggio); overflow: hidden; }
.riga {
  display: flex; align-items: center; gap: 12px; padding: 0 16px; min-height: 44px; width: 100%;
  background: none; border: 0; font: inherit; color: inherit; text-align: left; position: relative;
}
.riga + .riga::before { content: ""; position: absolute; top: 0; right: 0; left: 16px; border-top: .5px solid var(--linea); }
.riga.con-tessera + .riga::before, .riga + .riga.con-tessera::before { left: 60px; }
button.riga, a.riga { cursor: pointer; }
button.riga:active, a.riga:active { background: var(--riempimento); }
@media (hover: hover) { button.riga:hover, a.riga:hover { background: color-mix(in srgb, var(--riempimento) 50%, transparent); } }
.riga .testi { flex: 1; min-width: 0; padding: 11px 0; }
.riga .titolo { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.riga .sotto { font-size: 13px; color: var(--tenue); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.riga .destra { text-align: right; flex: none; display: grid; justify-items: end; gap: 1px; }
.riga .destra .sotto { margin: 0; }
.riga .importo { font-size: 16px; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.riga .freccia { color: var(--tenue-2); width: 14px; height: 14px; stroke-width: 2.4; flex: none; }
.riga.rossa { color: var(--uscita); justify-content: center; }
.riga.accento { color: var(--accento); }
.riga .barra-lunga { margin-top: 7px; }
.titolo-giorno { font-size: 13px; font-weight: 600; color: var(--tenue); padding: 0 16px 6px; }

/* tessera: icona bianca su quadrato colorato, come nelle Impostazioni */
.tessera { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex: none; color: #fff; background: var(--grigio); }
.tessera .icona { width: 19px; height: 19px; stroke-width: 2; }
.tessera.grande { width: 44px; height: 44px; border-radius: 11px; }
.tessera.grande .icona { width: 24px; height: 24px; }
.t-rosso { background: var(--rosso); } .t-arancio { background: var(--arancio); } .t-giallo { background: var(--giallo); }
.t-verde { background: var(--verde); } .t-menta { background: var(--menta); } .t-azzurro { background: var(--azzurro); }
.t-blu { background: var(--blu); } .t-indaco { background: var(--indaco); } .t-viola { background: var(--viola); }
.t-rosa { background: var(--rosa); } .t-marrone { background: var(--marrone); } .t-grigio { background: var(--grigio); }
.t-accento { background: var(--accento); }

/* -------------------------------------------------------------- eroe */
.eroe { display: grid; gap: 4px; padding: 4px 4px 0; }
.eroe .etichetta { font-size: 15px; color: var(--tenue); font-weight: 500; }
.eroe .valore { font-family: var(--tondo); font-size: clamp(40px, 9vw, 56px); font-weight: 700; letter-spacing: -.025em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.eroe .sotto { font-size: 15px; color: var(--tenue); }
.eroe .sotto strong { color: var(--testo); font-weight: 600; }

.cifre { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.cifra { background: var(--carta); border-radius: var(--raggio); padding: 14px 16px; display: grid; gap: 2px; align-content: start; }
.cifra .etichetta { color: var(--tenue); font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.cifra .etichetta .icona { width: 15px; height: 15px; stroke-width: 2.2; }
.cifra .valore { font-family: var(--tondo); font-size: 26px; font-weight: 700; letter-spacing: -.015em; font-variant-numeric: tabular-nums; margin-top: 4px; }
.cifra .nota { font-size: 13px; color: var(--tenue); }

/* ---------------------------------------------------------- comandi */
button, .bottone {
  font: inherit; font-size: 16px; border: 0; background: var(--riempimento); color: var(--accento);
  padding: 0 16px; min-height: 40px; border-radius: 10px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-weight: 500; transition: transform .15s var(--molla), opacity .15s;
}
button:active, .bottone:active { transform: scale(.97); opacity: .8; }
button.primario, .bottone.primario { background: var(--accento); color: #fff; font-weight: 600; min-height: 50px; border-radius: 12px; padding: 0 22px; font-size: 17px; }
button.leggero { background: none; padding: 0 8px; min-height: 44px; }
button.leggero:active { transform: none; opacity: .5; }
button.forte { font-weight: 600; }
button.distruttivo { color: var(--uscita); }
button.tondo { width: 36px; height: 36px; min-height: 36px; padding: 0; border-radius: 50%; }
button.tondo .icona { width: 20px; height: 20px; stroke-width: 2.4; }
button:disabled { opacity: .4; cursor: default; transform: none; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accento) 55%, transparent); outline-offset: 2px; }
@media (pointer: coarse) { button.tondo { width: 44px; height: 44px; } }

input, select, textarea {
  font: inherit; font-size: 16px; color: var(--testo); background: var(--riempimento); border: 0; border-radius: 10px;
  padding: 10px 12px; min-height: 44px; min-width: 0; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accento) 40%, transparent); }
select { appearance: none; -webkit-appearance: none; padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 9l4-4 4 4M8 15l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 16px; }
textarea { resize: vertical; min-height: 80px; }

/* campo di ricerca come in iOS */
.ricerca { position: relative; }
.ricerca .icona { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--tenue); stroke-width: 2.2; }
.ricerca input { padding-left: 34px; }

/* filtri a capsula, scorrono in orizzontale sul telefono */
.capsule { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: -2px; }
.capsule::-webkit-scrollbar { display: none; }
.capsule select, .capsule input[type=date], .capsule button { width: auto; flex: none; min-height: 36px; border-radius: 18px; font-size: 15px; padding-top: 6px; padding-bottom: 6px; }
.capsule button { padding: 0 14px; color: var(--testo); }
.capsule button.scelto { background: var(--accento); color: #fff; }
.capsule select.attivo { background-color: var(--accento-tenue); color: var(--accento); font-weight: 500; }

/* controllo a segmenti */
.segmenti { display: flex; background: var(--riempimento); border-radius: 9px; padding: 2px; gap: 0; }
.segmenti button { flex: 1; border: 0; background: transparent; min-height: 30px; padding: 0 10px; border-radius: 7px; font-size: 13px; font-weight: 500; color: var(--testo); white-space: nowrap; }
.segmenti button:active { transform: none; }
.segmenti button.scelto { background: var(--carta); box-shadow: 0 3px 8px rgba(0,0,0,.12), 0 3px 1px rgba(0,0,0,.04); font-weight: 600; }
@media (prefers-color-scheme: dark) { .segmenti button.scelto { background: #636366; } }
@media (pointer: coarse) { .segmenti button { min-height: 32px; } }

/* interruttore */
input.interruttore { appearance: none; -webkit-appearance: none; width: 51px; height: 31px; min-height: 31px; padding: 0; border-radius: 16px; background: var(--riempimento); position: relative; flex: none; cursor: pointer; transition: background .2s; }
input.interruttore::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 3px 8px rgba(0,0,0,.15), 0 1px 1px rgba(0,0,0,.16); transition: transform .25s var(--molla); }
input.interruttore:checked { background: var(--verde); }
input.interruttore:checked::after { transform: translateX(20px); }

/* moduli a gruppi: etichetta a sinistra, valore a destra */
.campi { background: var(--carta); border-radius: var(--raggio); overflow: hidden; }
.campo { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 16px; position: relative; }
.campo + .campo::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--linea); }
.campo > span { flex: none; font-size: 16px; color: var(--testo); }
.campo input, .campo select { background-color: transparent; text-align: right; padding: 10px 0; flex: 1; }
.campo select { text-align-last: right; padding-right: 22px; background-position: right 0 center; }
.campo input:focus, .campo select:focus { box-shadow: none; }
.campo.verticale { display: grid; gap: 4px; padding: 10px 16px; }
.campo.verticale > span { font-size: 13px; color: var(--tenue); }
.campo.verticale textarea, .campo.verticale input { background: transparent; padding: 0; text-align: left; min-height: 0; }
.campo.spunte { display: grid; gap: 0; padding: 6px 16px 10px; }
.campo.spunte > span { font-size: 13px; color: var(--tenue); padding: 6px 0; }
.spunta { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: 16px; }
.spunta input[type=checkbox]:not(.interruttore) { width: 22px; height: 22px; min-height: 0; accent-color: var(--accento); flex: none; }
.nota-campi { font-size: 13px; color: var(--tenue); padding: 6px 16px 0; }

/* ---------------------------------------------------------- barre */
.barra-lunga { height: 6px; background: var(--riempimento); border-radius: 99px; overflow: hidden; }
.barra-lunga > i { display: block; height: 100%; background: var(--accento); border-radius: 99px; transform-origin: left; animation: cresce .6s var(--molla); }
@keyframes cresce { from { transform: scaleX(0); } }
.barra-lunga.sfora > i { background: var(--uscita); }
.barra-lunga.ok > i { background: var(--entrata); }

/* anello degli obiettivi */
.anello { width: 52px; height: 52px; flex: none; transform: rotate(-90deg); }
.anello circle { fill: none; stroke-width: 7; stroke-linecap: round; }
.anello .fondo { stroke: var(--riempimento); }
.anello .avanti { stroke: var(--accento); transition: stroke-dasharray .8s var(--molla); }
.anello.ok .avanti { stroke: var(--entrata); }
.anello.sfora .avanti { stroke: var(--attenzione); }
.obiettivo { display: flex; gap: 14px; align-items: center; }
.obiettivo .pct { font-family: var(--tondo); font-weight: 700; font-size: 13px; }
.anello-box { position: relative; display: grid; place-items: center; }
.anello-box .pct { position: absolute; }

/* --------------------------------------------------------- grafici */
svg.grafico { width: 100%; height: auto; display: block; overflow: visible; }
svg.grafico text { fill: var(--tenue); font-size: 11px; font-family: inherit; }
.legenda { display: flex; gap: 16px; font-size: 13px; color: var(--tenue); margin-top: 10px; }
.legenda i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.legenda i.pallino-e { background: var(--entrata); }
.legenda i.pallino-u { background: var(--accento); }

/* ------------------------------------------------- avvisi e cartellini */
.cartellino { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: var(--riempimento); color: var(--tenue); white-space: nowrap; }
.cartellino.verde { background: color-mix(in srgb, var(--entrata) 15%, transparent); color: var(--entrata); }
.cartellino.rosso { background: color-mix(in srgb, var(--uscita) 14%, transparent); color: var(--uscita); }
.cartellino.giallo { background: color-mix(in srgb, var(--attenzione) 15%, transparent); color: var(--attenzione); }
.striscia { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--raggio); background: var(--accento-tenue); font-size: 15px; }
.striscia .icona { color: var(--accento); margin-top: 1px; }
.vuoto { display: grid; justify-items: center; gap: 8px; text-align: center; padding: 28px 20px; color: var(--tenue); font-size: 15px; }
.vuoto .icona { width: 34px; height: 34px; stroke-width: 1.5; color: var(--tenue-2); }

/* -------------------------------------------------------- importa */
.caduta { border: 2px dashed var(--tenue-2); border-radius: 16px; padding: 40px 20px; text-align: center; display: grid; gap: 10px; justify-items: center; background: var(--carta); transition: border-color .2s, background .2s; }
.caduta .icona { width: 44px; height: 44px; color: var(--accento); stroke-width: 1.5; }
.caduta strong { font-size: 19px; font-weight: 600; }
.caduta.sopra { border-color: var(--accento); background: var(--accento-tenue); }
.caduta button { margin-top: 6px; }

/* --------------------------------------------------- primo ingresso */
.benvenuto { display: grid; gap: 22px; justify-items: center; text-align: center; padding: 24px 0 8px; max-width: 520px; margin: 0 auto; width: 100%; }
.benvenuto h1 { font-size: 34px; font-weight: 700; letter-spacing: -.022em; }
.benvenuto > p { color: var(--tenue); font-size: 17px; }
.benvenuto .gruppo { width: 100%; text-align: left; }
.benvenuto .riga .testi .titolo { font-weight: 600; }
.benvenuto .riga .testi .sotto { white-space: normal; }

/* --------------------------------------------------------- tabelle (rendiconto) */
.tabella { width: 100%; border-collapse: collapse; font-size: 15px; }
.tabella th { text-align: left; font-weight: 600; color: var(--tenue); font-size: 13px; padding: 0 0 8px; }
.tabella td { padding: 10px 0; border-top: .5px solid var(--linea); vertical-align: middle; }
.tabella th + th, .tabella td + td { padding-left: 12px; }
.tabella .destra { text-align: right; }
.tabella tfoot td { font-weight: 600; }
.scorre { overflow-x: auto; }

/* ------------------------------------------------------------- foglio */
dialog#foglio {
  border: 0; padding: 0; color: var(--testo); background: var(--sfondo);
  width: min(560px, 100%); max-height: min(88vh, 900px); border-radius: 14px; overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,.3);
}
dialog#foglio[open] { display: flex; flex-direction: column; animation: sale .38s var(--molla); }
dialog#foglio::backdrop { background: rgba(0,0,0,.32); animation: scurisce .3s ease; }
@keyframes sale { from { transform: translateY(24px) scale(.98); opacity: 0; } }
@keyframes scurisce { from { opacity: 0; } }
.testa-foglio { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 6px 8px; min-height: 52px; border-bottom: .5px solid var(--linea); background: var(--materiale); }
.testa-foglio h2 { font-size: 17px; font-weight: 600; text-align: center; padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.testa-foglio > :first-child { justify-self: start; }
.testa-foglio > :last-child { justify-self: end; }
.corpo-foglio { overflow-y: auto; padding: 20px 16px calc(28px + env(safe-area-inset-bottom)); display: grid; gap: 22px; align-content: start; }
.maniglia { display: none; }
@media (max-width: 899px) {
  dialog#foglio { margin: auto 0 0; width: 100%; max-width: none; max-height: 92vh; max-height: 92dvh; border-radius: 14px 14px 0 0; }
  dialog#foglio[open] { animation: sale-basso .42s var(--molla); }
  @keyframes sale-basso { from { transform: translateY(100%); } }
  .maniglia { display: block; width: 36px; height: 5px; border-radius: 3px; background: var(--tenue-2); margin: 6px auto 0; flex: none; }
  .testa-foglio { border-bottom: 0; background: transparent; }
}
.dettaglio-importo { display: grid; justify-items: center; gap: 6px; text-align: center; padding: 6px 0 0; }
.dettaglio-importo .tessera { margin-bottom: 4px; }
.dettaglio-importo .valore { font-family: var(--tondo); font-size: 40px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.dettaglio-importo .chi { font-size: 17px; font-weight: 600; }

/* --------------------------------------------------------- messaggio */
#messaggio {
  position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  background: var(--materiale); color: var(--testo); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  padding: 12px 20px; border-radius: 99px; font-size: 15px; font-weight: 500; max-width: calc(100% - 32px); text-align: center;
  box-shadow: 0 8px 30px rgba(0,0,0,.16); animation: messaggio .4s var(--molla);
}
@keyframes messaggio { from { transform: translate(-50%, 20px); opacity: 0; } }
#messaggio.errore { background: var(--uscita); color: #fff; }
@media (min-width: 900px) { #messaggio { bottom: 28px; left: calc(50% + 126px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
  .laterale, .barra-schede, .barra-piccola, .non-stampare, #messaggio, dialog { display: none !important; }
  #app { display: block; }
  body { background: #fff; color: #000; }
  main { padding: 0; animation: none; }
  .scheda, .cifra, .gruppo { border: 1px solid #ddd; break-inside: avoid; }
}

/* ------------------------------------------------------- dettagli */
.riga .titolo.a-capo, .riga .sotto.a-capo { white-space: normal; }
.riga .titolo .cartellino { margin-left: 8px; vertical-align: 1px; }
.riga .sotto .da-classificare { color: var(--accento); font-weight: 500; }
.riga .sotto .barra-lunga { margin: 7px 0 5px; }
.riga .sotto .sotto-barra { display: block; }
.riga.spento .titolo, .riga.spento .importo { color: var(--tenue); }
.riga.accento { gap: 8px; justify-content: center; font-weight: 500; }
.riga.rossa { font-weight: 500; }
.riga.obiettivo .anello-box { margin: 8px 0; }
.riga .destra .leggero { margin-right: -8px; }
.valore-campo { margin-left: auto; color: var(--tenue); text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tessera.monogramma { font-family: var(--tondo); font-weight: 700; font-size: 15px; }
.anello.grande { width: 96px; height: 96px; }
.anello.grande + .pct { font-size: 20px; }
.pulsanti { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.riga-modulo { display: flex; gap: 8px; }
.riga-modulo input { flex: 2; background: var(--carta); }
.riga-modulo select { flex: 1; width: auto; background-color: var(--carta); }
.riga-modulo button { background: var(--carta); }
.cartellini { display: flex; flex-wrap: wrap; gap: 6px; }
.bottone.tondo { width: 36px; height: 36px; min-height: 36px; padding: 0; border-radius: 50%; }
.bottone.tondo .icona { width: 20px; height: 20px; stroke-width: 2.2; }
@media (pointer: coarse) { .bottone.tondo { width: 44px; height: 44px; } }
details.apri > summary { cursor: pointer; color: var(--accento); font-weight: 500; list-style: none; padding: 4px 4px 10px; }
details.apri > summary::-webkit-details-marker { display: none; }
.vuoto.spiegazione { color: var(--testo); padding: 32px 24px; gap: 12px; max-width: 560px; margin: 0 auto; }
.vuoto.spiegazione h3 { font-size: 19px; font-weight: 600; }
.vuoto.spiegazione p { color: var(--tenue); }
.vuoto.spiegazione .bottone { margin-top: 6px; }
.eroe .valore.neg { color: var(--uscita); }
.campo input.interruttore { flex: none; width: 51px; min-height: 31px; padding: 0; background-color: var(--riempimento); margin-left: auto; }
.campo input.interruttore:checked { background-color: var(--verde); }
.campo input[type=checkbox]:not(.interruttore) { flex: none; width: 22px; }
@media (max-width: 599px) {
  .cifre { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .cifre:has(> :nth-child(4)) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cifra { padding: 12px; }
  .cifra .etichetta { font-size: 12px; }
  .cifra .etichetta .icona { display: none; }
  .cifra .valore { font-size: 20px; }
  .cifra .nota { font-size: 12px; }
}
.anello-box .pct { font-family: var(--tondo); font-weight: 700; font-size: 13px; }
.anello.grande + .pct { font-size: 22px; }
.cartellini button.cartellino { min-height: 32px; padding: 0 12px; font-size: 13px; font-weight: 500; border-radius: 99px; background: var(--riempimento); color: var(--testo); }
.cartellini button.cartellino.verde { background: color-mix(in srgb, var(--entrata) 15%, transparent); color: var(--entrata); }

/* ---------------------------------------------- telefono: niente che sfora */
main, .sezione { grid-template-columns: minmax(0, 1fr); }
main > *, .sezione > * { min-width: 0; }

/* la carta del patrimonio, come una carta di Wallet */
.carta-eroe {
  position: relative; overflow: hidden; color: #fff; border-radius: 24px; padding: 22px 22px 18px;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(255, 255, 255, .22) 0%, rgba(255, 255, 255, 0) 55%),
    radial-gradient(80% 70% at 0% 100%, rgba(40, 0, 20, .35) 0%, rgba(40, 0, 20, 0) 60%),
    linear-gradient(150deg, #d63f69 0%, #a81d43 55%, #7c1030 100%);
  box-shadow: 0 18px 40px -18px rgba(150, 20, 60, .65), inset 0 1px 0 rgba(255, 255, 255, .25);
  display: grid; gap: 4px;
}
.carta-eroe .etichetta { font-size: 13px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; opacity: .78; }
.carta-eroe .valore { font-family: var(--tondo); font-size: clamp(38px, 11vw, 54px); font-weight: 700; letter-spacing: -.03em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.carta-eroe .valore.neg { color: #fff; }
.carta-eroe .sotto { font-size: 14px; opacity: .82; }
.carta-eroe .tre { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 16px; padding-top: 14px; border-top: .5px solid rgba(255, 255, 255, .28); }
.carta-eroe .tre > div { display: grid; gap: 2px; padding-right: 8px; }
.carta-eroe .tre > div + div { padding-left: 12px; border-left: .5px solid rgba(255, 255, 255, .22); }
.carta-eroe .tre span { font-size: 12px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.carta-eroe .tre strong { font-family: var(--tondo); font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* tessera di un marchio: iniziale bianca sul colore del marchio */
.tessera.marchio { font-family: var(--tondo); font-weight: 700; font-size: 15px; letter-spacing: -.01em; box-shadow: inset 0 0 0 .5px rgba(255, 255, 255, .12); }
.tessera.marchio.grande { font-size: 22px; }

.avviso-riga .titolo.a-capo { font-size: 15px; line-height: 1.35; }
.descrizione-banca { font-size: 13px; color: var(--tenue); word-break: break-word; }

@media (max-width: 599px) {
  main { gap: 24px; padding-left: 16px; padding-right: 16px; }
  .sezione h2 { font-size: 20px; }
  .riga .importo { font-size: 15px; }
  .riga .titolo { font-size: 15.5px; }
}

/* ================================================================
 * v3: il banner colorato in cima a ogni pagina, carte dei conti,
 * barra delle spese, barra delle schede che galleggia.
 * ================================================================ */
:root { --banner: radial-gradient(120% 90% at 100% 0%, rgba(255,255,255,.20) 0%, rgba(255,255,255,0) 55%), radial-gradient(90% 80% at 0% 100%, rgba(40,0,20,.35) 0%, rgba(40,0,20,0) 60%), linear-gradient(155deg, #dc4570 0%, #ad1f47 52%, #761030 100%); }

.testata.banner {
  color: #fff; background: var(--banner);
  margin: calc(-52px - env(safe-area-inset-top)) -16px 0; padding: calc(58px + env(safe-area-inset-top)) 20px 22px;
  border-radius: 0 0 30px 30px; box-shadow: 0 20px 40px -24px rgba(140, 20, 55, .7);
  display: grid; gap: 12px; position: relative; overflow: hidden;
}
.testata.banner h1 { color: #fff; font-size: 30px; }
.testata.banner .sottotitolo { color: rgba(255,255,255,.82); margin: -4px 0 0; }
.testata.banner .azioni button.tondo, .testata.banner .azioni .bottone.tondo { background: rgba(255,255,255,.2); color: #fff; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.testata.banner .riga-titolo { min-height: 44px; align-items: center; }
.cifra-banner { display: grid; gap: 2px; margin-top: 2px; }
.cifra-banner .etichetta { font-size: 12.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; opacity: .8; }
.cifra-banner .valore { font-family: var(--tondo); font-size: clamp(38px, 11.5vw, 56px); font-weight: 700; letter-spacing: -.03em; line-height: 1.04; font-variant-numeric: tabular-nums; }
.cifra-banner .sotto { font-size: 14px; opacity: .85; }
.testata.banner .tre { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding-top: 14px; border-top: .5px solid rgba(255,255,255,.28); }
.testata.banner .tre > div { display: grid; gap: 2px; padding-right: 8px; min-width: 0; }
.testata.banner .tre > div + div { padding-left: 12px; border-left: .5px solid rgba(255,255,255,.22); }
.testata.banner .tre span { font-size: 12px; opacity: .78; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.testata.banner .tre strong { font-family: var(--tondo); font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* le azioni rapide: cerchi di vetro */
.rapide { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 4px; }
.rapida { background: none; color: #fff; display: grid; justify-items: center; gap: 6px; padding: 0; min-height: 0; font-size: 12px; font-weight: 500; }
.rapida .cerchio { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.18); box-shadow: inset 0 0 0 .5px rgba(255,255,255,.35); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.rapida .cerchio .icona { width: 23px; height: 23px; stroke-width: 2; }
.rapida:active { transform: scale(.94); opacity: 1; }
/* nel banner: segmenti e ricerca di vetro */
.testata.banner .segmenti { background: rgba(255,255,255,.16); }
.testata.banner .segmenti button { color: #fff; }
.testata.banner .segmenti button.scelto { background: #fff; color: var(--accento); box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.testata.banner .ricerca input { background: rgba(255,255,255,.2); color: #fff; }
.testata.banner .ricerca input::placeholder { color: rgba(255,255,255,.78); }
.testata.banner .ricerca .icona { color: rgba(255,255,255,.85); }
.testata.banner .ricerca input:focus { box-shadow: 0 0 0 3px rgba(255,255,255,.4); }

/* la barra in alto quando scorri: dello stesso colore del banner */
.barra-piccola.piena { background: rgba(160, 28, 64, .86); color: #fff; border-color: transparent; }

/* le carte dei conti, da sfogliare */
.carosello { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -16px; padding: 4px 16px 12px; scrollbar-width: none; }
.carosello::-webkit-scrollbar { display: none; }
.carta-conto { flex: 0 0 74%; max-width: 300px; scroll-snap-align: start; aspect-ratio: 1.586; border-radius: 20px; color: #fff; padding: 16px 18px; display: grid; align-content: space-between;
  box-shadow: 0 14px 28px -16px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.18); transition: transform .2s var(--molla); }
.carta-conto:active { transform: scale(.97); }
.carta-conto .cima { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 600; opacity: .9; }
.carta-conto .cima .icona { width: 22px; height: 22px; opacity: .85; }
.carta-conto .saldo { font-family: var(--tondo); font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.carta-conto .nome { font-size: 13px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

/* le spese del mese in una barra */
.scheda-spese { display: grid; gap: 14px; color: var(--testo); }
.totale-spese { display: flex; align-items: baseline; gap: 8px; }
.totale-spese strong { font-family: var(--tondo); font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.totale-spese span { color: var(--tenue); font-size: 14px; }
.barra-spese { display: flex; gap: 3px; height: 14px; border-radius: 99px; overflow: hidden; }
.barra-spese i { display: block; min-width: 6px; border-radius: 3px; animation: cresce .7s var(--molla); transform-origin: left; }
.legenda-spese { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; }
.legenda-spese > div { display: flex; align-items: center; gap: 8px; font-size: 14px; min-width: 0; }
.legenda-spese i { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.legenda-spese .nome { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--tenue); }
.legenda-spese .num { font-weight: 600; }

/* elenchi più morbidi, icone rotonde come nelle app delle banche */
.gruppo, .scheda, .campi { border-radius: 20px; }
.tessera, .tessera.grande { border-radius: 50%; }
.riga { min-height: 60px; }
.riga.con-tessera + .riga::before, .riga + .riga.con-tessera::before { left: 64px; }
.tessera { width: 36px; height: 36px; }
.tessera .icona { width: 18px; height: 18px; }

/* la barra delle schede galleggia, come una pillola di vetro */
.barra-schede { left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); padding: 6px; border-radius: 28px; border: .5px solid var(--linea);
  box-shadow: 0 12px 32px rgba(0,0,0,.14); background: rgba(255,255,255,.82); }
@media (prefers-color-scheme: dark) { .barra-schede { background: rgba(30,30,33,.82); } }
.barra-schede a { border-radius: 22px; padding: 6px 0 4px; }
.barra-schede a.attiva { background: var(--accento-tenue); }
main { padding-bottom: calc(120px + env(safe-area-inset-bottom)); }
#messaggio { bottom: calc(100px + env(safe-area-inset-bottom)); }

/* computer: il banner occupa la cima della colonna */
@media (min-width: 900px) {
  .testata.banner { margin: -40px -40px 0; padding: 44px 40px 30px; border-radius: 0 0 32px 32px; }
  .testata.banner h1 { font-size: 32px; }
  .rapide { max-width: 420px; }
  .carosello { margin: 0; padding: 4px 0 8px; flex-wrap: wrap; overflow: visible; }
  .carta-conto { flex: 0 0 260px; }
  main { padding-bottom: 80px; }
}
@media print { .testata.banner { color: #000; background: none; box-shadow: none; margin: 0; padding: 0; } }
.legenda-spese { grid-template-columns: minmax(0, 1fr); gap: 10px; }
.legenda-spese .nome { color: var(--testo); }

/* ------------------------------------------- movimento a mano (contanti) */
.inserisci-importo { display: grid; gap: 14px; justify-items: center; padding-top: 4px; }
.inserisci-importo .segmenti { width: min(280px, 100%); }
.riga-importo { display: flex; align-items: baseline; justify-content: center; gap: 6px; width: 100%; }
.riga-importo .segno { font-family: var(--tondo); font-size: 34px; font-weight: 600; color: var(--tenue); }
input.importo-grande { font-family: var(--tondo); font-size: 52px; font-weight: 700; letter-spacing: -.03em; text-align: left; background: transparent; padding: 0; min-height: 64px; min-width: 1ch; max-width: 80%; font-variant-numeric: tabular-nums; }
input.importo-grande:focus { box-shadow: none; }
.titolo-scelte { font-size: 13px; font-weight: 600; color: var(--tenue); padding: 0 4px 8px; }
.scelte-categoria { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.scelta { display: grid; justify-items: center; align-content: start; gap: 6px; padding: 10px 6px; min-height: 84px; border-radius: 16px; background: var(--carta); color: var(--testo); font-size: 12px; font-weight: 500; line-height: 1.2; text-align: center; box-shadow: inset 0 0 0 1px transparent; }
.scelta span:last-child { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.scelta.scelta-attiva { box-shadow: inset 0 0 0 2px var(--accento); background: var(--accento-tenue); }
.scelte-categoria + input { margin-top: 10px; background: var(--carta); }

/* tira giù per aggiornare */
html, body { overscroll-behavior-y: contain; }
.tira-giu { position: fixed; top: calc(env(safe-area-inset-top) + 6px); left: 50%; z-index: 40; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; background: var(--carta); color: var(--accento); box-shadow: 0 8px 22px rgba(0,0,0,.2);
  transform: translate(-50%, -70px); opacity: 0; pointer-events: none; transition: opacity .15s, background .15s, color .15s; }
.tira-giu .icona { width: 20px; height: 20px; stroke-width: 2.4; }
.tira-giu.visibile { opacity: 1; }
.tira-giu.pronto { background: var(--accento); color: #fff; }
.tira-giu.gira { transition: transform .25s var(--molla), opacity .15s; }
.tira-giu.gira .icona { animation: gira .8s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }
