/* Archivo (SIL Open Font License) incluso nel programma: funziona anche senza internet */
@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  src: url(../font/archivo-latin-ext-wdth-normal.woff2) format('woff2-variations');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  src: url(../font/archivo-latin-wdth-normal.woff2) format('woff2-variations');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
/* ISCGEST 2.0 — Grafica Danea Style (Corporate Professional) */
:root {
  --cemento: #f4f7f9;
  --cemento-2: #e2e8f0;
  --carta: #ffffff;
  --inchiostro: #1e293b;
  --inchiostro-2: #334155;
  --testo: #1e293b;
  --tenue: #64748b;
  --linea: #cbd5e1;
  --giallo: #3b82f6; /* Sostituito il giallo cantiere con un Blu Danea Professionale */
  --giallo-scuro: #2563eb;
  --rosso: #ef4444;
  --verde: #10b981;
  --blu: #3b82f6;
  --viola: #8b5cf6;
  --ambra: #f59e0b;
  --r-sm: 6px;
  --r-md: 10px;
  --ombra: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5;
  color: var(--testo); background: var(--cemento);
  font-variation-settings: "wdth" 100;
}
a { color: var(--blu); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--inchiostro); line-height: 1.2; margin: 0; font-stretch: 92%; }
h1 { font-size: 1.65rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.12rem; font-weight: 650; }
h3 { font-size: .98rem; font-weight: 650; }
p { margin: 0 0 .6em; }
.ico { flex: none; vertical-align: -3px; }
.muted { color: var(--tenue); }
.small { font-size: .85rem; }
.late { color: var(--rosso); font-weight: 600; }
.ok { color: var(--verde); font-weight: 600; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
:focus-visible { outline: 3px solid var(--giallo); outline-offset: 2px; }

/* ---------- struttura ---------- */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side {
  background: var(--inchiostro); color: #cfd6e4; position: sticky; top: 0; height: 100vh;
  overflow-y: auto; display: flex; flex-direction: column; padding: 18px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 800; font-size: 1.15rem; padding: 0 8px 18px; font-stretch: 85%; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 6px; background: var(--giallo); color: #fff;
  display: grid; place-items: center; font-weight: 900; font-size: .9rem;
}
.brand small { display: block; font-weight: 500; font-size: .72rem; color: #8e9ab3; font-stretch: 100%; }
.nav-gruppo { margin: 14px 0 4px; padding: 0 10px; font-size: .76rem; color: #7f8ba6; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--r-sm);
  color: #d5dbe7; font-size: .93rem; position: relative;
}
.nav a:hover { background: rgba(255, 255, 255, .07); text-decoration: none; color: #fff; }
.nav a.on { background: rgba(59, 130, 246, .2); color: #fff; }
.nav a.on::before { content: ""; position: absolute; left: -12px; top: 6px; bottom: 6px; width: 4px; background: var(--giallo); border-radius: 0 3px 3px 0; }
.nav .conta { margin-left: auto; background: var(--giallo); color: #fff; font-size: .72rem; font-weight: 700; padding: 0 7px; border-radius: 10px; }
.side-piede { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid rgba(255, 255, 255, .1); font-size: .85rem; }
.side-piede a { color: #aeb8cc; display: flex; gap: 8px; align-items: center; padding: 4px 0; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top {
  display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: var(--carta);
  border-bottom: 1px solid var(--linea); position: sticky; top: 0; z-index: 20;
}
.cerca { flex: 1; max-width: 520px; position: relative; }
.cerca input { width: 100%; padding: 9px 12px 9px 36px; border: 1px solid var(--linea); border-radius: var(--r-md); background: var(--cemento); font: inherit; }
.cerca input:focus { background: #fff; border-color: var(--giallo); outline: none; }
.cerca .ico { position: absolute; left: 11px; top: 11px; color: var(--tenue); }
.cerca kbd { position: absolute; right: 10px; top: 9px; font: .72rem var(--font); color: var(--tenue); border: 1px solid var(--linea); border-radius: 4px; padding: 1px 5px; background: #fff; }
.top .spazio { flex: 1; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: .8rem; }
.menu-btn { display: none; background: none; border: 0; padding: 6px; color: var(--inchiostro); }

.contenuto { padding: 24px 28px 60px; max-width: 1400px; width: 100%; }
.testata { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.testata .titoli { flex: 1; min-width: 240px; }
.testata .sotto { color: var(--tenue); margin-top: 4px; }
.briciole { font-size: .85rem; color: var(--tenue); margin-bottom: 6px; }
.briciole a { color: var(--tenue); }
.azioni { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- pulsanti ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--linea); background: var(--carta); color: var(--inchiostro); font: 600 .9rem var(--font);
  cursor: pointer; white-space: nowrap; line-height: 1.2;
}
.btn:hover { text-decoration: none; border-color: var(--inchiostro-2); }
.btn-primario { background: var(--giallo); border-color: var(--giallo-scuro); color: #fff; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .12); }
.btn-primario:hover { background: var(--giallo-scuro); border-color: var(--giallo-scuro); color: #fff; }
.btn-scuro { background: var(--inchiostro); border-color: var(--inchiostro); color: #fff; }
.btn-scuro:hover { background: var(--inchiostro-2); }
.btn-pericolo { color: var(--rosso); }
.btn-pericolo:hover { border-color: var(--rosso); }
.btn-piccolo { padding: 5px 9px; font-size: .82rem; }
.btn-link { border: 0; background: none; padding: 4px; color: var(--blu); }
.btn-grande { padding: 14px 18px; font-size: 1.05rem; border-radius: var(--r-md); justify-content: center; }
.btn-blocco { width: 100%; justify-content: center; }

/* ---------- pannelli ---------- */
.pannello { background: var(--carta); border: 1px solid var(--linea); border-radius: var(--r-md); box-shadow: var(--ombra); }
.pannello + .pannello { margin-top: 18px; }
.griglia > .pannello + .pannello { margin-top: 0; }
.pannello-testa { display: flex; align-items: center; gap: 10px; padding: 13px 18px; border-bottom: 1px solid var(--linea); }
.pannello-testa h2 { flex: 1; font-size: 1rem; }
.pannello-corpo { padding: 16px 18px; }
.vuoto { padding: 26px 18px; color: var(--tenue); text-align: center; }
.vuoto .btn { margin-top: 10px; }
.griglia { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-scheda { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); align-items: start; }
.colonna > * + * { margin-top: 18px; }

/* ---------- indicatori dashboard ---------- */
.kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi a {
  display: block; background: var(--carta); border: 1px solid var(--linea); border-radius: var(--r-md); padding: 14px 16px;
  color: var(--testo); border-top: 4px solid var(--giallo);
}
.kpi a:hover { text-decoration: none; border-color: var(--giallo-scuro); }
.kpi .val { font-size: 1.7rem; font-weight: 800; color: var(--inchiostro); font-stretch: 85%; line-height: 1.1; }
.kpi .lab { font-size: .86rem; color: var(--tenue); }
.kpi a.allerta { border-top-color: var(--rosso); }
.kpi a.allerta .val { color: var(--rosso); }
.kpi a.giallo { border-top-color: var(--ambra); }
.kpi a.verde { border-top-color: var(--verde); }

/* ---------- tabelle ---------- */
.tabella-wrap { overflow-x: auto; }
table.tab { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tab th { text-align: left; font-weight: 600; color: var(--tenue); font-size: .82rem; padding: 9px 14px; border-bottom: 1px solid var(--linea); white-space: nowrap; background: #f8fafc; }
.tab th a { color: var(--tenue); }
.tab td { padding: 10px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.tab tr:last-child td { border-bottom: 0; }
.tab tbody tr:hover td { background: #f8fafc; }
.tab tr.cliccabile { cursor: pointer; }
.tab .num, .tab td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tab tfoot td { font-weight: 700; border-top: 2px solid var(--linea); }

/* ---------- filtri ---------- */
.filtri { display: flex; gap: 10px; flex-wrap: wrap; padding: 12px 18px; border-bottom: 1px solid var(--linea); align-items: center; }
.filtri input[type=search] { flex: 1; min-width: 200px; }
.filtri select { width: auto; min-width: 150px; }
.paginazione { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--linea); font-size: .88rem; }

/* ---------- etichette di stato ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px 1px 7px; font-size: .78rem; font-weight: 600;
  border-radius: 3px; background: #f1f5f9; color: #475467; border-left: 3px solid #94a3b8; white-space: nowrap;
}
.b-aperto, .b-aperta, .b-bozza, .b-preventivo { background: #eff6ff; color: #1e40af; border-color: var(--blu); }
.b-pianificato, .b-inviato { background: #f5f3ff; color: #5b21b6; border-color: var(--viola); }
.b-in_corso, .b-emessa, .b-sospesa, .b-parziale, .b-alta { background: #fffbeb; color: #92400e; border-color: #f59e0b; }
.b-completato, .b-pagata, .b-accettato, .b-risolto, .b-carico { background: #ecfdf5; color: #065f46; border-color: var(--verde); }
.b-fatturato, .b-chiusa { background: #f8fafc; color: #475467; border-color: #64748b; }
.b-annullato, .b-rifiutato, .b-urgente, .b-da_rifare, .b-scarico { background: #fef2f2; color: #991b1b; border-color: var(--rosso); }
.b-bassa { background: #f8fafc; color: #64748b; border-color: #cbd5e1; }
.b-normale { background: #f8fafc; color: #334155; border-color: #94a3b8; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: -1px; }

.bar { height: 7px; background: #e2e8f0; border-radius: 4px; overflow: hidden; min-width: 70px; }
.bar span { display: block; height: 100%; background: var(--inchiostro); border-radius: 4px; }
.bar.rosso span { background: var(--rosso); }
.bar.giallo span { background: var(--giallo); }

/* ---------- form ---------- */
input, select, textarea {
  width: 100%; font: inherit; color: var(--testo); padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: var(--r-sm); background: #fff;
}
input:focus, select:focus, textarea:focus { border-color: var(--giallo); outline: 2px solid rgba(59, 130, 246, .3); outline-offset: 0; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--giallo); vertical-align: -3px; }
input[type=color] { padding: 2px; height: 38px; width: 70px; }
textarea { resize: vertical; }
.campi { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px 18px; }
.campo label { display: block; font-size: .86rem; font-weight: 600; margin-bottom: 4px; color: var(--inchiostro-2); }
.campo.largo { grid-column: 1 / -1; }
.campo .aiuto { font-size: .8rem; color: var(--tenue); margin-top: 3px; }
.campo .errore, .errorlist { color: var(--rosso); font-size: .84rem; margin: 4px 0 0; padding: 0; list-style: none; }
.campo.check label { display: flex; gap: 8px; align-items: center; margin-top: 26px; }
.form-piede { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 18px; border-top: 1px solid var(--linea); background: #f8fafc; border-radius: 0 0 var(--r-md) var(--r-md); }

/* ---------- messaggi ---------- */
.messaggi { margin-bottom: 16px; }
.msg { padding: 10px 14px; border-radius: var(--r-sm); margin-bottom: 8px; background: #ecfdf5; color: #065f46; border-left: 4px solid var(--verde); display: flex; justify-content: space-between; align-items: center; }
.msg.error { background: #fef2f2; color: #991b1b; border-color: var(--rosso); }
.msg.warning { background: #fffbeb; color: #92400e; border-color: #f59e0b; }
.msg button { background: none; border: 0; color: inherit; cursor: pointer; }

/* ---------- schede ---------- */
.dati { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px 22px; }
.dati dt { font-size: .8rem; color: var(--tenue); }
.dati dd { margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; }
.dati .largo { grid-column: 1 / -1; }
.dati dd.testo { white-space: pre-line; font-weight: 400; }

.numeri { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); border-bottom: 1px solid var(--linea); }
.numeri > div { padding: 14px 18px; border-right: 1px solid var(--linea); }
.numeri > div:last-child { border-right: 0; }
.numeri .val { font-size: 1.3rem; font-weight: 750; color: var(--inchiostro); font-stretch: 88%; font-variant-numeric: tabular-nums; }
.numeri .lab { font-size: .8rem; color: var(--tenue); }
.numeri .val.neg { color: var(--rosso); }
.numeri .val.pos { color: var(--verde); }

.voce-costo { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; margin-bottom: 10px; font-size: .9rem; }
.voce-costo .bar { grid-column: 1 / -1; }

/* flusso di stato dell'intervento */
.flusso { display: flex; gap: 0; margin: 4px 0 2px; overflow-x: auto; }
.flusso li { list-style: none; flex: 1; min-width: 110px; position: relative; padding: 9px 12px 9px 22px; background: #f1f5f9; color: var(--tenue); font-size: .85rem; font-weight: 600; clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%, 12px 50%); margin-right: -6px; }
.flusso li:first-child { clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%); padding-left: 14px; }
.flusso li.fatto { background: #dbeafe; color: var(--inchiostro); }
.flusso li.ora { background: var(--giallo); color: #fff; }
.flusso button { all: unset; cursor: pointer; display: block; }

.foto-griglia { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.foto-griglia img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--linea); }
.firma-img { max-width: 260px; border: 1px solid var(--linea); border-radius: var(--r-sm); background: #fff; }
.checklist li { margin-bottom: 4px; }

/* ---------- planner ---------- */
.planner { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 18px; align-items: start; }
.pl-tab { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.pl-tab th { font-size: .82rem; color: var(--tenue); font-weight: 600; padding: 8px; text-align: left; background: #f8fafc; border-bottom: 1px solid var(--linea); }
.pl-tab th.oggi { color: var(--inchiostro); background: #eff6ff; }
.pl-tab th:first-child, .pl-tab td:first-child { width: 132px; }
.pl-tab td { border-bottom: 1px solid #f1f5f9; border-left: 1px solid #f1f5f9; vertical-align: top; padding: 5px; height: 84px; }
.pl-tab td.weekend { background: #f8fafc; }
.pl-tab td.oggi { background: #eff6ff; }
.pl-tab td.sopra { background: #fef3c7; outline: 2px dashed var(--giallo-scuro); outline-offset: -3px; }
.pl-persona { display: flex; gap: 8px; align-items: center; font-weight: 600; font-size: .88rem; }
.pl-persona .avatar { width: 26px; height: 26px; font-size: .7rem; }
.pl-carico { font-size: .75rem; color: var(--tenue); font-weight: 400; }
.scheda-int {
  display: block; background: #fff; border: 1px solid var(--linea); border-left: 4px solid var(--blu); border-radius: 4px;
  padding: 5px 7px; margin-bottom: 4px; font-size: .78rem; color: var(--testo); cursor: grab; line-height: 1.3;
}
.scheda-int:hover { text-decoration: none; border-color: var(--inchiostro-2); }
.scheda-int strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-weight: 600; overflow: hidden; overflow-wrap: anywhere; }
.scheda-int .muted { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scheda-int.s-in_corso { border-left-color: #f59e0b; }
.scheda-int.s-completato, .scheda-int.s-fatturato { border-left-color: var(--verde); opacity: .7; }
.scheda-int.p-urgente { background: #fef2f2; }
.scheda-int.trascina { opacity: .4; }
.coda { max-height: 70vh; overflow-y: auto; padding: 10px; }
.coda.sopra { background: #fef3c7; }

/* ---------- ricerca ---------- */
.risultato { display: flex; gap: 12px; align-items: center; padding: 10px 18px; border-bottom: 1px solid #f1f5f9; color: var(--testo); }
.risultato:hover { background: #f8fafc; text-decoration: none; }

/* ---------- menu nuovo ---------- */
.tendina { position: relative; }
.tendina-menu { display: none; position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--linea); border-radius: var(--r-md); box-shadow: 0 10px 30px rgba(30, 41, 59, .15); min-width: 230px; padding: 6px; z-index: 40; }
.tendina.aperta .tendina-menu { display: block; }
.tendina-menu a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: var(--r-sm); color: var(--testo); font-size: .92rem; }
.tendina-menu a:hover { background: var(--cemento); text-decoration: none; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background:
  repeating-linear-gradient(-45deg, var(--inchiostro) 0 22px, #1e293b 22px 44px); }
.login-box { background: #fff; border-radius: var(--r-md); width: 100%; max-width: 380px; padding: 28px; border-top: 8px solid var(--giallo); }
.login-box h1 { margin: 12px 0 4px; }
.login-box .campo { margin-top: 14px; }

/* ---------- documenti (righe) ---------- */
.righe td { padding: 6px 6px; vertical-align: top; }
.righe input, .righe select { padding: 6px 7px; font-size: .9rem; }
.righe .c-desc { min-width: 220px; }
.righe .c-num { width: 90px; }
.righe .c-um { width: 64px; }
.righe .c-art { width: 170px; }
.totali { margin-left: auto; width: 300px; font-size: .95rem; }
.totali div { display: flex; justify-content: space-between; padding: 4px 0; }
.totali .grande { font-size: 1.2rem; font-weight: 800; color: var(--inchiostro); border-top: 2px solid var(--inchiostro); margin-top: 6px; padding-top: 8px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .g-scheda, .planner { grid-template-columns: 1fr; }
  .g3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .app.menu-aperto .side { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
  .menu-btn { display: block; }
  .top { padding: 10px 16px; }
  .cerca kbd { display: none; }
  .contenuto { padding: 18px 16px 50px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .tab .nascondi-m { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

@media print {
  .side, .top, .azioni, .no-print, .messaggi { display: none !important; }
  .app { display: block; }
  body { background: #fff; }
  .pannello { box-shadow: none; }
}

/* ---------- schede della commessa ---------- */
.schede { display: flex; gap: 2px; border-bottom: 2px solid var(--linea); margin: 0 0 18px; overflow-x: auto; }
.schede a { padding: 9px 14px; color: var(--tenue); font-weight: 600; font-size: .92rem; white-space: nowrap; border-bottom: 3px solid transparent; margin-bottom: -2px; display: flex; gap: 7px; align-items: center; }
.schede a:hover { color: var(--inchiostro); text-decoration: none; }
.schede a.on { color: var(--inchiostro); border-bottom-color: var(--giallo); }
.capitolo td { background: #f1f5f9; font-weight: 700; color: var(--inchiostro); }
.tab input.q { width: 110px; text-align: right; padding: 5px 7px; }
.tab td.desc { max-width: 460px; }
.tab td.desc div { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.riquadro-totali { background: var(--inchiostro); color: #fff; border-radius: var(--r-md); padding: 16px 18px; }
.riquadro-totali div { display: flex; justify-content: space-between; padding: 4px 0; font-variant-numeric: tabular-nums; }
.riquadro-totali .grande { border-top: 1px solid rgba(255,255,255,.25); margin-top: 6px; padding-top: 10px; font-size: 1.25rem; font-weight: 800; color: var(--giallo); }
.riquadro-totali .muted { color: #aeb8cc; }
/* Gantt */
.gantt { position: relative; overflow-x: auto; }
.gantt table { border-collapse: collapse; width: 100%; min-width: 760px; }
.gantt td, .gantt th { border-bottom: 1px solid #f1f5f9; padding: 0; height: 38px; font-size: .85rem; }
.gantt th { font-weight: 600; color: var(--tenue); text-align: left; padding: 6px 8px; background: #f8fafc; }
.gantt .nome { width: 230px; padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 230px; }
.gantt .linea { position: relative; }
.gantt .barra { position: absolute; top: 9px; height: 20px; border-radius: 4px; background: #dbeafe; overflow: hidden; }
.gantt .barra span { display: block; height: 100%; background: var(--inchiostro); }
.gantt .barra.ritardo { outline: 2px solid var(--rosso); }
.gantt .oggi-linea { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--giallo-scuro); z-index: 2; }
.gantt .mesi { position: relative; height: 26px; }
.gantt .mesi span { position: absolute; top: 4px; font-size: .78rem; color: var(--tenue); border-left: 1px solid var(--linea); padding-left: 4px; }
/* bacheca */
.nota { display: flex; gap: 12px; padding: 14px 18px; border-bottom: 1px solid #f1f5f9; }
.nota .avatar { width: 34px; height: 34px; flex: none; }
.nota .testo { white-space: pre-line; }
.nota img { max-width: 260px; border-radius: var(--r-sm); margin-top: 8px; border: 1px solid var(--linea); }
/* foglio presenze */
.presenze { border-collapse: collapse; font-size: .82rem; }
.presenze th, .presenze td { border: 1px solid #cbd5e1; padding: 4px 5px; text-align: center; min-width: 34px; }
.presenze th { background: #f8fafc; color: var(--tenue); font-weight: 600; }
.presenze td.nome { text-align: left; min-width: 160px; font-weight: 600; position: sticky; left: 0; background: #fff; }
.presenze td.fest { background: #f1f5f9; }
.presenze td.anom { background: #fffbeb; color: #92400e; font-weight: 700; }
.presenze td.tot { font-weight: 800; background: #eff6ff; }
.tab.compatta th, .tab.compatta td { padding: 8px 9px; }
.tab.compatta td.desc { max-width: 300px; }

/* ---------- assistente AI ---------- */
.ai-fab { position: fixed; right: 22px; bottom: 22px; z-index: 60; display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-radius: 30px;
  background: var(--inchiostro); color: #fff; border: 2px solid var(--giallo); font: 700 .95rem var(--font); cursor: pointer; box-shadow: 0 8px 24px rgba(30,41,59,.28); }
.ai-fab:hover { background: var(--inchiostro-2); }
.ai-aperto .ai-fab { display: none; }
#ai-pannello { position: fixed; top: 0; right: 0; bottom: 0; width: 430px; max-width: 100vw; background: #fff; border-left: 1px solid var(--linea);
  box-shadow: -12px 0 32px rgba(30,41,59,.14); z-index: 70; display: flex; flex-direction: column; transform: translateX(105%); transition: transform .18s ease; }
.ai-aperto #ai-pannello { transform: none; }
@media (min-width: 1300px) { .ai-aperto .main { margin-right: 430px; } }
.ai-testa { display: flex; align-items: center; gap: 6px; padding: 12px 14px; background: var(--inchiostro); color: #fff; }
.ai-testa strong { flex: 1; font-size: 1rem; }
.ai-testa button { background: none; border: 0; color: #cfd6e4; cursor: pointer; padding: 5px 7px; border-radius: 5px; font: 600 .82rem var(--font); }
.ai-testa button:hover { background: rgba(255,255,255,.1); color: #fff; }
#ai-messaggi { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: #f8fafc; }
.ai-msg th { white-space: nowrap; }
.ai-msg td, .ai-msg th { overflow-wrap: normal; word-break: normal; }
body.ai-aperto .cerca kbd { display: none; }
.ai-msg { max-width: 92%; padding: 10px 13px; border-radius: 12px; font-size: .92rem; line-height: 1.5; overflow-wrap: anywhere; }
.ai-user { align-self: flex-end; background: var(--inchiostro); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.ai-assistant { align-self: flex-start; background: #fff; border: 1px solid var(--linea); border-bottom-left-radius: 4px; }
.ai-assistant p { margin: 0 0 .5em; } .ai-assistant p:last-child { margin: 0; }
.ai-assistant ul, .ai-assistant ol { margin: .3em 0 .6em; padding-left: 1.3em; }
.ai-assistant .ai-h { font-weight: 700; color: var(--inchiostro); margin-top: .4em; }
.ai-assistant code { background: #f1f5f9; padding: 0 4px; border-radius: 3px; font-size: .85em; }
.ai-assistant hr { border: 0; border-top: 1px solid var(--linea); }
.ai-tab { overflow-x: auto; margin: .4em 0 .6em; }
.ai-tab table { border-collapse: collapse; font-size: .82rem; }
.ai-tab th, .ai-tab td { border: 1px solid var(--linea); padding: 4px 6px; text-align: left; }
.ai-tab th { background: #f1f5f9; }
.ai-attesa { color: var(--tenue); display: flex; align-items: center; gap: 8px; }
.ai-errore { border-color: #fca5a5; background: #fef2f2; }
#ai-suggerimenti { padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--linea); }
#ai-suggerimenti::before { content: "Prova a chiedere"; font-size: .78rem; color: var(--tenue); }
#ai-suggerimenti button { text-align: left; background: #fff; border: 1px solid var(--linea); border-radius: 8px; padding: 7px 10px; font: .86rem var(--font); color: var(--inchiostro); cursor: pointer; }
#ai-suggerimenti button:hover { border-color: var(--giallo-scuro); background: #eff6ff; }
.ai-piede { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--linea); align-items: flex-end; }
.ai-piede textarea { resize: none; min-height: 44px; max-height: 140px; }
.ai-nota { font-size: .72rem; color: var(--tenue); padding: 0 14px 10px; }
.ai-storico button { display: flex; justify-content: space-between; gap: 10px; width: 100%; text-align: left; background: #fff; border: 1px solid var(--linea); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; font: .86rem var(--font); cursor: pointer; }
.ai-storico button:hover { border-color: var(--inchiostro-2); }
.ai-storico small { color: var(--tenue); white-space: nowrap; }
.spinner { width: 16px; height: 16px; border: 2px solid #cbd5e1; border-top-color: var(--inchiostro); border-radius: 50%; display: inline-block; animation: giro .8s linear infinite; flex: none; }
@keyframes giro { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }
.ai-campo { position: relative; display: flex; gap: 8px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.ai-btn-campo { background: #fff; border: 1px solid var(--linea); color: var(--inchiostro); border-radius: 14px; padding: 2px 10px; font: 600 .78rem var(--font); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.ai-btn-campo:hover { border-color: var(--giallo-scuro); background: #eff6ff; }
.ai-menu-campo { position: absolute; top: calc(100% + 4px); left: 0; z-index: 45; background: #fff; border: 1px solid var(--linea); border-radius: 8px; box-shadow: 0 10px 26px rgba(30,41,59,.16); padding: 4px; min-width: 210px; }
.ai-menu-campo button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 5px; font: .88rem var(--font); cursor: pointer; color: var(--testo); }
.ai-menu-campo button:hover { background: var(--cemento); }
.ai-annulla { background: none; border: 0; color: var(--blu); font: .8rem var(--font); cursor: pointer; text-decoration: underline; }
.ai-errore-campo { color: var(--rosso); font-size: .8rem; }
.attesa-ai { display: flex; gap: 14px; align-items: flex-start; }
.attesa-ai .spinner { width: 26px; height: 26px; border-width: 3px; margin-top: 3px; }
.testo-letto { white-space: pre-wrap; font-size: .93rem; line-height: 1.6; max-height: 70vh; overflow-y: auto; }
.btn-ai { border-color: var(--giallo-scuro); }
.link-leggi { font-size: .82rem; margin-left: 8px; white-space: nowrap; }
@media (max-width: 860px) { .ai-fab { right: 14px; bottom: 14px; padding: 11px 15px; } }
@media print { .ai-fab, #ai-pannello, .ai-campo { display: none !important; } }

/* impostazioni AI: scelta tra Ollama e Claude */
.scelta-ai { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.opzione-ai { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--linea); border-radius: var(--r-md); cursor: pointer; background: #fff; }
.opzione-ai:has(input:checked) { border-color: var(--inchiostro); box-shadow: inset 0 0 0 1px var(--inchiostro); background: #f8fafc; }
.opzione-ai input { margin-top: 3px; width: auto; flex: none; box-shadow: none; }
.pannello[hidden]:first-child + .pannello { margin-top: 0; }
.opzione-ai small { display: block; color: var(--tenue); margin-top: 3px; line-height: 1.4; }
.stato-ollama { display: flex; gap: 8px; align-items: center; padding: 9px 12px; border-radius: var(--r-sm); font-size: .9rem; }
.stato-ollama.ok { background: #ecfdf5; color: #065f46; }
.stato-ollama.no { background: #fef2f2; color: #991b1b; }
.codice-ai { font-family: ui-monospace, Consolas, monospace; background: var(--cemento); border: 1px solid var(--linea); border-radius: 4px; padding: 6px 9px; margin: 6px 0; }
.codice-ai.inline { display: inline; padding: 1px 5px; margin: 0; }
[data-per][hidden] { display: none !important; }
@media (max-width: 700px) { .scelta-ai { grid-template-columns: 1fr; } }
