/* =====================================================================
   Registro presenze — stile leggero, chiaro/scuro automatico
   ===================================================================== */
:root {
  --bg: #f4f3ef; --surface: #ffffff; --surface-2: #f7f6f2; --text: #1c1c1a; --muted: #6d6c66;
  --border: #e2dfd7; --border-strong: #cfcbc1;
  --accent: #1f5f8b; --accent-soft: #e3eef6; --accent-text: #ffffff;
  --in: #1b7a4b; --out: #1f5f8b; --warn: #9a5800; --err: #b3261e;
  --mine: #fbefc0; --mine-text: #4d3d00; --leave: #e2f3e9; --leave-text: #1b6b42; --sick: #efe7fa; --sick-text: #5f3596;
  --logo: #1c1c1a;
  /* Liquid Glass */
  --glass: rgba(255, 255, 255, .58); --glass-strong: rgba(255, 255, 255, .78);
  --glass-edge: rgba(255, 255, 255, .75); --glass-line: rgba(28, 28, 26, .08);
  --glass-hi: rgba(255, 255, 255, .95); --glass-lo: rgba(28, 28, 26, .06);
  --glass-drop: 0 12px 34px rgba(28, 28, 26, .16), 0 2px 6px rgba(28, 28, 26, .08);
  --drop: rgba(255, 255, 255, .92);
  --glass-rim: rgba(28, 28, 26, .14);   /* contorno delle superfici di vetro: visibile sul chiaro */
  --spring: cubic-bezier(.34, 1.4, .64, 1);
  --closed: #ecebe6; --shadow: 0 1px 2px rgba(28, 28, 26, .06), 0 1px 1px rgba(28, 28, 26, .03);
  --radius: 12px; --radius-sm: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141413; --surface: #1d1d1b; --surface-2: #232321; --text: #ecebe6; --muted: #a3a29b;
    --border: #33322f; --border-strong: #45443f;
    --accent: #79b4e3; --accent-soft: #1d3141; --accent-text: #0c1a25;
    --in: #62c794; --out: #79b4e3; --warn: #e6a95a; --err: #f28b82;
    --mine: #4b3f12; --mine-text: #fbe7a1; --leave: #173a28; --leave-text: #8fdcb3; --sick: #33254a; --sick-text: #cbb2f0;
    --closed: #191918; --shadow: none;
    --logo: #ffffff;
    --glass: rgba(38, 38, 36, .52); --glass-strong: rgba(34, 34, 32, .78);
    --glass-edge: rgba(255, 255, 255, .16); --glass-line: rgba(255, 255, 255, .06);
    --glass-hi: rgba(255, 255, 255, .22); --glass-lo: rgba(0, 0, 0, .35);
    --glass-drop: 0 14px 38px rgba(0, 0, 0, .5), 0 2px 8px rgba(0, 0, 0, .35);
    --drop: rgba(255, 255, 255, .13);
    --glass-rim: rgba(255, 255, 255, .16);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; touch-action: manipulation; }
button, .btn, a, .cal .cell, label { -webkit-tap-highlight-color: transparent; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif; }
a { color: var(--accent); }
code { font: 13px ui-monospace, Consolas, monospace; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 5px; padding: 0 4px; }

/* ---------- header ---------- */
header.top { position: sticky; top: 0; z-index: 10; padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  background: color-mix(in srgb, var(--surface) 92%, transparent); border-bottom: 1px solid var(--border); }
/* stessa colonna del contenuto: logo e pulsanti allineati a main */
.hdr-inner { max-width: 1240px; margin: 0 auto; padding: 12px 16px; min-height: 78px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 16px; min-width: 0; text-decoration: none; color: inherit; }
.brand-logo { width: 58px; height: 54px; flex: none; background: var(--logo);
  -webkit-mask: url(img/logo.svg) center / contain no-repeat; mask: url(img/logo.svg) center / contain no-repeat; }
.brand-sep { width: 1px; height: 38px; flex: none; background: var(--border-strong); opacity: .7; }
.brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand-text .ttl { font-size: 18px; font-weight: 650; letter-spacing: -.01em; line-height: 1.2; margin: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-text .sub { font-size: 13px; color: var(--muted); line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hdr-actions { gap: 6px; flex-wrap: nowrap; }
.hdr-actions .btn, .hdr-actions button { background: transparent; border-color: var(--border-strong); }
.hdr-actions .btn:hover, .hdr-actions button:hover { background: var(--drop); }

/* logo A.Ma.Ro.: colore dal tema (bianco su scuro) */
.logo { display: block; background: var(--logo); aspect-ratio: 615 / 581; margin: 0 auto;
  -webkit-mask: url(img/logo.svg) center / contain no-repeat; mask: url(img/logo.svg) center / contain no-repeat; }
.login .logo { width: 120px; margin-bottom: 18px; }
.punch-screen .logo { width: clamp(90px, 28vw, 130px); margin-bottom: 18px; }
main { padding: 16px; max-width: 1240px; margin: 0 auto; padding-bottom: max(24px, env(safe-area-inset-bottom)); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; }

/* ---------- controlli ---------- */
button, .btn { font: inherit; font-size: 14px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  min-height: 36px; padding: 6px 12px; border-radius: var(--radius-sm); cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
  transition: background .12s, border-color .12s; }
button:hover, .btn:hover { background: var(--surface-2); border-color: var(--muted); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.primary:hover { filter: brightness(1.08); background: var(--accent); }
button.danger { color: var(--err); }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, select, textarea { font: inherit; font-size: 14px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 7px 9px; max-width: 100%; min-height: 36px; }
input[type="checkbox"] { min-height: 0; width: 18px; height: 18px; accent-color: var(--accent); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
label { display: block; margin: 10px 0 4px; color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); font-size: 13px; }
.in { color: var(--in); font-weight: 600; } .out { color: var(--out); font-weight: 600; }
.warn { color: var(--warn); } .err { color: var(--err); }
.hidden { display: none !important; }

/* ---------- card, schede, tabelle ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px;
  margin-bottom: 14px; box-shadow: var(--shadow); }
.card h3 { font-size: 15px; margin: 0 0 10px; }
.tabs { display: flex; gap: 2px; overflow-x: auto; padding: 3px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; scrollbar-width: none; max-width: 100%; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 0; background: transparent; min-height: 32px; padding: 5px 12px; border-radius: 7px; flex: none; color: var(--muted); }
.tabs button:hover { background: var(--surface); color: var(--text); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 1px var(--border); }
/* navigazione principale: in alto su desktop, in basso su telefono */
.navmain { display: flex; gap: 2px; padding: 3px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.navmain::-webkit-scrollbar { display: none; }
.navmain button { border: 0; background: transparent; color: var(--muted); min-height: 34px; padding: 5px 12px; border-radius: 7px;
  flex: none; position: relative; gap: 7px; }
.navmain button:hover { background: var(--surface); color: var(--text); }
.navmain button[aria-current="page"] { background: var(--surface); color: var(--text); font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 1px var(--border); }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.navsub { width: fit-content; margin: -4px 0 14px; }
.hdr-more { display: none; }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; margin: 14px 0; }
.sheet-actions > * { width: 100%; min-height: 46px; }
.sheet-close { width: 100%; }

.badge { background: var(--err); color: #fff; border-radius: 99px; min-width: 18px; padding: 0 6px; font-size: 11px;
  line-height: 18px; font-weight: 700; text-align: center; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; overflow-wrap: anywhere; }
@media (min-width: 721px) {
  .docs-table { table-layout: fixed; }
  .docs-table td:nth-child(1) { width: 22%; } .docs-table td:nth-child(2) { width: 30%; }
  .docs-table td:last-child { width: 130px; text-align: right; }
  .docs-table td:only-child { width: auto; text-align: left; }
}
@media (max-width: 720px) {
  .docs-table td:nth-child(3):not(:last-child) { display: none; }   /* data di caricamento: inutile su telefono */
  .docs-table td:last-child:not(:only-child) { text-align: right; }
  .toolbar .monthnav.invisible { display: none; }                   /* niente buco quando il mese non serve */
}
.invisible { visibility: hidden; }
textarea.ips { width: min(100%, 420px); }
input[type="file"] { padding: 5px; min-height: 36px; }
input[type="file"]::file-selector-button { font: inherit; font-size: 13px; margin-right: 10px; padding: 5px 12px; border-radius: 6px;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); cursor: pointer; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* riquadri numerici (riepiloghi) */
.stats { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; min-width: 120px; }
.stat .lbl { display: block; font-size: 12px; color: var(--muted); }
.stat strong { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat.warn strong { color: var(--warn); }

/* moduli a campi con etichetta */
.fields { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; }
.fields label { margin: 0; }
.fields .field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fields .field > span { font-size: 12px; color: var(--muted); }
.fields .field.grow { flex: 1 1 220px; }
.fields .field.grow input { width: 100%; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; margin: 0; color: var(--text); font-size: 14px; }

/* ---------- calendario ---------- */
.monthnav { display: flex; align-items: center; gap: 6px; }
.monthnav strong { min-width: 150px; text-align: center; text-transform: capitalize; font-size: 15px; }
.monthnav button { width: 36px; padding: 0; font-size: 18px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal .dow { font-size: 12px; font-weight: 600; color: var(--muted); text-align: center; padding: 2px 0; text-transform: uppercase; letter-spacing: .04em; }
.cal .cell { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 7px; min-height: 104px;
  font-size: 13px; display: flex; flex-direction: column; gap: 3px; min-width: 0; box-shadow: var(--shadow); }
.cal .cell.click { cursor: pointer; transition: border-color .12s; }
.cal .cell.click:hover { border-color: var(--accent); }
.cal .cell.closed { background: repeating-linear-gradient(135deg, var(--closed) 0 6px, transparent 6px 12px), var(--surface-2); box-shadow: none; }
.cal .cell.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.cal .cell.today .num > span:first-child { background: var(--accent); color: var(--accent-text); border-radius: 6px; padding: 0 6px; }
.cal .cell .num { font-weight: 650; display: flex; justify-content: space-between; align-items: center; gap: 4px; min-height: 22px; }
.cal .cell .num button { min-height: 26px; padding: 2px 8px; font-size: 12px; }
.cal .cell .num .wd { display: none; font-weight: 400; color: var(--muted); }
.cal .shift { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; padding: 0 4px; }
.cal .shift.mine { background: var(--mine); color: var(--mine-text); border-radius: 5px; font-weight: 650; }
.cal .leave { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--leave); color: var(--leave-text);
  border-radius: 5px; padding: 0 4px; font-size: 12px; }
.cal .leave.mine { font-weight: 650; }
.cal .leave.sick, dialog .leave.sick { background: var(--sick); color: var(--sick-text); }
dialog .leave.sick { border-radius: 5px; padding: 1px 6px; font-weight: 650; }
.cal .note { font-style: italic; color: var(--warn); padding: 0 4px; }
.cal .punches { padding: 0 4px; font-variant-numeric: tabular-nums; }
.cal .empty { visibility: hidden; }
.cal textarea { width: 100%; min-height: 0; resize: vertical; font: 13px/1.4 ui-monospace, Consolas, monospace; padding: 5px; }
.cal input.note-in { width: 100%; font-size: 12px; padding: 3px 6px; min-height: 28px; }
.cal .msg { font-size: 12px; }
.weekbar { grid-column: 1 / -1; display: flex; justify-content: flex-end; margin: 4px 0 -2px; }
.weekbar button { font-size: 12px; min-height: 26px; padding: 2px 8px; border-style: dashed; color: var(--muted); background: transparent; }

/* ---------- panoramica del mese (manager) ---------- */
.mode-switch { width: fit-content; margin-bottom: 14px; }
.ov-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 5px; font-size: 12.5px; line-height: 1.35;
  font-variant-numeric: tabular-nums; padding: 1px 2px; }
.ov-line b { font-weight: 650; }
.ov-line .ov-p { flex-basis: 100%; padding-left: 13px; color: var(--muted); font-size: 12px; }
.ov-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; align-self: center; background: var(--muted); }
.st-ok .ov-dot { background: var(--in); }
.st-missing .ov-dot { background: var(--err); }
.st-missing .ov-shift { color: var(--err); }
.st-inservice .ov-dot { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); animation: pulse 1.6s ease-in-out infinite; }
.st-inservice .ov-p { color: var(--accent); font-weight: 600; }
.st-extra .ov-dot { background: var(--out); }
.st-future .ov-dot { background: transparent; border: 1.5px solid var(--muted); }
.st-leave .ov-dot { background: var(--leave-text); }
.st-sick .ov-dot { background: var(--sick-text); }
.st-sick .ov-shift { color: var(--sick-text); }
.st-sick .ov-p { color: var(--sick-text); font-weight: 600; }
.ov-auto { font-style: italic; opacity: .85; }
.ov-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 12px; }
.ov-legend .ov-line { font-size: 12px; color: var(--muted); }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px transparent; } }

/* ---------- pagina timbratura ---------- */
.punch-screen { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px 16px; gap: 10px; }
.punch-screen .big { font-size: clamp(30px, 9vw, 46px); font-weight: 800; letter-spacing: .5px; }
.punch-screen .time { font-size: clamp(56px, 18vw, 88px); font-weight: 250; font-variant-numeric: tabular-nums; line-height: 1; }
.punch-screen .btn { margin-top: 16px; }
.login { width: min(380px, calc(100% - 32px)); margin: 10vh auto; }
.login input { width: 100%; }

/* ---------- dialog e avvisi ---------- */
dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
  width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 18px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog textarea { width: 100%; }
/* QR sempre su fondo bianco, anche col tema scuro, così le fotocamere lo leggono */
.qr-box { display: flex; justify-content: center; background: #fff; border-radius: 12px; padding: 12px; margin: 12px 0; }
.qr-img { width: min(280px, 70vw); height: auto; image-rendering: pixelated; }
dialog h3 { margin-top: 0; }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.credit { text-align: center; font-size: 12px; color: var(--muted); padding: 8px 16px 24px; }
.credit a { color: var(--muted); }
#root:has(.punch-screen) ~ .credit { margin-top: -64px; }
#toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; display: none; z-index: 50; max-width: calc(100vw - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.25); }
#toast.err { background: var(--err); color: #fff; }


/* =====================================================================
   Liquid Glass: superfici di vetro, goccia scorrevole, animazioni a molla
   ===================================================================== */
.glass, header.top, .navmain, #toast, dialog {
  -webkit-backdrop-filter: blur(22px) saturate(180%); backdrop-filter: blur(22px) saturate(180%);
}
header.top { background: var(--glass); border-bottom: 1px solid var(--glass-line);
  box-shadow: inset 0 -1px 0 var(--glass-lo); }
.hdr-right { display: flex; align-items: center; gap: 8px; flex: none; }
.hdr-bell { position: relative; width: 40px; min-height: 40px; padding: 0; border-radius: 99px; flex: none;
  background: var(--glass); border: 1px solid var(--glass-rim); box-shadow: inset 0 1px 0 var(--glass-hi), 0 2px 8px rgba(0,0,0,.12); }
.hdr-bell .ico { width: 20px; height: 20px; }
.bell-badge { position: absolute; top: -4px; right: -4px; box-shadow: 0 0 0 2px var(--bg); }
.push-card { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin: 10px 0 4px;
  padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); font-size: 14px; }
.push-card > span { flex: 1 1 200px; }
.notif-list { display: flex; flex-direction: column; gap: 2px; margin: 10px 0; max-height: min(60vh, 520px); overflow-y: auto; }
.notif { display: flex; align-items: flex-start; justify-content: flex-start; gap: 10px; width: 100%; text-align: left;
  white-space: normal; border: 0; background: transparent; padding: 10px; border-radius: 10px; min-height: 0; }
.notif:hover { background: var(--surface-2); }
.notif .ndot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex: none; }
.notif.unread .ndot { background: var(--accent); }
.notif .ntext { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notif strong { font-weight: 550; }
.notif.unread strong { font-weight: 700; }
.notif .nbody { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.notif .ntime { color: var(--muted); font-size: 12px; }
.hdr-more { background: var(--glass); border: 1px solid var(--glass-rim);
  box-shadow: inset 0 1px 0 var(--glass-hi), 0 2px 8px rgba(0,0,0,.12); }

/* barra di navigazione: la goccia di vetro scorre sotto la voce attiva */
.navmain { position: relative; isolation: isolate; }
.nav-ind { position: absolute; top: 3px; bottom: 3px; left: 0; width: 0; z-index: 0; border-radius: 8px; opacity: 0;
  background: var(--drop); border: 1px solid var(--glass-rim);
  box-shadow: inset 0 1px 0 var(--glass-hi), inset 0 -1px 0 var(--glass-lo), 0 2px 8px rgba(0,0,0,.12);
  transition: transform .5s var(--spring), width .5s var(--spring), opacity .2s; pointer-events: none; }
.nav-ind.on { opacity: 1; }
.navmain button { z-index: 1; background: transparent !important; box-shadow: none !important;
  transition: color .25s, transform .2s var(--spring); }
.navmain button[aria-current="page"] .ico { animation: icon-pop .5s var(--spring); }

/* tocco: leggera pressione */
button:active, .btn:active { transform: scale(.96); }
.cal .cell.click:active { transform: scale(.985); }
button, .btn, .cal .cell { transition: background .12s, border-color .12s, transform .18s var(--spring); }

/* contenuti che entrano */
.view > *, .navsub:not(.hidden) { animation: rise .32s cubic-bezier(.2, .8, .2, 1) both; }
.view > *:nth-child(2) { animation-delay: .04s; }
.view > *:nth-child(3) { animation-delay: .08s; }

/* finestre: vetro + salita dal basso (telefono) o comparsa (desktop) */
dialog { background: var(--glass-strong); border: 1px solid var(--glass-rim);
  box-shadow: inset 0 1px 0 var(--glass-hi), var(--glass-drop); }
dialog[open] { animation: pop-in .38s var(--spring); }
dialog::backdrop { background: rgba(0, 0, 0, .28); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  animation: fade .25s ease both; }

/* avvisi a capsula di vetro */
#toast { background: var(--glass-strong); color: var(--text); border: 1px solid var(--glass-rim); border-radius: 99px;
  box-shadow: inset 0 1px 0 var(--glass-hi), var(--glass-drop); animation: toast-in .45s var(--spring); }
#toast.err { background: color-mix(in srgb, var(--err) 85%, transparent); color: #fff; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 16px) scale(.9); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes icon-pop { 0% { transform: scale(1); } 40% { transform: scale(1.22) translateY(-2px); } 100% { transform: scale(1); } }

/* browser senza sfocatura: vetro più coprente */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  header.top, .navmain, #toast, dialog { background: var(--surface); }
}
/* chi ha attivato "Riduci movimento" */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- tablet in verticale: calendario su 2 colonne (7 sarebbero troppo strette) ---------- */
@media (min-width: 721px) and (max-width: 1023px) {
  .cal { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .cal .dow, .cal .empty { display: none; }
  .cal .cell { min-height: 0; }
  .cal .cell .num .wd { display: inline; }
}

/* ---------- telefono ---------- */
@media (max-width: 720px) {
  main { padding: 12px; }
  .hdr-inner { padding: 10px 14px; min-height: 66px; gap: 12px; }
  .brand { gap: 12px; }
  .brand-logo { width: 46px; height: 43px; }
  .brand-sep { height: 32px; }
  .brand-text .ttl { font-size: 16px; }
  .brand-text .sub { font-size: 12px; }
  .toolbar { gap: 8px; }
  .hdr-actions { display: none !important; }
  .hdr-more { display: inline-flex; width: 40px; min-height: 40px; padding: 0; flex: none; border-radius: 99px; }
  .hdr-more .ico { width: 20px; height: 20px; }
  /* capsula di vetro sospesa sopra la linea "home" di iPhone */
  .navmain { position: fixed; z-index: 20; left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right));
    bottom: calc(env(safe-area-inset-bottom) + 10px); padding: 5px; border-radius: 30px; justify-content: space-around;
    overflow: visible; background: var(--glass); border: 1px solid var(--glass-rim);
    box-shadow: inset 0 1px 0 var(--glass-hi), inset 0 -1px 0 var(--glass-lo), var(--glass-drop); }
  /* livello grafico proprio: su iPhone evita salti durante lo scorrimento */
  .navmain { -webkit-transform: translateZ(0); transform: translateZ(0); will-change: transform;
    transition: transform .3s cubic-bezier(.2, .8, .2, 1), opacity .2s; }
  .navmain.nav-away { transform: translateY(calc(100% + 40px)); opacity: 0; pointer-events: none; }
  .nav-ind { top: 5px; bottom: 5px; border-radius: 24px; }
  .navmain button { flex: 1 1 0; flex-direction: column; gap: 2px; min-height: 54px; padding: 4px 2px; font-size: 11px;
    border-radius: 24px; min-width: 0; }
  .navmain button .lbl { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .navmain .ico { width: 22px; height: 22px; }
  .navmain button[aria-current="page"] { background: transparent; box-shadow: none; color: var(--accent); }
  .navmain button[aria-current="page"] .ico { stroke-width: 2.4; }
  .navmain .badge { position: absolute; top: 3px; left: calc(50% + 6px); }
  .navsub { width: 100%; margin-top: 0; }
  .mode-switch { width: 100%; }
  .mode-switch button { flex: 1 1 0; }
  .ov-line { font-size: 14px; }
  .ov-line .ov-p { font-size: 13px; }
  .navsub button { flex: 1 1 auto; }
  main { padding-bottom: 8px; }
  body:has(.navmain) .credit { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
  body:has(.navmain) #toast { bottom: calc(env(safe-area-inset-bottom) + 86px); }
  dialog[open] { animation: sheet-up .42s cubic-bezier(.2, .9, .25, 1.05); }
  .monthnav { width: 100%; justify-content: space-between; }
  /* 16px evita lo zoom automatico di iPhone quando si tocca un campo */
  input, select, textarea, .cal textarea, .cal input.note-in { font-size: 16px; }
  .cal input.note-in { min-height: 40px; padding: 6px 9px; }
  /* bersagli tattili comodi */
  .weekbar button { min-height: 40px; font-size: 13px; }
  .cal .cell .num button { min-height: 36px; padding: 4px 14px; font-size: 13px; }
  button, .btn { min-height: 40px; }
  .card { padding: 14px; }
  .stat { flex: 1 1 40%; min-width: 0; }
  .fields .field { flex: 1 1 45%; }
  .fields .field input, .fields .field select { width: 100%; }
  .cal { grid-template-columns: 1fr; gap: 8px; }
  .cal .dow, .cal .empty { display: none; }
  .cal .cell { min-height: 0; padding: 10px; font-size: 14px; }
  .cal .cell .num .wd { display: inline; }
  .weekbar { justify-content: stretch; }
  .weekbar button { width: 100%; }
  dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 26px 26px 0 0; border-bottom: 0;
    padding-bottom: max(18px, calc(env(safe-area-inset-bottom) + 10px)); }
  th, td { padding: 8px 6px; }
  /* tabelle → schede impilate */
  table[data-stacked] thead { display: none; }
  table[data-stacked] tbody tr { display: block; padding: 8px 0; border-bottom: 1px solid var(--border); }
  table[data-stacked] tbody tr:last-child { border-bottom: 0; }
  table[data-stacked] tbody tr:hover td { background: none; }
  /* griglia a 2 colonne: etichetta a sinistra, contenuto a destra. L'etichetta fa parte della riga,
     quindi se va a capo la riga si allunga invece di sbordare su quella sotto. */
  table[data-stacked] td { display: grid; grid-template-columns: minmax(0, 34%) minmax(0, 1fr); column-gap: 10px;
    align-items: baseline; border: 0; padding: 5px 2px; min-height: 28px; }
  table[data-stacked] td::before { content: attr(data-label); grid-column: 1; grid-row: 1 / span 12; align-self: start;
    padding-top: 2px; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
    line-height: 1.3; overflow-wrap: break-word; }
  table[data-stacked] td > * { grid-column: 2; min-width: 0; }
  table[data-stacked] td[data-label=""], table[data-stacked] td[colspan] { display: block; }
  table[data-stacked] td[data-label=""]::before, table[data-stacked] td[colspan]::before { content: none; }
  table[data-stacked] td:has(input, select) { display: block; }
  table[data-stacked] td:has(input, select)::before { display: block; margin-bottom: 6px; }
  table[data-stacked] td:has(input, select) input:not([type=checkbox]), table[data-stacked] td:has(input, select) select { max-width: 100%; }
  /* dipendenti: scheda compatta a due colonne */
  table.people-table[data-stacked] tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; padding: 12px 0; }
  .people-table td:nth-child(1), .people-table td:nth-child(6) { grid-column: 1 / -1; }
  .people-table td input:not([type=checkbox]), .people-table td select, .people-table td:nth-child(6) button { width: 100%; }
  .people-table td:nth-child(5) { display: block; }
  .people-table td:nth-child(5)::before { display: block; margin-bottom: 6px; }
}
