/* ============================================================
   Calcetto — design system
   Stesso impianto del Gestionale: superfici di vetro su fondo
   azzurrino, tipografia Apple a tracking stretto, raggi ampi.
   Le due app sono sorelle e devono sembrarlo.

   L'unica aggiunta è quello che qui serve e là no: le figurine
   dei giocatori e il campo da gioco. Verde e arancione restano
   riservati agli stati del pagamento, mai usati come decorazione.
   ============================================================ */

/* ---------- token ---------- */

:root {
  --bg: #DFF2FD;
  --bg-elev: rgba(255, 255, 255, .60);
  --bg-sunken: #D0E9F8;
  --glass: saturate(170%) blur(20px);

  --text: #17405F;
  --text-2: rgba(24, 64, 95, .66);
  --text-3: rgba(24, 64, 95, .40);

  --fill1: rgba(47, 168, 238, .26);
  --fill2: rgba(47, 168, 238, .18);
  --fill3: rgba(47, 168, 238, .12);
  --sep: rgba(18, 57, 94, .13);
  --sep-strong: rgba(18, 57, 94, .26);

  --accent: #2FA8EE;
  --accent-2: #54BCF5;
  --accent-soft: rgba(47, 168, 238, .14);
  --green: #1FA35C;
  --red: #E74C3C;
  --orange: #F9B234;

  --accent-fill: color-mix(in srgb, var(--accent) 50%, #072A45);
  --tile-surface: #F2FAFE;

  /* il campo da gioco: verde della stessa famiglia, non fluorescente */
  --erba: #2E9A63;
  --erba-2: #268B58;

  --r-xs: 10px;
  --r-sm: 14px;
  --r-md: 18px;
  --r-lg: 24px;
  --r-xl: 30px;
  --shadow-1: 0 1px 2px rgba(18, 57, 94, .05), 0 6px 20px rgba(18, 57, 94, .07);
  --shadow-2: 0 2px 6px rgba(18, 57, 94, .08), 0 16px 40px rgba(18, 57, 94, .13);
  --shadow-pop: 0 -2px 10px rgba(18, 57, 94, .07), 0 -20px 60px rgba(18, 57, 94, .2);

  --tabbar-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --gutter: 16px;
  --maxw: 720px;

  --ease: cubic-bezier(.32, .72, 0, 1);
  --spring: cubic-bezier(.34, 1.4, .5, 1);

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #071726;
    --bg-elev: rgba(23, 64, 95, .46);
    --bg-sunken: #04101B;
    --text: #EAF6FE;
    --text-2: rgba(217, 238, 252, .64);
    --text-3: rgba(217, 238, 252, .36);
    --fill1: rgba(84, 188, 245, .30);
    --fill2: rgba(84, 188, 245, .20);
    --fill3: rgba(84, 188, 245, .14);
    --sep: rgba(147, 199, 232, .20);
    --sep-strong: rgba(147, 199, 232, .38);
    --accent: #54BCF5;
    --accent-2: #3FB1F0;
    --accent-soft: rgba(84, 188, 245, .20);
    --green: #2ECC71;
    --red: #FF6B5E;
    --orange: #F9B234;
    --tile-surface: #0F2941;
    --erba: #23794E;
    --erba-2: #1C6742;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 12px 40px rgba(0, 0, 0, .55);
    --shadow-pop: 0 -20px 60px rgba(0, 0, 0, .65);
  }
}

:root[data-theme="light"] {
  --bg: #DFF2FD; --bg-elev: rgba(255,255,255,.60); --bg-sunken: #D0E9F8;
  --text: #17405F; --text-2: rgba(24,64,95,.66); --text-3: rgba(24,64,95,.40);
  --fill1: rgba(47,168,238,.26); --fill2: rgba(47,168,238,.18); --fill3: rgba(47,168,238,.12);
  --sep: rgba(18,57,94,.13); --sep-strong: rgba(18,57,94,.26);
  --accent: #2FA8EE; --accent-2: #54BCF5; --accent-soft: rgba(47,168,238,.14);
  --green: #1FA35C; --red: #E74C3C; --orange: #F9B234;
  --tile-surface: #F2FAFE; --erba: #2E9A63; --erba-2: #268B58;
  --shadow-1: 0 1px 2px rgba(18,57,94,.05), 0 6px 20px rgba(18,57,94,.07);
  --shadow-2: 0 2px 6px rgba(18,57,94,.08), 0 16px 40px rgba(18,57,94,.13);
  --shadow-pop: 0 -2px 10px rgba(18,57,94,.07), 0 -20px 60px rgba(18,57,94,.2);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #071726; --bg-elev: rgba(23,64,95,.46); --bg-sunken: #04101B;
  --text: #EAF6FE; --text-2: rgba(217,238,252,.64); --text-3: rgba(217,238,252,.36);
  --fill1: rgba(84,188,245,.30); --fill2: rgba(84,188,245,.20); --fill3: rgba(84,188,245,.14);
  --sep: rgba(147,199,232,.20); --sep-strong: rgba(147,199,232,.38);
  --accent: #54BCF5; --accent-2: #3FB1F0; --accent-soft: rgba(84,188,245,.20);
  --green: #2ECC71; --red: #FF6B5E; --orange: #F9B234;
  --tile-surface: #0F2941; --erba: #23794E; --erba-2: #1C6742;
  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 12px 40px rgba(0,0,0,.55);
  --shadow-pop: 0 -20px 60px rgba(0,0,0,.65);
  color-scheme: dark;
}

/* ---------- base ---------- */

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(115% 75% at -5% -5%, rgba(84, 188, 245, .38), transparent 60%),
    radial-gradient(95% 65% at 105% 8%, rgba(249, 178, 52, .16), transparent 55%);
  background-attachment: fixed;
  color: var(--text);
  font-size: 17px;
  line-height: 1.35;
  letter-spacing: -.01em;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { background: none; border: none; cursor: pointer; }
input, select, textarea { background: none; border: none; outline: none; }
a { color: var(--accent); text-decoration: none; }

.num, .stat-val { font-variant-numeric: tabular-nums; }
::selection { background: var(--accent-soft); }

/* ---------- impianto ---------- */

#app {
  max-width: var(--maxw);
  margin-inline: auto;
  min-height: 100dvh;
  position: relative;
}

.view {
  padding: 14px var(--gutter) calc(var(--tabbar-h) + var(--safe-b) + 34px);
  animation: viewIn .34s var(--ease) both;
}
.view > *:first-child { margin-top: 0; }

@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.avvio {
  min-height: 72dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; color: var(--text-2);
}
.avvio .palla {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--fill2); border-top-color: var(--accent);
  animation: gira .9s linear infinite;
}
@keyframes gira { to { transform: rotate(360deg); } }

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: calc(var(--safe-t) + 8px) var(--gutter) 8px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: calc(var(--safe-t) + 50px);
  border-bottom: .5px solid transparent;
  transition: border-color .2s;
}
.topbar.scrolled { border-bottom-color: var(--sep); }
.topbar h1 {
  font-size: 22px; font-weight: 700; letter-spacing: -.5px;
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar .sub { font-size: 12.5px; font-weight: 500; color: var(--text-2); letter-spacing: 0; }
.topbar .title-wrap { flex: 1; min-width: 0; }

.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--accent);
  background: var(--fill3);
  font-size: 17px; font-weight: 600;
  flex: none;
  transition: transform .15s var(--spring), background .15s;
}
.icon-btn:active { transform: scale(.9); background: var(--fill1); }
.icon-btn svg { width: 19px; height: 19px; fill: currentColor; }
.icon-btn.plain { background: none; }

.big-title { font-size: 34px; font-weight: 800; letter-spacing: -1.1px; margin: 4px 0 2px; }
.view-intro { color: var(--text-2); font-size: 14.5px; margin-bottom: 16px; }

/* ---------- superfici di vetro ---------- */

.card, .list, .field-group, .stat, .campo-box, .deposito {
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  border: .5px solid rgba(255, 255, 255, .5);
}
@media (prefers-color-scheme: dark) {
  .card, .list, .field-group, .stat, .campo-box, .deposito { border-color: rgba(147, 199, 232, .14); }
}
:root[data-theme="dark"] .card, :root[data-theme="dark"] .list,
:root[data-theme="dark"] .field-group, :root[data-theme="dark"] .stat,
:root[data-theme="dark"] .campo-box, :root[data-theme="dark"] .deposito {
  border-color: rgba(147, 199, 232, .14);
}
:root[data-theme="light"] .card, :root[data-theme="light"] .list,
:root[data-theme="light"] .field-group, :root[data-theme="light"] .stat,
:root[data-theme="light"] .campo-box, :root[data-theme="light"] .deposito {
  border-color: rgba(255, 255, 255, .5);
}

.card {
  background: var(--bg-elev);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  padding: 16px;
  margin-bottom: 14px;
}
.card.tight { padding: 12px; }
.card.flush { padding: 0; overflow: hidden; }

/* la partita in evidenza: stessa scheda, con un velo dell'accento */
.card.prossima {
  background:
    linear-gradient(150deg, var(--accent-soft), transparent 62%),
    var(--bg-elev);
}

.card-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.card-head h2 { font-size: 17px; font-weight: 700; letter-spacing: -.35px; flex: 1; }
.card-head .link { font-size: 14px; font-weight: 600; color: var(--accent); }

.section-title {
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text-2);
  margin: 22px 4px 8px;
}
.section-title .n { color: var(--text-3); font-weight: 600; }

/* ---------- righe di elenco ---------- */

.list {
  background: var(--bg-elev);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-1);
  margin-bottom: 14px;
}

.row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  position: relative;
  width: 100%;
  text-align: left;
  transition: background .12s;
  color: inherit;
}
.row + .row::before {
  content: ''; position: absolute; left: 56px; right: 0; top: 0;
  height: .5px; background: var(--sep);
}
.row:active { background: var(--fill3); }
.body { flex: 1; min-width: 0; }
.body .t { display: block; font-size: 16px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.body .s { display: block; font-size: 12.5px; color: var(--text-2); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .end { font-size: 12.5px; font-weight: 600; color: var(--text-2); text-align: right; flex: none; }
.row .chev { color: var(--text-3); font-size: 13px; flex: none; }
.row .azioni { display: flex; gap: 6px; flex: none; }

.muted { color: var(--text-2); }

/* ---------- segmenti, chip, pillole ---------- */

.segmented {
  display: flex; background: var(--fill3); border-radius: 11px; padding: 2px; gap: 2px;
  margin-bottom: 14px;
}
.segmented button {
  flex: 1; padding: 7px 4px; border-radius: 9px;
  font-size: 13.5px; font-weight: 600; color: var(--text);
  transition: background .18s var(--ease), transform .15s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.segmented button[aria-selected="true"] { background: var(--bg-elev); box-shadow: var(--shadow-1); font-weight: 650; }
.segmented button:active { transform: scale(.97); }

.chips { display: flex; gap: 7px; flex-wrap: wrap; padding: 2px 0 4px; }
.chip {
  padding: 7px 14px; border-radius: 999px; background: var(--fill3);
  font-size: 13.5px; font-weight: 600; white-space: nowrap;
  transition: transform .15s var(--spring);
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text);
}
.chip[aria-pressed="true"] { background: var(--accent); color: #fff; }
.chip:active { transform: scale(.94); }
.chip.ghost { background: none; border: .5px solid var(--sep-strong); color: var(--accent); }

.pill {
  display: inline-block; padding: 2.5px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .1px; white-space: nowrap;
  background: var(--fill3); color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill.good { background: color-mix(in srgb, var(--green) 15%, transparent); color: var(--green); }
.pill.warn { background: color-mix(in srgb, var(--orange) 18%, transparent); color: #A96C00; }
.pill.bad { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
@media (prefers-color-scheme: dark) { .pill.warn { color: var(--orange); } }
:root[data-theme="dark"] .pill.warn { color: var(--orange); }

.pill-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; }

/* ---------- avvisi ---------- */

.notice {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: var(--r-md);
  font-size: 14px; font-weight: 550; line-height: 1.35;
  margin-bottom: 14px;
  width: 100%; text-align: left;
}
.notice.warn { background: color-mix(in srgb, var(--orange) 16%, transparent); color: #8F5B00; }
.notice.bad { background: color-mix(in srgb, var(--red) 13%, transparent); color: var(--red); }
.notice.good { background: color-mix(in srgb, var(--green) 13%, transparent); color: var(--green); }
.notice.info { background: var(--accent-soft); color: var(--accent); }
.notice .e { font-size: 18px; flex: none; }
@media (prefers-color-scheme: dark) { .notice.warn { color: var(--orange); } }
:root[data-theme="dark"] .notice.warn { color: var(--orange); }

/* ---------- figurine ---------- */

/* Il tondo con la foto è l'identità dell'app: qui prende i materiali
   del resto dell'interfaccia — ombra tenue, bordo chiaro — e tiene per
   sé soltanto l'anello colorato, che dice se il pagamento è confermato. */

.album {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  gap: 16px 6px;
}

.fig {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  text-align: center; width: 100%;
  color: inherit;
  transition: transform .16s var(--spring);
}
.fig.tap:active { transform: scale(.93); }

.faccia {
  position: relative;
  width: 54px; height: 54px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 17px; font-weight: 700; letter-spacing: -.3px;
  color: #fff;
  background-size: cover; background-position: center;
  flex: none;
  box-shadow: var(--shadow-1);
}
.faccia::after {
  content: attr(data-segno);
  position: absolute; right: -3px; bottom: -3px;
  width: 19px; height: 19px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
  border: 2px solid var(--bg);
  color: #fff;
}
.fig.pagato .faccia { outline: 3px solid var(--green); outline-offset: 2px; }
.fig.pagato .faccia::after { background: var(--green); }
.fig.attesa .faccia { outline: 3px dashed var(--orange); outline-offset: 2px; }
.fig.attesa .faccia::after { background: var(--orange); }
.fig.scaduto .faccia { outline: 2px solid var(--sep-strong); outline-offset: 2px; filter: grayscale(1); opacity: .5; }
.fig.scaduto .faccia::after { background: var(--text-3); }
.fig.neutro .faccia::after { content: none; }

.faccia.liscia::after { content: none; }

.fig .nome {
  font-size: 12.5px; font-weight: 600; letter-spacing: -.1px;
  max-width: 78px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fig .sotto { font-size: 11px; font-weight: 600; color: var(--text-3); }
.fig.scaduto .nome { color: var(--text-3); }

/* barra dell'incasso */
.avanz { height: 8px; border-radius: 999px; background: var(--fill3); overflow: hidden; margin-top: 10px; }
.avanz span { display: block; height: 100%; border-radius: 999px; background: var(--green); transition: width .4s var(--ease); }

/* ---------- campo da gioco ---------- */

.campo-box {
  border-radius: var(--r-lg);
  padding: 8px;
  background: var(--bg-elev);
  box-shadow: var(--shadow-1);
  margin-bottom: 14px;
}

.campo {
  position: relative;
  border-radius: var(--r-md);
  aspect-ratio: 5 / 7;
  padding: 14px 6px;
  display: flex; flex-direction: column; justify-content: space-between;
  background: repeating-linear-gradient(180deg, var(--erba) 0 8.5%, var(--erba-2) 8.5% 17%);
  overflow: hidden;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .34);
}
.campo::before {
  content: ''; position: absolute; left: 0; right: 0; top: 50%;
  height: 2px; background: rgba(255, 255, 255, .34);
}
.campo::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 76px; height: 76px; transform: translate(-50%, -50%);
  border: 2px solid rgba(255, 255, 255, .34); border-radius: 50%;
}
.area {
  position: absolute; left: 50%; transform: translateX(-50%);
  width: 52%; height: 9%;
  border: 2px solid rgba(255, 255, 255, .3);
}
.area.alta { top: -2px; border-top: 0; }
.area.bassa { bottom: -2px; border-bottom: 0; }

.meta-campo {
  position: relative; z-index: 1;
  display: flex; flex-wrap: wrap; align-content: center; justify-content: center;
  gap: 10px 4px;
  min-height: 42%;
}
.cfig {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  width: 60px; color: #fff;
  transition: transform .16s var(--spring);
}
.cfig:active { transform: scale(.92); }
.cfig .faccia { width: 42px; height: 42px; font-size: 14px; box-shadow: 0 3px 8px rgba(0, 0, 0, .3); }
.cfig .faccia::after { content: none; }
.cfig.a .faccia { outline: 3px solid #FFD54A; outline-offset: 1px; }
.cfig.b .faccia { outline: 3px solid #FFFFFF; outline-offset: 1px; }
.cfig .nome {
  font-size: 11px; font-weight: 650; color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .55);
  max-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.pettorina {
  position: absolute; z-index: 2;
  font-size: 10.5px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px;
}
.pettorina.a { top: 9px; left: 9px; background: #FFD54A; color: #4A3400; }
.pettorina.b { bottom: 9px; right: 9px; background: #fff; color: #123A25; }

/* ---------- moduli ---------- */

.field-group {
  background: var(--bg-elev);
  border-radius: var(--r-md);
  overflow: hidden;
  margin-bottom: 14px;
  box-shadow: var(--shadow-1);
}
.field {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  position: relative;
  min-height: 48px;
  width: 100%; text-align: left;
}
.field + .field::before {
  content: ''; position: absolute; left: 14px; right: 0; top: 0; height: .5px; background: var(--sep);
}
.field > label, .field .k { font-size: 16px; font-weight: 500; flex: none; min-width: 112px; }
.field input, .field select, .field textarea { flex: 1; font-size: 16px; text-align: right; min-width: 0; }
.field input::placeholder, .field textarea::placeholder { color: var(--text-3); }
.field textarea { resize: none; text-align: left; min-height: 76px; line-height: 1.45; }
.field.col { flex-direction: column; align-items: stretch; gap: 8px; }
.field.col > label, .field.col .k { font-size: 13px; font-weight: 600; color: var(--text-2); min-width: 0; }
.field.col input, .field.col textarea, .field.col select { text-align: left; }
.field .v { flex: 1; text-align: right; font-size: 16px; color: var(--text-2); }
.field .v.set { color: var(--text); font-weight: 500; }

/* i campi data e ora tengono la geometria delle altre righe: via le
   icone native, che sporgono e rompono l'allineamento a destra */
.field input[type="date"], .field input[type="time"] {
  -webkit-appearance: none; appearance: none;
  color: var(--text); font-weight: 500;
  padding: 0; margin: 0; min-height: 22px;
}
.field input::-webkit-date-and-time-value { text-align: right; margin: 0; }
.field input::-webkit-calendar-picker-indicator { display: none; }
.field input::-webkit-inner-spin-button, .field input::-webkit-clear-button { display: none; }

.field-note { font-size: 12.5px; color: var(--text-2); padding: 0 6px 14px; margin-top: -8px; line-height: 1.4; }
/* il margine negativo serve a riavvicinare la nota al riquadro che la
   precede; dopo una fila di pastiglie, invece, le finirebbe addosso */
.chips + .field-note { margin-top: 4px; }

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

.btn {
  display: block; width: 100%;
  padding: 14px; border-radius: var(--r-sm);
  font-size: 17px; font-weight: 650;
  background: var(--bg-elev); color: var(--accent);
  backdrop-filter: var(--glass); -webkit-backdrop-filter: var(--glass);
  border: .5px solid var(--sep);
  transition: transform .15s var(--spring), opacity .15s;
  text-align: center;
  box-shadow: var(--shadow-1);
  margin-bottom: 14px;
}
.btn:active { transform: scale(.975); }
.btn:disabled { opacity: .4; box-shadow: none; }
.btn.primary { background: var(--accent-fill); color: #fff; border-color: transparent; }
.btn.secondary { background: var(--fill3); color: var(--accent); box-shadow: none; }
.btn.danger { background: var(--fill3); color: var(--red); box-shadow: none; }
.btn.good { background: color-mix(in srgb, var(--green) 90%, #04331C); color: #fff; border-color: transparent; }
.btn.sm { padding: 10px; font-size: 15px; border-radius: var(--r-xs); }
.btn-row { display: flex; gap: 8px; margin-bottom: 14px; }
.btn-row .btn { margin: 0; }

/* ---------- barra a schede ---------- */

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex;
  padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--bg-elev) 78%, transparent);
  backdrop-filter: saturate(180%) blur(26px);
  -webkit-backdrop-filter: saturate(180%) blur(26px);
  border-top: .5px solid var(--sep);
  max-width: var(--maxw);
  margin-inline: auto;
}
.tabbar button {
  flex: 1; height: var(--tabbar-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-3); font-size: 10.5px; font-weight: 600;
  transition: color .18s;
  position: relative;
}
.tabbar button svg { width: 24px; height: 24px; fill: currentColor; transition: transform .22s var(--spring); }
.tabbar button[aria-current="page"] { color: var(--accent); }
.tabbar button[aria-current="page"] svg { transform: translateY(-1px) scale(1.06); }
.tabbar button:active svg { transform: scale(.86); }
.tabbar .badge {
  position: absolute; top: 6px; left: 54%;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700; display: grid; place-items: center;
  font-variant-numeric: tabular-nums;
}

/* ---------- pulsante d'azione ---------- */

.fab {
  position: fixed;
  right: max(var(--gutter), calc(50vw - var(--maxw) / 2 + var(--gutter)));
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
  width: 56px; height: 56px; border-radius: 20px;
  background: var(--tile-surface); color: var(--accent);
  border: .5px solid var(--sep);
  display: grid; place-items: center;
  box-shadow: var(--shadow-2);
  z-index: 45;
  transition: transform .2s var(--spring);
}
.fab svg { width: 26px; height: 26px; fill: currentColor; }
.fab:active { transform: scale(.9); }

/* ---------- fogli modali ---------- */

.scrim {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0, 0, 0, .42);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: fade .28s var(--ease) both;
  display: flex; align-items: flex-end; justify-content: center;
}
@keyframes fade { from { opacity: 0; } }

.sheet {
  background: var(--bg);
  background-image:
    radial-gradient(120% 60% at 0% 0%, rgba(84, 188, 245, .30), transparent 62%),
    radial-gradient(100% 50% at 100% 4%, rgba(249, 178, 52, .14), transparent 58%);
  width: 100%; max-width: var(--maxw);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-pop);
  max-height: 92dvh;
  display: flex; flex-direction: column;
  animation: sheetUp .42s var(--ease) both;
  overflow: hidden;
}
@keyframes sheetUp { from { transform: translateY(100%); } }

.sheet-grab { padding: 8px 0 2px; display: grid; place-items: center; flex: none; }
.sheet-grab span { width: 36px; height: 5px; border-radius: 999px; background: var(--fill1); }

.sheet-head { display: flex; align-items: center; gap: 10px; padding: 6px 14px 12px; flex: none; }
.sheet-head h2 { flex: 1; font-size: 18px; font-weight: 700; letter-spacing: -.4px; text-align: center; }
.sheet-head .act { font-size: 16px; font-weight: 600; color: var(--accent); padding: 4px; min-width: 62px; }
.sheet-head .act.right { text-align: right; font-weight: 650; }

.sheet-body {
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 0 var(--gutter) calc(var(--safe-b) + 24px);
  flex: 1;
}

/* ---------- ricevuta ---------- */

.deposito {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  padding: 13px 14px;
  border-radius: var(--r-md);
  background: var(--bg-elev);
  box-shadow: var(--shadow-1);
  margin-bottom: 10px;
  transition: transform .15s var(--spring);
}
.deposito:active { transform: scale(.985); }
.deposito .anteprima {
  width: 46px; height: 62px; border-radius: 10px; flex: none;
  background: var(--fill3) center / cover no-repeat;
  display: grid; place-items: center;
  font-size: 20px; color: var(--accent);
  border: .5px solid var(--sep);
}
.deposito .body { flex: 1; min-width: 0; }
.deposito .t { font-size: 15.5px; font-weight: 600; }
.deposito .s { font-size: 12.5px; color: var(--text-2); margin-top: 2px; line-height: 1.35; }

.letto { display: flex; flex-direction: column; gap: 7px; }
.letto .riga { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--text-2); }
.letto .riga b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.segno {
  width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 10px; font-weight: 700; flex: none;
}
.segno.ok { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); }
.segno.bad { background: color-mix(in srgb, var(--red) 16%, transparent); color: var(--red); }
.segno.boh { background: var(--fill3); color: var(--text-3); }

.provino {
  width: 100%; max-height: 320px; object-fit: contain;
  border-radius: var(--r-sm);
  border: .5px solid var(--sep);
  background: var(--bg-sunken);
  margin-bottom: 14px;
}

/* ---------- stato vuoto ---------- */

.empty { text-align: center; padding: 44px 20px; color: var(--text-2); }
.empty .e { font-size: 42px; margin-bottom: 12px; opacity: .85; }
.empty h3 { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 5px; letter-spacing: -.3px; }
.empty p { font-size: 14.5px; line-height: 1.45; max-width: 320px; margin-inline: auto; }
.empty .btn { max-width: 260px; margin: 18px auto 0; }

/* ---------- avvisi temporanei ---------- */

.toast-host {
  position: fixed; left: 0; right: 0;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 82px);
  z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; padding: 0 20px;
}
.toast {
  background: color-mix(in srgb, var(--text) 88%, transparent);
  color: var(--bg);
  padding: 11px 18px; border-radius: 999px;
  font-size: 14.5px; font-weight: 600;
  box-shadow: var(--shadow-2);
  animation: toastIn .34s var(--spring) both;
  max-width: 100%; text-align: center;
}
.toast.male { background: var(--red); color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.94); } }

/* ---------- rifiniture ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

@media (min-width: 700px) {
  .cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
  .cols-2 > * { margin-bottom: 0; }
}
