/* Tabellone da ufficio. Solo font di sistema: nessun dato inviato a terzi per caricarli. */
:root {
  color-scheme: light dark;
  --ink: #1b2a4a; --paper: #eef1f8; --surface: #fff; --fg: #1b2a4a; --muted: #5b6785; --line: #e2e6f0;
  --accent: #2f5bea; --on-accent: #fff; --absent: #ffb224; --on-absent: #3a2700;
  --sat: #f3f5fa; --feast: #fdecee; --red: #c8323c; --done: #1f8a5b;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #0f1a33; --paper: #0b1020; --surface: #151c30; --fg: #e8ecf7; --muted: #9aa5c3; --line: #27304a;
    --accent: #7b9bff; --on-accent: #0b1020; --absent: #e0991a; --on-absent: #241800;
    --sat: #1a2237; --feast: #33202c; --red: #ff7a83; --done: #5fd0a0;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 16px/1.4 -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, system-ui, sans-serif; background: var(--paper); color: var(--fg); }
h1, h2 { margin: 0; letter-spacing: -.02em; line-height: 1.1; }
h2 { font-size: 22px; margin-bottom: 16px; }
button, input, select { font: inherit; min-height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); padding: 8px 14px; }
button { cursor: pointer; font-weight: 600; }
button:disabled { opacity: .5; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.absence { background: var(--absent); border-color: var(--absent); color: var(--on-absent); }
button.danger { color: var(--red); }
button.quiet { min-height: 36px; padding: 4px 12px; margin-left: auto; font-size: 14px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* Struttura: intestazione, contenuto che scorre, azioni in basso */
.shell { display: flex; flex-direction: column; height: 100dvh; max-width: 760px; margin: 0 auto; }
header { background: var(--ink); color: #fff; padding: max(8px, env(safe-area-inset-top)) 16px 12px; border-radius: 0 0 22px 22px; }
.now { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 4px 0 6px; font-variant-numeric: tabular-nums; }
.now .date { font-size: 14px; opacity: .85; }
.now .date::first-letter { text-transform: uppercase; }
.now .clock { font-size: 18px; font-weight: 700; }
.account { display: flex; justify-content: center; gap: 8px; margin: 0 0 10px; }
.account button { min-height: 36px; padding: 4px 16px; background: rgb(255 255 255 / .12); border: 0; border-radius: 18px; color: #fff; font-size: 13px; }
.brand { font-size: clamp(32px, 10.5vw, 44px); font-weight: 850; letter-spacing: -.035em; text-align: center; margin: 0 0 8px; white-space: nowrap; }
.now .date { display: block; }
.month-head { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; min-height: 44px; }
.month-head h2 { margin: 0 auto 0 0; font-size: 21px; font-weight: 650; }
.month-head h2::first-letter { text-transform: uppercase; }
.month-head h2 span { font-weight: 400; opacity: .6; }
button.arrow { width: 44px; min-height: 44px; padding: 0; border-radius: 50%; font-size: 24px; background: rgb(255 255 255 / .12); border: 0; color: #fff; }
nav { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: rgb(255 255 255 / .12); }
nav button { min-height: 38px; padding: 4px; border: 0; border-radius: 10px; background: transparent; color: #fff; }
nav button[aria-current] { background: #fff; color: #1b2a4a; }
section { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 10px 10px 0; overflow: auto; }
footer { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 10px 12px max(10px, env(safe-area-inset-bottom)); }

/* Tabellone: nomi fermi in alto, giorni fermi a sinistra */
.scroll { flex: 1; min-height: 220px; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
table { border-collapse: separate; border-spacing: 0; min-width: 100%; }
th, td { padding: 0; height: 46px; border-bottom: 1px solid var(--line); }
td, th.person { min-width: 76px; border-left: 1px solid var(--line); }
thead th { position: sticky; top: 0; z-index: 2; height: 66px; background: var(--surface); border-bottom: 2px solid var(--ink); vertical-align: bottom; }
th.person { max-width: 100px; padding: 6px 4px; font-size: 13px; font-weight: 600; }
.avatar { display: grid; place-items: center; width: 30px; height: 30px; margin: 0 auto 3px; border-radius: 50%; background: var(--paper); font-size: 12px; font-weight: 700; }
th.me .avatar { background: var(--accent); color: var(--on-accent); }
.who { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: 90px; margin: 0 auto; }
th.day { position: sticky; left: 0; width: 54px; min-width: 54px; text-align: center; background: var(--surface); line-height: 1; font-variant-numeric: tabular-nums; }
tbody th.day { z-index: 1; }
thead th.day { z-index: 3; }
.num { display: grid; place-items: center; width: 28px; height: 26px; margin: 0 auto; border-radius: 9px; font-size: 18px; font-weight: 750; }
.wd { display: block; margin-top: 2px; font-size: 11px; color: var(--muted); }
th.today .num { background: var(--accent); color: var(--on-accent); }
tr.sabato td, tr.sabato th { background: var(--sat); }
tr.festivo td, tr.festivo th, tr.superfestivo td, tr.superfestivo th { background: var(--feast); }
tr.festivo .num, tr.festivo .wd, tr.superfestivo .wd { color: var(--red); }
tr.festivo th.today .num { background: var(--accent); color: var(--on-accent); }
tr.superfestivo .num, .key.superfestivo { background: var(--red); color: var(--surface); }

td button { position: relative; display: grid; place-items: center; width: 100%; height: 46px; min-height: 0; padding: 0; border: 0; border-radius: 0; background: transparent; }
/* Nastro di assenza: continuo sui giorni consecutivi */
.ribbon { position: absolute; left: 8px; right: 8px; top: 5px; bottom: 5px; border-radius: 10px; background: var(--absent); }
td.from-prev .ribbon { top: -1px; border-top-left-radius: 0; border-top-right-radius: 0; }
td.to-next .ribbon { bottom: -1px; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
td.mattina .ribbon { bottom: 50%; }
td.pomeriggio .ribbon { top: 50%; }
.badge { position: relative; display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 700; }

.legend { padding: 6px 6px 0; font-size: 13px; color: var(--muted); }
.legend summary { min-height: 30px; cursor: pointer; }
.legend p { margin: 4px 0; }
.legend ul { margin: 4px 0; padding: 0; list-style: none; }
.key { display: inline-block; width: 13px; height: 13px; margin: 0 4px 0 6px; vertical-align: -2px; border-radius: 4px; border: 1px solid var(--line); }
.key.absent { background: var(--absent); }
.key.sabato { background: var(--sat); }
.key.festivo { background: var(--feast); }

/* Task ed elenchi */
.tasks, dialog ul { list-style: none; margin: 0; padding: 0; }
.tasks li, dialog li { margin-bottom: 10px; padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); overflow-wrap: anywhere; }
.title { font-weight: 650; }
.meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.chip { padding: 2px 10px; border-radius: 20px; background: var(--paper); color: var(--fg); font-weight: 600; }
li.in_corso .chip { background: var(--accent); color: var(--on-accent); }
li.fatto .chip { background: var(--done); color: var(--surface); }
li.fatto .title { text-decoration: line-through; opacity: .6; }
.tasks li.overdue { border-color: var(--red); }
li.overdue .when { color: var(--red); font-weight: 700; }
.empty, .muted { color: var(--muted); font-size: 14px; }
.error { color: var(--red); font-weight: 600; }
.error:empty { display: none; }

/* Moduli */
label { display: grid; gap: 5px; margin-bottom: 14px; font-size: 14px; font-weight: 600; }
input, select { width: 100%; font-weight: 400; font-size: 16px; }
.bar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
dialog { width: min(100vw, 460px); max-width: 100vw; max-height: 90dvh; padding: 20px; border: 0; border-radius: 22px; background: var(--surface); color: var(--fg); }
dialog::backdrop { background: rgb(11 16 32 / .55); }
@media (max-width: 520px) { dialog { margin: auto 0 0; border-radius: 22px 22px 0 0; padding-bottom: max(20px, env(safe-area-inset-bottom)); } }
@media (prefers-reduced-motion: no-preference) {
  dialog[open] { animation: sheet .18s ease-out; }
  @keyframes sheet { from { transform: translateY(24px); opacity: 0; } }
}

/* Accesso */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: #1b2a4a; }
.login > div { width: min(100%, 380px); padding: 26px; border-radius: 22px; background: var(--surface); }
.login > p { color: #fff; }
.login h1 { font-size: 28px; font-weight: 800; }
.login > div > p { margin: 6px 0 20px; color: var(--muted); }
.login button { width: 100%; }
footer.single { grid-template-columns: 1fr; }
.users .title .chip { margin-left: 8px; font-size: 12px; }
.users li.off > .title, .users li.off > .muted { opacity: .6; }
input[readonly] { color: var(--muted); }
.users li.off .left-tasks { margin-top: 10px; }
.history { margin: 6px 0 0; font-size: 13px; }
