/* Cantiere 211 — stile. Mobile first, tema chiaro/scuro, animazioni leggere. */

:root {
  color-scheme: light;
  --sfondo: #f4f1ec;
  --superficie: #ffffff;
  --superficie-2: #f1ede6;
  --superficie-3: #e8e3da;
  --bordo: #e4dfd5;
  --testo: #1b1a17;
  --testo-2: #5d5a53;
  --testo-3: #8f8b82;
  --inchiostro: #1f2a37;
  --inchiostro-testo: #ffffff;
  --accento: #e2622b;
  --accento-2: #f08a4b;
  --accento-tenue: #fde9df;
  --serie: #2a78d6;
  --serie-tenue: #dbe8f8;
  --griglia: #ece8e0;
  --buono: #16803a;
  --buono-tenue: #e3f4e8;
  --critico: #d03b3b;
  --critico-tenue: #fbe5e5;
  --attenzione: #b87700;
  --attenzione-tenue: #fff4d6;
  --ombra-1: 0 1px 2px rgb(40 30 10 / .05), 0 2px 10px rgb(40 30 10 / .05);
  --ombra-2: 0 8px 30px rgb(40 30 10 / .14);
  --r: 20px;
  --r-s: 14px;
  --barra-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --molla: cubic-bezier(.2, .9, .25, 1.12);
  --dolce: cubic-bezier(.25, .8, .25, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --sfondo: #111110;
    --superficie: #1c1b19;
    --superficie-2: #262522;
    --superficie-3: #312f2b;
    --bordo: #34322d;
    --testo: #f5f3ee;
    --testo-2: #bdb9ae;
    --testo-3: #8a867c;
    --inchiostro: #f5f3ee;
    --inchiostro-testo: #151412;
    --accento: #ef7440;
    --accento-2: #f59a63;
    --accento-tenue: #3a2418;
    --serie: #3987e5;
    --serie-tenue: #1d314b;
    --griglia: #2a2926;
    --buono: #4cc46b;
    --buono-tenue: #173220;
    --critico: #ef6b6b;
    --critico-tenue: #3a1b1b;
    --attenzione: #f0b43c;
    --attenzione-tenue: #36290c;
    --ombra-1: none;
    --ombra-2: 0 8px 30px rgb(0 0 0 / .5);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  background: var(--sfondo);
  color: var(--testo);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
h1, h2, h3, p { margin: 0; }
h2 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-user-select: none; user-select: none; }
svg { width: 22px; height: 22px; flex: none; }
[hidden] { display: none !important; }
.muted { color: var(--testo-2); }
.piccolo { font-size: 13px; }
.centro { text-align: center; }
.errore { color: var(--critico); font-size: 14px; min-height: 1.2em; }
.errore:empty { min-height: 0; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Pulsanti ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 16px; padding: 14px 18px; min-height: 52px;
  font-weight: 650; font-size: 16px; cursor: pointer;
  transition: transform .15s var(--dolce), background .2s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 20px; height: 20px; }
.btn.primario { background: var(--inchiostro); color: var(--inchiostro-testo); }
.btn.primario:disabled { opacity: .3; transform: none; cursor: default; }
.btn.secondario { background: var(--superficie-2); color: var(--testo); }
.btn.accento { background: var(--accento); color: #fff; }
.btn.pericolo { background: transparent; color: var(--critico); }
.btn.pieno { display: flex; width: 100%; }
.btn.grande { min-height: 58px; font-size: 17px; border-radius: 18px; }
.btn-testo { background: none; border: 0; padding: 10px 2px; cursor: pointer; color: var(--testo-2); min-width: 70px; text-align: left; font-size: 16px; }
.btn-testo.forte { color: var(--accento); font-weight: 700; text-align: right; }
.tondo {
  width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--superficie); box-shadow: var(--ombra-1);
  display: grid; place-items: center; cursor: pointer; color: var(--testo-2); transition: transform .15s;
}
.tondo:active { transform: scale(.92); }
.link { background: none; border: 0; color: var(--accento); font-weight: 650; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; padding: 4px 0; font-size: 15px; }
.link svg { width: 16px; height: 16px; }

/* ---------- Campi ---------- */
.campo {
  width: 100%; padding: 14px 16px; border-radius: 14px; border: 1.5px solid transparent;
  background: var(--superficie-2); font-size: 17px; outline: none; transition: border-color .2s, background .2s;
}
.campo:focus { border-color: var(--accento); background: var(--superficie); }
.campo::placeholder { color: var(--testo-3); }
textarea.campo { resize: vertical; }
.campo.grande-testo { font-size: 20px; font-weight: 650; }
.campo-etichetta { display: grid; gap: 6px; font-size: 13px; color: var(--testo-2); font-weight: 600; }
.due { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- Accesso ---------- */
.accesso { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.accesso-box { width: 100%; max-width: 340px; display: grid; gap: 12px; text-align: center; justify-items: center; animation: sali .6s var(--molla) both; }
.accesso-logo { border-radius: 22px; box-shadow: var(--ombra-2); margin-bottom: 6px; }
.accesso-box h1 { font-size: 28px; letter-spacing: -.02em; }
.accesso-box .campo, .accesso-box .btn { width: 100%; }

/* ---------- Struttura ---------- */
.testata {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 6px;
  padding: calc(14px + var(--safe-t)) 18px 12px;
  background: color-mix(in srgb, var(--sfondo) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(16px); -webkit-backdrop-filter: saturate(1.4) blur(16px);
}
.testata-titolo { flex: 1; min-width: 0; }
.testata h1 { font-size: 26px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.testata p { font-size: 13px; }
.sync { background: none; border: 0; width: 34px; height: 42px; cursor: pointer; display: grid; place-items: center; }
.sync span { width: 9px; height: 9px; border-radius: 50%; background: var(--buono); transition: background .3s, transform .3s; }
.sync.offline span { background: var(--critico); }
.sync.lavora span { animation: pulsa 1s ease-in-out infinite; }

main { max-width: 680px; margin: 0 auto; padding: 4px 16px calc(var(--barra-h) + 110px + var(--safe-b)); }
.vista { display: grid; gap: 14px; }
.vista.entra { animation: entra .35s var(--dolce) both; }

.barra {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(3, 1fr); padding: 6px 12px calc(6px + var(--safe-b));
  background: color-mix(in srgb, var(--superficie) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(18px); -webkit-backdrop-filter: saturate(1.4) blur(18px);
  border-top: 1px solid var(--bordo);
}
.tab {
  background: none; border: 0; cursor: pointer; color: var(--testo-3); height: 56px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11.5px; font-weight: 650; transition: color .2s;
}
.tab svg { width: 25px; height: 25px; transition: transform .25s var(--molla); }
.tab.attivo { color: var(--accento); }
.tab.attivo svg { transform: translateY(-1px) scale(1.08); }
.fab {
  position: fixed; z-index: 31; right: 18px; bottom: calc(var(--barra-h) + 18px + var(--safe-b));
  width: 64px; height: 64px; border-radius: 22px; border: 0; cursor: pointer;
  background: linear-gradient(145deg, var(--accento-2), var(--accento)); color: #fff;
  box-shadow: 0 10px 24px color-mix(in srgb, var(--accento) 45%, transparent), 0 2px 6px rgb(0 0 0 / .15);
  display: grid; place-items: center; transition: transform .2s var(--molla);
  animation: comparsa .5s .2s var(--molla) both;
}
.fab svg { width: 30px; height: 30px; }
.fab:active { transform: scale(.9) rotate(90deg); }
@media (min-width: 720px) { .fab { right: calc(50% - 340px + 18px); } }

/* ---------- Home ---------- */
.card, .tile { background: var(--superficie); border-radius: var(--r); box-shadow: var(--ombra-1); }
.card { padding: 18px; display: grid; gap: 12px; }
.card-testa { display: flex; align-items: center; justify-content: space-between; }

.hero {
  position: relative; overflow: hidden; border-radius: 26px; padding: 22px 22px 20px; color: #fff;
  background:
    radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--accento) 55%, transparent) 0%, transparent 55%),
    linear-gradient(160deg, #26374a 0%, #1a2430 100%);
  box-shadow: 0 14px 34px rgb(26 36 48 / .28);
}
@media (prefers-color-scheme: dark) {
  .hero { background: radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--accento) 45%, transparent) 0%, transparent 55%), linear-gradient(160deg, #26303b 0%, #191e24 100%); }
}
.hero-label { font-size: 14px; font-weight: 600; opacity: .8; }
.hero-valore { font-size: 52px; font-weight: 800; letter-spacing: -.035em; line-height: 1.05; margin: 6px 0 8px; }
.hero-valore.negativo { color: #ffb4a8; }
.hero-nota { font-size: 14px; line-height: 1.45; opacity: .82; }
.hero-barra { margin-top: 14px; height: 6px; border-radius: 3px; background: rgb(255 255 255 / .16); overflow: hidden; }
.hero-barra div { height: 100%; width: 0; border-radius: 3px; background: linear-gradient(90deg, #fff, #ffd2b8); transition: width 1s var(--dolce); }

.saldo { gap: 14px; }
.saldo-persone { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.persona { display: grid; justify-items: center; gap: 6px; text-align: center; }
.avatar {
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; font-size: 20px; color: #fff; transition: transform .4s var(--molla);
}
.avatar.a { background: linear-gradient(145deg, #3f8ae0, #2a64b8); }
.avatar.d { background: linear-gradient(145deg, #e06c9a, #b8467a); }
.persona b { font-size: 15px; }
.persona small { color: var(--testo-2); font-size: 13px; }
.flusso { display: grid; justify-items: center; gap: 2px; color: var(--accento); min-width: 90px; }
.flusso svg { width: 34px; height: 34px; animation: scorri-freccia 1.6s ease-in-out infinite; }
.flusso.sinistra svg { transform: scaleX(-1); animation-name: scorri-freccia-s; }
.flusso b { font-size: 19px; font-weight: 800; color: var(--testo); }
.saldo-frase { text-align: center; font-size: 15px; color: var(--testo-2); }
.saldo-frase strong { color: var(--testo); }
.pari { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--buono); font-weight: 700; }

.indicatori { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { padding: 14px 16px; }
.tile-label { font-size: 13px; color: var(--testo-2); font-weight: 550; }
.tile-valore { font-size: 22px; font-weight: 750; margin-top: 3px; letter-spacing: -.02em; }
.tile-nota { font-size: 12px; color: var(--testo-3); margin-top: 1px; }

.avviso {
  display: flex; gap: 12px; align-items: flex-start; text-align: left; cursor: pointer; width: 100%;
  background: var(--attenzione-tenue); border: 0; border-radius: var(--r-s); padding: 14px 16px; font-size: 14px; color: var(--testo);
  transition: transform .15s;
}
.avviso:active { transform: scale(.98); }
.avviso svg { color: var(--attenzione); margin-top: 1px; }
.avviso strong { display: block; margin-bottom: 2px; }

.grafico { position: relative; height: 190px; touch-action: pan-y; }
.grafico svg { display: block; width: 100%; height: 100%; overflow: visible; }
.grafico .asse { font-size: 11px; fill: var(--testo-3); font-variant-numeric: tabular-nums; }
.grafico .griglia { stroke: var(--griglia); stroke-width: 1; }
.grafico .linea { fill: none; stroke: var(--serie); stroke-width: 2; stroke-linejoin: round; stroke-dasharray: var(--lung, 0); stroke-dashoffset: var(--lung, 0); animation: disegna 1.1s .1s var(--dolce) forwards; }
.grafico .area { fill: var(--serie); opacity: 0; animation: appari .8s .6s forwards; }
.grafico .croce { stroke: var(--testo-3); stroke-width: 1; stroke-dasharray: 3 3; }
.grafico .punto { fill: var(--serie); stroke: var(--superficie); stroke-width: 2; }
.vuoto { color: var(--testo-3); font-size: 15px; padding: 26px 8px; text-align: center; }

.tabella-dati { font-size: 13px; }
.tabella-dati summary { cursor: pointer; color: var(--testo-2); }
.tabella-dati table { width: 100%; border-collapse: collapse; margin-top: 8px; font-variant-numeric: tabular-nums; }
.tabella-dati td, .tabella-dati th { padding: 6px 4px; border-bottom: 1px solid var(--griglia); text-align: right; }
.tabella-dati td:first-child, .tabella-dati th:first-child { text-align: left; }

.classifica { display: grid; gap: 12px; }
.riga-cat { display: grid; gap: 6px; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; width: 100%; }
.riga-cat .intesta { display: flex; justify-content: space-between; gap: 8px; font-size: 14.5px; }
.riga-cat .intesta span:last-child { font-variant-numeric: tabular-nums; font-weight: 650; }
.riga-cat .quota { color: var(--testo-3); margin-left: 6px; }
.traccia { height: 8px; border-radius: 4px; background: var(--superficie-2); overflow: hidden; }
.riempi { height: 100%; width: 0; border-radius: 4px; background: var(--serie); transition: width .9s var(--dolce); }

/* ---------- Righe spesa ---------- */
.righe { display: grid; }
.riga {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; width: 100%;
  padding: 10px 0; background: none; border: 0; text-align: left; cursor: pointer; border-bottom: 1px solid var(--griglia);
  transition: transform .15s, opacity .2s;
}
.riga:last-child { border-bottom: 0; }
.riga:active { transform: scale(.985); opacity: .7; }
.riga-icona {
  width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; overflow: hidden;
  background: var(--superficie-2); color: var(--testo-2); font-weight: 750; font-size: 16px;
}
.riga-icona img { width: 100%; height: 100%; object-fit: cover; }
.riga-icona.attrezzo { background: var(--accento-tenue); color: var(--accento); }
.riga-testo { min-width: 0; }
.riga-titolo { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.riga-meta { font-size: 13px; color: var(--testo-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.riga-importo { font-weight: 750; font-variant-numeric: tabular-nums; text-align: right; }
.riga-importo small { display: block; font-size: 12px; font-weight: 500; color: var(--testo-3); }
.pallino { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.pallino.a { background: #3f8ae0; }
.pallino.d { background: #e06c9a; }
.etichetta { display: inline-block; font-size: 10.5px; font-weight: 800; letter-spacing: .03em; padding: 2px 7px; border-radius: 6px; background: var(--superficie-2); color: var(--testo-2); vertical-align: 1px; }
.etichetta.attenzione { background: var(--attenzione-tenue); color: var(--attenzione); }
.etichetta.in-corso { background: var(--accento-tenue); color: var(--accento); }
.etichetta.fatto { background: var(--buono-tenue); color: var(--buono); }
.etichetta.ditta { background: var(--serie-tenue); color: var(--serie); }

/* ---------- Spese ---------- */
.barra-filtri { position: sticky; top: calc(76px + var(--safe-t)); z-index: 10; display: grid; gap: 10px; padding: 2px 0 6px; background: var(--sfondo); }
.ricerca { display: flex; align-items: center; gap: 8px; background: var(--superficie); border-radius: 14px; padding: 0 14px; box-shadow: var(--ombra-1); }
.ricerca svg { color: var(--testo-3); width: 20px; height: 20px; }
.ricerca input { border: 0; background: none; outline: none; width: 100%; padding: 13px 0; font-size: 17px; }
.riga-totale { font-size: 14px; color: var(--testo-2); display: flex; justify-content: space-between; padding: 0 4px; }
.riga-totale strong { color: var(--testo); font-variant-numeric: tabular-nums; }
.elenco { display: grid; gap: 16px; }
.mese h3 { font-size: 13px; color: var(--testo-2); font-weight: 700; margin: 0 6px 8px; display: flex; justify-content: space-between; text-transform: capitalize; }
.mese-lista { background: var(--superficie); border-radius: var(--r); box-shadow: var(--ombra-1); padding: 4px 16px; }

/* ---------- Chip ---------- */
.chips { display: flex; gap: 8px; }
.chips.avvolgi { flex-wrap: wrap; }
.chips.scorri { overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px; scroll-padding: 16px; }
.chips.scorri::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  border: 1.5px solid var(--bordo); background: var(--superficie); border-radius: 999px; padding: 9px 15px;
  font-size: 15px; font-weight: 550; white-space: nowrap; cursor: pointer; color: var(--testo);
  transition: background .2s, color .2s, border-color .2s, transform .15s var(--dolce);
}
.chip:active { transform: scale(.94); }
.chip.attivo { background: var(--inchiostro); color: var(--inchiostro-testo); border-color: var(--inchiostro); }
.chip.attivo.accento { background: var(--accento); border-color: var(--accento); color: #fff; }
.chip.tenue { border-style: dashed; color: var(--testo-2); }
.chip small { opacity: .6; font-weight: 500; }
.chip svg { width: 16px; height: 16px; }
.chip.pop { animation: pop .35s var(--molla); }
.chip-input { border: 1.5px solid var(--accento); background: var(--superficie); border-radius: 999px; padding: 9px 15px; font-size: 15px; outline: none; min-width: 150px; }
.suggerimenti { margin-top: 8px; }
.suggerimenti .chip { font-size: 14px; padding: 7px 12px; }

.segmenti { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--superficie-2); border-radius: 16px; }
.segmento {
  border: 0; background: none; border-radius: 12px; padding: 11px 8px; font-weight: 650; font-size: 15px; cursor: pointer;
  color: var(--testo-2); display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .25s var(--dolce), color .2s, box-shadow .25s, transform .15s;
}
.segmento:active { transform: scale(.96); }
.segmento.attivo { background: var(--superficie); color: var(--testo); box-shadow: 0 1px 4px rgb(0 0 0 / .12); }
@media (prefers-color-scheme: dark) { .segmento.attivo { background: var(--superficie-3); } }
.segmento .mini { width: 22px; height: 22px; font-size: 11px; }

/* ---------- Lavori ---------- */
.sommario { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sommario div { background: var(--superficie); border-radius: var(--r-s); box-shadow: var(--ombra-1); padding: 12px; text-align: center; }
.sommario b { display: block; font-size: 22px; font-weight: 800; }
.sommario span { font-size: 12.5px; color: var(--testo-2); }
.lavori { display: grid; gap: 12px; }
.gruppo { font-size: 13px; font-weight: 800; color: var(--testo-2); text-transform: uppercase; letter-spacing: .05em; margin: 12px 6px -2px; }
.gruppo:first-child { margin-top: 0; }
.lavoro {
  background: var(--superficie); border-radius: var(--r); box-shadow: var(--ombra-1); padding: 16px 18px; display: grid; gap: 10px;
  cursor: pointer; text-align: left; border: 0; width: 100%; transition: transform .15s var(--dolce);
}
.lavoro:active { transform: scale(.98); }
.lavoro-testa { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.lavoro-testa h3 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.stato-btn { border: 0; cursor: pointer; font-family: inherit; white-space: nowrap; flex: none; padding: 5px 9px; transition: transform .2s var(--molla); }
.stato-btn:active { transform: scale(.9); }
.lavoro-numeri { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 14px; color: var(--testo-2); }
.lavoro-numeri b { color: var(--testo); font-variant-numeric: tabular-nums; }
.risp { font-weight: 750; font-variant-numeric: tabular-nums; }
.risp.pos { color: var(--buono); }
.risp.neg { color: var(--critico); }
.meter { height: 8px; border-radius: 4px; background: var(--superficie-2); overflow: hidden; }
.meter div { height: 100%; width: 0; border-radius: 4px; background: var(--serie); transition: width .9s var(--dolce); }
.meter.oltre div { background: var(--critico); }
.lavoro .sotto { font-size: 13px; color: var(--testo-3); }
.lavoro .sotto .oltre { color: var(--critico); font-weight: 650; }
.spiega { padding: 4px 12px; }

/* ---------- Fogli (dialog) ---------- */
.foglio {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px;
  max-height: calc(100dvh - 40px - var(--safe-t));
  border-radius: 28px 28px 0 0; background: var(--superficie); color: var(--testo);
  transform: translateY(100%); transition: transform .38s var(--molla);
  overscroll-behavior: contain;
}
.foglio.alto { height: calc(100dvh - 40px - var(--safe-t)); }
.foglio.aperto { transform: translateY(0); }
.foglio::backdrop { background: rgb(10 8 5 / 0); transition: background .3s; }
.foglio.aperto::backdrop { background: rgb(10 8 5 / .45); }
@media (min-width: 620px) {
  .foglio { margin: auto; border-radius: 28px; transform: translateY(24px) scale(.97); opacity: 0; transition: transform .3s var(--molla), opacity .2s; }
  .foglio.alto { height: min(820px, calc(100dvh - 60px)); }
  .foglio.aperto { transform: none; opacity: 1; }
}
.maniglia { width: 40px; height: 5px; border-radius: 3px; background: var(--superficie-3); margin: 8px auto 0; }
.passo { padding: 4px 18px calc(22px + var(--safe-b)); display: grid; gap: 16px; align-content: start; }
.passo.entra { animation: entra .3s var(--dolce) both; }
.foglio-testa {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 52px;
  position: sticky; top: 0; z-index: 3; margin: 0 -18px; padding: 0 18px; background: var(--superficie);
}
.foglio-testa strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 52vw; }
.foglio-testa strong { font-size: 17px; }
.foglio-testa > :last-child { justify-self: end; }
.campo-gruppo { display: grid; gap: 10px; }
.campo-gruppo h3 { font-size: 14px; font-weight: 700; color: var(--testo-2); }
.campo-gruppo h3 small { font-weight: 500; color: var(--testo-3); margin-left: 4px; }

/* Importo */
.display-box { text-align: center; padding: 14px 0 4px; }
.display-importo { font-size: 56px; font-weight: 800; letter-spacing: -.035em; font-variant-numeric: tabular-nums; min-height: 68px; overflow-wrap: anywhere; transition: color .2s; }
.display-importo.vuoto-imp { color: var(--testo-3); }
.display-importo.batti { animation: batti .18s var(--dolce); }
.display-nota { color: var(--testo-3); font-size: 14px; min-height: 20px; }
.display-nota.ok { color: var(--buono); font-weight: 600; }
.tastierino { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tastierino button {
  height: 62px; border: 0; border-radius: 18px; background: var(--superficie-2); font-size: 27px; font-weight: 550; cursor: pointer;
  transition: transform .1s, background .15s;
}
.tastierino button:active { transform: scale(.93); background: var(--superficie-3); }
.azioni-importo { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }

.riepilogo-importo { display: flex; gap: 12px; align-items: stretch; }
.importo-pill {
  flex: 1; font-size: 34px; font-weight: 800; letter-spacing: -.03em; background: var(--superficie-2); border: 0; border-radius: 18px;
  padding: 10px 14px; cursor: pointer; font-variant-numeric: tabular-nums; text-align: left; transition: transform .15s;
}
.importo-pill:active { transform: scale(.98); }
.importo-pill small { display: block; font-size: 12px; font-weight: 600; color: var(--testo-3); letter-spacing: 0; }
.foto-box { width: 84px; flex: none; }
.foto-box button {
  width: 100%; height: 100%; min-height: 72px; border-radius: 18px; border: 1.5px dashed var(--bordo); background: var(--superficie);
  display: grid; place-items: center; align-content: center; gap: 2px; cursor: pointer; color: var(--testo-2); font-size: 11.5px; font-weight: 600; overflow: hidden; padding: 0; position: relative;
}
.foto-box img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.foto-box .caricamento { position: absolute; inset: 0; display: grid; place-items: center; background: rgb(0 0 0 / .45); color: #fff; }

.interruttore { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; cursor: pointer; padding: 12px 16px; border-radius: 16px; background: var(--superficie-2); }
.interruttore input { position: absolute; opacity: 0; pointer-events: none; }
.int-testo b { display: block; font-size: 15.5px; }
.int-testo small { color: var(--testo-2); font-size: 13px; }
.int-leva { width: 52px; height: 32px; border-radius: 16px; background: var(--superficie-3); position: relative; transition: background .25s; }
.int-leva::after { content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .3); transition: transform .3s var(--molla); }
.interruttore input:checked + .int-testo + .int-leva { background: var(--accento); }
.interruttore input:checked + .int-testo + .int-leva::after { transform: translateX(20px); }

.altro-dettagli summary { cursor: pointer; color: var(--testo-2); font-weight: 600; font-size: 15px; padding: 4px 0; }
.altro-dettagli[open] { display: grid; gap: 14px; }
.salva-fisso { position: sticky; bottom: calc(-22px - var(--safe-b)); margin: 0 -18px calc(-22px - var(--safe-b)); padding: 12px 18px calc(16px + var(--safe-b)); background: linear-gradient(to bottom, transparent, var(--superficie) 30%); }

/* Dettaglio spesa */
.dett-importo { font-size: 44px; font-weight: 800; letter-spacing: -.035em; text-align: center; }
.dett-titolo { text-align: center; font-size: 17px; font-weight: 650; margin-top: -8px; }
.dett-foto { width: 100%; max-height: 260px; object-fit: cover; border-radius: 18px; cursor: zoom-in; background: var(--superficie-2); }
.dett-righe { display: grid; background: var(--superficie-2); border-radius: 16px; padding: 4px 16px; }
.dett-righe div { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--bordo); font-size: 15px; }
.dett-righe div:last-child { border-bottom: 0; }
.dett-righe span { color: var(--testo-2); }
.dett-righe b { font-weight: 600; text-align: right; }
.azioni-due { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Menu */
.voce-menu { display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px; border: 0; border-radius: 16px; background: var(--superficie-2); font-size: 16px; font-weight: 600; cursor: pointer; text-align: left; transition: transform .15s; }
.voce-menu:active { transform: scale(.98); }
.voce-menu.pericolo { color: var(--critico); }

/* Visore foto */
.visore { position: fixed; inset: 0; z-index: 100; background: rgb(0 0 0 / .92); display: grid; place-items: center; padding: 20px; animation: appari .2s both; cursor: zoom-out; }
.visore img { max-width: 100%; max-height: 100%; border-radius: 8px; animation: comparsa .3s var(--molla) both; }

/* Tooltip, toast */
.tooltip {
  position: fixed; z-index: 60; pointer-events: none;
  background: var(--inchiostro); color: var(--inchiostro-testo); border-radius: 10px; padding: 7px 10px; font-size: 13px; line-height: 1.35;
  box-shadow: var(--ombra-2); white-space: nowrap;
}
.toast {
  position: fixed; z-index: 90; left: 50%; bottom: calc(var(--barra-h) + 100px + var(--safe-b));
  display: flex; align-items: center; gap: 10px;
  background: var(--inchiostro); color: var(--inchiostro-testo); border-radius: 16px; padding: 12px 18px; font-size: 15px; font-weight: 600;
  box-shadow: var(--ombra-2); pointer-events: none;
  transform: translate(-50%, 30px) scale(.9); opacity: 0; transition: transform .35s var(--molla), opacity .25s;
}
.toast.visibile { transform: translate(-50%, 0) scale(1); opacity: 1; }
.toast svg { color: var(--buono); width: 20px; height: 20px; }
@media (prefers-color-scheme: dark) { .toast svg { color: #16803a; } }

/* Comparsa a cascata degli elementi */
.cascata > * { animation: sali .45s var(--dolce) both; animation-delay: calc(var(--i, 0) * 35ms); }

/* ---------- Animazioni ---------- */
@keyframes entra { from { opacity: 0; transform: translateY(10px); } }
@keyframes sali { from { opacity: 0; transform: translateY(14px); } }
@keyframes comparsa { from { opacity: 0; transform: scale(.6); } }
@keyframes appari { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { 50% { transform: scale(1.08); } }
@keyframes batti { 50% { transform: scale(1.04); } }
@keyframes pulsa { 50% { transform: scale(.5); opacity: .5; } }
@keyframes disegna { to { stroke-dashoffset: 0; } }
@keyframes scorri-freccia { 50% { transform: translateX(5px); } }
@keyframes scorri-freccia-s { 0%, 100% { transform: scaleX(-1); } 50% { transform: scaleX(-1) translateX(5px); } }
.grafico .area { animation-name: area-appari; }
@keyframes area-appari { to { opacity: .12; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
  .grafico .linea { stroke-dasharray: none; }
}

/* Le griglie a una colonna non devono allargarsi oltre lo schermo per colpa delle righe scorrevoli. */
.vista, .barra-filtri, .passo, .card, .campo-gruppo, .altro-dettagli[open] { grid-template-columns: minmax(0, 1fr); }
main { overflow-x: clip; }

/* Chip più compatte dentro l'editor: più scelte per riga, meno scorrimento. */
.foglio .chips.avvolgi { gap: 7px; }
.foglio .chip { font-size: 14.5px; padding: 8px 13px; }

/* ---------- Avanzamento lavori ---------- */
.avanzamento { gap: 10px; text-align: left; border: 0; width: 100%; color: inherit; font: inherit; }
.cliccabile { cursor: pointer; transition: transform .15s var(--dolce); }
.cliccabile:active { transform: scale(.985); }
.avanzamento h2 b, .avanz-titolo b { font-size: 1.15em; }
.avanz-titolo { font-size: 15px; color: var(--testo-2); margin-top: -4px; }
.barra-stati { display: flex; gap: 3px; height: 14px; border-radius: 7px; overflow: hidden; background: var(--superficie-2); }
.barra-stati .seg { width: 0; height: 100%; transition: width .9s var(--dolce); }
.seg.fatto, .pall.fatto { background: var(--buono); }
.seg.in-corso, .pall.in-corso { background: var(--accento); }
.seg.da-fare, .pall.da-fare { background: var(--superficie-3); }
.legenda { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13.5px; color: var(--testo-2); }
.legenda span { display: inline-flex; align-items: center; gap: 6px; }
.pall { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }

/* ---------- Lista lavorazioni (tipo checklist) ---------- */
.lista-lavori { background: var(--superficie); border-radius: var(--r); box-shadow: var(--ombra-1); padding: 2px 14px; }
.lista-lavori .vuoto { padding: 22px 0; }
.riga-lav {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--griglia); cursor: pointer; transition: opacity .3s, transform .15s;
}
.riga-lav:last-child { border-bottom: 0; }
.riga-lav:active { transform: scale(.985); }
.riga-lav.fatta .riga-lav-nome { color: var(--testo-2); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--testo-3) 60%, transparent); }
.cerchio {
  width: 44px; height: 44px; border: 0; background: none; padding: 0; cursor: pointer; display: grid; place-items: center;
  color: var(--testo-3); border-radius: 50%; transition: transform .2s var(--molla), color .25s;
}
.cerchio svg { width: 30px; height: 30px; }
.cerchio:active { transform: scale(.85); }
.cerchio.in-corso { color: var(--accento); }
.cerchio.fatto { color: var(--buono); }
.cerchio.pop, .stato-grande.pop { animation: pop .35s var(--molla); }
.cerchio.vuoto-c { cursor: default; }
.riga-lav-testo { display: grid; gap: 4px; min-width: 0; }
.riga-lav-nome { font-weight: 650; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.riga-lav-sotto { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--testo-2); font-variant-numeric: tabular-nums; min-width: 0; }
.riga-lav-sotto > span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-barra { flex: none; width: 54px; height: 6px; border-radius: 3px; background: var(--superficie-2); overflow: hidden; }
.mini-barra span { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--serie); transition: width .8s var(--dolce); }
.mini-barra.oltre span { background: var(--critico); }
.riga-lav-destra { text-align: right; }
.valore-lav { font-weight: 750; font-variant-numeric: tabular-nums; font-size: 15px; }
.pos { color: var(--buono); }
.neg { color: var(--critico); }
.pill-prev { display: inline-block; font-size: 12.5px; font-weight: 700; color: var(--accento); background: var(--accento-tenue); padding: 5px 10px; border-radius: 999px; white-space: nowrap; }
.pill-ditta { display: inline-block; font-size: 12px; font-weight: 700; color: var(--serie); background: var(--serie-tenue); padding: 4px 9px; border-radius: 999px; }

.nuova-riga { min-height: 56px; }
.nuova-lav {
  width: 100%; min-height: 56px; border: 1.5px dashed var(--bordo); border-radius: var(--r); background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 16px; font-weight: 650; color: var(--testo-2);
  transition: transform .15s, border-color .2s;
}
.nuova-lav:active { transform: scale(.98); border-color: var(--accento); }
.nuova-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; animation: entra .25s var(--dolce); }
.nuova-form .campo { background: var(--superficie); border-color: var(--accento); }

/* ---------- Foglio lavorazione ---------- */
.titolo-input {
  width: 100%; border: 0; background: none; outline: none; font-size: 28px; font-weight: 800; letter-spacing: -.02em;
  padding: 4px 0; border-bottom: 2px solid transparent; transition: border-color .2s; color: var(--testo);
}
.titolo-input:focus { border-bottom-color: var(--accento); }
.stati-grandi { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stato-grande {
  display: grid; justify-items: center; gap: 6px; padding: 14px 6px 12px; border-radius: 18px; cursor: pointer;
  border: 2px solid var(--bordo); background: var(--superficie); color: var(--testo-3); font-weight: 700; font-size: 14.5px;
  transition: border-color .25s, background .25s, color .25s, transform .15s var(--dolce);
}
.stato-grande svg { width: 32px; height: 32px; }
.stato-grande span { color: var(--testo-2); }
.stato-grande:active { transform: scale(.95); }
.stato-grande.attivo.da-fare { border-color: var(--testo-3); background: var(--superficie-2); }
.stato-grande.attivo.in-corso { border-color: var(--accento); background: var(--accento-tenue); color: var(--accento); }
.stato-grande.attivo.fatto { border-color: var(--buono); background: var(--buono-tenue); color: var(--buono); }
.stato-grande.attivo span { color: var(--testo); }
.preventivo-box { gap: 12px; background: var(--superficie-2); box-shadow: none; }
.preventivo-box h3 { font-size: 15px; font-weight: 700; }
.importo-input { display: flex; align-items: baseline; gap: 8px; background: var(--superficie); border-radius: 16px; padding: 8px 16px; border: 2px solid transparent; transition: border-color .2s; cursor: text; }
.importo-input:focus-within { border-color: var(--accento); }
.importo-input input { flex: 1; min-width: 0; border: 0; outline: none; background: none; font-size: 38px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; color: var(--testo); }
.importo-input span { font-size: 26px; font-weight: 700; color: var(--testo-3); }
.preventivo-box .campo { background: var(--superficie); }
.preventivo-azioni { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 26px; }
.salvato { display: inline-flex; align-items: center; gap: 4px; color: var(--buono); font-size: 13.5px; font-weight: 650; opacity: 0; }
.salvato svg { width: 16px; height: 16px; }
.salvato.visibile { animation: salvato 2.2s var(--dolce) forwards; }
@keyframes salvato { 0% { opacity: 0; transform: translateY(4px); } 12%, 75% { opacity: 1; transform: none; } 100% { opacity: 0; } }
.piccolo-int { background: var(--superficie); padding: 10px 14px; }
.vl-dinamico { display: grid; gap: 12px; }
.numeri-lav { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; }
.numeri-lav div { display: grid; gap: 2px; }
.numeri-lav span { font-size: 12.5px; color: var(--testo-2); }
.numeri-lav b { font-size: 20px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.riga-lav-nome { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.25; }
.seg.da-fare, .pall.da-fare { background: color-mix(in srgb, var(--testo-3) 40%, transparent); }
