:root {
  --sfondo: #f3f6fb;
  --carta: #ffffff;
  --inchiostro: #0f1b2d;
  --tenue: #5b6b80;
  --linea: #dbe3ee;
  --barra: #0b2a5b;
  --accento: #1d5fd1;
  --accento-tenue: #e8f0fd;
  --ss: #eef4ff;
  --tag: #1d5fd1;
  --ok: #15803d;
  --errore: #b91c1c;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  color: var(--inchiostro);
  background: var(--sfondo);
}
* { box-sizing: border-box; }
body { margin: 0; font-size: 15px; line-height: 1.4; background: var(--sfondo); }
a { color: var(--accento); }

.barra {
  display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; align-items: center; justify-content: space-between;
  padding: .75rem max(16px, 4vw); background: var(--barra); color: #fff;
}
.barra a { color: #fff; text-decoration: none; opacity: .85; }
.barra a:hover { opacity: 1; }
.barra .logo { display: inline-flex; align-items: center; gap: .6rem; font-weight: 700; letter-spacing: .02em; opacity: 1; }
.barra .logo img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; border: 2px solid #b89b6a; box-shadow: 0 0 0 2px rgb(0 0 0 / .25); }
.barra nav { display: flex; flex-wrap: wrap; align-items: center; gap: 1.25rem; }
.barra .esci { margin: 0; }
.barra .esci button { background: none; border: 1px solid rgb(255 255 255 / .35); color: #fff; padding: .2rem .7rem; font-size: .85rem; }
.accesso { max-width: 360px; margin: 3rem auto; background: var(--carta); border: 1px solid var(--linea); border-radius: 14px; padding: 1.5rem; text-align: center; }
.accesso img { width: 96px; height: 96px; border-radius: 50%; border: 2px solid #b89b6a; }
.accesso input { width: 100%; font: inherit; padding: .55rem .7rem; border: 1px solid var(--linea); border-radius: 8px; margin: 0 0 .6rem; }
.accesso h1 { margin-bottom: 1rem; }
.accesso .errore { color: var(--errore); margin: 0; }

main { max-width: 1280px; margin: 0 auto; padding: 1.5rem max(16px, 4vw) 4rem; }

.intestazione { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1rem; }
.intestazione h1 { margin: .1rem 0; font-size: 2.1rem; letter-spacing: -.01em; }
.sopratitolo { margin: 0; color: var(--tenue); text-transform: uppercase; font-size: .75rem; letter-spacing: .08em; }
.sottotitolo { margin: 0; color: var(--tenue); max-width: 60ch; }
.azioni { display: flex; gap: .5rem; }
.azioni form { margin: 0; }

button { font: inherit; cursor: pointer; border-radius: 8px; }
.primario { background: var(--accento); color: #fff; border: 0; padding: .55rem 1rem; font-weight: 600; }
.secondario { background: transparent; color: var(--inchiostro); border: 1px solid var(--linea); padding: .5rem .9rem; }
.primario:hover { filter: brightness(1.08); }
.secondario:hover { background: var(--carta); }

.legenda { background: var(--carta); border: 1px solid var(--linea); border-radius: 10px; padding: .6rem 1rem; margin-bottom: 1.5rem; }
.legenda summary { cursor: pointer; font-weight: 600; }
.legenda ul { margin: .5rem 0 0; padding-left: 1.2rem; color: var(--tenue); }

.seduta { margin-bottom: 2rem; }
.seduta h2 { font-size: 1.2rem; margin: 0 0 .6rem; display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; }
.giorno { background: var(--accento); color: #fff; font-size: .75rem; padding: .15rem .55rem; border-radius: 99px; text-transform: uppercase; letter-spacing: .06em; }

.tabella-wrap { overflow-x: auto; background: var(--carta); border: 1px solid var(--linea); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 880px; }
th, td { padding: .55rem .6rem; border-bottom: 1px solid var(--linea); text-align: left; vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--barra); font-weight: 600; background: var(--accento-tenue); }
th span { display: block; text-transform: none; letter-spacing: 0; font-weight: 400; }
.c-num { width: 2rem; color: var(--tenue); text-align: center; }
.c-es { min-width: 18rem; }
.c-rec { width: 6.5rem; white-space: nowrap; }
.c-w { width: 8.5rem; }
tr.ss td { background: var(--ss); }
tr.stretching-testa td { background: var(--barra); color: #fff; border-bottom: 0; }
tr.stretching-testa .meta { color: #c9d8f2; }
tr.stretching-testa .c-num { color: #c9d8f2; }
tr.stretching td { padding-top: .4rem; padding-bottom: .4rem; background: #f7faff; }
.stretching-blocco { margin-top: .75rem; }
.solo-stampa-blocco { display: none; }
.tabella-stretching { min-width: 760px; }
.tabella-stretching .c-es { width: 30%; min-width: 16rem; }
.tabella-stretching .c-str { width: 9.5rem; white-space: nowrap; }
.tabella-stretching .c-descr { color: var(--tenue); font-size: .85rem; }
tr.stretching .nome { font-weight: 500; }
tr.stretching .alt { margin-top: .2rem; }
.tag { display: inline-block; background: var(--tag); color: #fff; font-size: .7rem; font-weight: 700; border-radius: 4px; padding: 0 .35rem; margin-right: .3rem; }
.nome { font-weight: 600; }
.meta { display: block; color: var(--tenue); font-size: .8rem; }
.alt { margin-top: .35rem; font-size: .78rem; padding: .15rem .55rem; border: 1px solid var(--linea); background: var(--carta); color: var(--tenue); }
.alt:hover { color: var(--accento); border-color: var(--accento); }
.presc { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
input.carico {
  width: 100%; margin-top: .3rem; padding: .3rem .4rem; font: inherit; font-size: .9rem;
  border: 1px solid var(--linea); border-radius: 6px; background: #fff;
}
input.carico:focus { outline: 2px solid var(--accento); outline-offset: -1px; border-color: transparent; }
input.carico.in-attesa { background: var(--accento-tenue); }
.carico-stampa, .solo-stampa { display: none; }

dialog { border: 0; border-radius: 14px; padding: 1.25rem; max-width: min(560px, calc(100vw - 32px)); width: 100%; }
dialog::backdrop { background: rgb(0 0 0 / .4); }
dialog h3 { margin: 0 0 .3rem; }
.nota { color: var(--tenue); font-size: .85rem; margin: 0 0 .8rem; }
#alt-lista { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .4rem; }
.scelta { width: 100%; text-align: left; background: var(--sfondo); border: 1px solid var(--linea); padding: .55rem .75rem; }
.scelta:hover { border-color: var(--accento); background: var(--accento-tenue); }
.scelta span { display: block; color: var(--tenue); font-size: .8rem; }
.dlg-azioni { display: flex; justify-content: flex-end; gap: .5rem; }
#conferma-testo { margin: 0 0 1rem; }

#toast {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%) translateY(150%);
  background: var(--ok); color: #fff; padding: .45rem .9rem; border-radius: 99px; font-size: .85rem;
  transition: transform .2s ease, opacity .2s ease; pointer-events: none; opacity: 0;
}
#toast.visibile { transform: translateX(-50%) translateY(0); opacity: 1; }
#toast.errore { background: var(--errore); }

.archivio { list-style: none; padding: 0; display: grid; gap: .6rem; }
.archivio a { display: block; background: var(--carta); border: 1px solid var(--linea); border-radius: 12px; padding: .8rem 1rem; text-decoration: none; color: inherit; }
.archivio a:hover { border-color: var(--accento); }
.archivio span { display: block; }

table.catalogo { font-size: .88rem; }
table.catalogo { min-width: 900px; }
table.catalogo td.descr { color: var(--inchiostro); min-width: 26rem; }
.scartati { margin-top: 2rem; }
.scartati summary { cursor: pointer; font-weight: 600; margin-bottom: .6rem; }

@media (max-width: 640px) {
  .intestazione h1 { font-size: 1.6rem; }
}

@media print {
  @page { size: A4 landscape; margin: 10mm; }
  :root, body { background: #fff; font-size: 10.5pt; }
  .no-print, .legenda, dialog, .alt { display: none !important; }
  main { max-width: none; padding: 0; }
  .intestazione { margin-bottom: 4mm; }
  .intestazione h1 { font-size: 18pt; }
  .seduta { break-after: page; margin: 0; }
  .seduta:last-of-type { break-after: auto; }
  .seduta h2 { font-size: 13pt; }
  .giorno { border: 1px solid #000; color: #000; background: #fff; }
  .tabella-wrap { overflow: visible; border: 1px solid #999; border-radius: 0; }
  table { min-width: 0; }
  th, td { padding: 2mm 2mm; border-bottom: 1px solid #bbb; }
  th { background: #eee !important; color: #000; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  tr.ss td { background: #f2f2f2 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .tag { background: #fff; color: #000; border: 1px solid #000; }
  tr { break-inside: avoid; }
  tr.stretching-testa td { background: #dfe7f3 !important; color: #000; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  tr.stretching-testa .meta, tr.stretching-testa .c-num { color: #333; }
  tr.stretching td { padding-top: 1mm; padding-bottom: 1mm; background: #fff !important; }
  .stretching-blocco { break-before: page; margin: 0; }
  .solo-stampa-blocco { display: block; font-size: 12pt; margin: 0 0 3mm; }
  .tabella-stretching .c-descr { font-size: 9pt; color: #333; }
  input.carico { display: none; }
  .solo-stampa { display: inline; font-weight: 400; color: #555; }
  .carico-stampa {
    display: block; min-height: 6.5mm; margin-top: 1mm; padding: .5mm 1.5mm;
    border: 1px solid #999; border-radius: 1mm; font-size: 10pt;
  }
}
