/* ==========================================================================
   Helpdesk IT - foglio di stile unico (nessun framework, nessuna build)
   Stile di contactitalia.it: Inter, blu Contact #003DA6, superfici bianche e
   grigio chiaro #F5F5F7, pulsanti a pillola. Colori di stato riservati.
   ========================================================================== */

/* Inter servito dal portale (nessuna chiamata a Google Fonts: niente dati
   degli utenti a terzi, e la CSP resta font-src 'self'). Variabile, solo
   caratteri latini. Licenza SIL OFL in /static/fonts/Inter-LICENSE.txt. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/Inter-var-latin.woff2") format("woff2");
}

:root {
  color-scheme: light;

  /* Superfici e testo */
  --plane: #f5f5f7;
  --surface: #ffffff;
  --surface-alt: #f4f6fa;
  --ink: #1e1e1e;
  --ink-2: #54595f;
  --ink-muted: #6e6e73;
  --line: #e5e5ea;
  --line-strong: #c9ccd3;
  --ring: rgba(0, 61, 166, 0.12);

  /* Accento */
  --accent: #003da6;
  --accent-strong: #0049c7;
  --accent-soft: #e9effa;
  --accent-ink: #002a73;

  /* Serie dei grafici (slot categoriali, ordine fisso) */
  --series-1: #003da6;
  --series-2: #eb6834;
  --series-3: #1baf7a;

  /* Rampa ordinale blu (dal più intenso al più chiaro) */
  --ramp-1: #002a73;
  --ramp-2: #003da6;
  --ramp-3: #4a7fd6;
  --ramp-4: #9db9ea;

  /* Stati (riservati: mai usati come colore di serie) */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;

  /* Coppie sfondo/testo dei badge e dei messaggi.
     Sono token e non valori scritti nelle regole perché il tema scuro non è
     un'inversione automatica: ogni coppia va scelta, non calcolata. */
  --on-accent: #fff;
  --good-soft: #e7f4e7;
  --good-ink: #14610f;
  --good-bg: #f0f9f0;
  --good-line: #b9dfb9;
  --warn-soft: #fdf1dc;
  --warn-ink: #7a4d06;
  --bad-soft: #fbe7e7;
  --bad-ink: #8e2020;
  --bad-bg: #fdf3f3;
  --bad-line: #e9c4c4;
  --info-bg: #f1f5fc;
  --info-line: #c9d8f2;
  --neutral-soft: #f0f1f4;
  --neutral-ink: #3a3a3c;
  --purple-soft: #ece9f7;
  --purple-ink: #362a7a;
  --internal-bg: #fdf7e8;
  --internal-line: #f0dfb4;

  /* Superfici semitrasparenti e ombre */
  --topbar-bg: rgba(255, 255, 255, 0.92);
  --scrim: rgba(0, 9, 26, 0.42);
  --code-bg: rgba(0, 9, 26, 0.05);
  --focus-glow: rgba(0, 61, 166, 0.16);
  --drawer-shadow: rgba(0, 9, 26, 0.18);
  --shot-bg: #f0f2f5;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(0, 9, 26, 0.04), 0 8px 24px rgba(0, 9, 26, 0.05);
  --sidebar-width: 256px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
}

a {
  color: var(--accent-strong);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.25;
  font-weight: 650;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 17px;
}

h3 {
  font-size: 15px;
}

p {
  margin: 0 0 12px;
}

img {
  max-width: 100%;
  /* Con width e height nell'HTML, senza questo un'immagine ristretta dal
     contenitore manterrebbe l'altezza e risulterebbe schiacciata. */
  height: auto;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 20px 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ==========================================================================
   Impalcatura
   ========================================================================== */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
  color: var(--ink);
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--on-accent);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
  flex: none;
}

.brand-text strong {
  display: block;
  font-size: 14px;
  line-height: 1.2;
}

.brand-text span {
  font-size: 11.5px;
  color: var(--ink-muted);
}

.nav-group {
  margin-top: 14px;
}

.nav-label {
  padding: 0 10px 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-weight: 500;
}

.nav-link:hover {
  background: var(--surface-alt);
  color: var(--ink);
  text-decoration: none;
}

.nav-link.is-active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
}

.nav-link svg {
  width: 17px;
  height: 17px;
  flex: none;
  stroke-width: 1.7;
}

.nav-count {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-muted);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--ink-muted);
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  background: var(--topbar-bg);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  font-size: 17px;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  /* 40px: la soglia sotto la quale un bersaglio da toccare diventa scomodo. */
  width: 40px;
  height: 40px;
  padding: 0;
  cursor: pointer;
  color: var(--ink-2);
  flex: none;
}

/* Senza questa regola l'SVG non ha dimensione e il pulsante resta un
   riquadro vuoto: è esattamente com'era prima, e il menu sembrava assente. */
.nav-toggle svg,
.nav-close svg {
  width: 22px;
  height: 22px;
  display: block;
  stroke-width: 1.8;
}

.nav-toggle:hover {
  background: var(--surface-alt);
  color: var(--ink);
}

/* Testata del menu: marchio a sinistra, chiusura a destra (solo su mobile). */
.sidebar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-head .brand {
  flex: 1;
  min-width: 0;
}

.nav-close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-top: -2px;
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  cursor: pointer;
  flex: none;
}

.nav-close:hover {
  background: var(--surface-alt);
  color: var(--ink);
}

/* Velo dietro al menu aperto. */
.nav-scrim {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--scrim);
  opacity: 0;
  transition: opacity 0.18s ease;
}

body.nav-open .nav-scrim {
  opacity: 1;
}

/* Blocca lo scorrimento della pagina mentre il menu è aperto. */
body.no-scroll {
  overflow: hidden;
}

.content {
  padding: 22px 24px 48px;
  width: 100%;
  max-width: 1320px;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 18px;
}

.page-head .sub {
  color: var(--ink-2);
  font-size: 13px;
  margin: 4px 0 0;
}

.page-head-actions {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Utente in alto a destra */
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 999px;
  color: var(--ink-2);
}

.user-chip:hover {
  background: var(--surface-alt);
  text-decoration: none;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 700;
  flex: none;
}

.avatar.sm {
  width: 24px;
  height: 24px;
  font-size: 10px;
}

.avatar.lg {
  width: 46px;
  height: 46px;
  font-size: 16px;
}

/* ==========================================================================
   Card, griglie
   ========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card + .card {
  margin-top: 16px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.card-head h2,
.card-head h3 {
  margin: 0;
}

.card-head .actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.card-body {
  padding: 18px;
}

.card-body.tight {
  padding: 12px 18px;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.main-aside {
  grid-template-columns: minmax(0, 1fr) 320px;
  align-items: start;
}

/* ==========================================================================
   Stat tile / KPI
   ========================================================================== */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: block;
  color: inherit;
}

a.kpi:hover {
  border-color: var(--line-strong);
  text-decoration: none;
}

.kpi-label {
  font-size: 12px;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 6px;
}

.kpi-value {
  font-size: 30px;
  font-weight: 650;
  line-height: 1.15;
  margin-top: 6px;
  letter-spacing: -0.02em;
}

.kpi-hint {
  font-size: 11.5px;
  color: var(--ink-muted);
  margin-top: 2px;
}

.kpi.is-alert .kpi-value {
  color: var(--bad-ink);
}

.hero-figure {
  font-size: 48px;
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1;
}

/* ==========================================================================
   Grafici
   ========================================================================== */
.chart-bars {
  display: grid;
  gap: 10px;
}

.chart-row {
  display: grid;
  grid-template-columns: minmax(84px, 152px) minmax(0, 1fr) 54px;
  align-items: center;
  gap: 10px;
}

.chart-row .label {
  font-size: 12.5px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-track {
  background: var(--surface-alt);
  border-radius: 0 4px 4px 0;
  height: 10px;
  position: relative;
}

.chart-fill {
  height: 10px;
  background: var(--series-1);
  border-radius: 0 4px 4px 0;
  min-width: 2px;
  display: block;
}

.chart-row .value {
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--ink);
}

.chart-row .value small {
  display: block;
  font-weight: 400;
  color: var(--ink-muted);
  font-size: 11px;
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-grid-line {
  stroke: var(--line);
  stroke-width: 1;
}

.chart-axis-text {
  fill: var(--ink-muted);
  font-size: 10.5px;
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
}

.chart-end-label {
  fill: var(--ink);
  font-size: 11.5px;
  font-weight: 600;
  font-family: var(--font);
}

.chart-line {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-marker {
  stroke: var(--surface);
  stroke-width: 2;
}

.chart-hit {
  fill: transparent;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 0 0 6px;
  padding: 0;
  list-style: none;
  font-size: 12.5px;
  color: var(--ink-2);
}

.legend li {
  display: flex;
  align-items: center;
  gap: 7px;
}

.legend .key {
  width: 14px;
  height: 3px;
  border-radius: 2px;
  background: var(--series-1);
  flex: none;
}

details.data-table {
  margin-top: 12px;
}

details.data-table summary {
  cursor: pointer;
  font-size: 12.5px;
  color: var(--ink-2);
}

/* ==========================================================================
   Tabelle
   ========================================================================== */
.table-wrap {
  overflow-x: auto;
}

table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

table.table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

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

table.table tbody tr:hover {
  background: var(--surface-alt);
}

table.table .num {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.cell-title {
  font-weight: 600;
  color: var(--ink);
  display: block;
}

.cell-sub {
  font-size: 11.5px;
  color: var(--ink-muted);
}

.code-chip {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 11.5px;
  color: var(--ink-2);
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
  white-space: nowrap;
}

/* ==========================================================================
   Badge e pillole
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.75;
  flex: none;
}

.badge.no-dot::before {
  display: none;
}

.badge-success {
  background: var(--good-soft);
  color: var(--good-ink);
}

.badge-info {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.badge-warning {
  background: var(--warn-soft);
  color: var(--warn-ink);
}

.badge-danger {
  background: var(--bad-soft);
  color: var(--bad-ink);
}

.badge-neutral {
  background: var(--neutral-soft);
  color: var(--neutral-ink);
}

.badge-muted {
  background: var(--surface-alt);
  color: var(--ink-muted);
  border-color: var(--line);
}

.badge-purple {
  background: var(--purple-soft);
  color: var(--purple-ink);
}

.sla-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
}

.sla-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

.sla-ok .sla-dot {
  background: var(--good);
}
.sla-ok {
  color: var(--good-ink);
}
.sla-met .sla-dot {
  background: var(--good);
}
.sla-met {
  color: var(--good-ink);
}
.sla-risk .sla-dot {
  background: var(--warning);
}
.sla-risk {
  color: var(--warn-ink);
}
.sla-breached .sla-dot {
  background: var(--critical);
}
.sla-breached {
  color: var(--bad-ink);
}
.sla-none .sla-dot {
  background: var(--line-strong);
}
.sla-none {
  color: var(--ink-muted);
}

/* ==========================================================================
   Bottoni
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.btn:hover {
  background: var(--surface-alt);
  text-decoration: none;
}

.btn svg {
  width: 15px;
  height: 15px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.btn-primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.btn-danger {
  background: var(--surface);
  border-color: var(--bad-line);
  color: var(--bad-ink);
}

.btn-danger:hover {
  background: var(--bad-soft);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--ink-2);
}

.btn-ghost:hover {
  background: var(--surface-alt);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ==========================================================================
   Form
   ========================================================================== */
.field {
  margin-bottom: 14px;
}

.field > label,
.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 5px;
}

.req {
  color: var(--bad-ink);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="date"],
input[type="number"],
input[type="tel"],
select,
textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-glow);
}

textarea {
  min-height: 130px;
  resize: vertical;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%23898781' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M2.5 4.5L6 8l3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

input[type="file"] {
  font-size: 12.5px;
  width: 100%;
}

.help {
  font-size: 11.5px;
  color: var(--ink-muted);
  margin-top: 5px;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
}

.check input {
  margin: 2px 0 0;
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  flex: none;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 16px;
}

.form-grid .span-2 {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding-top: 6px;
}

.form-actions .spacer {
  margin-left: auto;
}

/* Barra filtri */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-alt);
  border-radius: var(--radius) var(--radius) 0 0;
}

.filters input[type="search"],
.filters select {
  width: auto;
  min-width: 130px;
  font-size: 12.5px;
  padding: 6px 10px;
  background: var(--surface);
}

.filters input[type="search"] {
  min-width: 210px;
  flex: 1 1 210px;
}

.filters .spacer {
  margin-left: auto;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
}

.chip:hover {
  background: var(--surface-alt);
  text-decoration: none;
}

.chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

/* ==========================================================================
   Messaggi
   ========================================================================== */
.flash-stack {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.flash {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13px;
  box-shadow: var(--shadow);
}

.flash strong {
  font-weight: 700;
}

.flash-success {
  border-color: var(--good-line);
  background: var(--good-bg);
  color: var(--good-ink);
}

.flash-error {
  border-color: var(--bad-line);
  background: var(--bad-bg);
  color: var(--bad-ink);
}

.flash-info {
  border-color: var(--info-line);
  background: var(--info-bg);
  color: var(--accent-ink);
}

.alert {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid var(--bad-line);
  background: var(--bad-bg);
  color: var(--bad-ink);
  margin-bottom: 14px;
}

.notice {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid var(--line);
  background: var(--surface-alt);
  color: var(--ink-2);
}

.empty {
  padding: 38px 20px;
  text-align: center;
  color: var(--ink-muted);
}

.empty h3 {
  color: var(--ink-2);
  margin-bottom: 6px;
}

.empty svg {
  width: 30px;
  height: 30px;
  stroke: var(--line-strong);
  margin-bottom: 8px;
}

/* ==========================================================================
   Dettaglio ticket
   ========================================================================== */
.meta-list {
  margin: 0;
  display: grid;
  gap: 11px;
}

.meta-list dt {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.meta-list dd {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--ink);
}

.timeline {
  display: grid;
  gap: 14px;
}

.entry {
  display: flex;
  gap: 12px;
}

.entry-body {
  flex: 1;
  min-width: 0;
}

.entry-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.entry-head .who {
  font-weight: 650;
  font-size: 13px;
}

.entry-head .when {
  font-size: 11.5px;
  color: var(--ink-muted);
}

.bubble {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 13.5px;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.bubble.internal {
  background: var(--internal-bg);
  border-color: var(--internal-line);
}

.bubble p:last-child {
  margin-bottom: 0;
}

.bubble ul,
.bubble ol {
  margin: 0 0 10px;
  padding-left: 20px;
}

.bubble code {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 12.5px;
  background: var(--code-bg);
  padding: 1px 4px;
  border-radius: 4px;
}

.event-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-2);
  padding-left: 42px;
}

.event-line .when {
  color: var(--ink-muted);
  font-size: 11.5px;
}

.event-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line-strong);
  flex: none;
}

.attachment-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.attachment {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 12.5px;
}

.attachment .name {
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment .size {
  color: var(--ink-muted);
  font-size: 11.5px;
}

.attachment form {
  margin-left: auto;
}

.attachment svg {
  width: 16px;
  height: 16px;
  color: var(--ink-muted);
  flex: none;
}

/* ==========================================================================
   FAQ (accordion senza JavaScript: <details>/<summary>)
   ========================================================================== */
.faq-group + .faq-group {
  margin-top: 24px;
}

.faq-group-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding: 0 2px 8px;
}

.faq-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.faq-item + .faq-item {
  margin-top: 8px;
}

.faq-item > summary {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  list-style: none;
  border-radius: var(--radius-sm);
}

.faq-item > summary::-webkit-details-marker {
  display: none;
}

/* Chevron disegnato in CSS: ruota all'apertura. */
.faq-item > summary::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-top: 5px;
  flex: none;
  border-right: 2px solid var(--ink-muted);
  border-bottom: 2px solid var(--ink-muted);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

.faq-item[open] > summary::before {
  transform: rotate(45deg);
}

.faq-item > summary:hover {
  background: var(--surface-alt);
}

.faq-item[open] > summary {
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.faq-item summary .badge {
  margin-left: auto;
  flex: none;
}

.faq-answer {
  padding: 13px 16px 15px 31px;
  font-size: 13.5px;
  color: var(--ink-2);
}

.faq-answer > p:last-child,
.faq-answer > ul:last-child,
.faq-answer > ol:last-child {
  margin-bottom: 0;
}

.faq-answer ul,
.faq-answer ol {
  margin: 0 0 10px;
  padding-left: 20px;
}

.faq-answer code {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 12.5px;
  background: var(--code-bg);
  padding: 1px 4px;
  border-radius: 4px;
}

.faq-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.faq-actions .meta {
  font-size: 11.5px;
  color: var(--ink-muted);
  margin-right: auto;
}

/* ==========================================================================
   Righe elenco con modifica in linea (amministrazione)
   ========================================================================== */
.list-row {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.list-row:last-child {
  border-bottom: 0;
}

.list-row-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.list-row-head .grow {
  flex: 1 1 220px;
  min-width: 0;
}

.list-row details {
  margin-top: 10px;
}

.list-row summary,
.inline-toggle summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent-strong);
  width: fit-content;
}

.inline-form {
  margin-top: 12px;
  padding: 16px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.inline-form .field:last-of-type {
  margin-bottom: 10px;
}

/* ==========================================================================
   Paginazione
   ========================================================================== */
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
}

.pagination .info {
  font-size: 12px;
  color: var(--ink-muted);
  margin-right: auto;
}

.page-link {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--surface);
}

.page-link:hover {
  background: var(--surface-alt);
  text-decoration: none;
}

.page-link.is-current {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.page-link.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* ==========================================================================
   Pagine senza impalcatura (login, errori)
   ========================================================================== */
.plain {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 16px;
  background: var(--plane);
}

.plain-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 30px 28px;
  box-shadow: var(--shadow);
}

.plain-card.wide {
  max-width: 520px;
}

.plain-head {
  text-align: center;
  margin-bottom: 22px;
}

.plain-head .brand-mark {
  margin: 0 auto 12px;
  width: 42px;
  height: 42px;
  font-size: 15px;
}

.plain-head p {
  color: var(--ink-2);
  font-size: 13px;
  margin: 6px 0 0;
}

.plain-foot {
  margin-top: 18px;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-muted);
}

.error-code {
  font-size: 44px;
  font-weight: 700;
  color: var(--line-strong);
  line-height: 1;
  margin-bottom: 8px;
}

/* ==========================================================================
   Utilità
   ========================================================================== */
.row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.row.wrap {
  flex-wrap: wrap;
}

.muted {
  color: var(--ink-muted);
}

.small {
  font-size: 12px;
}

.strong {
  font-weight: 650;
}

.nowrap {
  white-space: nowrap;
}

.mt-0 {
  margin-top: 0;
}

.mt-16 {
  margin-top: 16px;
}

.mb-0 {
  margin-bottom: 0;
}

.mb-16 {
  margin-bottom: 16px;
}

.text-right {
  text-align: right;
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 16px 0;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1080px) {
  .grid.main-aside {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(300px, 86vw);
    z-index: 60;
    transform: translateX(-100%);
    /* visibility: a menu chiuso i link non devono essere raggiungibili con
       il tabulatore né letti dagli screen reader. Transita in modo discreto,
       quindi resta visibile per tutta la durata dell'uscita. */
    visibility: hidden;
    transition: transform 0.2s ease, visibility 0.2s;
    box-shadow: 0 0 40px var(--drawer-shadow);
    padding-top: max(18px, env(safe-area-inset-top, 0px));
  }

  body.nav-open .sidebar {
    transform: translateX(0);
    visibility: visible;
  }

  .nav-toggle,
  .nav-close {
    display: inline-flex;
  }

  .content {
    padding: 18px 16px 40px;
  }

  .topbar {
    padding: 10px 16px;
  }

  .grid.cols-2,
  .grid.cols-3 {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .chart-row {
    grid-template-columns: minmax(74px, 104px) minmax(0, 1fr) 46px;
  }

  .page-head-actions {
    margin-left: 0;
    width: 100%;
  }

  .user-chip .who,
  .hide-sm {
    display: none;
  }

  .kpi-value {
    font-size: 26px;
  }
}

/* --------------------------------------------------------------------------
   Telefono: la tabella diventa un elenco di schede.
   Sette colonne in 390px non ci stanno: o si scorre di lato, o si strizzano
   le celle fino a spezzare ogni parola. Le classi col-* permettono di
   ricomporre la riga senza duplicare la marcatura.
   -------------------------------------------------------------------------- */
@media (max-width: 720px) {
  /* Solo le tabelle trasformate in schede smettono di scorrere di lato:
     una tabella rimasta tabella deve restare dentro la propria cornice,
     altrimenti allarga tutta la pagina (visto sul registro accessi). */
  .table-wrap:has(> .table-cards) {
    overflow-x: visible;
  }

  .table-cards,
  .table-cards tbody,
  .table-cards tr,
  .table-cards td {
    display: block;
    width: auto;
  }

  .table-cards thead {
    display: none;
  }

  .table-cards tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    padding: 13px 14px;
    margin-bottom: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
  }

  .table-cards tr:last-child {
    margin-bottom: 0;
  }

  /* `table.table td` ha specificità maggiore di `.table-cards td`: senza
     ripetere l'elemento, il bordo della tabella resterebbe disegnato dentro
     ogni scheda. */
  table.table-cards td,
  table.table-cards tbody tr:last-child td {
    border: 0;
    padding: 0;
  }

  table.table-cards tbody tr:hover {
    background: none;
  }

  /* Oggetto e codice sulla propria riga, il resto scorre sotto. */
  .table-cards .col-title {
    flex: 1 0 100%;
  }

  .table-cards .cell-title {
    font-size: 14.5px;
  }

  /* L'intestazione della colonna sparisce: per i nomi serve dire di chi. */
  .table-cards td[data-label]::before {
    content: attr(data-label);
    margin-right: 5px;
    color: var(--ink-muted);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  .table-cards .col-age {
    margin-left: auto;
  }

  /* I filtri a coppie invece che uno per riga: metà dello spazio. */
  .filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .filters input[type="search"] {
    grid-column: 1 / -1;
  }

  /* I gruppi di scelta rapida scorrono in orizzontale invece di andare
     a capo su tre righe. */
  .chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }

  .chips::-webkit-scrollbar {
    display: none;
  }

  .chip {
    flex: none;
    padding: 7px 13px;
  }
}

@media (max-width: 520px) {
  .content {
    padding: 14px 12px 40px;
  }

  .topbar {
    padding: 8px 12px;
    gap: 8px;
  }

  .topbar h1 {
    font-size: 15.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Le azioni del titolo pagina a tutta larghezza, una accanto all'altra. */
  .page-head-actions .btn {
    flex: 1;
    justify-content: center;
  }
}

@media print {
  .sidebar,
  .topbar,
  .page-head-actions,
  .filters,
  .pagination {
    display: none !important;
  }

  .shell {
    grid-template-columns: 1fr;
  }

  body {
    background: #fff;
  }
}


/* ==========================================================================
   Classi introdotte per la CSP
   La direttiva style-src non ammette unsafe-inline: nessun attributo
   style="" nei template, nemmeno per un margine. Quello che prima era
   scritto in linea vive qui.
   ========================================================================== */
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mb-6  { margin-bottom: 6px; }
.teaser { margin: 6px 0 10px; }
.inline-block { display: inline; }
.btn-row-center { justify-content: center; }
.shrinkable { min-width: 0; }

.textarea-md { min-height: 110px; }
.textarea-lg { min-height: 180px; }
.textarea-xl { min-height: 320px; }

.bubble-plain {
  background: transparent;
  border: 0;
  padding: 0;
  font-size: 14px;
}

/* Colore della chiave in legenda: una classe per slot, come nel grafico. */
.legend .key-series-1 { background: var(--series-1); }
.legend .key-series-2 { background: var(--series-2); }
.legend .key-series-3 { background: var(--series-3); }

/* Rampa ordinata delle barre (usata solo dove le categorie hanno un ordine
   naturale, come la priorità). */
.chart-fill.ramp-1 { background: var(--ramp-1); }
.chart-fill.ramp-2 { background: var(--ramp-2); }
.chart-fill.ramp-3 { background: var(--ramp-3); }
.chart-fill.ramp-4 { background: var(--ramp-4); }

/* Larghezza delle barre in punti percentuali interi: la precisione persa
   non è percepibile e in cambio non serve nessuno stile in linea. */
.w-0 { width: 0%; }
.w-1 { width: 1%; }
.w-2 { width: 2%; }
.w-3 { width: 3%; }
.w-4 { width: 4%; }
.w-5 { width: 5%; }
.w-6 { width: 6%; }
.w-7 { width: 7%; }
.w-8 { width: 8%; }
.w-9 { width: 9%; }
.w-10 { width: 10%; }
.w-11 { width: 11%; }
.w-12 { width: 12%; }
.w-13 { width: 13%; }
.w-14 { width: 14%; }
.w-15 { width: 15%; }
.w-16 { width: 16%; }
.w-17 { width: 17%; }
.w-18 { width: 18%; }
.w-19 { width: 19%; }
.w-20 { width: 20%; }
.w-21 { width: 21%; }
.w-22 { width: 22%; }
.w-23 { width: 23%; }
.w-24 { width: 24%; }
.w-25 { width: 25%; }
.w-26 { width: 26%; }
.w-27 { width: 27%; }
.w-28 { width: 28%; }
.w-29 { width: 29%; }
.w-30 { width: 30%; }
.w-31 { width: 31%; }
.w-32 { width: 32%; }
.w-33 { width: 33%; }
.w-34 { width: 34%; }
.w-35 { width: 35%; }
.w-36 { width: 36%; }
.w-37 { width: 37%; }
.w-38 { width: 38%; }
.w-39 { width: 39%; }
.w-40 { width: 40%; }
.w-41 { width: 41%; }
.w-42 { width: 42%; }
.w-43 { width: 43%; }
.w-44 { width: 44%; }
.w-45 { width: 45%; }
.w-46 { width: 46%; }
.w-47 { width: 47%; }
.w-48 { width: 48%; }
.w-49 { width: 49%; }
.w-50 { width: 50%; }
.w-51 { width: 51%; }
.w-52 { width: 52%; }
.w-53 { width: 53%; }
.w-54 { width: 54%; }
.w-55 { width: 55%; }
.w-56 { width: 56%; }
.w-57 { width: 57%; }
.w-58 { width: 58%; }
.w-59 { width: 59%; }
.w-60 { width: 60%; }
.w-61 { width: 61%; }
.w-62 { width: 62%; }
.w-63 { width: 63%; }
.w-64 { width: 64%; }
.w-65 { width: 65%; }
.w-66 { width: 66%; }
.w-67 { width: 67%; }
.w-68 { width: 68%; }
.w-69 { width: 69%; }
.w-70 { width: 70%; }
.w-71 { width: 71%; }
.w-72 { width: 72%; }
.w-73 { width: 73%; }
.w-74 { width: 74%; }
.w-75 { width: 75%; }
.w-76 { width: 76%; }
.w-77 { width: 77%; }
.w-78 { width: 78%; }
.w-79 { width: 79%; }
.w-80 { width: 80%; }
.w-81 { width: 81%; }
.w-82 { width: 82%; }
.w-83 { width: 83%; }
.w-84 { width: 84%; }
.w-85 { width: 85%; }
.w-86 { width: 86%; }
.w-87 { width: 87%; }
.w-88 { width: 88%; }
.w-89 { width: 89%; }
.w-90 { width: 90%; }
.w-91 { width: 91%; }
.w-92 { width: 92%; }
.w-93 { width: 93%; }
.w-94 { width: 94%; }
.w-95 { width: 95%; }
.w-96 { width: 96%; }
.w-97 { width: 97%; }
.w-98 { width: 98%; }
.w-99 { width: 99%; }
.w-100 { width: 100%; }

/* ==========================================================================
   Scelta del tipo di richiesta
   ========================================================================== */
.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: border-color 0.12s ease, transform 0.12s ease;
}

.choice:hover {
  border-color: var(--accent);
  text-decoration: none;
  transform: translateY(-1px);
}

.choice-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-ink);
  flex: none;
}

.choice-icon svg {
  width: 20px;
  height: 20px;
}

.choice-text {
  display: block;
  min-width: 0;
}

.choice-text strong {
  display: block;
  font-weight: 650;
  margin-bottom: 2px;
}

.choice-text span {
  display: block;
}

/* «Altro» non è una delle scelte: è la via d'uscita quando nessuna va bene. */
.choice-free {
  border-style: dashed;
  background: none;
  box-shadow: none;
}

.choice-free .choice-icon {
  background: var(--neutral-soft);
  color: var(--neutral-ink);
}

/* ==========================================================================
   Suggerimenti (FAQ e guide pertinenti)
   ========================================================================== */
.suggestions .card-head h2 {
  display: flex;
  align-items: center;
  gap: 7px;
}

.suggestions .card-head svg {
  width: 17px;
  height: 17px;
  color: var(--accent);
}

.suggestion {
  display: block;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  margin-bottom: 8px;
}

.suggestion:last-child {
  margin-bottom: 0;
}

.suggestion:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  text-decoration: none;
}

.suggestion strong {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin: 2px 0;
}

.suggestion span {
  display: block;
}

.suggestion-kind {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

/* ==========================================================================
   Anteprime delle immagini allegate
   ========================================================================== */
.shots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.shot {
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--shot-bg);
  overflow: hidden;
  line-height: 0;
}

.shot:hover {
  border-color: var(--accent);
}

.shot img {
  /* Altezza fissa e larghezza libera: le schermate sono quasi tutte
     orizzontali, e una griglia di riquadri quadrati le taglierebbe proprio
     dove sta il messaggio d'errore. */
  height: 132px;
  width: auto;
  max-width: 320px;
  object-fit: cover;
  display: block;
}

/* ==========================================================================
   Valutazione del richiedente
   ========================================================================== */
.rating-card {
  border-color: var(--accent);
}

.rating-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.rating-option {
  flex: 1 1 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.rating-option svg {
  width: 26px;
  height: 26px;
}

.rating-option:hover {
  border-color: currentColor;
}

.rating-happy:hover { color: var(--good-ink); background: var(--good-bg); }
.rating-neutral:hover { color: var(--ink); background: var(--surface-alt); }
.rating-sad:hover { color: var(--bad-ink); background: var(--bad-bg); }

.rating-mark {
  display: inline-flex;
  flex: none;
}

.rating-mark svg {
  width: 18px;
  height: 18px;
}

.rating-mark.rating-happy { color: var(--good); }
.rating-mark.rating-neutral { color: var(--ink-muted); }
.rating-mark.rating-sad { color: var(--critical); }

/* ==========================================================================
   Trascina e rilascia gli allegati
   ========================================================================== */
.dropzone {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 11px;
  background: var(--surface);
}

.dropzone.is-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone-hint {
  margin: 6px 0 0;
}

/* ==========================================================================
   Interruttore del tema
   Due pulsanti, uno solo visibile: quale, lo sa soltanto il CSS, che è
   l'unico a conoscere l'impostazione del sistema operativo.
   ========================================================================== */
.theme-switch {
  display: flex;
}

.theme-switch .to-light {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-switch .to-dark {
    display: none;
  }

  :root:not([data-theme="light"]) .theme-switch .to-light {
    display: inline-flex;
  }
}

:root[data-theme="dark"] .theme-switch .to-dark {
  display: none;
}

:root[data-theme="dark"] .theme-switch .to-light {
  display: inline-flex;
}

/* La scelta esplicita «sempre chiaro» vince anche su un sistema scuro. */
:root[data-theme="light"] .theme-switch .to-dark {
  display: inline-flex;
}

/* ==========================================================================
   Aggiunte minori
   ========================================================================== */
.row.between {
  justify-content: space-between;
}

@media (max-width: 560px) {
  .choice-grid {
    grid-template-columns: 1fr;
  }

  .shot img {
    height: 110px;
    max-width: 100%;
  }
}

/* Il pulsante nativo del campo file non segue i token da solo: in tema scuro
   resterebbe un riquadro grigio chiaro in mezzo alla pagina. */
input[type="file"] {
  font: inherit;
  font-size: 13px;
  color: var(--ink-2);
  max-width: 100%;
}

input[type="file"]::file-selector-button {
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  margin-right: 10px;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--ink);
  cursor: pointer;
}

input[type="file"]::file-selector-button:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* Sotto i 720px la barra in alto non ha posto per tutti i comandi: resta il
   cambio tema, e «Esci» passa nel menu laterale insieme al profilo. */
.sidebar-account {
  display: none;
}

@media (max-width: 720px) {
  .topbar-logout {
    display: none;
  }

  .sidebar-account {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
  }

  .theme-switch .btn,
  .topbar-actions > .btn {
    width: 36px;
    height: 36px;
    padding: 0;
  }
}


/* ==========================================================================
   Tema scuro
   Due strade per lo stesso elenco di token: l'impostazione del sistema
   operativo e la scelta esplicita salvata in sessione. `:not([data-theme=
   "light"])` fa si che chi ha scelto «sempre chiaro» resti chiaro anche su
   un sistema scuro.

   I due blocchi sono identici e vanno tenuti tali: se ne cambi uno, cambia
   anche l'altro.
   ========================================================================== */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  color-scheme: dark;

  /* Superfici e testo */
  --plane: #0a0f1a;
  --surface: #111827;
  --surface-alt: #182235;
  --ink: #eef1f6;
  --ink-2: #b6bfcd;
  --ink-muted: #8b95a7;
  --line: #233047;
  --line-strong: #34435f;
  --ring: rgba(255, 255, 255, 0.12);

  /* Accento: piu chiaro dello sfondo, con testo scuro sopra.
     Sul nero un blu al 4.5:1 con il bianco diventa cupo; invertendo il
     rapporto il pulsante resta leggibile e non sembra spento. */
  --accent: #7aa5f7;
  --accent-strong: #9dbcf9;
  --accent-soft: #132449;
  --accent-ink: #adc7fb;
  --on-accent: #05112b;

  /* Serie dei grafici: stessi ruoli, gradini piu chiari */
  --series-1: #7aa5f7;
  --series-2: #f08a5c;
  --series-3: #3ec795;

  --ramp-1: #adc7fb;
  --ramp-2: #7aa5f7;
  --ramp-3: #4677d0;
  --ramp-4: #2a4f93;

  /* Stati */
  --good: #35c05f;
  --warning: #e0a93a;
  --serious: #ec835a;
  --critical: #e05a5a;

  --good-soft: #16301c;
  --good-ink: #7ddb96;
  --good-bg: #14291a;
  --good-line: #2b5c38;
  --warn-soft: #33270f;
  --warn-ink: #e8c274;
  --bad-soft: #3a1c1c;
  --bad-ink: #f19a9a;
  --bad-bg: #2e1717;
  --bad-line: #5e2f2f;
  --info-bg: #122240;
  --info-line: #28416e;
  --neutral-soft: #1d2638;
  --neutral-ink: #c3c9d4;
  --purple-soft: #262147;
  --purple-ink: #bab1ee;
  --internal-bg: #2e2716;
  --internal-line: #56492a;

  /* Superfici semitrasparenti e ombre */
  --topbar-bg: rgba(17, 24, 39, 0.92);
  --scrim: rgba(0, 0, 0, 0.62);
  --code-bg: rgba(255, 255, 255, 0.08);
  --focus-glow: rgba(122, 165, 247, 0.28);
  --drawer-shadow: rgba(0, 0, 0, 0.6);
  --shot-bg: #182235;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  /* Superfici e testo */
  --plane: #0a0f1a;
  --surface: #111827;
  --surface-alt: #182235;
  --ink: #eef1f6;
  --ink-2: #b6bfcd;
  --ink-muted: #8b95a7;
  --line: #233047;
  --line-strong: #34435f;
  --ring: rgba(255, 255, 255, 0.12);

  /* Accento: piu chiaro dello sfondo, con testo scuro sopra.
     Sul nero un blu al 4.5:1 con il bianco diventa cupo; invertendo il
     rapporto il pulsante resta leggibile e non sembra spento. */
  --accent: #7aa5f7;
  --accent-strong: #9dbcf9;
  --accent-soft: #132449;
  --accent-ink: #adc7fb;
  --on-accent: #05112b;

  /* Serie dei grafici: stessi ruoli, gradini piu chiari */
  --series-1: #7aa5f7;
  --series-2: #f08a5c;
  --series-3: #3ec795;

  --ramp-1: #adc7fb;
  --ramp-2: #7aa5f7;
  --ramp-3: #4677d0;
  --ramp-4: #2a4f93;

  /* Stati */
  --good: #35c05f;
  --warning: #e0a93a;
  --serious: #ec835a;
  --critical: #e05a5a;

  --good-soft: #16301c;
  --good-ink: #7ddb96;
  --good-bg: #14291a;
  --good-line: #2b5c38;
  --warn-soft: #33270f;
  --warn-ink: #e8c274;
  --bad-soft: #3a1c1c;
  --bad-ink: #f19a9a;
  --bad-bg: #2e1717;
  --bad-line: #5e2f2f;
  --info-bg: #122240;
  --info-line: #28416e;
  --neutral-soft: #1d2638;
  --neutral-ink: #c3c9d4;
  --purple-soft: #262147;
  --purple-ink: #bab1ee;
  --internal-bg: #2e2716;
  --internal-line: #56492a;

  /* Superfici semitrasparenti e ombre */
  --topbar-bg: rgba(17, 24, 39, 0.92);
  --scrim: rgba(0, 0, 0, 0.62);
  --code-bg: rgba(255, 255, 255, 0.08);
  --focus-glow: rgba(122, 165, 247, 0.28);
  --drawer-shadow: rgba(0, 0, 0, 0.6);
  --shot-bg: #182235;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* ==========================================================================
   Ordinamento FAQ (trascina e rilascia)
   ========================================================================== */
.faq-sort-group .card-head .meta {
  margin-left: auto;
}

.sort-list {
  list-style: none;
  margin: 0;
  padding: 8px;
}

.sort-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13.5px;
  font-weight: 600;
}

.sort-item + .sort-item {
  margin-top: 6px;
}

.sort-text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.sort-text .badge {
  margin-left: 6px;
}

.sort-handle {
  display: none;
  color: var(--ink-muted);
  flex: none;
}

.sort-handle svg {
  display: block;
  fill: currentColor;
}

.sort-pos input {
  width: 64px;
}

.sort-buttons {
  display: flex;
  gap: 2px;
  flex: none;
}

.sort-buttons[hidden] {
  display: none;
}

/* Con JavaScript attivo: maniglia visibile, numeri nascosti. */
.faq-sort.is-enhanced .sort-handle {
  display: block;
}

.faq-sort.is-enhanced .sort-pos {
  display: none;
}

.faq-sort.is-enhanced .sort-item {
  cursor: grab;
}

.faq-sort.is-enhanced .sort-item:hover {
  border-color: var(--line-strong);
}

.sort-item.is-dragging {
  cursor: grabbing;
  opacity: 0.55;
  border-style: dashed;
  border-color: var(--accent);
  background: var(--accent-soft);
}

.faq-sort-actions {
  position: sticky;
  bottom: 0;
  padding: 12px 0;
  background: var(--plane);
}

/* Apertura ticket: domanda sul dispositivo */
.device-question {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 0 0 16px;
  background: var(--surface-alt);
}

.device-details {
  margin-top: 12px;
}

.device-details[hidden],
.device-question [data-device-other][hidden] {
  display: none;
}

.device-details .field:last-child {
  margin-bottom: 0;
}

/* Accesso: separatore tra password e link via email */
.plain-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  color: var(--ink-muted);
  font-size: 12px;
}

.plain-divider::before,
.plain-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--line);
}

/* Intestazioni ordinabili della lista ticket */
.th-sort {
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.th-sort:hover,
.th-sort.is-active {
  color: var(--accent-strong);
}

.plain-link {
  margin: 14px 0 0;
  text-align: center;
  font-size: 13px;
}

/* --- Verifica in due passaggi ------------------------------------------- */
.mfa-steps {
  margin: 0 0 18px;
  padding-left: 20px;
  font-size: 13.5px;
  color: var(--ink-2);
}

.mfa-steps li + li {
  margin-top: 6px;
}

.mfa-qr {
  display: flex;
  justify-content: center;
  margin: 0 0 14px;
}

/* Sfondo bianco anche nel tema scuro: le app leggono solo QR scuri su chiaro. */
.mfa-qr img {
  background: #fff;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  max-width: 100%;
  height: auto;
}

.mfa-manual {
  margin: 0 0 18px;
  font-size: 13px;
}

.mfa-manual summary {
  cursor: pointer;
  color: var(--ink-2);
}

.mfa-secret {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 15px;
  letter-spacing: 0.06em;
  word-break: break-all;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 6px 0 0;
  user-select: all;
}

.mfa-code {
  font-size: 20px;
  letter-spacing: 0.3em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}


/* ==========================================================================
   Identità Contact Italia
   Regole che danno al portale l'aspetto di contactitalia.it: marchio,
   tipografia Inter, pulsanti a pillola, superfici bianche su grigio chiaro.
   Stanno in fondo perché prevalgono sulle regole di base senza aumentarne la
   specificità.
   ========================================================================== */
body {
  font-size: 14.5px;
  letter-spacing: -0.003em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4 {
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* --- Marchio ------------------------------------------------------------- */
.brand {
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 10px 20px;
}

.brand-logo {
  display: block;
  width: 150px;
  max-width: 100%;
  height: auto;
}

.brand-app {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.brand-app::before {
  content: "";
  width: 14px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}

.plain-logo {
  display: block;
  width: 190px;
  max-width: 70%;
  height: auto;
  margin: 0 auto 18px;
}

/* Versione bianca ufficiale del marchio nel tema scuro. */
.logo-on-dark {
  display: none !important;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-on-light {
    display: none !important;
  }

  :root:not([data-theme="light"]) .logo-on-dark {
    display: block !important;
  }
}

:root[data-theme="dark"] .logo-on-light {
  display: none !important;
}

:root[data-theme="dark"] .logo-on-dark {
  display: block !important;
}

/* --- Menu laterale e barra superiore ------------------------------------- */
.sidebar {
  padding: 22px 16px;
  gap: 2px;
}

.nav-label {
  padding: 0 12px 8px;
  font-size: 11px;
  letter-spacing: 0.08em;
}

.nav-link {
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--ink-2);
  font-weight: 500;
}

.nav-link:hover {
  background: var(--surface-alt);
  color: var(--accent);
}

.nav-link.is-active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
}

.nav-link.is-active svg {
  color: var(--accent);
}

.topbar {
  padding: 14px 28px;
  min-height: 68px;
}

.topbar h1 {
  font-size: 18px;
}

.content {
  padding: 28px 28px 56px;
}

.page-head {
  margin-bottom: 22px;
}

.page-head h1 {
  font-size: 26px;
  letter-spacing: -0.025em;
}

.page-head .sub {
  font-size: 14px;
  color: var(--ink-muted);
}

.avatar {
  background: var(--accent);
  color: var(--on-accent);
}

/* --- Pulsanti a pillola -------------------------------------------------- */
.btn {
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 13.5px;
  font-weight: 600;
  border-color: var(--line-strong);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--surface);
}

.btn-primary {
  color: var(--on-accent);
}

/* Al passaggio i colori si invertono: sfondo della pagina, testo e bordo
   blu. La regola ".btn:hover" sopra porta lo sfondo a --surface, quindi il
   testo non può restare bianco (era bianco su bianco, illeggibile). */
.btn-primary:hover {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 6px 16px var(--focus-glow);
}

.btn-danger:hover {
  color: var(--bad-ink);
  border-color: var(--bad-line);
}

.btn-ghost {
  border-color: transparent;
}

.btn-ghost:hover {
  border-color: transparent;
  background: var(--accent-soft);
}

.btn-danger {
  border-color: var(--bad-line);
}

.btn-sm {
  padding: 6px 13px;
  font-size: 12.5px;
}

/* --- Card, campi, tabelle ------------------------------------------------ */
.card {
  box-shadow: none;
}

.card-head h2 {
  font-size: 16px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="date"],
input[type="number"],
input[type="tel"],
select,
textarea {
  border-radius: 10px;
}

/* --- Pagine senza menu (accesso, password, verifica) ------------------- */
.plain {
  background:
    radial-gradient(1200px 420px at 50% -120px, var(--accent-soft), transparent 70%),
    var(--plane);
}

.plain-card {
  border-radius: 20px;
  padding: 36px 34px;
  box-shadow: 0 1px 2px rgba(0, 9, 26, 0.04), 0 18px 48px rgba(0, 9, 26, 0.08);
}

.plain-head h1 {
  font-size: 22px;
}

.plain-foot {
  margin-top: 22px;
}

@media (max-width: 520px) {
  .plain-card {
    padding: 28px 22px;
    border-radius: 18px;
  }
}

input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 7px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

input[type="file"]::file-selector-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Registro accessi su telefono: evento e ora in testa alla scheda, poi chi,
   il dettaglio e l'indirizzo, ciascuno sulla propria riga. */
@media (max-width: 720px) {
  .audit-table .col-event {
    order: 0;
  }

  .audit-table .col-when {
    order: 1;
    margin-left: auto;
    color: var(--ink-muted);
  }

  .audit-table .col-who,
  .audit-table .col-detail,
  .audit-table .col-ip {
    flex: 1 0 100%;
    order: 2;
    overflow-wrap: anywhere;
  }

  .audit-table .col-who {
    font-weight: 600;
    color: var(--ink);
  }

  .audit-table .col-detail {
    order: 3;
  }

  .audit-table .col-ip {
    order: 4;
  }
}

/* Rete di sicurezza: niente dentro il contenuto può allargare la pagina oltre
   lo schermo. */
.content,
.card,
.card-body {
  min-width: 0;
}

/* Una select prende la larghezza dell'opzione più lunga: nei filtri su
   telefono («Tipo di evento» del registro) sforava lo schermo. */
select,
input,
textarea {
  max-width: 100%;
}

.filters .field,
.form-grid .field {
  min-width: 0;
}

/* Solo su telefono i filtri sono a griglia e ogni campo riempie la sua
   cella; su schermo largo restano in fila con la larghezza naturale. */
@media (max-width: 720px) {
  .filters select,
  .filters input[type="search"] {
    width: 100%;
  }

  .filters .field-wide {
    grid-column: 1 / -1;
  }

  .filters .field > input,
  .filters .field > select {
    width: 100%;
  }
}


/* ---------------------------------------------------------------------------
   Schermi larghi e ritocchi di impaginazione
   --------------------------------------------------------------------------- */
:root {
  --content-max: 1440px;
}

/* Oltre la larghezza massima il contenuto resta al centro, non incollato a
   sinistra con una fascia vuota a destra (iMac, monitor 27"). */
.content {
  max-width: var(--content-max);
  margin-inline: auto;
}

/* La barra in alto segue gli stessi margini: titolo e pulsanti in linea con
   il contenuto sottostante. Il 100% è la larghezza dell'area principale. */
@media (min-width: 721px) {
  .topbar {
    padding-inline: max(28px, calc((100% - var(--content-max)) / 2 + 28px));
  }
}

/* Un elemento flessibile non scende sotto la larghezza del suo testo: senza
   min-width il titolo lungo di un allegato o di una guida usciva dalla card. */
.attachment .name {
  min-width: 0;
}

/* Le guide in dashboard vanno a capo invece di troncarsi. */
.guide-list .attachment {
  align-items: flex-start;
}

.guide-list .attachment .name {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.guide-list .attachment svg {
  margin-top: 1px;
}

/* Il livello "Identità Contact Italia" fissa i margini di .content e della
   barra dopo le regole per telefono, annullandole: qui tornano validi. */
@media (max-width: 720px) {
  .content {
    padding: 18px 16px 40px;
  }

  .topbar {
    padding: 10px 16px;
    min-height: 60px;
  }
}

@media (max-width: 520px) {
  .content {
    padding: 14px 12px 40px;
  }

  .topbar {
    padding: 8px 12px;
  }
}

/* In una griglia le card stanno già distanziate dal gap: il margine della
   regola ".card + .card" le disallineava (la seconda scendeva di 16px). */
.grid > .card + .card {
  margin-top: 0;
}

/* Il grafico scala con la larghezza: su uno schermo largo diventava alto
   quanto la pagina, con testi enormi. Oltre questa altezza resta centrato. */
.chart-svg {
  max-height: 340px;
}

/* --- Prodotto ordinato: SLA sospeso ------------------------------------- */
.sla-paused .sla-dot {
  background: var(--purple-ink);
}

.sla-paused {
  color: var(--purple-ink);
}

/* Consegna prevista già passata: l'attenzione serve qui, non sullo SLA. */
.sla-late .sla-dot {
  background: var(--critical);
}

.sla-late {
  color: var(--bad-ink);
}

/* Campi che compaiono solo con un certo valore di un'altra tendina
   (app.js, data-show-when). Senza JavaScript restano visibili. */
.is-hidden-when {
  display: none;
}
