/* Operativita: pattern condivisi per le pagine con dati, ricerca e knowledge base. */
.btn-link-reset { align-items: center; display: inline-flex; text-decoration: none; }
.interactive-row { cursor: pointer; }
.wiki-page-name { color: var(--green-800); font-weight: 700; }
.muted-value { color: var(--gray-400); }

.wiki-page-header,
.wiki-page-actions,
.wiki-page-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.wiki-page-header {
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 3px solid var(--green-200);
}
.wiki-page-title,
.wiki-editor-title {
  margin: 0;
  color: var(--green-800);
  font-size: var(--text-xl);
  font-weight: 700;
}
.wiki-page-meta { margin-top: 0.35rem; color: var(--text-secondary); font-size: var(--text-xs); }
.wiki-page-meta a { color: var(--green-700); font-weight: 700; }
.wiki-page-content { color: var(--text); font-size: var(--text-sm); line-height: 1.7; }
.wiki-danger-zone { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.wiki-editor-title { margin-bottom: 1.5rem; padding-bottom: 0.75rem; border-bottom: 3px solid var(--green-200); }
.wiki-html-editor { min-height: 350px; }
.wiki-editor-actions { margin-top: 1rem; }

.search-form { display: flex; gap: 0.5rem; max-width: 36rem; }
.search-form input { flex: 1; }
.search-summary { margin: 0.75rem 0 1rem; color: var(--text-secondary); font-size: var(--text-sm); line-height: 1.5; }
.search-summary strong { color: var(--text); }
.search-result-table { width: 100%; }
.search-result-table td { vertical-align: middle; }
.search-result-link { color: inherit; text-decoration: none; }
.search-result-link:hover { color: var(--green-700); text-decoration: underline; }
.history-open-button { padding: 0; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.history-open-button:hover { color: var(--green-700); text-decoration: underline; }
.search-client-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.search-client-list .job-client { padding: 0.35rem 0.75rem; font-size: var(--text-sm); text-decoration: none; }

/* Storico: layout a 11 colonne, descrizione/operazioni/note protagoniste.
   Mantiene fixed per allineare sticky-col ed evitare salti. */
.history-table { table-layout: fixed; min-width: 1150px; }
/* Celle piu' strette ai lati: con 12 colonne ogni pixel serve per non tagliare i titoli. */
.history-table th, .history-table td { padding-inline: 0.5rem; }

/* Le due righe di intestazione devono combaciare: la riga dei gruppi ha
   un'altezza dichiarata e la seconda si attacca esattamente sotto (lo sticky
   di ognuna usa lo stesso numero). Senza, durante lo scorrimento si apriva
   una fessura fra i due livelli e le righe ci passavano in mezzo. */
.history-table thead .history-group-row th { top: 0; height: 1.55rem; }
.history-table thead tr:not(.history-group-row) th { top: 1.55rem; }

/* L'angolo in alto a sinistra lo arrotonda solo la prima cella vera (la
   casella di selezione, che occupa le due righe): ripeterlo sulla colonna
   Cliente della riga sotto creava lo scalino. Stesso discorso a destra. */
.history-table thead tr:not(.history-group-row) th:first-child,
.history-table thead tr:not(.history-group-row) th:last-child { border-radius: 0; }

.history-table th.history-col-client, .history-table td.history-col-client { width: 9%; }
.history-table th.history-col-desc, .history-table td.history-col-desc { width: 24%; }
.history-table th.history-col-assigned, .history-table td.history-col-assigned { width: 6%; }
.history-table th.history-col-operations, .history-table td.history-col-operations { width: 12%; }
.history-table th.history-col-time, .history-table td.history-col-time { width: 5%; }
.history-table th.history-col-date, .history-table td.history-col-date { width: 7%; }
.history-table th.history-col-exec, .history-table td.history-col-exec { width: 6%; }
.history-table th.history-col-note, .history-table td.history-col-note { width: 12%; }
.history-table th.history-col-fatturato, .history-table td.history-col-fatturato { width: 5%; text-align: center; }
.history-table th.history-col-material, .history-table td.history-col-material { width: 9%; text-align: center; }
.history-table th.history-col-actions, .history-table td.history-col-actions { width: 5%; }

/* Allineamento delle colonne: intestazione e celle devono guardare nello
   stesso verso, altrimenti l'occhio non collega il titolo al dato.
   - testo (cliente, descrizione, operazioni, note) a sinistra;
   - sigle brevi e badge al centro;
   - cifre (tempo, data) a destra, con le cifre tabulari già attive.
   I selettori hanno due classi, quindi vincono sul `cell-numeric` a destra
   che l'intestazione porta dalle regole generiche della tabella. */
.history-table .history-col-client,
.history-table .history-col-desc,
.history-table .history-col-operations,
.history-table .history-col-note { text-align: left; }

.history-table .history-col-assigned,
.history-table .history-col-exec,
.history-table .history-col-fatturato,
.history-table .history-col-material,
.history-table .history-col-actions { text-align: center; }

.history-table .history-col-time,
.history-table .history-col-date { text-align: right; }

.history-table .history-col-assigned {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Tutte le celle al centro della riga: prima Cliente e Note erano in alto e il resto al centro, e le righe sembravano sfalsate. */
.history-table td { vertical-align: middle; }
.history-table .history-note-cell {
  max-width: none;
  color: var(--gray-700);
  font-size: var(--text-sm);
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.history-table .history-open-button {
  display: -webkit-box;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: normal;
}
.history-table .history-note-button { text-align: left; }

@media (max-width: 768px) {
  /* Su mobile la riga diventa una scheda: niente tabella da trascinare. */
  .history-table.mobile-card-table { min-width: 0; }
  .history-table.mobile-card-table tbody tr td { width: 100%; }
  .history-table.mobile-card-table .sticky-col {
    position: static;
    border-right: 0;
  }
  .history-table.mobile-card-table td:nth-child(2),
  .history-table.mobile-card-table td.history-col-note { vertical-align: middle; }
  .history-table.mobile-card-table .history-col-assigned,
  .history-table.mobile-card-table .history-col-time,
  .history-table.mobile-card-table .history-col-date { text-align: left; }
  .history-table.mobile-card-table .history-open-button { -webkit-line-clamp: 4; }
}

.search-result-table mark,
.search-wiki-list mark,
.search-notes-list mark,
.search-client-list mark { background: var(--amber-100); color: var(--amber-700); border-radius: 2px; padding: 0 0.15rem; font-weight: 700; }
[data-theme="dark"] .search-result-table mark,
[data-theme="dark"] .search-wiki-list mark,
[data-theme="dark"] .search-notes-list mark,
[data-theme="dark"] .search-client-list mark { background: var(--amber-300); color: var(--gray-900); }
.search-wiki-list,
.search-notes-list { display: grid; gap: 0.6rem; }
.search-wiki-list .history-item,
.search-notes-list .history-item { border-left: 4px solid var(--green-500); transition: all 0.15s; }
.search-wiki-list .history-item:hover,
.search-notes-list .history-item:hover { border-left-color: var(--green-600); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.search-notes-list .history-item { border-left-color: var(--blue-600); }

.client-jobs-actions { display: flex; justify-content: flex-end; margin-top: -1.25rem; margin-bottom: 0.75rem; }
.client-job-link { color: inherit; font-weight: 650; text-decoration: none; }
.client-job-link:hover { color: var(--green-700); text-decoration: underline; }
.client-job-deadline { color: var(--text-secondary); font-size: var(--text-xs); }
.client-job-deadline.is-overdue { color: var(--danger-fg); font-weight: 700; }

.sigla-toolbar { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.sigla-toolbar-copy { max-width: 42rem; color: var(--text-secondary); font-size: var(--text-sm); line-height: 1.5; }
.sigla-search { min-width: min(100%, 17rem); }
.sigla-summary { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.sigla-summary-item { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.4rem 0.65rem; border: 1px solid var(--border); border-radius: var(--radius-full); background: var(--surface-alt); color: var(--text); font-size: var(--text-xs); font-weight: 700; }
.sigla-summary-item::before { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--gray-400); content: ''; }
.sigla-summary-item.is-aligned::before { background: var(--green-500); }
.sigla-summary-item.is-mismatch::before { background: var(--rose-500); }
.sigla-summary-item.is-excluded::before { background: var(--gray-400); }
.sigla-help { margin: 0 0 1rem; color: var(--text-secondary); font-size: var(--text-xs); }
.sigla-form-fields { min-width: 0; margin: 0; padding: 0; border: 0; }
.sigla-client-row.is-changed { box-shadow: inset 4px 0 var(--amber-500); }
.sigla-client-row.is-hidden { display: none; }
.sigla-change-label { display: none; color: var(--amber-700); font-size: var(--text-xs); font-weight: 800; }
.sigla-client-row.is-changed .sigla-change-label { display: inline; }
.sigla-cell-ok { box-shadow: inset 0 0 0 1px var(--success-border); }
.sigla-cell-mismatch { box-shadow: inset 0 0 0 1px var(--danger-border); }
.sigla-state-label { display: block; margin-top: 0.3rem; font-size: 0.63rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; }
.sigla-cell-ok .sigla-state-label { color: var(--success-fg); }
.sigla-cell-mismatch .sigla-state-label { color: var(--danger-fg); }
.sigla-cell-excluded .sigla-state-label { color: var(--text-secondary); }
.sigla-product-control { display: flex; flex-direction: column; gap: 0.2rem; }
.sigla-exclude-control { display: flex; align-items: center; gap: 0.25rem; color: var(--text-secondary); font-size: 0.65rem; cursor: pointer; }
.sigla-exclude-control input[type="checkbox"] { width: 0.8rem; height: 0.8rem; accent-color: var(--green-600); }
.sigla-mod-gp-cell { text-align: center; }
.sigla-empty-cell { padding: 2rem; color: var(--text-secondary); font-style: italic; text-align: center; }
.sigla-save-actions { margin-top: 1rem; }

/* ── Monitoraggio automatico delle versioni (services/sigla_monitor.py) ──
   Nota sui colori del testo: dentro questi riquadri lo sfondo e' leggermente
   grigio (--surface-alt), quindi --text-secondary non raggiunge il contrasto
   minimo richiesto (4.5:1) e le prove di accessibilita' lo segnalavano. Qui si
   usa --gray-600, che sul chiaro e' piu' scuro di --text-secondary e sul
   tema scuro e' comunque chiaro: in entrambi i temi sta sopra la soglia. */
.sigla-monitor { margin: 0 0 1.5rem; padding: 1rem 1.1rem; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-alt); }
.sigla-monitor__head { display: flex; flex-wrap: wrap; align-items: start; justify-content: space-between; gap: 0.75rem; }
.sigla-monitor__title { display: flex; align-items: center; gap: 0.4rem; margin: 0 0 0.35rem; font-size: var(--text-base); font-weight: 700; color: var(--text); }
.sigla-monitor__copy { max-width: 46rem; margin: 0; color: var(--gray-600); font-size: var(--text-sm); line-height: 1.5; }
.sigla-monitor__esito { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; margin: 0.75rem 0 0; color: var(--gray-600); font-size: var(--text-xs); }
.sigla-monitor__problemi { display: grid; gap: 0.3rem; margin: 0.6rem 0 0; padding: 0.6rem 0.75rem 0.6rem 1.6rem; border: 1px solid var(--warning-border); border-radius: var(--radius-sm); background: var(--surface); color: var(--warning-fg); font-size: var(--text-xs); line-height: 1.45; }

/* ── Proposte in attesa di una decisione ── */
.sigla-proposte { margin: 0 0 1.5rem; padding: 1rem 1.1rem; border: 1px solid var(--success-border); border-radius: var(--radius-md); background: var(--surface); }
.sigla-proposte__title { display: flex; align-items: center; gap: 0.4rem; margin: 0 0 0.75rem; font-size: var(--text-base); font-weight: 700; color: var(--text); }
.sigla-proposte__lista { display: grid; gap: 0.6rem; margin: 0; padding: 0; list-style: none; }
.sigla-proposta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.7rem 0.8rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-alt); }
.sigla-proposta__testo { display: grid; gap: 0.15rem; min-width: 0; }
.sigla-proposta__prodotto { color: var(--text); font-size: var(--text-sm); }
.sigla-proposta__versione { color: var(--success-fg); font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace; font-size: var(--text-base); font-weight: 700; }
.sigla-proposta__data, .sigla-proposta__fonte { color: var(--gray-600); font-size: var(--text-xs); }
.sigla-proposta__azioni { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.sigla-proposte__nota { margin: 0.75rem 0 0; color: var(--gray-600); font-size: var(--text-xs); line-height: 1.5; }

/* ── Interruttore di aggiornamento automatico per prodotto ── */
.sigla-auto { margin: 0 0 1.5rem; padding: 1rem 1.1rem; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.sigla-auto__title { display: flex; align-items: center; gap: 0.4rem; margin: 0 0 0.75rem; font-size: var(--text-base); font-weight: 700; color: var(--text); }
.sigla-auto__lista { display: grid; gap: 0.4rem; margin: 0; padding: 0; list-style: none; }
.sigla-auto__riga { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; }
.sigla-auto__etichetta { display: inline-flex; align-items: center; gap: 0.45rem; cursor: pointer; }
.sigla-auto__etichetta input[type="checkbox"] { width: 1rem; height: 1rem; accent-color: var(--green-600); cursor: pointer; }
.sigla-auto__nome { color: var(--text); font-size: var(--text-sm); font-weight: 650; }
.sigla-auto__stato { display: inline-flex; align-items: center; padding: 0.2rem 0.5rem; border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: 700; }
.sigla-auto__stato.is-on { background: var(--success-bg); color: var(--success-fg); }
.sigla-auto__stato.is-off { background: var(--gray-100); color: var(--gray-700); }
.sigla-auto__nota { margin: 0.75rem 0 0; color: var(--gray-600); font-size: var(--text-xs); line-height: 1.5; }
.section-title-plain { margin: 0; padding: 0; border: 0; }
.error-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; }
.error-actions a { text-decoration: none; }
.schedule-scroll-hint { display: none; align-items: center; gap: 0.35rem; margin: 0 0 0.5rem; color: var(--text-secondary); font-size: var(--text-xs); }
.schedule-day-picker { display: none; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0.3rem; margin-bottom: 0.75rem; }
.schedule-day-button { display: grid; place-items: center; gap: 0.1rem; min-height: 3.1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-secondary); font: inherit; font-size: var(--text-xs); cursor: pointer; }
.schedule-day-button strong { color: var(--text); font-size: var(--text-base); }
.schedule-day-button.is-active { border-color: var(--green-600); background: var(--green-50); color: var(--green-800); }

/* NB: la navigazione (.nav-sections / .section-link) e definita in
   components.css, nel blocco "INTESTAZIONE A DUE PIANI". Qui non ci sono
   piu' i vecchi .nav-group: le sezioni sono una lista unica. */

/* Bacheca: i controlli restano densi per lasciare spazio ai lavori. */
.dashboard-kicker { color: var(--green-700); font-size: var(--text-xs); font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.dashboard-filter-panel { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 0.55rem; padding: 0.7rem 0.8rem; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-alt); }
.dashboard-filter-panel .dashboard-views { margin: 0; background: var(--surface); }
.dashboard-filter-panel .dashboard-view { color: var(--text); }
.dashboard-filter-panel .dashboard-view.active { color: var(--on-success); }
.dashboard-filter-panel .dashboard-filter-form label, .dashboard-filter-panel .filter-reset { color: var(--text); }
.dashboard-filter-panel .dashboard-filter-form { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(15rem, 1fr) auto auto auto; align-items: end; gap: 0.6rem; padding: 0.55rem 0 0; border-top: 1px solid var(--border); }
.dashboard-filter-panel .dashboard-filter-form label { min-width: 0; }
.dashboard-filter-form .dashboard-search { display: flex; align-items: center; gap: 0.45rem; min-height: 2.4rem; padding: 0 0.65rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.dashboard-search input { width: 100%; min-width: 0; padding: 0; border: 0; background: transparent; color: var(--text); }
.dashboard-search input:focus { outline: 0; }
.dashboard-search:focus-within { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.dashboard-filter-details { min-width: 0; }
.dashboard-filter-details summary { min-height: 2.4rem; padding: 0.55rem 0.65rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); cursor: pointer; font-size: var(--text-sm); font-weight: 700; }
.dashboard-filter-fields { display: grid; grid-template-columns: repeat(3, minmax(8rem, 1fr)); gap: 0.5rem; margin-top: 0.5rem; }
.dashboard-filter-details[open] { grid-column: span 2; }
.dashboard-pagination { display: flex; align-items: center; justify-content: center; gap: 0.75rem; margin: 1.25rem 0; color: var(--text-secondary); font-size: var(--text-sm); }
.dashboard-filter-panel .save-filter-form { padding: 0; }
.dashboard-filter-panel .saved-filter-list { grid-column: 1 / -1; }
.dashboard-insights { position: relative; overflow: hidden; padding: 0.85rem; }
.dashboard-insights::before { position: absolute; inset: 0 auto 0 0; width: 4px; background: linear-gradient(var(--green-500), var(--green-200)); content: ''; }
.dashboard-insights .insights-heading { margin-bottom: 0.65rem; cursor: pointer; list-style: none; }
.dashboard-insights .insights-heading::-webkit-details-marker { display: none; }
.dashboard-insights .insights-caption::after { content: ' +'; margin-left: 0.25rem; }
.dashboard-insights[open] .insights-caption::after { content: ' -'; }
.dashboard-insights .kpi-grid { gap: 0.5rem; }
.dashboard-insights .kpi-card { min-height: 5.25rem; padding: 0.65rem; }
.dashboard-insights .kpi-card strong { font-size: var(--text-xl); }
.dashboard-insights .insight-breakdown { gap: 0.65rem; margin-top: 0.7rem; }
.dashboard-insights .insight-breakdown > div { padding: 0.65rem; }
.kpi-card.is-primary { border-top-color: var(--green-700); background: var(--green-50); }
.kpi-card.is-primary strong { color: var(--green-800); }
.kpi-card.is-attention { background: color-mix(in srgb, var(--surface) 88%, var(--danger-bg)); }
.kpi-card.is-warning.is-attention { background: color-mix(in srgb, var(--surface) 88%, var(--warning-bg)); }
.status-section-heading { display: grid; gap: 0.1rem; margin: 0; }
.status-section-heading small { color: var(--text-secondary); font-size: var(--text-xs); font-weight: 600; }
.bacheca .status-section[data-status="In Progress"] { border-top: 3px solid var(--green-500); }
.bacheca .status-section[data-status="Pending"] { border-top: 3px solid var(--amber-500); }
.bacheca .status-section[data-status="New"] { border-top: 3px solid var(--gray-300); }
.bacheca .btn-complete { background: var(--success-solid); color: var(--on-success); }
.bacheca .btn-complete:hover { background: var(--success-solid-hover); }

/* FullCalendar usa variabili proprie: allinearle ai token evita intestazioni bianche nel tema scuro. */
[data-theme="dark"] .cal-container {
  --fc-page-bg-color: var(--surface);
  --fc-neutral-bg-color: var(--surface-alt);
  --fc-border-color: var(--border);
  --fc-neutral-text-color: var(--text-secondary);
}
[data-theme="dark"] .cal-container.fc a[aria-label] { color: var(--text) !important; }

@media (min-width: 769px) and (max-width: 1100px) {
  /* Le regole dell'intestazione stanno tutte in components.css
     ("INTESTAZIONE A DUE PIANI"). Qui serve solo ricordare che la ricerca
     si stringe per prima: le sezioni hanno la loro riga e non soffrono. */
  .topbar-inner { padding-inline: 1rem; }
  .topbar-search { max-width: 12rem; }
}

@media (max-width: 768px) {
  .wiki-page-actions { width: 100%; }
  .wiki-page-actions > a { flex: 1; justify-content: center; }
  .search-form { max-width: none; }
  .client-jobs-actions { justify-content: stretch; margin: -0.5rem 0 0.75rem; }
  .client-jobs-actions .btn-secondary { width: 100%; }
  .sigla-toolbar { align-items: stretch; }
  .sigla-search { width: 100%; }
  .sigla-client-card-table tbody tr.is-changed { border-color: var(--warning-border); box-shadow: inset 4px 0 var(--amber-500); }
  .sigla-client-card-table .sigla-state-label { display: inline; margin-left: 0.4rem; }
  .schedule-scroll-hint { display: flex; padding: 0.6rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-alt); color: var(--gray-600); }
  .schedule-day-picker { display: grid; }
  /* Turni: meglio scorrere in orizzontale che mostrare giorni troncati.
     La tabella mantiene i 7 giorni leggibili dentro un contenitore che scorre,
     e l'avviso qui sopra spiega come muoversi. */
  .schedule-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .schedule-table { min-width: 44rem; }
  .schedule-table th, .schedule-table td { min-width: 4.6rem; }
  .schedule-table .sticky-col { min-width: 6.5rem; }
  .dashboard-filter-panel { display: grid; grid-template-columns: 1fr; align-items: stretch; padding: 0.75rem; }
  .dashboard-filter-panel .dashboard-views { width: 100%; overflow-x: auto; }
  .dashboard-filter-panel .dashboard-filter-form { display: grid; grid-template-columns: 1fr auto; padding-top: 0.55rem; }
  .dashboard-search { grid-column: 1 / -1; }
  .dashboard-filter-details, .dashboard-filter-details[open] { grid-column: 1 / -1; }
  .dashboard-filter-fields { grid-template-columns: 1fr; }
  .dashboard-filter-panel .save-filter-form { justify-content: flex-start; }
  .status-section-heading small { font-size: 0.68rem; }
}

/* =====================================================================
   ORARI CASINÒ: barra contestuale unica + legenda compatta
   I controlli (settimana precedente/successiva, data, Mese, Invia,
   Pubblica, Riapri) stanno in una sola striscia ordinata: a sinistra
   dove siamo, al centro lo stato, a destra le azioni.
   ===================================================================== */
.schedule-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.9rem;
  margin-bottom: 0.9rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  background: var(--surface);
}
/* La tabella dei turni ha una larghezza minima: senza min-width: 0 la griglia
   dei blocchi si allargerebbe fino a far scorrere tutta la pagina e il
   contenitore con overflow-x non potrebbe più scorrere i giorni da solo. */
.schedule-month-blocks { grid-template-columns: minmax(0, 1fr); }
.schedule-month-blocks > * { min-width: 0; }
.schedule-week-block { min-width: 0; }
.schedule-toolbar-page { margin-top: 0.5rem; }
/* Dentro una settimana la barra non si ridipinge: la card c'e già, basta
   un filetto sotto per separare i controlli dalla tabella dei turni. */
.schedule-week-block .schedule-toolbar {
  padding: 0 0 0.6rem;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
}
.schedule-toolbar-lead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.7rem;
  min-width: 0;
}
.schedule-toolbar-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; }
.schedule-toolbar-title { margin: 0; font-size: var(--text-base); }
.schedule-toolbar-title small { color: var(--text-secondary); font-weight: 400; }
.schedule-toolbar .schedule-week-badges { margin-top: 0; }
.schedule-toolbar .schedule-week-actions { margin-bottom: 0; }

/* Legenda turni: una tabella con le intestazioni scritte.
   Prima era un elenco compatto con sigle C/E/T: si capiva solo passando il
   mouse sopra la sigla, e sul telefono il mouse non c'è. Qui ogni colonna
   dice cosa contiene, quindi si legge senza interaction.
   - larghezza minima + wrapper: su schermi stretti scorre invece di
     squeezare le colonne fino a renderle illeggibili;
   - cifre tabulari: le ore incolonnate. */
.schedule-legend { margin-top: 1.25rem; padding: 0.7rem 0.8rem; }
.legend-table {
  width: auto;
  min-width: 26rem;
  border-collapse: collapse;
  font-size: 0.78rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-control);
}
.legend-table th,
.legend-table td {
  padding: 0.4rem 0.7rem;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}
.legend-table thead th {
  font-weight: 700;
  color: var(--text);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--surface-alt);
  white-space: nowrap;
}
.legend-table tbody th { font-weight: 400; }
.legend-table tbody tr:last-child th,
.legend-table tbody tr:last-child td { border-bottom: 0; }
/* Le ore incolonnate a destra: sono numeri, si confrontano in verticale. */
.legend-table td.num-tabular { text-align: right; white-space: nowrap; }
/* La sigla resta riconoscibile e il nome accanto è il significato. */
.legend-sigla {
  min-width: 2.2rem;
  margin-right: 0.45rem;
  color: var(--green-800);
  font-weight: 800;
  text-align: center;
}
.legend-name { color: var(--text); }
/* Turni disattivati: restano leggibili (contrasto AA), la barratura basta. */
.legend-table tbody tr.is-inactive .legend-name { color: var(--gray-600); text-decoration: line-through; }
.legend-flag {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0 0.35rem;
  border-radius: var(--radius-full);
  background: var(--gray-100);
  color: var(--gray-700);
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.legend-flag-inline {
  padding: 0 0.3rem;
  border-radius: var(--radius-full);
  background: var(--gray-100);
  color: var(--gray-700);
  font-size: 0.9em;
  white-space: nowrap;
}
/* Grigio 600 e non "testo secondario": su fondo chiaro il 500 non arriva
   al contrasto minimo richiesto (WCAG AA). */
.legend-note {
  margin: 0.6rem 0 0;
  color: var(--gray-600);
  font-size: 0.72rem;
  line-height: 1.45;
}

/* =====================================================================
   SEGRETERIA: colonne alte quanto il contenuto, un solo invito
   Le colonne non hanno più altezza minima: una colonna vuota è una
   striscia bassa, non un pannello a tutta altezza. Il bordo colorato
   sparisce (era decorazione): il colore vive nel pallino di identità
   e nei bordi di scadenza/priorità, che sono eccezioni reali.
   ===================================================================== */
.kanban-column {
  min-height: 0;
  border-top: 1px solid var(--gray-200);
  background: var(--surface);
}
.kanban-note-list { min-height: 0; }
.kanban-column .empty-state { padding: 0.9rem 0.7rem; }
.kanban-column .empty-state p { margin: 0; }

@media (max-width: 768px) {
  /* Su schermi stretti la barra va a capo: i pulsanti restano uno sotto
     l'altro, cliccabili, invece di scorrere fuori dal pannello. */
  .schedule-toolbar { align-items: stretch; }
  .schedule-toolbar-lead, .schedule-week-actions { justify-content: flex-start; }
  .schedule-toolbar .schedule-week-actions { margin-left: 0; }
  .schedule-toolbar-nav { flex: 1 1 100%; }
}

/* =====================================================================
   COERENZA DEL COLORE: un solo accento (verde IeO)
   Azioni secondarie, badge e contatori passano a ruoli neutri o
   all'accento. Restano colorati solo gli avvisi che danno un'informazione
   (scadenza, priorità, errore, festività, "oggi").
   ===================================================================== */
.btn-link { color: var(--green-700); }
.btn-link:hover { color: var(--green-800); }
/* Contatore su sfondo brand: verde come il resto, non blu. */
.count-pill-info { background: var(--green-600); color: #fff; }
/* On site / Remoto: due ruoli secondari invece di verde + blu. */
.execution-badge.execution-on_site { background: var(--green-100); color: var(--green-800); }
.execution-badge.execution-remoto { background: var(--gray-100); color: var(--gray-700); }
/* Elenchi di ricerca: wiki e note non hanno due colori diversi. */
.search-notes-list .history-item { border-left-color: var(--green-300); }
/* Riepilogo mensile: la reperibilità è un dato, non un secondo accento. */
.stat-oncall { border-left-color: var(--gray-300); }
.stat-oncall span .icon-xs { background: var(--gray-100); color: var(--gray-700); }

/* Bacheca su telefono: "Seleziona" e "Storico" diventano solo icona (restano
   leggibili dai lettori di schermo via aria-label) e "Nuovo lavoro" prende lo
   spazio rimasto: tre pulsanti su una riga invece di tre righe piene. */
@media (max-width: 768px) {
  .dashboard-page-header .page-header-actions { grid-template-columns: auto auto 1fr; gap: 0.5rem; }
  .dashboard-page-header .page-header-btn { width: auto; min-height: 44px; }
  .dashboard-page-header .btn-label-wide { display: none; }
}

/* Riepilogo chiuso: tre numeri in riga; spariscono quando il riepilogo e' aperto
   (li' i numeri ci sono gia' in grande). */
.insights-glance { display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; margin-left: auto; }
.glance-item { color: var(--text-secondary); font-size: var(--text-sm); white-space: nowrap; }
.glance-item strong { color: var(--text); font-size: var(--text-base); }
.glance-item.is-alert strong { color: var(--danger-fg); }
.dashboard-insights[open] .insights-glance { display: none; }
@media (max-width: 768px) { .insights-glance { margin-left: 0; } .dashboard-insights .insights-heading { flex-wrap: wrap; } }

/* Larghezze delle colonne dello Storico (somma 100%, la casella di selezione e' fissa). */
.history-colw-check { width: 2.25rem; }
.history-colw-client { width: 9.5%; }
.history-colw-desc { width: 15.5%; }
.history-colw-assigned { width: 7.5%; }
.history-colw-operations { width: 13%; }
.history-colw-time { width: 5%; }
.history-colw-date { width: 10.5%; }
.history-colw-exec { width: 8.5%; }
.history-colw-note { width: 9.5%; }
.history-colw-fatturato { width: 8%; }
.history-colw-material { width: 7.5%; }
.history-colw-actions { width: 5.5%; }
/* Colonne nascoste dal selettore "Colonne": spariscono anche dall'elenco. */
.history-table.is-without-material .history-colw-material,
.history-table.is-without-fatturato .history-colw-fatturato { display: none; }
/* Il badge del cliente non deve uscire dalla sua cella (nomi lunghi vanno a capo). */
.history-table .history-col-client .job-client { max-width: 100%; overflow-wrap: anywhere; box-sizing: border-box; }
