/* Casa in Ordine · stile "Elettrica" */
:root {
  --bg: #F5F6FA; --card: #FFFFFF; --soft: #ECEDF6; --ink: #15132B; --muted: #5D5B73;
  --line: #E1E2EE; --line2: #C9CADB;
  --primary: #4433FF; --primary-ink: #FFFFFF; --primary-dark: #2E1FD6;
  --accent: #C8F23A; --accent-ink: #15132B;
  --red: #D92D20; --red-soft: #FDE6E3; --orange: #B54708; --orange-soft: #FFEBD6; --orange-line: #F79009;
  --green: #1F7A45; --green-soft: #DDF3E5;
  --head: 'Space Grotesk', system-ui, sans-serif;
  --body: 'Inter', system-ui, sans-serif;
  --r-l: 26px; --r-m: 18px; --r-s: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
/* Rispetta la dimensione del testo scelta sull'iPhone */
html { font-size: 17px; }
@supports (font: -apple-system-body) { html { font: -apple-system-body; } }
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
body { font-family: var(--body); background: var(--bg); color: var(--ink); line-height: 1.4; min-height: 100vh;
  -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

#app { max-width: 560px; margin: 0 auto; padding: calc(20px + var(--safe-t)) 18px calc(110px + var(--safe-b)); }

/* Titoli */
.oggi { font-size: .9rem; color: var(--muted); }
.oggi::first-letter { text-transform: uppercase; }
h1 { font-family: var(--head); font-weight: 700; font-size: 2.2rem; line-height: 1.05; letter-spacing: -.03em; margin: 4px 0 18px; }
h2 { font-family: var(--head); font-weight: 700; font-size: 1.25rem; letter-spacing: -.02em; margin: 26px 0 12px; }

/* Aggiungi al volo */
.rapido { display: flex; gap: 8px; margin-bottom: 16px; }
.rapido input { flex: 1; min-width: 0; min-height: 52px; border-radius: 16px; background: var(--card); border: 1.5px solid var(--line);
  padding: 0 14px; font-size: 1rem; }
.rapido input::placeholder { color: var(--muted); }
.rapido input:focus { border-color: var(--primary); outline: none; }
.btn-accento { min-height: 52px; border-radius: 16px; padding: 0 18px; font-weight: 700; background: var(--accent); color: var(--accent-ink); flex: none; }
.btn-accento[disabled] { opacity: .6; }

/* Card totale */
.totale { border-radius: var(--r-l); padding: 20px; background: var(--primary); color: var(--primary-ink); position: relative; overflow: hidden; }
.totale .deco { position: absolute; right: -34px; top: -34px; width: 140px; height: 140px; border-radius: 50%; background: var(--accent); }
.totale .lab { font-size: .9rem; opacity: .9; position: relative; }
.totale .cifra { font-family: var(--head); font-weight: 700; font-size: 2.6rem; letter-spacing: -.03em; margin: 2px 0 10px; position: relative; }
.pillola { display: inline-flex; gap: 6px; align-items: center; background: rgba(255,255,255,.16); padding: 6px 12px; border-radius: 99px; font-size: .9rem; }
.pillola b { color: #FFD9D2; }

.banner { margin-top: 14px; border-radius: var(--r-m); padding: 14px 16px; background: var(--soft); display: flex; justify-content: space-between; gap: 10px; width: 100%; text-align: left; min-height: 52px; align-items: center; }

/* Filtri */
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 18px -18px 4px; padding: 0 18px 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 44px; padding: 0 16px; border-radius: 99px; border: 1.5px solid var(--line); background: var(--card); display: flex; align-items: center; gap: 7px; font-size: .95rem; }
.chip i { width: 10px; height: 10px; border-radius: 50%; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* Righe */
.riga { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 20px; background: var(--card); margin-bottom: 10px; border: 1px solid var(--line); }
.riga .apri { display: flex; gap: 12px; align-items: center; flex: 1; min-width: 0; text-align: left; }
.giorno { width: 54px; flex: none; text-align: center; border-radius: 14px; background: var(--soft); padding: 7px 0; }
.giorno b { display: block; font-family: var(--head); font-weight: 700; font-size: 1.45rem; line-height: 1; }
.giorno span { font-size: .78rem; text-transform: uppercase; color: var(--muted); letter-spacing: .03em; }
.giorno.rosso b { color: var(--red); }
.centro { flex: 1; min-width: 0; }
.titolo { font-weight: 700; font-size: 1rem; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.etichetta { font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; color: #fff; }
.nota { font-size: .88rem; color: var(--muted); margin-top: 2px; }
.stato { display: inline-block; font-size: .75rem; font-weight: 700; margin-top: 5px; padding: 2px 8px; border-radius: 6px; background: var(--soft); }
.stato.scaduta { background: var(--red-soft); color: var(--red); }
.stato.inscadenza { background: var(--orange-soft); color: var(--orange); }
.stato.fatta { background: var(--green-soft); color: var(--green); }
.destra { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.importo { font-weight: 700; font-size: 1rem; white-space: nowrap; }
.spunta { width: 46px; height: 46px; border-radius: 50%; border: 2px solid var(--line2); display: grid; place-items: center; background: var(--card); }
.spunta svg { width: 20px; height: 20px; stroke: var(--muted); fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.riga.fatta { opacity: .65; }
.riga.fatta .spunta { background: var(--primary); border-color: var(--primary); }
.riga.fatta .spunta svg { stroke: #fff; }

.vuoto { text-align: center; padding: 34px 20px; border-radius: var(--r-l); background: var(--card); border: 1px dashed var(--line2); }
.vuoto b { display: block; font-family: var(--head); font-size: 1.3rem; margin-bottom: 4px; }
.vuoto p { color: var(--muted); }
.piccolo { font-size: .88rem; color: var(--muted); }

/* Navigazione in basso */
.nav { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,.96); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  display: flex; justify-content: space-around; padding: 6px 0 calc(6px + var(--safe-b)); z-index: 10; }
.nav button { font-size: .72rem; color: var(--muted); min-width: 72px; min-height: 52px; display: flex; flex-direction: column; align-items: center; gap: 3px; justify-content: center; }
.nav svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.nav button[aria-current="page"] { color: var(--primary); font-weight: 700; }

/* Foglio (modulo, menu) */
.foglio { position: fixed; inset: 0; background: var(--bg); z-index: 20; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.foglio .dentro { max-width: 560px; margin: 0 auto; padding: calc(14px + var(--safe-t)) 18px calc(130px + var(--safe-b)); }
.indietro { min-height: 44px; display: inline-flex; align-items: center; gap: 4px; color: var(--primary); font-weight: 600; margin-left: -6px; padding: 0 6px; }
.sotto-titolo { color: var(--muted); margin: -12px 0 18px; }
.riquadro-arancio { background: var(--orange-soft); color: #7A2E0E; border-radius: var(--r-m); padding: 14px 16px; margin-bottom: 18px; }

.campo { margin-bottom: 16px; }
.campo > label, .campo > .lab { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.campo input, .campo select, .campo textarea { width: 100%; min-height: 52px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--card); padding: 12px 14px; font-size: 1rem; appearance: none; -webkit-appearance: none; }
.campo select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
.campo textarea { min-height: 90px; resize: vertical; }
.campo input:focus, .campo select:focus, .campo textarea:focus { border-color: var(--primary); outline: none; }
.campo.grande input { font-family: var(--head); font-weight: 700; font-size: 1.5rem; }
.campo.mancante input, .campo.mancante select, .campo.mancante .chips-scelta { border-color: var(--orange-line); box-shadow: 0 0 0 1px var(--orange-line); border-radius: 14px; }
.campo .manca { display: none; color: var(--orange); font-size: .85rem; font-weight: 600; margin-top: 5px; }
.campo.mancante .manca { display: block; }
.due { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chips-scelta { display: flex; flex-wrap: wrap; gap: 8px; }
.chips-scelta .chip { border-width: 1.5px; }
.interruttore { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 52px; background: var(--card); border: 1.5px solid var(--line); border-radius: 14px; padding: 8px 14px; margin-bottom: 16px; width: 100%; }
.interruttore input { appearance: none; -webkit-appearance: none; width: 51px; height: 31px; border-radius: 99px; background: var(--line2); position: relative; flex: none; transition: background .2s; }
.interruttore input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.interruttore input:checked { background: var(--primary); }
.interruttore input:checked::after { transform: translateX(20px); }

.barra-fondo { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(245,246,250,.96); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: 12px 18px calc(12px + var(--safe-b)); z-index: 21; }
.barra-fondo .dentro-barra { max-width: 560px; margin: 0 auto; display: flex; gap: 10px; }
.btn { min-height: 54px; border-radius: 16px; padding: 0 18px; font-weight: 700; font-size: 1rem; }
.btn-primario { flex: 1; background: var(--primary); color: var(--primary-ink); }
.btn-primario:active { background: var(--primary-dark); }
.btn-secondario { background: var(--card); border: 1.5px solid var(--line); }
.btn-pericolo { color: var(--red); background: var(--card); border: 1.5px solid var(--line); }
.btn[disabled] { opacity: .6; }

/* Menu importa */
.menu-voce { display: flex; gap: 14px; align-items: center; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-m); padding: 16px; margin-bottom: 10px; min-height: 64px; }
.menu-voce .ic { width: 44px; height: 44px; border-radius: 14px; background: var(--soft); display: grid; place-items: center; flex: none; font-size: 1.3rem; }
.menu-voce b { display: block; }
.menu-voce[aria-disabled="true"] { opacity: .55; }

/* Accesso */
.accesso { min-height: 80vh; display: flex; flex-direction: column; justify-content: center; }
.accesso .logo { width: 72px; height: 72px; border-radius: 20px; margin-bottom: 18px; }
.errore { background: var(--red-soft); color: var(--red); border-radius: var(--r-s); padding: 12px 14px; margin-bottom: 14px; font-weight: 600; }

/* Messaggio in basso */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + var(--safe-b)); background: var(--ink); color: #fff; border-radius: 16px; padding: 12px 14px 12px 18px;
  display: flex; gap: 14px; align-items: center; z-index: 30; width: calc(100% - 36px); max-width: 520px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.toast span { flex: 1; }
.toast button { color: var(--accent); font-weight: 700; min-height: 44px; padding: 0 6px; }

.segnaposto { text-align: center; padding: 40px 10px; }
.segnaposto .grande { font-size: 3rem; margin-bottom: 8px; }
.accesso .btn-primario { flex: none; }
