:root {
  --ink: #1d2d3d;
  --muted: #617487;
  --line: #d9e2ea;
  --surface: #ffffff;
  --page: #f3f7fa;
  --navy: #1c4b72;
  --navy-deep: #123957;
  --accent: #0d7a88;
  --danger: #bb3e3e;
  --warn: #a56812;
  --success: #277a5d;
  --shadow: 0 12px 32px rgba(26, 52, 74, .12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--page);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; background: var(--page); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled, input:disabled { cursor: not-allowed; opacity: .62; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg, #eaf3f5, #f6f9fb); }
.login-card { width: min(100%, 430px); background: var(--surface); padding: 38px; border-radius: 18px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.eyebrow { margin: 0 0 7px; color: var(--accent); font-weight: 800; font-size: .76rem; letter-spacing: .12em; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 1.75rem; margin-bottom: 10px; }
h2 { font-size: 1.3rem; margin-bottom: 6px; }
.login-copy, .view-heading p, .dialog-subtitle { color: var(--muted); line-height: 1.45; }
.stack-form { display: grid; gap: 16px; margin-top: 28px; }
.stack-form label, .reference-date label, .search-box, #temp-months-field, #temp-date-field, #prestazione-edit-date-field, #prestazione-edit-note-field, #prestazione-edit-form > label { display: grid; gap: 7px; color: var(--muted); font-size: .84rem; font-weight: 700; }
input, select, textarea { width: 100%; padding: 10px 11px; border: 1px solid #b9c9d6; border-radius: 8px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(13, 122, 136, .18); border-color: var(--accent); }
input[type="radio"] { width: auto; padding: 0; border: 0; border-radius: 0; background: transparent; accent-color: var(--accent); }
.primary-button, .secondary-button, .danger-button, .text-button, .tab, .metric-link { border-radius: 8px; border: 1px solid transparent; transition: .15s ease; }
.primary-button { padding: 11px 14px; background: var(--navy); color: white; font-weight: 800; }
.primary-button:hover { background: var(--navy-deep); }
.secondary-button { padding: 9px 12px; color: var(--navy); background: #fff; border-color: #b9c9d6; font-weight: 700; }
.secondary-button:hover { background: #edf5f8; }
.danger-button { padding: 9px 12px; color: #fff; background: var(--danger); font-weight: 700; }
.text-button { color: var(--navy); background: transparent; text-decoration: underline; padding: 6px; }
.form-error { margin: 0; color: #a02424; font-weight: 700; font-size: .9rem; }

.app-shell { min-height: 100vh; }
.topbar { min-height: 94px; padding: 18px 34px; display: flex; justify-content: space-between; gap: 22px; align-items: center; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 1.45rem; }
.header-actions { display: flex; align-items: end; gap: 18px; }
.reference-date { min-width: 176px; }
.user-box { display: grid; gap: 2px; min-width: 130px; font-size: .84rem; }
.user-box span { color: var(--muted); }
.tabs { padding: 0 34px; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; gap: 4px; }
.tab { padding: 13px 15px; background: transparent; color: var(--muted); font-weight: 750; border-radius: 8px 8px 0 0; border-bottom: 3px solid transparent; }
.tab:hover { color: var(--navy); background: #f3f8fa; }
.tab.is-active { color: var(--navy); border-bottom-color: var(--accent); }
.page-content { padding: 28px 34px 48px; max-width: 1900px; margin: auto; }
.view-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.view-heading p { margin-bottom: 0; }
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.dashboard-card { background: var(--surface); border: 1px solid var(--line); border-radius: 13px; min-height: 155px; padding: 18px; box-shadow: 0 3px 12px rgba(26, 52, 74, .05); display: grid; grid-template-rows: 1fr auto; }
.dashboard-card h3 { font-size: 1rem; margin: 0 0 16px; line-height: 1.3; }
.dashboard-metrics { border-top: 1px solid var(--line); padding-top: 10px; display: grid; gap: 6px; }
.metric-link { padding: 4px 0; display: flex; justify-content: space-between; text-align: left; background: transparent; color: var(--navy); font-weight: 750; }
.metric-link:hover { color: var(--accent); text-decoration: underline; }
.metric-link strong { font-size: 1rem; }
.empty-state { padding: 28px; border: 1px dashed #afc1cd; color: var(--muted); background: #fff; border-radius: 12px; }
.alert { padding: 12px 15px; border-radius: 9px; margin-bottom: 18px; }
.alert-error { color: #862a2a; border: 1px solid #e8bebe; background: #fff2f2; }
.loading { margin: 0 0 18px; color: var(--accent); font-weight: 800; }
.matrix-heading { align-items: flex-start; }
.matrix-tools { display: flex; gap: 12px; align-items: end; }
.search-box { width: min(290px, 100%); }
.summary-strip { margin-bottom: 12px; display: flex; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: .88rem; }
.summary-chip { padding: 6px 9px; border-radius: 999px; background: #e9f0f4; }
.matrix-scroll { width: 100%; overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 2px 9px rgba(26, 52, 74, .04); }
.matrix { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: .76rem; }
.matrix th, .matrix td { border-right: 1px solid #e0e7ed; border-bottom: 1px solid #e0e7ed; padding: 5px 5px; vertical-align: middle; white-space: nowrap; }
.matrix thead th { position: sticky; top: 0; z-index: 3; background: #edf4f7; color: #244861; font-weight: 850; text-align: left; }
.matrix thead tr:first-child th { background: #dcecf1; text-align: center; }
.matrix thead tr:nth-child(2) th { text-align: center; }
.matrix th.common-head { background: #edf4f7 !important; text-align: left !important; }
.matrix th.sortable { cursor: pointer; user-select: none; }
.matrix th.sortable:hover { background: #d3e8ef !important; }
.matrix tbody tr:hover td { background: #f7fbfc; }
.matrix tbody tr:last-child td { border-bottom: 0; }
.matrix tr td:last-child, .matrix tr th:last-child { border-right: 0; }
.worker-name { font-weight: 800; min-width: 160px; }
.worker-name-manutenzione,
.worker-mansione-manutenzione {
  background: #dff3ee !important;
}
.cell-center { text-align: center; }
.note-button { width: 28px; height: 28px; padding: 0; border-radius: 50%; border: 0; background: #ecf4f7; color: var(--accent); font-weight: 900; }
.note-button:hover { background: #d3e9ee; }
.note-button-present { color: #e60000; }
.note-empty { color: #a5b3be; }
.temp-button { min-width: 36px; padding: 5px 7px; background: #f6f8fa; color: #28596e; border: 1px dashed #a9bbc8; border-radius: 6px; font-weight: 750; }
.temp-button:hover { background: #e5f1f4; border-color: var(--accent); }
.temp-disabled { color: #9babb6; }
.date-cell { min-width: 95px; }
.date-main { font-weight: 750; }
.date-main-info-mancante {
  display: block;
  white-space: pre-line;
  text-align: center;
  font-size: .64rem;
  line-height: 1.05;
  font-weight: 700;
}
.cell-status { display: block; margin-top: 3px; color: var(--muted); font-size: .72rem; line-height: 1.15; }
.status-SCADUTA { color: #b32929; font-weight: 850; }
.status-IN_SCADENZA { color: #a56812; font-weight: 850; }
.status-DA_VERIFICARE { color: #756026; font-weight: 850; }
.status-ESCLUSA { color: #78838b; }
.status-PROGRAMMATA { color: #277a5d; }
.no-data { color: #a2afb9; }
.dialog { border: 0; padding: 0; border-radius: 13px; box-shadow: var(--shadow); width: min(94vw, 520px); }
.dialog::backdrop { background: rgba(19, 44, 61, .45); }
.dialog-card { padding: 22px; background: #fff; }
.dialog-header { display: flex; justify-content: space-between; gap: 16px; align-items: start; margin-bottom: 10px; }
.dialog-header h2 { margin: 0; }
.icon-button { width: 30px; height: 30px; border-radius: 50%; border: 0; background: #eef4f6; color: var(--ink); font-size: 1.3rem; line-height: 1; }
.note-content { white-space: pre-wrap; line-height: 1.5; margin: 0; }
.current-temp { padding: 9px 11px; background: #f3f7f9; border-radius: 7px; color: var(--muted); margin: 14px 0; font-size: .9rem; }
.temp-mode-group { border: 0; display: grid; gap: 8px; padding: 0; margin: 16px 0; }
.temp-mode-group label { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 650; }
.dialog-actions { display: flex; align-items: center; gap: 9px; margin-top: 22px; }
.dialog-spacer { flex: 1; }

@media (max-width: 830px) {
  .topbar, .header-actions, .view-heading, .matrix-heading { align-items: stretch; flex-direction: column; }
  .topbar { padding: 18px 20px; }
  .tabs { padding: 0 12px; overflow-x: auto; }
  .page-content { padding: 22px 14px 38px; }
  .matrix-tools { flex-direction: column; align-items: stretch; }
  .search-box { width: 100%; }
}


.archive-detail-content { display: grid; gap: 16px; }
.archive-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: #f7fafb; }
.archive-meta dt { color: var(--muted); font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.archive-meta dd { margin: 3px 0 0; font-weight: 700; }
.archive-status { font-weight: 850; }
.archive-worker-button { padding: 0; border: 0; background: transparent; color: var(--navy); font-weight: 850; text-align: left; text-decoration: underline; }
.archive-worker-button:hover { color: var(--accent); }
.archive-prestations { width: 100%; border-collapse: collapse; font-size: .84rem; }
.archive-prestations th, .archive-prestations td { border-bottom: 1px solid var(--line); padding: 7px 5px; text-align: left; vertical-align: top; }
.archive-prestations th { color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; }
.dialog-wide { width: min(96vw, 840px); }
@media (max-width: 640px) { .archive-meta { grid-template-columns: 1fr; } }


.active-worker-button { padding: 0; border: 0; background: transparent; color: var(--ink); font-weight: 850; text-align: left; text-decoration: underline; }
.active-worker-button:hover { color: var(--accent); }
.worker-detail-content { display: grid; gap: 16px; }
.worker-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: #f7fafb; }
.worker-meta dt { color: var(--muted); font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.worker-meta dd { margin: 3px 0 0; font-weight: 700; }
.worker-prestations { width: 100%; border-collapse: collapse; font-size: .84rem; }
.worker-prestations th, .worker-prestations td { border-bottom: 1px solid var(--line); padding: 7px 5px; text-align: left; vertical-align: top; }
.worker-prestations th { color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; }
.worker-prestations .cell-action { text-align: right; }
.small-button { padding: 6px 9px; color: var(--navy); background: #fff; border: 1px solid #b9c9d6; border-radius: 7px; font-weight: 750; }
.small-button:hover { background: #edf5f8; }
.small-danger-button { padding: 6px 9px; color: #fff; background: var(--danger); border: 1px solid var(--danger); border-radius: 7px; font-weight: 750; }
.small-danger-button:hover { filter: brightness(.92); }
.dialog-hint { margin: 0; color: var(--muted); font-size: .84rem; line-height: 1.4; }
@media (max-width: 640px) { .worker-meta { grid-template-columns: 1fr; } .worker-prestations { font-size: .78rem; } }


.dialog-extra-wide .dialog-card { width: min(1120px, calc(100vw - 36px)); max-height: calc(100vh - 36px); overflow: auto; }
.worker-create-content { display: grid; gap: 20px; }
.form-section { border-top: 1px solid var(--line); padding-top: 18px; }
.form-section:first-child { border-top: 0; padding-top: 0; }
.form-section h3 { margin-bottom: 10px; }
.form-section h4 { margin: 0 0 10px; font-size: .98rem; }
.form-grid { display: grid; gap: 14px; }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.section-copy, .muted-inline { color: var(--muted); font-size: .88rem; }
.initial-prestazioni-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.initial-prestazione-card { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fbfdff; display: grid; gap: 10px; }
.initial-prestazione-details { display: grid; gap: 10px; }
.force-list { display: grid; gap: 10px; }
.force-row { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: #fbfdff; }
.checkbox-label { display: flex; gap: 8px; align-items: center; font-weight: 700; }
.checkbox-label input { width: auto; }
.force-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.empty-small { color: var(--muted); margin: 0; }
@media (max-width: 720px) {
  .two-columns, .initial-prestazioni-grid, .force-fields { grid-template-columns: 1fr; }
}

/* Correzione BLOCCO 4F.1: il dialog di inserimento deve essere largo quanto il modulo. */
.dialog.dialog-extra-wide {
  width: min(96vw, 1120px);
  max-width: calc(100vw - 36px);
}
.dialog.dialog-extra-wide .dialog-card {
  width: 100%;
  max-height: calc(100vh - 36px);
  overflow: auto;
}
.form-grid > label,
.initial-prestazione-card > label,
.force-fields > label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: .84rem;
  font-weight: 700;
}

/* BLOCCO 4O_1C — intestazione visibile: rende più evidente il nome del sistema
   senza alterare titoli, struttura o comportamento responsive. */
.topbar .eyebrow {
  margin-bottom: 8px;
  font-size: clamp(.98rem, 1.05vw, 1.12rem);
  font-weight: 900;
  letter-spacing: .12em;
}

/* BLOCCO 6E.1 — Scadenzario operativo diviso per categoria.
   La categoria arriva dalla riga del database: qui cambia solo la visualizzazione. */
.operational-category-container,
.matrix-scroll.operational-category-container {
  display: grid;
  gap: 22px;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.operational-category-section {
  display: grid;
  gap: 10px;
}
.operational-category-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 2px 9px rgba(26, 52, 74, .04);
}
.operational-category-heading h2 {
  margin: 0;
  font-size: 1.08rem;
  color: var(--navy-deep);
}
.operational-category-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: .84rem;
}
.operational-category-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
  color: var(--muted);
  font-size: .82rem;
}
.operational-category-summary span {
  padding: 5px 8px;
  border-radius: 999px;
  background: #e9f0f4;
  white-space: nowrap;
}
.operational-category-summary strong {
  color: var(--ink);
}
.operational-category-summary .is-overdue {
  background: #fff0f0;
  color: #982d2d;
}
.operational-category-summary .is-overdue strong {
  color: #982d2d;
}
.operational-category-summary .is-due {
  background: #fff7e8;
  color: #8a570a;
}
.operational-category-summary .is-due strong {
  color: #8a570a;
}
.operational-category-summary .is-review {
  background: #fffbe8;
  color: #756026;
}
.operational-category-summary .is-review strong {
  color: #756026;
}
.operational-category-table-scroll {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 9px rgba(26, 52, 74, .04);
}
@media (max-width: 830px) {
  .operational-category-heading {
    align-items: stretch;
    flex-direction: column;
  }
  .operational-category-summary {
    justify-content: flex-start;
  }
}

/* SCADENZIARIO_6F3C_R4_STILE_DATA_NERA_PERSISTENTE_TEST
   Regola passiva: ha effetto solo se il frontend TEST assegna la classe
   vaccino-data-test-nera alla cella DATA del vaccino antitetanico. */
table.matrix td.vaccino-data-test-nera,
table.matrix td.vaccino-data-test-nera * {
  background-color: #000000 !important;
  background-image: none !important;
  color: #000000 !important;
}
