/* =====================================================================
   Orari settimanali, confronto clienti, blocchi finali
   Modulo estratto da components.css. L'ordine di caricamento conta (alcune
   regole devono stare dopo altre con la stessa specificità) ed è fissato in
   templates/_stylesheets.html: non riordinare i moduli.
   ===================================================================== */

/* ===== WEEKLY SCHEDULE ===== */
.week-nav {
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  align-items: center;
}

.week-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.3rem 0.7rem;
  border-radius: 20px;
}
.published-badge {
  background: var(--green-100);
  color: var(--green-700);
}
.draft-badge {
  background: var(--warning-bg);
  color: var(--warning-fg);
}
.sent-badge {
  background: var(--info-bg);
  color: var(--info-fg);
}
.coverage-ok {
  background: var(--success-bg);
  color: var(--success-fg);
}
.coverage-ko {
  background: var(--danger-bg);
  color: var(--danger-fg);
}

/* ─── Vista mese orari casinò: settimane impilate ─── */
.schedule-month-blocks { display: grid; gap: 1.25rem; margin-top: 1rem; }
.schedule-week-block {
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.schedule-week-outer.is-current-week > .schedule-week-block {
  border-color: var(--green-500);
  box-shadow: var(--shadow-green);
}
.schedule-week-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--border);
}
.schedule-week-title h2 { margin: 0; font-size: var(--text-lg); }
.schedule-week-title h2 small { color: var(--text-secondary); font-weight: 400; }
.schedule-week-badges { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.4rem; }
.schedule-week-badges .week-badge { font-size: 0.75rem; padding: 0.2rem 0.6rem; }
.schedule-week-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: 0.85rem; }
.schedule-week-actions > span { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.schedule-week-actions:empty { display: none; }
/* Giorni fuori dal mese visto: attenuati ma modificabili/inviabili. */
/* Giorni fuori dal mese visto: tinta attenuata (niente opacity: i testi
   devono restare sopra la soglia di contrasto WCAG AA). */
.schedule-table th.is-outer,
.schedule-table td.is-outer { background: var(--surface-alt); }
@media (max-width: 700px) {
  .schedule-week-block { padding: 0.85rem; }
}

.week-status-bar {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  padding: 0.5rem 0.75rem;
  background: var(--green-50);
  border-radius: 6px;
}

.schedule-table-wrap {
  overflow-x: auto;
  margin-bottom: 1rem;
}

.schedule-table {
  border: 1px solid var(--gray-300);
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 10px;
  min-width: 900px;
  font-size: 0.85rem;
}
/* NB: qui NON si usa overflow: hidden. Servirebbe solo ad arrotondare gli
   angoli, ma su una tabella disattiva position: sticky e la colonna fissa
   "Dipendente" sparirebbe scorrendo a destra (sembrava una riga al centro).
   Gli angoli si arrotondano sulle celle d'angolo. */
.schedule-table thead th:first-child { border-top-left-radius: 9px; }
.schedule-table thead th:last-child { border-top-right-radius: 9px; }
.schedule-table tbody tr:last-child td:first-child { border-bottom-left-radius: 9px; }
.schedule-table tbody tr:last-child td:last-child { border-bottom-right-radius: 9px; }

.schedule-table th,
.schedule-table td {
  border-right: 1px solid var(--gray-200);
  border-bottom: 1px solid var(--gray-200);
  padding: 0.55rem 0.5rem;
  text-align: center;
  min-width: 90px;
  white-space: nowrap;
  vertical-align: middle;
}

.schedule-table th {
  border-bottom-color: var(--green-200);
  background: color-mix(in srgb, var(--green-50) 70%, var(--surface));
  color: var(--green-800);
  font-weight: 600;
  font-size: 0.8rem;
}

.schedule-table th:last-child,
.schedule-table td:last-child { border-right: 0; }

.schedule-table tbody tr:last-child td { border-bottom: 0; }

/* La colonna di oggi è esclusa da zebra e hover (come le festività) perché
   altrimenti le regole, più specifiche, ne cancellerebbero lo sfondo. */
.schedule-table tbody tr:nth-child(even):not(.oncall-row) td:not(.holiday):not(.today) { background: color-mix(in srgb, var(--green-50) 32%, var(--surface)); }
.schedule-table tbody tr:hover:not(.oncall-row) td:not(.holiday):not(.today) { background: var(--green-50); }

.schedule-table .sticky-col {
  position: sticky;
  left: 0;
  z-index: var(--z-raised-2);
  background: color-mix(in srgb, var(--green-50) 48%, var(--surface));
  color: var(--green-800);
  min-width: 100px;
  text-align: left;
  padding-left: 0.75rem;
  border-right: 2px solid var(--green-200);
}

.schedule-table thead .sticky-col {
  z-index: var(--z-raised-3);
  background: color-mix(in srgb, var(--green-100) 72%, var(--surface));
}

.schedule-table .holiday {
  background: var(--amber-200);
  color: var(--amber-800);
  font-weight: 700;
}

/* Giorno corrente: sfondo coerente su intestazione e celle; la barra blu
   segna la colonna solo sull'intestazione, senza ripetersi su ogni cella. */
.schedule-table .today {
  background: var(--info-bg);
  color: var(--info-fg);
  font-weight: 700;
}

.schedule-table thead th.today,
.schedule-table tbody td.today {
  background: var(--info-bg);
  color: var(--info-fg);
}

.schedule-table thead th.today {
  box-shadow: inset 0 3px 0 var(--blue-500);
}

.schedule-table tbody tr:nth-child(even):not(.oncall-row) .sticky-col,
.schedule-table tbody tr:hover:not(.oncall-row) .sticky-col { background: color-mix(in srgb, var(--green-100) 54%, var(--surface)); }
.schedule-table .holiday.today {
  background: var(--amber-200);
  color: var(--amber-800);
}

/* Se oggi è anche festivo, la barra dell'intestazione resta ambra. */
.schedule-table thead th.holiday.today {
  box-shadow: inset 0 3px 0 var(--amber-600);
}

.schedule-table .emp-sigla {
  font-size: 0.9rem;
}

.schedule-table .oncall-row td {
  border-top: 2px solid var(--amber-200);
  background: color-mix(in srgb, var(--amber-100) 65%, var(--surface));
  color: var(--amber-700);
  font-weight: 700;
}
.schedule-table .oncall-row .sticky-col {
  background: color-mix(in srgb, var(--amber-100) 82%, var(--surface));
  color: var(--amber-700);
}
.schedule-table .oncall-row .holiday { background: var(--amber-200); color: var(--amber-800); }
[data-theme="dark"] .schedule-table .holiday,
[data-theme="dark"] .schedule-table .holiday select,
[data-theme="dark"] .schedule-table .holiday input,
[data-theme="dark"] .schedule-table .holiday .shift-display {
  color: #1c1917;
}
[data-theme="dark"] .schedule-table .holiday select,
[data-theme="dark"] .schedule-table .holiday input {
  background: var(--amber-200);
  border-color: var(--amber-600);
  color-scheme: light;
}
[data-theme="dark"] .schedule-table .holiday select option { color: #1c1917; background: #fff; }
/* In modalità scura le celle editabili (fase bozza) usano testo bianco e menu nativi scuri. */
[data-theme="dark"] .schedule-table .shift-select,
[data-theme="dark"] .schedule-table .oncall-select,
[data-theme="dark"] .schedule-table .custom-shift-inputs input {
  color: #ffffff;
  color-scheme: dark;
}
.schedule-dirty-status { display: inline-flex; align-items: center; gap: .35rem; margin-top: .6rem; color: var(--warning-fg); font-size: var(--text-sm); font-weight: 700; }
.schedule-dirty-status .icon-xs { fill: currentColor; }

.shift-select,
.oncall-select {
  width: 100%;
  min-width: 70px;
  font-size: 0.8rem;
  padding: 0.2rem 0.15rem;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}
.shift-select:focus,
.oncall-select:focus { position: relative; z-index: var(--z-raised-1); border-color: var(--green-500); box-shadow: 0 0 0 3px rgb(16 185 129 / 15%); }
.oncall-select { border-color: var(--amber-300); background: color-mix(in srgb, var(--amber-50) 70%, var(--surface)); color: var(--amber-700); font-weight: 700; }

.shift-display {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
}

.custom-shift-inputs input {
  font-size: 0.75rem;
}

/* Legend */
.schedule-legend {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 0.85rem;
}

.schedule-legend h3 {
  font-size: 0.75rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* NB: la legenda turni non e' piu' una tabella (.legend-table rimosso):
   ora e' un elenco compatto (.legend-list) definito in operations.css,
   leggibile anche su telefono. */

/* =====================================================================
   CONTENITORI DEI MESSAGGI

   Lo stile del messaggio in se' (classe `.flash`, definita in
   components-ui.css) e' lo stesso per tutta l'app. Qui c'e' solo quello che
   riguarda i contenitori di questa pagina.

   NB: `.schedule-alerts` nasce nascosto (`.hidden-initial`) e showAlert lo
   scopre mettendo `style.display = 'block'`; per questo NON si usa un flex,
   che verrebbe sovrascritto e mescolerebbe le due responsabilita'.
   ===================================================================== */
.schedule-alerts.flash { margin: 0 0 1rem; }
.schedule-delivery.flash { margin: 0; }
/* Pulsanti "È in programma" per le sovrapposizioni da confermare. */
.schedule-overlap-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }

.btn-link {
  background: none;
  border: none;
  color: var(--blue-600);
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0;
}

.btn-link:hover {
  color: var(--blue-800);
}

.day-name {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.day-num {
  display: block;
  font-size: 1rem;
  font-weight: 700;
}
/* Monthly styles estratti in monthly.css — importato da style.css (AGENTS.md CSS modulare) */
.cal-event-resolved {
    opacity: 0.62;
    text-decoration: line-through;
}

.note-modal-actions {
    display: flex;
    gap: 0.5rem;
    margin-right: auto;
}

.calendar-day-cell--selectable {
  cursor: pointer;
}

/* Shared secretary Kanban: columns are work surfaces, not fixed status buckets. */
.kanban-category-form {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
  padding: 0.7rem;
  border: 1px solid var(--green-200);
  border-radius: var(--radius-md);
  background: var(--green-50);
}
.kanban-category-form input[type="text"] { min-width: min(100%, 15rem); }
.kanban-category-form input[type="color"] { width: 2.5rem; min-height: 2.5rem; padding: 0.15rem; }
.kanban-category-move { display: inline-flex; align-items: center; gap: 0.45rem; color: var(--text-secondary); font-size: var(--text-sm); }
.kanban-board {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  overflow-x: auto;
  padding: 0.25rem 0.1rem 1rem;
  scroll-snap-type: x proximity;
}
.kanban-column {
  flex: 0 0 min(20rem, 84vw);
  min-height: 29rem;
  border: 1px solid var(--gray-200);
  border-top: 4px solid var(--column-color);
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  scroll-snap-align: start;
}
.kanban-column-header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .7rem .7rem .55rem; }
.kanban-column-color { width: .65rem; height: .65rem; border-radius: 50%; background: var(--column-color); }
.kanban-column-actions { display: inline-flex; gap: .2rem; }
.kanban-note-list { display: grid; align-content: start; gap: .55rem; min-height: 22rem; padding: .2rem .55rem .65rem; }
.kanban-note-card { cursor: grab; background: var(--surface); }
.kanban-note-card:active { cursor: grabbing; }
.kanban-column:has(.kanban-note-card[draggable="true"]:hover) { box-shadow: var(--shadow); }
@media (max-width: 768px) {
  .kanban-board { gap: .65rem; }
  .kanban-column { flex-basis: min(18rem, 88vw); }
  .kanban-category-form { align-items: stretch; }
  .kanban-category-form input[type="text"], .kanban-category-form select { width: 100%; }
}

/* ===== CLIENT MERGE ===== */
.client-merge-progress { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; font-size: var(--text-sm); color: var(--text-secondary); }
.merge-progress-bar { flex: 1; height: 8px; border-radius: 999px; background: var(--gray-200); overflow: hidden; }
.merge-progress-fill { height: 100%; width: 0; background: var(--green-500); transition: width 0.3s ease; }
.merge-card { border: 1px solid var(--gray-200); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.merge-card-header { display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem 1rem; background: var(--gray-50); border-bottom: 1px solid var(--gray-200); flex-wrap: wrap; }
.merge-compare { display: grid; grid-template-columns: 1fr auto 1fr; gap: 0; }
.merge-side { padding: 1rem; }
.merge-side h3 { display: flex; align-items: center; gap: 0.4rem; margin: 0 0 0.5rem; font-size: var(--text-sm); font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em; }
/* I token --rose-50 e --rose-700 non esistono: il riquadro di origine del
   confronto clienti restava senza colore. Uso la coppia che il resto del
   foglio usa gia' (fondo chiaro, testo scuro), che funziona in entrambi i temi. */
.merge-source h3 { color: var(--rose-800); }
.merge-target h3 { color: var(--green-700); }
.merge-source { background: var(--rose-100); border-right: 1px solid var(--gray-200); }
.merge-target { background: var(--green-50); }
.merge-arrow { display: flex; align-items: center; justify-content: center; padding: 0 0.5rem; background: var(--surface); color: var(--gray-400); }
.merge-name { margin: 0 0 0.6rem; font-weight: 800; font-size: var(--text-base); color: var(--text); overflow-wrap: anywhere; }
.merge-details { display: grid; grid-template-columns: 90px 1fr; gap: 0.25rem 0.6rem; margin: 0; font-size: var(--text-sm); }
.merge-details dt { color: var(--text-secondary); font-weight: 600; }
.merge-details dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.merge-actions { display: flex; align-items: center; gap: 0.6rem; padding: 0.8rem 1rem; border-top: 1px solid var(--gray-200); background: var(--surface); flex-wrap: wrap; }
.merge-result { font-size: var(--text-sm); font-weight: 600; }
.merge-result.is-success { color: var(--green-700); }
.merge-result.is-error { color: var(--rose-800); }
.merge-nav { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin-top: 1rem; }
@media (max-width: 768px) {
  .merge-compare { grid-template-columns: 1fr; }
  .merge-source { border-right: 0; border-bottom: 1px solid var(--gray-200); }
  .merge-arrow { display: none; }
}

/* ===== SOSTITUTI DEGLI STILI INLINE =====
   La CSP dell'app blocca gli attributi style (style-src-attr 'none'):
   queste classi coprono i casi che prima erano inline e quindi ignorati.
   I colori dinamici (categorie, livelli) arrivano via data-* + base.js. */

/* Titolo con icona affiancata (storico, materiali) */
.history-title { display: flex; align-items: center; gap: 0.55rem; }
/* L'header storico spinge le azioni a destra e va a capo su schermi stretti */
.history-header { flex-wrap: wrap; }
.history-header > :first-child { flex: 1 1 auto; }
/* Form compatti nei pannelli materiale */
.form-group-compact { margin: 0; }
/* Riepilogo cliccabile del pannello materiale */
.job-material-heading { cursor: pointer; list-style: none; }
.job-material-grid { display: grid; gap: 0.75rem; }
.disclosure-arrow { font-size: 0.8rem; color: var(--text-secondary); }
/* Celle speciali delle tabelle */
.cell-center { text-align: center; }
.cell-strong { font-weight: 600; }
.desc-ellipsis { max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Modale esportazione Obsidian */
.obsidian-list { display: grid; gap: 0.5rem; max-height: 320px; overflow-y: auto; }
.obsidian-row { display: flex; gap: 0.6rem; align-items: center; padding: 0.6rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.obsidian-row-check { accent-color: var(--green-600); }
.obsidian-row-title { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.obsidian-row-desc { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-secondary); }
.obsidian-row-file { color: var(--text-tertiary); font-family: monospace; font-size: 0.7rem; }
@media (max-width: 600px) {
  /* Su telefono ogni riga occupa lo schermo: evita che i pulsanti facciano
     scorrere orizzontalmente il testo del lavoro fuori dal modale. */
  .obsidian-row { align-items: stretch; flex-wrap: wrap; }
  .obsidian-row > .flex-1-min0 { flex: 1 1 calc(100% - 2.5rem); min-width: 0; }
  .obsidian-row > .btn-primary, .obsidian-row > .btn-secondary { flex: 1 1 0; min-width: 0; }
  .obsidian-row-title, .obsidian-row-desc { white-space: normal; overflow: visible; text-overflow: clip; }
}
.obsidian-row-open { display: block; color: var(--warning-fg); font-weight: 700; }
.obsidian-actions { margin-top: 0.75rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }
/* Report stampabile */
.report-notes-cell { white-space: pre-wrap; word-break: break-word; background: var(--gray-50); }
.report-linked-head { background: var(--gray-100); color: var(--text); text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.72rem; }
/* Wiki */
.wiki-page-actions { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.wiki-back-nav { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); display: flex; justify-content: center; }
.wiki-related { margin-top: 1.5rem; }
.wiki-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--green-600); }
/* Toast statico nei form (non flottante) */
.toast-static { position: static; max-width: none; margin-bottom: 1rem; }
/* Anteprima report di prova */
.report-preview-box { min-height: 120px; border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem; background: var(--surface-alt); }
/* Contatore pill su sfondo brand */
.count-pill-info { background: var(--blue-600); color: #fff; }

/* =====================================================================
   INTESTAZIONE A DUE PIANI (console operativa)
   PIANO 1 = chi sei e cosa puoi fare adesso: logo, ricerca, report, profilo.
             Tre soli elementi, niente elenco: la riga resta calma.
   PIANO 2 = le sezioni dell'app, a tutta larghezza. Qui non c'è competizione
             con la ricerca, quindi nove voci con icona e nome restano
             leggibili senza stringersi.

   Le regole stanno in fondo al file e valgono su quelle iniziali perché hanno
   la stessa specificità: niente !important.
   ===================================================================== */
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-height: var(--topbar-plane1-h);
  padding: 0.3rem max(1.25rem, env(safe-area-inset-right)) 0.3rem max(1.25rem, env(safe-area-inset-left));
}
.topbar-logo { width: 38px; height: 38px; }
.topbar-title { font-size: var(--text-base); }
.topbar-brand { flex: 0 0 auto; }
.topbar-user { flex: 0 0 auto; }

/* La ricerca sta al centro e cresce fino a una larghezza comoda: con il logo
   e il profilo ai lati, `margin: auto` la centra nello spazio che resta. */
.topbar-search { flex: 1 1 auto; max-width: 26rem; margin: 0 auto; }

/* I tre pulsanti del report sono azioni, non sezioni: stanno accanto al
   profilo. Il verde pieno è solo l'invio del report giornaliero. */
.topbar-inner .report-bar { border-left: 0; padding-left: 0; gap: 0.4rem; }
.topbar-inner .report-pill { min-height: 32px; padding: 0.25rem 0.7rem; }
.topbar-inner .report-pill .topbar-action-icon { width: 16px; height: 16px; }

/* PIANO 2: la riga delle sezioni. Sfondo un filo più scuro del piano 1 cosi
   i due piani si distinguono, e i bordi sono contenuti per non far salire
   l'intestazione. */
.topbar-nav {
  position: relative;
  display: flex;
  justify-content: safe center;
  min-height: var(--topbar-sections-h);
  padding: 0.1rem max(1rem, env(safe-area-inset-right)) 0.1rem max(1rem, env(safe-area-inset-left));
  background: rgba(4, 55, 40, 0.3);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.nav-sections { display: flex; flex-wrap: nowrap; gap: 0.15rem; min-width: 0; }

/* Ogni sezione è un pulsante basso con icona e nome affiancati. La riga è a
   tutta larghezza, quindi lo spazio c'è: l'icona aiuta a riconoscere la
   sezione senza leggerne il nome. */
.section-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 36px;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-control);
  color: rgba(255, 255, 255, 0.82);
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.section-link:hover { color: #fff; background: rgba(255, 255, 255, 0.12); }
.section-link.active { color: #fff; background: rgba(255, 255, 255, 0.18); }
.section-icon { display: inline-flex; align-items: center; justify-content: center; }
.section-icon .nav-icon { width: 17px; height: 17px; }
.section-name { line-height: 1; }

/* La sezione attiva si distingue anche senza colore: una barra sotto il nome. */
.section-link { position: relative; }
.section-link.active::after {
  content: '';
  position: absolute;
  left: 0.7rem;
  right: 0.7rem;
  bottom: 0.1rem;
  height: 2px;
  border-radius: 2px;
  background: var(--green-300, #6ee7b7);
}

/* Il bottone a tre linee serve solo quando le nove voci non ci stanno: sotto
   i 1280px. Su schermi larghi la riga e' a tutta larghezza e le sezioni si
   vedono tutte, quindi il bottone sparisce. */
.hamburger-toggle { display: none; }

/* Finestre medie (769-1279px): nove voci non ci stanno con l'icona, quindi il
   menu si ripiega dietro le tre linee. Il piano 1 resta basso e completo. */
@media (min-width: 769px) and (max-width: 1279px) {
  .nav-sections { display: none; }
  .topbar-nav .hamburger-toggle { display: flex; }
  .hamburger-toggle {
    position: absolute;
    right: max(1.25rem, env(safe-area-inset-right));
    top: 50%;
    translate: 0 -50%;
    margin-left: 0;
  }
  /* Il pannello del menu è ancorato al pulsante e scende sopra la pagina. */
  .nav-sections.is-open {
    display: flex;
    position: absolute;
    top: calc(100% + 0.4rem);
    right: max(1.25rem, env(safe-area-inset-right));
    flex-direction: column;
    min-width: 16rem;
    max-height: calc(100vh - 8rem);
    padding: 0.35rem;
    border-radius: var(--radius-md);
    background: var(--topbar-end);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
    z-index: var(--z-menu);
  }
  .nav-sections.is-open .section-link {
    min-height: 44px;
    padding: 0.5rem 0.7rem;
    justify-content: flex-start;
    font-size: var(--text-base);
  }
  .nav-sections.is-open .section-link::after { display: none; }
}

/* Portatili 1280-1500: stringono profilo e ricerca. Si nasconde il nome utente
   (restano le icone) e si accorcia la ricerca: meglio due elementi in meno
   che una lista di voci da scorrere. */
@media (min-width: 1280px) and (max-width: 1500px) {
  .topbar-user-name { display: none; }
  .topbar-search { max-width: 15rem; }
  .section-link { padding: 0.35rem 0.5rem; font-size: var(--text-xs); }
  .section-icon .nav-icon { width: 16px; height: 16px; }
}

@media (max-width: 768px) {
  /* Sotto i 769px la navigazione è la barra in basso: il piano 2 sparisce
     e l'intestazione scende a una sola riga (il report resta nel piano 1,
     come icona). */
  .topbar-nav { display: none; }
  /* Su telefono il report giornaliero tiene il nome ("Report"): è l'azione
     della giornata e non deve essere un'icona da indovinare. Test report e
     Obsidian diventano icone sole (il nome lo dichiarano aria-label), perché
     nell'intestazione a una riga non c'è posto per tre etichette. */
  .topbar-inner .report-desktop-label { display: none; }
  .topbar-inner .report-mobile-label { display: inline; }
  .topbar-inner .report-pill { min-height: 40px; padding: 0.4rem 0.6rem; }
  .topbar-inner .report-pill-self,
  .topbar-inner .report-pill-obsidian { padding: 0.4rem 0.55rem; }
  /* Tema ed Esci non ci stanno con report, notifiche e impostazioni: sono
     gia' nel foglio "Altro", quindi non si perde nulla. */
  .topbar-user [data-theme-toggle], .topbar-logout { display: none; }
}

/* =====================================================================
   STORICO: tabella a 12 colonne leggibile
   - due livelli di intestazione (gruppi + intestazioni brevi con title);
   - selettore "Colonne" per nascondere Materiale e Fatturato;
   - cifre tabulari ereditate da utilities.css.

   Posizione della seconda riga di intestazione: `1.55rem` è l'altezza della
   riga dei gruppi. Lo stesso numero sta in operations.css, dove la prima
   riga lo dichiara con `height`. Se cambia uno dei due, si rompe la
   continuità dello sticky e va cambiato anche l'altro.
   ===================================================================== */
.history-table thead tr:not(.history-group-row) th { top: 1.55rem; }
.history-table .history-group {
  padding: 0.2rem 0.4rem;
  border-bottom: 1px solid var(--green-200);
  background: color-mix(in srgb, var(--green-100) 55%, var(--surface));
  color: var(--green-800);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  text-align: center;
  white-space: nowrap;
}
.history-table .history-col-check[rowspan] { vertical-align: middle; }
/* Con table-layout: fixed le larghezze le decide la PRIMA riga: la riga dei
   gruppi porta quindi le percentuali, somma esatta delle colonne che copre
   (9+24+6 | 12+5+7+6 | 12+5+9+5 = 39 | 30 | 31 = 100). */
.history-table .history-col-check[rowspan] { width: 2.25rem; }
.history-table .history-group-job { width: 39%; }
.history-table .history-group-usage { width: 30%; }
.history-table .history-group-extra { width: 31%; }
/* Se una colonna viene nascosta, la fascia del suo gruppo si restringe con lei
   e le fasce restano allineate alle colonne visibili. */
.history-table.is-without-fatturato .history-group-extra { width: 26%; }
.history-table.is-without-material .history-group-extra { width: 22%; }
.history-table.is-without-material.is-without-fatturato .history-group-extra { width: 17%; }

/* Selettore colonne: stesso linguaggio dei filtri, si apre e si chiude. */
.history-columns-picker { position: relative; }
.history-columns-picker > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.1rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 700;
  list-style: none;
  white-space: nowrap;
}
.history-columns-picker > summary::-webkit-details-marker { display: none; }
.history-columns-list {
  position: absolute;
  z-index: var(--z-sticky-column);
  top: calc(100% + 0.35rem);
  right: 0;
  display: grid;
  gap: 0.35rem;
  min-width: 12rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.history-columns-list label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: var(--text-sm);
  cursor: pointer;
}
.history-columns-list input[type="checkbox"] { accent-color: var(--green-600); }

/* Colonne nascoste: la tabella si restringe e le altre riprendono spazio. */
.history-table.is-without-material { min-width: 1080px; }
.history-table.is-without-fatturato { min-width: 1060px; }
.history-table.is-without-material.is-without-fatturato { min-width: 980px; }
.history-table.is-without-material th.history-col-material,
.history-table.is-without-material td.history-col-material,
.history-table.is-without-fatturato th.history-col-fatturato,
.history-table.is-without-fatturato td.history-col-fatturato { display: none; }
