/* Area riservata - stessi colori del sito pubblico */
:root {
  --blu: #0033a0; --blu-scuro: #002270; --rosso: #e4002b; --giallo: #ffc72c;
  --testo: #1b1f2a; --grigio: #5b6272; --sfondo: #f4f6fb; --bianco: #fff; --bordo: #dfe3ec;
  --mio: #e3ebff; --raggio: 12px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--testo); background: var(--sfondo); line-height: 1.5; font-size: 16px; }
a { color: var(--blu); }
h1 { font-size: 1.6rem; margin: 0 0 18px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
.ico { width: 22px; height: 22px; flex: none; }

/* Barra in alto */
.barra { position: sticky; top: 0; z-index: 30; background: var(--bianco); border-bottom: 1px solid var(--bordo); display: flex; align-items: center; gap: 12px; padding: 8px 16px; min-height: 60px; }
.marchio { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--blu); font-weight: 800; margin-right: auto; min-width: 0; }
.marchio img { height: 40px; width: auto; max-width: 52vw; }
.marchio span { white-space: nowrap; border-left: 2px solid var(--bordo); padding-left: 10px; }
.chi { display: flex; align-items: center; gap: 8px; }
.chi a { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--testo); }
.chi-nome { font-weight: 700; font-size: .95rem; line-height: 1.15; }
.chi-nome small { display: block; font-weight: 500; color: var(--grigio); font-size: .75rem; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--blu); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .85rem; flex: none; }
.esci { padding: 6px 10px; border-radius: 8px; color: var(--grigio) !important; }
.esci:hover { background: var(--sfondo); }
.apri-menu { display: none; }

/* Corpo: menu a sinistra + contenuto */
.corpo { display: flex; min-height: calc(100vh - 60px); }
.menu-lat { width: 230px; flex: none; background: var(--blu); padding: 16px 10px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto; }
.menu-lat a { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; padding: 11px 12px; border-radius: 10px; font-weight: 600; }
.menu-lat a:hover { background: rgba(255,255,255,.12); }
.menu-lat a[aria-current="page"] { background: #fff; color: var(--blu); }
.menu-lat .badge { margin-left: auto; }
.contenuto { flex: 1; min-width: 0; padding: 24px; max-width: 1180px; }

/* Elementi */
.riquadro { background: var(--bianco); border: 1px solid var(--bordo); border-radius: var(--raggio); padding: 18px; margin-bottom: 18px; }
.due-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.due-col > .riquadro { margin-bottom: 0; }
.tessere { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin-bottom: 22px; }
.tessera { background: var(--bianco); border: 1px solid var(--bordo); border-radius: var(--raggio); padding: 16px; text-decoration: none; color: var(--testo); display: flex; flex-direction: column; gap: 4px; border-top: 4px solid var(--blu); }
.tessera:hover { border-color: var(--blu); }
.tessera .ico { color: var(--blu); width: 28px; height: 28px; margin-bottom: 4px; }
.tessera span { color: var(--grigio); font-size: .9rem; }
.badge { background: var(--rosso); color: #fff; border-radius: 999px; font-size: .75rem; font-weight: 700; padding: 1px 8px; min-width: 22px; text-align: center; }
.badge[hidden] { display: none; }
.meta { color: var(--grigio); font-size: .85rem; margin: 2px 0 8px; }
.vuoto { color: var(--grigio); }
.flash { background: #e7f6ec; border: 1px solid #b5e2c3; color: #14532d; padding: 10px 14px; border-radius: 10px; }
.errore { background: #fdecee; border: 1px solid #f5b5bf; color: #8a0f22; padding: 10px 14px; border-radius: 10px; }
.avviso { background: #fff7e0; border: 1px solid #f3dc8f; padding: 10px 14px; border-radius: 10px; }
.stato { font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; vertical-align: middle; }
.stato.on { background: #e7f6ec; color: #14532d; } .stato.off { background: #eceef3; color: var(--grigio); }

/* Pulsanti e moduli */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 10px; font-weight: 700; text-decoration: none; border: 0; cursor: pointer; font-size: .95rem; font-family: inherit; }
.btn-pri { background: var(--rosso); color: #fff; }
.btn-sec { background: var(--sfondo); color: var(--blu); border: 1px solid var(--bordo); }
.btn.piccolo { padding: 5px 10px; font-size: .85rem; }
.btn:hover { filter: brightness(.95); }
.link-rosso { background: none; border: 0; color: var(--rosso); cursor: pointer; font: inherit; font-size: .9rem; padding: 0; text-decoration: underline; }
.btn.link-rosso { text-decoration: none; padding: 10px 16px; }
.modulo { display: grid; gap: 12px; max-width: 560px; }
.modulo label { display: grid; gap: 4px; font-weight: 600; font-size: .92rem; }
.modulo .spunta { display: flex; gap: 8px; align-items: center; font-weight: 500; }
input, select, textarea { font: inherit; padding: 9px 11px; border: 1px solid var(--bordo); border-radius: 8px; background: #fff; color: var(--testo); width: 100%; }
input[type=checkbox] { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blu); outline-offset: 0; border-color: var(--blu); }
.modulo .btn { justify-self: start; }
details.nuovo summary { cursor: pointer; font-weight: 700; color: var(--blu); }
details.nuovo[open] summary { margin-bottom: 14px; }
.in-linea { display: inline; }
.azioni-riga { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.filtri { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filtri a { padding: 6px 12px; border-radius: 999px; background: var(--bianco); border: 1px solid var(--bordo); text-decoration: none; font-size: .9rem; font-weight: 600; }
.filtri a[aria-current="page"] { background: var(--blu); color: #fff; border-color: var(--blu); }

/* Tabelle */
.tabella-scorre { overflow-x: auto; }
.tabella { width: 100%; border-collapse: collapse; background: var(--bianco); font-size: .93rem; }
.tabella th, .tabella td { padding: 9px 10px; border-bottom: 1px solid var(--bordo); text-align: left; vertical-align: top; }
.tabella th { background: var(--sfondo); font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; color: var(--grigio); }
.tabella .num, .tabella td.num { text-align: right; }
.tabella input.num { width: 110px; text-align: right; }
.tabella small { color: var(--grigio); }
.tabella tr.io td { background: #fff7e0; font-weight: 700; }
.tabella tr.spento td { opacity: .55; }
.medaglia { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-weight: 800; font-size: .85rem; }
.m1 { background: var(--giallo); } .m2 { background: #d6dae3; } .m3 { background: #e8b88a; }

/* Comunicazioni */
.comunicazione.importante, .mini.importante { border-left: 5px solid var(--rosso); }
.mini { padding: 8px 0 8px 12px; border-bottom: 1px solid var(--bordo); margin-bottom: 8px; border-left: 3px solid transparent; }
.mini p { margin: 0 0 4px; }
.etichetta-imp { background: var(--rosso); color: #fff; font-size: .7rem; padding: 2px 8px; border-radius: 999px; vertical-align: middle; text-transform: uppercase; }
.elenco-doc { padding-left: 18px; } .elenco-doc small { color: var(--grigio); }
.dati { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 16px; }
.dati dt { color: var(--grigio); } .dati dd { margin: 0; font-weight: 600; }
.provvisoria { border: 2px solid var(--giallo); background: #fffbeb; }
.provvisoria .pw { font-family: ui-monospace, Consolas, monospace; font-size: 1.6rem; font-weight: 800; letter-spacing: .08em; background: #fff; border: 1px dashed var(--grigio); padding: 8px 14px; display: inline-block; border-radius: 8px; margin: 4px 0; user-select: all; }

/* Rubrica */
.rubrica { list-style: none; margin: 0; padding: 0; }
.rubrica li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--bordo); flex-wrap: wrap; }
.r-nome { display: flex; flex-direction: column; min-width: 180px; } .r-nome small { color: var(--grigio); }
.r-azioni { margin-left: auto; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; font-size: .92rem; }

/* Chat */
.chat { display: grid; grid-template-columns: 280px 1fr; height: calc(100vh - 60px - 24px - 24px - 56px); min-height: 440px; background: var(--bianco); border: 1px solid var(--bordo); border-radius: var(--raggio); overflow: hidden; }
.chat-canali { border-right: 1px solid var(--bordo); overflow-y: auto; padding: 12px; background: #fafbfe; }
.chat-canali h2 { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--grigio); margin: 10px 4px 6px; }
.chat-canali ul { list-style: none; margin: 0 0 8px; padding: 0; }
.chat-canali input { margin-bottom: 6px; padding: 7px 10px; font-size: .9rem; }
.voce-canale { width: 100%; display: grid; grid-template-columns: 1fr auto; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 8px; cursor: pointer; font: inherit; color: var(--testo); }
.voce-canale:hover { background: var(--sfondo); }
.voce-canale.attivo { background: var(--blu); color: #fff; }
.voce-canale .nome { font-weight: 600; font-size: .93rem; }
.voce-canale small { grid-column: 1; color: var(--grigio); font-size: .75rem; }
.voce-canale.attivo small { color: #cdd8f5; }
.voce-canale .badge { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
.chat-finestra { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-testa { padding: 12px 16px; border-bottom: 1px solid var(--bordo); display: flex; align-items: center; gap: 10px; }
.chat-indietro { display: none; background: none; border: 0; font-size: 1.3rem; cursor: pointer; color: var(--blu); padding: 0 6px; }
.chat-messaggi { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; background: var(--sfondo); }
.chat-giorno { align-self: center; font-size: .75rem; color: var(--grigio); background: var(--bianco); border: 1px solid var(--bordo); padding: 2px 10px; border-radius: 999px; margin: 6px 0; }
.chat-vuota { color: var(--grigio); text-align: center; margin: auto; }
.msg { max-width: 75%; background: var(--bianco); border: 1px solid var(--bordo); border-radius: 12px 12px 12px 4px; padding: 7px 11px; align-self: flex-start; }
.msg.mio { align-self: flex-end; background: var(--mio); border-color: #c9d7fb; border-radius: 12px 12px 4px 12px; }
.msg-testa { font-size: .75rem; font-weight: 700; color: var(--blu); }
.msg.mio .msg-testa { text-align: right; }
.msg-testo { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-elimina { background: none; border: 0; color: var(--grigio); font-size: .72rem; cursor: pointer; padding: 0; text-decoration: underline; display: none; }
.msg:hover .msg-elimina, .msg-elimina[data-conferma] { display: inline; color: var(--rosso); }
.chat-scrivi { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--bordo); align-items: flex-end; }
.chat-scrivi textarea { resize: none; max-height: 160px; }
.chat-nota { margin: 0; padding: 0 12px 8px; font-size: .75rem; color: var(--grigio); }
.chat-errore { margin: 0 10px; color: var(--rosso); font-size: .85rem; }

/* Pagina di accesso */
.pagina-accesso { display: grid; place-items: center; min-height: 100vh; padding: 16px; background: linear-gradient(135deg, var(--blu), var(--blu-scuro)); }
.scatola-accesso { background: var(--bianco); border-radius: 16px; padding: 28px; width: 100%; max-width: 420px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.logo-accesso { height: 48px; width: auto; max-width: 100%; display: block; margin: 0 auto 14px; }
.scatola-accesso h1 { text-align: center; font-size: 1.35rem; }
.scatola-accesso .modulo .btn { justify-self: stretch; }
.nota { color: var(--grigio); font-size: .88rem; text-align: center; }

/* Telefono */
@media (max-width: 860px) {
  .due-col { grid-template-columns: 1fr; }
  .marchio span, .chi-nome, .esci span { display: none; }
  .apri-menu { display: inline-flex; background: var(--blu); color: #fff; border: 0; border-radius: 8px; padding: 8px 12px; font: inherit; font-weight: 700; cursor: pointer; }
  .menu-lat { display: none; position: fixed; top: 60px; left: 0; right: 0; height: auto; max-height: calc(100vh - 60px); width: auto; z-index: 25; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
  .menu-lat.aperto { display: flex; }
  .contenuto { padding: 16px; }
  h1 { font-size: 1.35rem; }
  .chat { grid-template-columns: 1fr; height: calc(100vh - 60px - 16px - 16px - 46px); }
  .chat-finestra { display: none; }
  .chat.aperta .chat-canali { display: none; }
  .chat.aperta .chat-finestra { display: flex; }
  .chat-indietro { display: inline; }
  .msg { max-width: 88%; }
  .r-azioni { margin-left: 48px; }
}

/* ---- Bozza 3: turni, ferie, gara, accedi come ---- */
.banda-come { background: var(--giallo); padding: 8px 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: .92rem; }
.banda-avviso { background: #fff7e0; margin: 0; padding: 8px 16px; font-size: .92rem; border-bottom: 1px solid #f3dc8f; }
.nota-sx { color: var(--grigio); font-size: .88rem; }
.evidenza { border: 2px solid var(--blu); }
.barra-turni { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.testa-periodo { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.testa-periodo strong { font-size: 1.05rem; }
.testa-periodo .scegli { margin-left: auto; } .testa-periodo .scegli select { width: auto; }
.link-oggi { font-size: .9rem; }
.tabella.turni th[scope=row] { white-space: nowrap; background: var(--bianco); position: sticky; left: 0; z-index: 1; }
.tabella.turni th[scope=row] small { display: block; font-weight: 500; text-transform: none; letter-spacing: 0; }
.tabella.turni thead th { text-align: center; }
.tabella.turni td { text-align: center; min-width: 96px; }
.tabella.turni.mese td { min-width: 30px; padding: 6px 2px; }
.tabella.turni.mese th { font-size: .7rem; padding: 6px 2px; }
.tabella.turni th.scoperto { background: #fdecee; color: #8a0f22; }
.tabella.turni th.oggi { box-shadow: inset 0 -3px 0 var(--blu); }
.turno { display: inline-block; padding: 3px 8px; border-radius: 8px; font-size: .82rem; font-weight: 600; line-height: 1.25; }
.turno small { display: block; font-weight: 500; }
.t-mattina { background: #e3ebff; color: #0b2a7a; } .t-pomeriggio { background: #e8f5ff; color: #064a73; }
.t-intero { background: #dfe7fb; color: var(--blu-scuro); } .t-spezzato { background: #ece6ff; color: #3a1d8a; }
.t-riposo { background: #eceef3; color: var(--grigio); } .t-ferie { background: #e7f6ec; color: #14532d; }
.t-permesso { background: #fff3d6; color: #6b4a00; } .t-malattia { background: #fdecee; color: #8a0f22; }
.t-inaltronegozio { background: #fff; border: 1px dashed var(--blu); color: var(--blu); }
.t-vuoto { color: #b8bdc9; }
.legenda { font-size: .85rem; color: var(--grigio); margin-top: 10px; }
.legenda .turno { padding: 1px 6px; }
.tabella.modifica td { min-width: 130px; vertical-align: top; }
.tabella.modifica select { padding: 5px; font-size: .85rem; }
.tabella.modifica .ore { display: flex; gap: 2px; margin-top: 3px; }
.tabella.modifica .ore input { padding: 3px; font-size: .78rem; }
.giornata { list-style: none; padding: 0; margin: 0; }
.giornata li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--bordo); }
.giornata .turno { margin-left: auto; }
.due-campi { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.due-campi[hidden] { display: none; }
.richiesta { display: flex; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--bordo); flex-wrap: wrap; }
.decidi { display: flex; gap: 6px; align-items: flex-start; flex-wrap: wrap; }
.decidi input { width: 200px; }
.elenco-richieste { list-style: none; padding: 0; margin: 0; }
.elenco-richieste li { padding: 8px 0; border-bottom: 1px solid var(--bordo); }
.stato.attesa { background: #fff3d6; color: #6b4a00; }
.cancello.chiuso { border-left: 6px solid var(--rosso); } .cancello.aperto { border-left: 6px solid #1f9d55; }
progress.barra-av { width: 120px; height: 10px; vertical-align: middle; accent-color: var(--blu); }
progress.barra-av.ok { accent-color: #1f9d55; }
.tabella td.ok { background: #e7f6ec; }
.tabella td small { color: var(--grigio); }
.esempio-msg { white-space: pre-wrap; background: var(--sfondo); padding: 12px; border-radius: 8px; font-family: inherit; font-size: .9rem; }
.dettaglio-persone { margin-top: 12px; } .dettaglio-persone summary { cursor: pointer; color: var(--blu); font-weight: 600; }
@media (max-width: 860px) { .testa-periodo .scegli { margin-left: 0; } .decidi input { width: 100%; } }
.giornata.miei li { padding: 8px 0; }
.giornata.miei li.oggi { background: #fff7e0; }
.giorno-lista { min-width: 80px; }
.nota-turno { color: var(--grigio); flex-basis: 100%; padding-left: 92px; }
@media (max-width: 860px) { progress.barra-av { width: 64px; } .tabella.avanzamento th:nth-child(5), .tabella.avanzamento td:nth-child(5) { display: none; } }
.spunte { border: 1px solid var(--bordo); border-radius: 8px; padding: 8px 12px; display: grid; gap: 6px; } .spunte legend { font-weight: 600; font-size: .92rem; padding: 0 4px; }
.pw-cella { font-family: ui-monospace, Consolas, monospace; font-weight: 800; letter-spacing: .06em; user-select: all; }
@media print { .barra, .menu-lat, .piede, details, form, .filtri { display: none !important; } .provvisoria { border: 0; } }
.allegato { display: inline-block; margin-top: 2px; font-size: .9rem; font-weight: 600; word-break: break-all; }
.richiesta > div:first-child { flex: 1 1 520px; min-width: 0; }
.quadro { margin-top: 10px; }
.quadro summary { cursor: pointer; font-weight: 700; color: var(--blu); margin-bottom: 6px; }
.quadro-tab td, .quadro-tab th { font-size: .88rem; vertical-align: top; padding: 6px 8px; }
.quadro-tab small { color: var(--grigio); }
.richiesta .avviso { margin: 8px 0 0; }
.t-festivo { background: #f3eefc; color: #4b2a7a; } .t-maternit { background: #fde9f4; color: #7a1450; }

.pw-qr { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; }
.pw-qr figure { margin: 0; text-align: center; }
.pw-qr figcaption { font-size: .8rem; color: var(--grigio); }
img.qr { display: block; background: #fff; image-rendering: pixelated; }
.tabella img.qr { width: 96px; height: 96px; }
.ok-mail { color: #166534; font-weight: 600; }

.tabella.vede th { font-size: .75rem; text-align: center; white-space: normal; min-width: 70px; }
.tabella.vede td.spunta-cella { text-align: center; }
.tabella.vede td.spunta-cella input { width: 20px; height: 20px; }
.tabella.vede tr.sezione th { background: var(--blu); color: #fff; text-align: left; }

.chi { position: relative; }
.come-menu { position: relative; }
.come-menu > summary { list-style: none; cursor: pointer; padding: 6px 12px; border: 1px solid var(--blu); color: var(--blu); border-radius: 8px; font-weight: 700; font-size: .9rem; white-space: nowrap; }
.come-menu > summary::-webkit-details-marker { display: none; }
.come-menu[open] > summary { background: var(--blu); color: #fff; }
.come-form { position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; background: #fff; border: 1px solid #d7dbe3; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 12px; display: grid; gap: 8px; width: 280px; }
.come-form label { font-weight: 700; font-size: .9rem; }
.come-form small { color: var(--grigio); }
.come-torna { margin: 0; }
@media (max-width: 700px) { .come-menu > summary { padding: 6px 8px; font-size: .8rem; } .come-form { width: min(280px, 90vw); } }
.come-menu .corto { display: none; }
@media (max-width: 500px) { .come-menu .lungo { display: none; } .come-menu .corto { display: inline; } .chi { gap: 4px; } }

.tessere-doc { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.tessere-doc .tessera { min-height: 150px; }
.tessere-doc .tessera strong { font-size: 1.1rem; }
.tessera .conta { margin-top: auto; font-weight: 700; color: var(--blu); font-size: .85rem; }
.filtri-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }

.tessera { position: relative; }
.tessera .nuovi { position: absolute; top: 12px; right: 12px; background: var(--rosso); color: #fff !important; font-weight: 800; font-size: .78rem; padding: 3px 9px; border-radius: 999px; }
