/* NotiziaE WhatsApp Manager — struttura, layout e tipografia (stile Apple HIG).
   v5: un'unica definizione per componente (i livelli v1–v4 sono stati fusi).
   Regole: griglia a 8 (4 solo per i dettagli interni ai controlli); bordi da 1px
   (0,5px sugli schermi ad alta densità, sezione 14); un solo bordo per lato;
   raggi per livello: contenitore 12 · elemento 10 · controllo 8 · interno 6.
   Materiali, ombre e stati sono qui (effects.css non esiste più). Movimento: motion.css.
   Nessuna risorsa esterna (CSP: style-src 'self'). Scala tipografica 34/28/22/17/15/13/12. */

/* =====================================================================
   1. Token
   ===================================================================== */
:root {
  color-scheme: light dark;
  --bg: #f5f5f7;               /* sfondo raggruppato */
  --surface: #ffffff;          /* card, liste */
  --surface-2: #fafafc;        /* intestazioni di tabella, campi */
  --elevated: rgba(255, 255, 255, .78);
  --label: #1d1d1f;
  --label-2: #424245;
  --label-3: #6e6e73;          /* 4.6:1 su #f5f5f7 */
  --sep: rgba(60, 60, 67, .16);
  --sep-strong: rgba(60, 60, 67, .28);
  --fill: rgba(118, 118, 128, .12);
  --fill-2: rgba(118, 118, 128, .2);
  --brand: #c4262f;            /* rosso NotiziaE: identità, distruttivo, emergenza */
  --brand-hover: #a91f27;
  --brand-ink: #ffffff;
  --brand-tint: rgba(196, 38, 47, .1);
  --tint: #0066cc;             /* link e focus */
  /* Unico stile primario, uguale nei due temi: grafite piena, testo e icona bianchi */
  --primary: #1d1d1f;
  --primary-hover: #3a3a3c;
  --primary-ink: #ffffff;
  --focus: rgba(0, 102, 204, .45);
  --ok: #1a7f37;    --ok-dot: #34c759; --ok-bg: rgba(52, 199, 89, .14);
  --warn: #8a4b00;  --warn-dot: #ff9f0a; --warn-bg: rgba(255, 159, 10, .17);
  --bad: #b3261e;   --bad-dot: #ff3b30; --bad-bg: rgba(255, 59, 48, .12);
  --info: #0058b0;  --info-dot: #0a84ff; --info-bg: rgba(10, 132, 255, .12);
  --muted: #515154; --muted-dot: #8e8e93; --muted-bg: rgba(118, 118, 128, .13);
  --code-bg: #f2f2f5;
  /* Materiali: carta con ombra morbida a più strati; stati sollevato e premuto */
  --surface-edge: rgba(0, 0, 0, .07);
  --surface-hi: rgba(255, 255, 255, .9);              /* filo di luce interno in alto */
  --shadow-surface: 0 0 0 .5px rgba(0, 0, 0, .03), 0 1px 1px rgba(0, 0, 0, .03), 0 2px 6px -1px rgba(0, 0, 0, .04), 0 12px 28px -12px rgba(0, 0, 0, .10);
  --shadow-raised: 0 0 0 .5px rgba(0, 0, 0, .04), 0 1px 2px rgba(0, 0, 0, .05), 0 6px 14px -4px rgba(0, 0, 0, .09), 0 18px 36px -16px rgba(0, 0, 0, .16);
  --shadow-tile: 0 1px 1px rgba(0, 0, 0, .04), 0 2px 5px -2px rgba(0, 0, 0, .07);
  --shadow-pressed: inset 0 1px 3px rgba(0, 0, 0, .14), inset 0 0 0 .5px rgba(0, 0, 0, .06);
  --shadow-btn: inset 0 1px 0 rgba(255, 255, 255, .25), 0 0 0 .5px rgba(0, 0, 0, .04), 0 1px 2px rgba(0, 0, 0, .06);
  --face-top: #ffffff; --face-bot: #f7f7f9;           /* facce delle tessere d'azione */
  --edge: rgba(60, 60, 67, .22); --edge-hover: rgba(196, 38, 47, .62);
  --surface-sheen: none;                              /* in scuro: luce dall'alto sulle superfici */
  --banner-hi: rgba(255, 255, 255, .45);
  --glass-hi: rgba(255, 255, 255, .7);
  --ring: #0066cc; --ring-halo: rgba(0, 102, 204, .2); /* focus: un solo anello, blu sistema */
  --select: rgba(196, 38, 47, .18);
  --thumb: rgba(60, 60, 67, .28); --thumb-hover: rgba(60, 60, 67, .45);
  --field-inset: inset 0 1px 1.5px rgba(0, 0, 0, .05);
  /* Raggi per livello (concentrici: esterno = interno + margine) */
  --r-container: 12px;   /* card, tabelle, liste inset, banner */
  --r-element: 10px;     /* tessere, gruppi annidati */
  --r-control: 8px;      /* campi e pulsanti */
  --r-inner: 6px;        /* elementi dentro un controllo (segmenti, conteggi) */
  --radius: var(--r-container); --radius-s: var(--r-control);
  /* Misure */
  --control-h: 40px; --control-h-s: 32px;
  --gutter: 40px;
  --side-w: 248px;
  --side-bg: #ececef;
  --tabbar-h: 56px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #232325;
    --elevated: rgba(44, 44, 46, .82);
    --label: #f5f5f7;
    --label-2: #d1d1d6;
    --label-3: #a1a1a6;        /* 7:1 su #1c1c1e */
    --sep: rgba(255, 255, 255, .11);
    --sep-strong: rgba(255, 255, 255, .2);
    --fill: rgba(120, 120, 128, .24);
    --fill-2: rgba(120, 120, 128, .36);
    --brand: #c4262f; --brand-hover: #d63a42; --brand-tint: rgba(255, 90, 95, .16);
    --tint: #4da3ff;
    --primary: #f2f2f7; --primary-hover: #ffffff; --primary-ink: #000000;
    --focus: rgba(77, 163, 255, .6);
    --ok: #4cd964;   --ok-dot: #30d158; --ok-bg: rgba(48, 209, 88, .16);
    --warn: #ffb340; --warn-dot: #ff9f0a; --warn-bg: rgba(255, 159, 10, .18);
    --bad: #ff6961;  --bad-dot: #ff453a; --bad-bg: rgba(255, 69, 58, .18);
    --info: #64b5ff; --info-dot: #0a84ff; --info-bg: rgba(10, 132, 255, .2);
    --muted: #c7c7cc; --muted-dot: #8e8e93; --muted-bg: rgba(120, 120, 128, .26);
    --code-bg: #2c2c2e;
    --surface-edge: rgba(255, 255, 255, .07);
    --surface-hi: rgba(255, 255, 255, .07);
    --shadow-surface: 0 0 0 .5px rgba(0, 0, 0, .6), 0 1px 2px rgba(0, 0, 0, .45), 0 14px 32px -14px rgba(0, 0, 0, .75);
    --shadow-raised: 0 0 0 .5px rgba(0, 0, 0, .7), 0 2px 4px rgba(0, 0, 0, .5), 0 20px 44px -16px rgba(0, 0, 0, .85);
    --shadow-tile: 0 1px 2px rgba(0, 0, 0, .5), 0 3px 8px -3px rgba(0, 0, 0, .55);
    --shadow-pressed: inset 0 1px 4px rgba(0, 0, 0, .55), inset 0 0 0 .5px rgba(255, 255, 255, .04);
    --shadow-btn: inset 0 1px 0 rgba(255, 255, 255, .06), 0 1px 2px rgba(0, 0, 0, .4);
    --face-top: #262628; --face-bot: #1e1e20;
    --edge: rgba(255, 255, 255, .13); --edge-hover: rgba(255, 105, 97, .7);
    --surface-sheen: linear-gradient(180deg, rgba(255, 255, 255, .025), rgba(255, 255, 255, 0) 120px);
    --banner-hi: rgba(255, 255, 255, .05);
    --glass-hi: rgba(255, 255, 255, .06);
    --ring: #4da3ff; --ring-halo: rgba(77, 163, 255, .28);
    --select: rgba(255, 90, 95, .34);
    --thumb: rgba(235, 235, 245, .22); --thumb-hover: rgba(235, 235, 245, .4);
    --field-inset: inset 0 1px 2px rgba(0, 0, 0, .35);
    --side-bg: #161618;
  }
}
@media (prefers-contrast: more) and (prefers-color-scheme: light) {
  :root { --sep: rgba(60, 60, 67, .4); --label-3: #48484a; }
}
@media (prefers-contrast: more) {
  :root { --edge: var(--label-3); --surface-edge: var(--label-3); --ring-halo: transparent; }
}
/* Proprietà animabili: la luce che corre sullo spigolo delle tessere d'azione */
@property --edge-angle { syntax: "<angle>"; inherits: false; initial-value: 180deg; }
@property --edge-hi { syntax: "<color>"; inherits: false; initial-value: rgba(60, 60, 67, .28); }

/* =====================================================================
   2. Base e ritmo tipografico
   ===================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--label); }
body { font: 400 15px/1.47 var(--font); letter-spacing: -0.01em; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
a { color: var(--tint); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3 { color: var(--label); margin: 0 0 8px; }
h1 { font-size: 34px; line-height: 40px; font-weight: 700; letter-spacing: -0.022em; }
h1 small { font-size: 17px; font-weight: 500; letter-spacing: -0.01em; }
h2 { font-size: 22px; line-height: 28px; font-weight: 700; letter-spacing: -0.018em; margin: 40px 0 16px; }
h2 small { font-size: 15px; font-weight: 500; }
h2 + p.muted { margin-top: -8px; margin-bottom: 16px; max-width: 72ch; }
h3 { font-size: 17px; line-height: 24px; font-weight: 600; }
p { margin: 0 0 16px; }
ol, ul { padding-left: 24px; margin: 0 0 16px; }
li + li { margin-top: 8px; }
code, .mono { font-family: var(--mono); font-size: .87em; }
code { word-break: break-all; color: var(--label-2); }
small { font-size: 13px; }
.muted, small.muted, .muted small { color: var(--label-3); }
strong { font-weight: 600; }
img { max-width: 100%; }
::selection { background: var(--select); color: inherit; }
html, .side, .table-wrap, pre, .sheet, textarea { scrollbar-width: thin; scrollbar-color: var(--thumb) transparent; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--thumb); border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--thumb-hover); }
table, .tnum, dl.kv dd, .stamp, .kpi .value, .b-val, .count { font-variant-numeric: tabular-nums; }

:focus { outline: none; }
/* Focus da tastiera: un anello unico, blu sistema */
:focus-visible { outline: 2px solid var(--ring); outline-offset: 3px; }
a:not(.btn):not(.gbtn):not(.gtile):not(.ntile):not(.board-row):not(.tab):not(.sheet-row):focus-visible { outline-offset: 2px; border-radius: 4px; box-shadow: 0 0 0 5px var(--ring-halo); }
@media (prefers-contrast: more) { :focus-visible { outline-width: 3px; } }

.skip { position: absolute; left: 8px; top: -80px; z-index: 100; background: var(--surface); color: var(--label); padding: 8px 16px; border-radius: var(--r-control); box-shadow: var(--shadow-raised); }
.skip:focus { top: 8px; }
.sr-only, .visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.js .js-hide { display: none; }

/* Icone: libreria a linea (.ic) e grafiche NotiziaE in linea (svg.ui) */
.ic { width: 20px; height: 20px; flex: none; display: block; }
svg.ui { display: block; flex: none; overflow: visible; }
.ui .ui-paper { fill: var(--surface); }
.ui .ui-red { fill: var(--brand); }
.ui .ui-ray, .ui .ui-redline { stroke: var(--brand); }
@media (prefers-color-scheme: dark) { .ui .ui-ray, .ui .ui-redline { stroke: #e5484f; } .ui .ui-red { fill: #d22f38; } }

/* =====================================================================
   3. Struttura: barra laterale, barra superiore, contenuto
   ===================================================================== */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.shell { min-width: 0; display: flex; flex-direction: column; }
@media (min-width: 861px) {
  .app { background: linear-gradient(90deg, var(--side-bg) calc(var(--side-w) - 1px), var(--sep) calc(var(--side-w) - 1px), var(--sep) var(--side-w), transparent var(--side-w)); }
}

.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; padding: 24px 16px 16px; background: transparent;
}
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 0 0 24px; color: var(--label); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-logo { height: 32px; width: auto; max-width: 180px; display: block; }
.brand .wordmark { font-size: 13px; line-height: 16px; font-weight: 500; color: var(--label-3); letter-spacing: 0; }
.brand-compact { display: none; padding: 0; }
.brand-mark { display: none; width: 28px; height: 28px; border-radius: 6px; }
.who-compact { display: none; }
.brand-compact .brand-logo { height: 28px; }

/* Navigazione: righe da 44 stile Sidebar HIG, icona della libreria NotiziaE a 22px; voce attiva con fondo primario */
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a.ntile {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px;
  border-radius: var(--r-control); color: var(--label); text-decoration: none; background: transparent;
}
.nav a.ntile:hover { background: var(--fill); text-decoration: none; }
.nav a.ntile:active { background: var(--fill-2); }
.nav a.ntile:focus-visible { outline-offset: -2px; border-radius: var(--r-control); }
.nav a.ntile svg.ui { width: 22px; height: 22px; }
.nav a.ntile .ui-accent { display: none; }
.nav a.ntile.on { background: rgba(118, 118, 128, .12); color: var(--label); font-weight: 600; }
@media (prefers-color-scheme: dark) { .nav a.ntile.on { background: rgba(118, 118, 128, .24); } }
.nav a.ntile.on .nav-label { font-weight: 600; }
.nav a.ntile.on .ui-accent { display: inline; }
.nav-label { flex: 1; min-width: 0; font-size: 15px; font-weight: 500; line-height: 20px; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.count {
  display: inline-flex; align-items: center; justify-content: center; flex: none; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; background: var(--brand); color: #fff; font-size: 12px; font-weight: 600;
}
.nav a.ntile .count { margin-left: auto; }
@media (forced-colors: active) { .nav a.ntile.on { outline: 2px solid ButtonText; } }

.side .who { margin-top: auto; padding: 16px 0 0; border-top: 1px solid var(--sep); font-size: 13px; }
.who-name { font-weight: 600; font-size: 15px; }
.who-mail { color: var(--label-3); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-actions { display: flex; gap: 0; margin: 8px 0 0 -8px; }
.who-actions .btn.plain, .who-actions button.plain { padding: 0 8px; min-height: 32px; }

/* Barra superiore: stato sempre visibile + arresto d'emergenza */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 8px var(--gutter);
  background: var(--bg); border-bottom: 1px solid var(--sep);
}
@supports (animation-timeline: scroll()) {
  @media (prefers-reduced-motion: no-preference) and (prefers-contrast: no-preference) {
    .topbar { animation: bar-line linear both; animation-timeline: scroll(root block); animation-range: 0 24px; }
  }
}
@keyframes bar-line { from { border-bottom-color: transparent; } to { border-bottom-color: var(--sep); } }
@media (prefers-contrast: more) { .topbar { border-bottom-color: var(--sep-strong); } }
.topbar .pills { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; flex: 1; min-width: 0; }
.topbar .pill-summary { display: none; }
.page-overview .topbar .pills { display: none; }
/* Panoramica (desktop): lo stato è già nel riepilogo; la barra sparisce e Stop sta nell'intestazione della pagina,
   sempre raggiungibile (resta in alto a destra anche scorrendo) */
@media (min-width: 861px) {
  .page-overview .topbar { min-height: 0; height: 0; padding: 0 var(--gutter); border: 0; background: none; animation: none; align-items: flex-start; }
  .page-overview .stop-form, .page-overview .stop-active { margin-top: 32px; transition: margin-top .18s ease; }
  html.is-scrolled .page-overview .stop-form, html.is-scrolled .page-overview .stop-active { margin-top: 12px; }
  html.is-scrolled .page-overview .stop { box-shadow: 0 4px 14px rgba(0, 0, 0, .18); }
  .page-overview .page-head.split { padding-right: 232px; }
}
.stop-form { margin: 0 0 0 auto; flex: none; }
.stop {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px 0 12px;
  background: #c4262f; color: #fff; border: 0; border-radius: 999px; box-shadow: inset 0 0 0 .5px rgba(0, 0, 0, .28);
  font: 600 15px/1 var(--font); letter-spacing: -0.01em; cursor: pointer;
}
/* Arresto d'emergenza: PIATTO, riconoscibile per colore e forma */
.stop:hover { background: #cf333c; color: #fff; }
.stop:active { background: #a51f27; }
.stop:focus-visible { outline: 3px solid var(--ring); outline-offset: 3px; border-radius: 999px; }
.stop svg.ui { width: 22px; height: 22px; }
.stop .ui-red { fill: #fff; }
.stop .ui-onred-fill { fill: #c4262f; }
.stop:hover .ui-onred-fill { fill: #cf333c; }
.stop:active .ui-onred-fill { fill: #a51f27; }
@media (forced-colors: active) { .stop { border: 1px solid ButtonText; } }
.stop-short { display: none; }
.stop-active {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px 0 12px; margin-left: auto;
  border-radius: 999px; background: var(--bad-bg); color: var(--bad); font-weight: 600; flex: none;
}
.stop-active svg.ui { width: 22px; height: 22px; }

.main { padding: 32px var(--gutter) 64px; max-width: 1320px; width: 100%; }
.main > .flash { margin-bottom: 24px; }

/* Intestazione di pagina: ritorno → titolo → sommario → 24px → contenuto */
.page-head { display: block; margin: 0 0 24px; }
.page-head.split { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px 24px; }
.page-head h1 { margin: 0; overflow-wrap: anywhere; }
.page-head .lead { margin: 8px 0 0; font-size: 15px; max-width: 72ch; }
.page-head .meta { margin: 8px 0 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; font-size: 15px; }
.lead { font-size: 17px; margin: 0; }
.meta-link { overflow-wrap: anywhere; min-width: 0; }
.stamp { margin: 0; font-size: 13px; color: var(--label-3); }
.backline { margin: 0 0 8px; }
.back { display: inline-flex; align-items: center; gap: 2px; min-height: 32px; margin: 0 0 0 -4px; padding: 0 8px 0 0; font-size: 15px; }
.back .ic, .back svg.ui { width: 16px; height: 16px; margin-right: 4px; }
.section-title { margin: 40px 0 16px; }
.h-count { font-size: 15px; font-weight: 500; color: var(--label-3); margin-left: 8px; }

/* =====================================================================
   4. Stato: testo con punto colorato; capsula dove deve saltare all'occhio
   ===================================================================== */
.pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; line-height: 1.3; white-space: nowrap;
  color: var(--muted); vertical-align: 1px;
}
.pill::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted-dot); flex: none;
  box-shadow: 0 0 0 2.5px color-mix(in srgb, currentColor 16%, transparent), inset 0 -1px 0 rgba(0, 0, 0, .12);   /* punto a inchiostro */
}
.pill.ok { color: var(--ok); }     .pill.ok::before { background: var(--ok-dot); box-shadow: 0 0 0 2.5px var(--ok-bg), inset 0 -1px 0 rgba(0, 0, 0, .12); }
.pill.warn { color: var(--warn); } .pill.warn::before { background: var(--warn-dot); box-shadow: 0 0 0 2.5px var(--warn-bg), inset 0 -1px 0 rgba(0, 0, 0, .12); }
.pill.bad { color: var(--bad); font-weight: 600; } .pill.bad::before { background: var(--bad-dot); box-shadow: 0 0 0 2.5px var(--bad-bg), inset 0 -1px 0 rgba(0, 0, 0, .12); }
.pill.info { color: var(--info); } .pill.info::before { background: var(--info-dot); box-shadow: 0 0 0 2.5px var(--info-bg), inset 0 -1px 0 rgba(0, 0, 0, .12); }
.pill.muted { color: var(--label-3); }
.pill.plain::before { display: none; }
.pill.plain { padding: 0 6px; border-radius: 999px; background: var(--fill); font-size: 12px; }
.pill.art { gap: 6px; }
.pill.art::before { display: none; }
.pill.art svg.ui { width: 18px; height: 18px; }
td .pill.art { vertical-align: -0.2em; }
/* Capsule nei titoli e nelle toolbar: tinta piatta, nessun bordo */
h2 .pill, .toolbar .pill { height: 24px; padding: 0 10px; border-radius: 999px; font-weight: 600; font-size: 13px; background: var(--muted-bg); }
h2 .pill.ok, .toolbar .pill.ok { background: var(--ok-bg); }
h2 .pill.warn, .toolbar .pill.warn { background: var(--warn-bg); }
h2 .pill.bad, .toolbar .pill.bad { background: var(--bad-bg); }
h2 .pill.info, .toolbar .pill.info { background: var(--info-bg); }
/* Barra in alto: un'unica riga di stato in testo semplice, punto colorato, niente capsule né grafiche */
.topbar .pills { gap: 4px 20px; }
.topbar .pill { font-size: 13px; font-weight: 500; }
.topbar .pill.art svg.ui { display: none; }
.topbar .pill.art::before { display: block; }
.topbar .pill.plain { background: none; border: 0; padding: 0; color: var(--label-3); }
h2 .pill { margin-left: 8px; }
.sev { min-width: 72px; }
.prov { display: inline-block; font-size: 12px; font-weight: 600; color: var(--label-3); letter-spacing: .02em; }

/* =====================================================================
   5. Contenitori: griglie, card, riepilogo, metriche, banner
   ===================================================================== */
.grid { display: grid; gap: 24px; }
.grid.k { grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr)); align-items: start; }
.stack { display: block; }
.stack > * + * { margin-top: 16px; }

/* Superfici di carta: ombra morbida a più strati; in scuro si leggono per luce dall'alto */
.card, .board, .metrics, .table-wrap {
  border: 1px solid var(--surface-edge); background-image: var(--surface-sheen);
  box-shadow: inset 0 1px 0 var(--surface-hi), var(--shadow-surface);
}
.card { background-color: var(--surface); border-radius: var(--r-container); padding: 24px; min-width: 0; }
.card > :first-child { margin-top: 0; }
.card > :last-child, .card > p:last-child, .card > ol:last-child, .card > ul:last-child { margin-bottom: 0; }
.card h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; line-height: 24px; margin: 0 0 16px; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.card h3 { font-size: 15px; margin: 0 0 8px; }
.card h3.mt-1 { margin-top: 24px; }
.card.mt-1 + .card.mt-1 { margin-top: 16px; }
.card ol { padding-left: 24px; }
.form-card { max-width: 560px; }

/* KPI */
.kpi .label { font-size: 13px; color: var(--label-3); font-weight: 500; }
.kpi .value { font-size: 28px; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; margin-top: 4px; }
.kpi .value small { font-size: 17px; font-weight: 500; color: var(--label-3); }
.kpi .sub { font-size: 13px; color: var(--label-3); margin-top: 4px; }
.card.kpi { padding: 16px 24px; }
.kpi.bad .value { color: var(--bad); } .kpi.warn .value { color: var(--warn); } .kpi.ok .value { color: var(--ok); }

/* Riepilogo in cima alla panoramica */
.board { background-color: var(--surface); border-radius: var(--r-container); overflow: hidden; }
.board-row {
  display: grid; grid-template-columns: 40px 136px minmax(120px, max-content) minmax(0, 1fr) 16px; align-items: center; gap: 0 16px;
  min-height: 64px; padding: 12px 16px; color: var(--label); text-decoration: none; border-top: 1px solid var(--sep);
}
.board-row:first-child { border-top: 0; }
.board-row:hover { text-decoration: none; background: linear-gradient(90deg, rgba(118, 118, 128, .07), rgba(118, 118, 128, .03)); }
.board-row:active { background: rgba(118, 118, 128, .12); }
.board-row:focus-visible { outline-offset: -3px; border-radius: 10px; }
.board-row:hover .chev { opacity: 1; color: var(--label-2); }
.b-glyph { position: relative; isolation: isolate; width: 40px; height: 40px; display: grid; place-items: center; color: var(--label-3); }
/* Il glifo di stato poggia su un dischetto di carta del suo colore */
.b-glyph::before {
  content: ""; position: absolute; inset: 2px; z-index: -1; border-radius: 10px;
  background: radial-gradient(circle at 50% 35%, color-mix(in srgb, currentColor 14%, transparent), transparent 72%);
}
@media (forced-colors: active) { .b-glyph::before { display: none; } }
.b-glyph svg.ui { width: 40px; height: 40px; }
.b-key { font-size: 15px; color: var(--label-2); }
.b-val { font-size: 22px; font-weight: 700; letter-spacing: -0.018em; line-height: 1.2; }
.b-sub { font-size: 13px; line-height: 18px; color: var(--label-3); min-width: 0; }
.board-row .chev { width: 14px; height: 14px; color: var(--label-3); opacity: .6; }
.board-row.ok .b-glyph { color: var(--ok); }     .board-row.ok .b-val { color: var(--label); }
.board-row.warn .b-glyph { color: var(--warn); } .board-row.warn .b-val { color: var(--warn); }
.board-row.bad .b-glyph { color: var(--bad); }   .board-row.bad .b-val { color: var(--bad); }
.board-row.info .b-glyph { color: var(--info); } .board-row.info .b-val { color: var(--info); }

/* Metriche del giorno: una striscia densa, separatori sottili */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); background-color: var(--surface); border-radius: var(--r-container); overflow: hidden; }
/* Desktop largo: le 7 metriche della panoramica su una sola riga (niente 6+1). */
@media (min-width: 1280px) { .metrics:has(> :nth-child(7):last-child) { grid-template-columns: repeat(7, minmax(0, 1fr)); } }
/* Separatori come filo destro e inferiore: quelli sul bordo esterno vengono tagliati, nessun buco né doppio bordo */
.metrics .kpi { padding: 16px; min-width: 0; box-shadow: 1px 0 0 var(--sep), 0 1px 0 var(--sep); }
.metrics .kpi .value { font-size: 28px; line-height: 32px; margin: 0; font-variant-numeric: tabular-nums; }
.metrics .kpi .value small { font-size: 15px; }
.metrics .kpi .label { font-size: 13px; line-height: 16px; margin-top: 4px; color: var(--label-2); font-weight: 500; }
.metrics .kpi .sub { font-size: 12px; line-height: 16px; margin-top: 2px; }

/* Banner di stato: icona centrata sulla prima riga (22px) */
.banner {
  position: relative; border-radius: var(--r-container); padding: 12px 16px 12px 48px; margin-bottom: 16px;
  background: var(--info-bg); color: var(--label); border: 1px solid transparent; font-size: 15px; line-height: 22px;
  box-shadow: inset 0 1px 0 var(--banner-hi);   /* carta tinta, filo di luce in alto */
}
.banner::before {
  content: ""; position: absolute; left: 16px; top: 13px; width: 20px; height: 20px; background: var(--info-dot);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm0 4.6a1.3 1.3 0 1 1 0 2.6 1.3 1.3 0 0 1 0-2.6zM13.4 17h-2.8v-1.6h.6v-4h-.6V9.8h2.2v5.6h.6z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm0 4.6a1.3 1.3 0 1 1 0 2.6 1.3 1.3 0 0 1 0-2.6zM13.4 17h-2.8v-1.6h.6v-4h-.6V9.8h2.2v5.6h.6z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.banner.bad, .banner.warn {
  --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm-1.3 5h2.6l-.4 7h-1.8zM12 15.3a1.4 1.4 0 1 1 0 2.8 1.4 1.4 0 0 1 0-2.8z'/%3E%3C/svg%3E");
}
.banner.bad::before, .banner.warn::before { -webkit-mask-image: var(--m); mask-image: var(--m); }
.banner.ok::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm-1.4 14.2-4-4 1.4-1.4 2.6 2.6 5.6-5.6 1.4 1.4z'/%3E%3C/svg%3E");
          mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm-1.4 14.2-4-4 1.4-1.4 2.6 2.6 5.6-5.6 1.4 1.4z'/%3E%3C/svg%3E");
}
.banner.bad { background: var(--bad-bg); border-color: rgba(255, 59, 48, .22); }   .banner.bad::before { background: var(--bad-dot); }
.banner.warn { background: var(--warn-bg); border-color: rgba(255, 159, 10, .28); } .banner.warn::before { background: var(--warn-dot); }
.banner.ok { background: var(--ok-bg); border-color: rgba(52, 199, 89, .25); }      .banner.ok::before { background: var(--ok-dot); }
.banner.info { background: var(--info-bg); border-color: rgba(10, 132, 255, .2); }
.banner.bad strong { color: var(--bad); } .banner.warn strong { color: var(--warn); } .banner.ok strong { color: var(--ok); } .banner.info strong { color: var(--info); }
.banner a { font-weight: 600; }
.banner .toolbar { margin: 12px 0 0; }
.banner details { margin-top: 8px; }
.banner.compact { padding: 8px 16px 8px 44px; font-size: 13px; line-height: 20px; }
.banner.compact::before { left: 16px; top: 9px; width: 18px; height: 18px; }

/* =====================================================================
   6. Tabelle: colonne allineate, linee di base comuni, numeri tabulari
   ===================================================================== */
.table-wrap {
  position: relative; background-color: var(--surface); border-radius: var(--r-container);
  overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; overscroll-behavior-x: contain;
}
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 12px 16px; vertical-align: baseline; }
td { border-top: 1px solid var(--sep); }
thead + tbody tr:first-child td { border-top: 0; }
th {
  font-size: 13px; font-weight: 600; line-height: 16px; color: var(--label-3); white-space: nowrap; background: var(--surface-2);
  padding-top: 8px; padding-bottom: 8px; vertical-align: bottom; border-bottom: 1px solid var(--sep); position: sticky; top: 0;
  background-image: linear-gradient(180deg, transparent, rgba(0, 0, 0, .012));
}
th:empty { padding: 0; }
tbody tr:hover td { background: linear-gradient(90deg, rgba(118, 118, 128, .07), rgba(118, 118, 128, .03)); }
td.num, th.num { text-align: right; white-space: nowrap; }
td small, td > small:only-child, td small.mono { font-size: 13px; }
td .pill + .pill { margin-left: 8px; }
td.right { text-align: right; white-space: nowrap; }
td.right, td:has(> form.inline), td:has(> .btn), td:has(> .inline-details) { vertical-align: middle; }
td.right > * + * { margin-left: 8px; }
td.right form.inline { vertical-align: middle; }
td.muted { text-align: center; padding: 24px 16px; }
td a { font-weight: 500; color: var(--label); }
td a:hover { color: var(--tint); }
td:first-child a { color: var(--label-3); }
td details pre { max-width: 520px; }
td .empty { padding: 24px 8px; }
.truncate { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.rows-44 td { padding-top: 12px; padding-bottom: 12px; }
table.rows-44 td.truncate { max-width: 300px; }
small.sub { display: inline-block; color: var(--label-3); font-size: 12px; }

/* Tabella pubblicazioni (coda, articoli, canale): colonne identiche ovunque.
   Il titolo ha almeno 14rem e va a capo su due righe invece dei puntini. */
@media (min-width: 861px) {
  table.pubtable { table-layout: fixed; min-width: 760px; }
  .pubtable th:nth-child(1) { width: 64px; }
  .pubtable th:nth-child(3) { width: 64px; }
  .pubtable th:nth-child(4) { width: 24%; }
  .pubtable th:nth-child(5) { width: 64px; }
  .pubtable th:nth-child(6), .pubtable th:nth-child(7) { width: 112px; }
  .pubtable td.c-art { max-width: none; min-width: 14rem; white-space: normal; }
  .pubtable td.c-art a { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
  .pubtable td.c-art br { display: none; }
  .pubtable td.c-art .sub { display: block; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pubtable td.c-st { white-space: normal; }
}
@media (min-width: 861px) and (max-width: 1180px) {
  .pubtable th:nth-child(4) { width: 22%; }
  .pubtable th:nth-child(6), .pubtable th:nth-child(7) { width: 104px; }
}

/* =====================================================================
   7. Liste: coppie etichetta/valore, elenchi semplici
   ===================================================================== */
dl.kv {
  display: grid; grid-template-columns: minmax(150px, 34%) minmax(0, 1fr); margin: 0 0 4px;
  background: var(--surface-2); border: 1px solid var(--sep); border-radius: var(--r-container); overflow: hidden;
}
dl.kv dt, dl.kv dd {
  padding: 12px 16px; min-height: 44px; line-height: 20px; border-top: 1px solid var(--sep);
  display: flex; align-items: center; overflow-wrap: anywhere; min-width: 0;
}
dl.kv dt { color: var(--label-2); font-size: 15px; }
dl.kv dd { margin: 0; padding-left: 0; word-break: break-word; justify-content: flex-start; flex-wrap: wrap; gap: 4px 8px; }
dl.kv dt:first-of-type, dl.kv dd:first-of-type { border-top: 0; }
dl.kv dd code { word-break: break-all; }
dl.kv dd code, dl.kv dd .mono { line-height: 20px; }
/* Dentro una scheda: lista inset da bordo a bordo, senza seconda cornice */
.card dl.kv { border: 0; border-radius: 0; background: transparent; margin: 0 -24px; border-top: 1px solid var(--sep); border-bottom: 1px solid var(--sep); }
.card dl.kv dt { padding-left: 24px; }
.card dl.kv dd { padding-right: 24px; }
.card > dl.kv:last-child { border-bottom: 0; margin-bottom: -24px; }
.card dl.kv + .toolbar, .card dl.kv + .list, .card dl.kv + details, .card dl.kv + p { margin-top: 16px; }
/* Barra d'azioni vuota (nessuna azione disponibile): niente spazio fantasma né bordo doppio */
.toolbar:not(:has(*)) { display: none; }
.card > dl.kv:has(+ .toolbar:not(:has(*)):last-child) { border-bottom: 0; margin-bottom: -24px; }

.list { list-style: none; padding: 0; margin: 16px 0 0; }
.list-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--sep); margin: 0; }
.list-row:first-child { border-top: 0; }
.list-row:has(.empty) { justify-content: center; padding: 0; }
.list-main { flex: 1; min-width: 0; }

/* =====================================================================
   8. Controlli: un'altezza per tutti (40) e una piccola (32)
   ===================================================================== */
form.inline { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 16px 0; }
.toolbar.filters { margin: 0 0 16px; }
.toolbar.actions { margin: 0 0 24px; }
.toolbar:has(> .gtile, > form > .gtile) { gap: 12px; }
.card .toolbar:first-child { margin-top: 0; }
.card .toolbar:last-child { margin-bottom: 0; }
.toolbar.filters > input[type=search] { flex: 1 1 280px; max-width: 400px; }
.card + .toolbar.filters, .control + .toolbar.filters { margin-top: 24px; margin-bottom: 0; }

input[type=text], input[type=search], input[type=email], input[type=password], input[type=number], input[type=date], input[type=file], select, textarea {
  font: 400 15px/1.3 var(--font); letter-spacing: -0.01em; min-height: var(--control-h); padding: 0 12px;
  border: 1px solid var(--sep-strong); border-radius: var(--r-control); background-color: var(--surface); color: var(--label);
  min-width: 0; max-width: 100%; box-shadow: var(--field-inset);
}
input:hover:not(:focus):not(:disabled), select:hover:not(:focus):not(:disabled), textarea:hover:not(:focus):not(:disabled) { border-color: color-mix(in srgb, var(--label-3) 70%, transparent); }
input:disabled, select:disabled, textarea:disabled { background-color: var(--fill); box-shadow: none; color: var(--label-3); }
input[aria-invalid="true"], .field:has(.errors) input { border-color: var(--bad); }
input[type=search] {
  padding-left: 32px; min-width: 240px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6'/%3E%3Cpath d='m15 15 5 5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 10px center; background-size: 16px;
}
input[type=file] { padding: 4px; display: inline-flex; align-items: center; }
select {
  -webkit-appearance: none; appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 14px;
}
textarea { width: 100%; min-height: 88px; padding: 8px 12px; resize: vertical; line-height: 1.47; }
input::placeholder, textarea::placeholder { color: var(--label-3); opacity: 1; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ring); box-shadow: var(--field-inset), 0 0 0 1px var(--ring), 0 0 0 5px var(--ring-halo); }
@media (prefers-contrast: more) { input:focus, select:focus, textarea:focus { box-shadow: 0 0 0 2px var(--ring); } }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; accent-color: var(--tint); vertical-align: -3px; margin: 0 6px 0 0; }
.card label:has(> input[type=checkbox]), .card label:has(> input[type=radio]) { display: inline-flex; align-items: center; gap: 2px; min-height: 40px; flex-wrap: wrap; }

/* Pulsante di sistema (selettore file nativo): stesso disegno dei pulsanti grafici */
input[type=file]::file-selector-button, input[type=file]::-webkit-file-upload-button {
  min-height: 30px; margin: 0 12px 0 0; padding: 0 12px; border: 1px solid var(--sep-strong); border-radius: var(--r-inner);
  background: var(--surface); color: var(--label); font: 600 13px/1 var(--font); letter-spacing: 0; cursor: pointer;
}

.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--control-h); padding: 0 16px;
  font: 500 15px/1.2 var(--font); letter-spacing: -0.01em; text-align: center;
  border-radius: var(--r-control); border: 0; background: var(--fill); color: var(--label);
  cursor: pointer; text-decoration: none; white-space: nowrap; box-shadow: var(--shadow-btn);
}
.btn:hover, button:hover { background: var(--fill-2); text-decoration: none; color: var(--label); }
.btn:active, button:active { box-shadow: inset 0 1px 3px rgba(0, 0, 0, .2); }
.btn:focus-visible, button:focus-visible, summary:focus-visible { outline-offset: 3px; }
.btn.primary, button.primary { background: var(--primary); color: var(--primary-ink); font-weight: 600; }
.btn.primary:hover, button.primary:hover { background: var(--primary-hover); color: var(--primary-ink); }
.btn.danger, button.danger { background: var(--brand); color: var(--brand-ink); font-weight: 600; }
.btn.danger:hover, button.danger:hover { background: var(--brand-hover); color: #fff; }
.btn.small, button.small { min-height: var(--control-h-s); padding: 0 12px; font-size: 13px; }
.btn.plain, button.plain { background: transparent; color: var(--tint); padding: 0 8px; box-shadow: none; }
.btn.plain:hover, button.plain:hover { background: var(--fill); color: var(--tint); }
.btn.plain small { font-size: 13px; color: inherit; }
button:disabled, .gtile[aria-disabled="true"], .gbtn[aria-disabled="true"] { box-shadow: none; filter: grayscale(1); opacity: .5; cursor: not-allowed; }

/* Pulsanti grafici: disegno + didascalia breve, tono editoriale (niente maiuscole) */
.gbtn, button.gbtn, summary.gbtn {
  position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: var(--control-h); padding: 0 16px 0 8px;
  border-radius: var(--r-control); color: var(--label);
  font: 600 13px/16px var(--font); letter-spacing: 0; text-transform: none; cursor: pointer; text-decoration: none; white-space: nowrap;
}
/* Tessere e pulsanti grafici (neutri): carta con spigolo a gradiente; in hover la luce rossa scorre lungo lo spigolo */
.gbtn, .gtile {
  --edge-angle: 180deg; --edge-hi: var(--edge);
  border: 1px solid transparent;
  background: linear-gradient(180deg, var(--face-top), var(--face-bot)) padding-box,
              linear-gradient(var(--edge-angle), var(--edge-hi) 0%, var(--edge) 46%, var(--edge) 100%) border-box;
  box-shadow: inset 0 1px 0 var(--surface-hi), var(--shadow-tile);
}
.gbtn:hover, .gtile:hover {
  --edge-angle: 135deg; --edge-hi: var(--edge-hover);
  background: linear-gradient(180deg, var(--face-top), var(--face-top)) padding-box,
              linear-gradient(var(--edge-angle), var(--edge-hi) 0%, var(--edge) 46%, var(--edge) 100%) border-box;
  box-shadow: inset 0 1px 0 var(--surface-hi), var(--shadow-raised); color: var(--label); text-decoration: none;
}
.gbtn:active, .gtile:active {
  background: linear-gradient(180deg, var(--face-bot), var(--face-bot)) padding-box,
              linear-gradient(var(--edge-angle), var(--edge-hi) 0%, var(--edge) 46%, var(--edge) 100%) border-box;
  box-shadow: var(--shadow-pressed);
}
.gtile:focus-visible { outline-offset: 3px; border-radius: 12px; }
@media (forced-colors: active) { .gtile, .gbtn { border: 1px solid ButtonText; } }
.gbtn svg.ui { width: 28px; height: 28px; }
.gbtn.small, button.gbtn.small, summary.gbtn.small { min-height: var(--control-h-s); padding: 0 12px 0 4px; gap: 4px; }
.gbtn.small svg.ui { width: 24px; height: 24px; }
.gbtn.primary, .gtile.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), var(--shadow-tile); }
.gbtn.primary:hover, .gtile.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--primary-ink); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), var(--shadow-raised); }
.gbtn.primary:active, .gtile.primary:active, .gbtn.danger:active, .gtile.danger:active { box-shadow: inset 0 2px 4px rgba(0, 0, 0, .3); }
.gbtn.primary .ui-paper { fill: var(--primary); }
.gbtn.danger, .gtile.danger { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), var(--shadow-tile); }
.gbtn.danger:hover, .gtile.danger:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: #fff; }
.gbtn.danger { border-radius: 4px 12px 4px 12px; }
.gbtn.danger .ui-red { fill: #fff; } .gbtn.danger .ui-ray, .gbtn.danger .ui-redline { stroke: #fff; }
summary.gbtn::before { display: none; }
.gcap { display: inline-block; font-size: 13px; font-weight: 600; letter-spacing: 0; text-transform: none; }

/* Tessere d'azione: per le decisioni principali di una pagina */
.gtile, button.gtile {
  position: relative; display: inline-flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 8px;
  width: 128px; min-height: 96px; padding: 12px; border-radius: var(--r-element); text-align: left;
  color: var(--label); cursor: pointer; text-decoration: none;
  font: 600 13px/16px var(--font); letter-spacing: 0; text-transform: none; white-space: normal;
}
.gtile svg.ui { width: 40px; height: 40px; }
.gtile.primary .ui-paper { fill: var(--primary); }
.gtile.danger { border-radius: 4px 16px 4px 16px; }
.gtile.danger .ui-red { fill: #fff; }
form.inline:has(> .gtile) { align-items: flex-end; gap: 8px; }
form.inline:has(> .gtile) > input { align-self: flex-end; }

/* Controllo segmentato (filtri): raggio interno = esterno − margine */
.segmented {
  display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--r-control); background: var(--fill); max-width: 100%;
  overflow-x: auto; scrollbar-width: none; box-shadow: inset 0 1px 2px rgba(0, 0, 0, .06);
}
.segmented::-webkit-scrollbar { display: none; }
.seg-select { display: none; }
.segmented label { position: relative; margin: 0; }
.segmented input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.segmented span {
  display: flex; align-items: center; min-height: 36px; padding: 0 16px; border-radius: var(--r-inner);
  font-size: 13px; font-weight: 500; color: var(--label); white-space: nowrap;
}
.segmented input:checked + span {
  background: var(--surface); font-weight: 600;
  box-shadow: inset 0 1px 0 var(--surface-hi), 0 0 0 .5px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .1), 0 3px 8px -2px rgba(0, 0, 0, .1);
}
.segmented input:focus-visible + span { outline: 2px solid var(--ring); outline-offset: 1px; }
@media (prefers-color-scheme: dark) { .segmented input:checked + span { background: #636366; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), 0 1px 3px rgba(0, 0, 0, .5); } }

/* Conteggi (coda) */
.tally { display: inline-flex; align-self: flex-start; flex-wrap: wrap; align-items: center; gap: 2px; padding: 2px; border-radius: var(--r-control); background: var(--fill); font-size: 13px; max-width: 100%; }
.tally-key { padding: 4px 8px; color: var(--label-3); }
.tally-item { padding: 4px 8px; border-radius: var(--r-inner); background: var(--surface); color: var(--label-2); white-space: nowrap; }
.tally-item b { font-weight: 600; color: var(--label); margin-left: 2px; }

/* Dettagli a scomparsa */
details { margin: 0; }
details summary { cursor: pointer; font-weight: 500; color: var(--tint); min-height: 32px; display: flex; align-items: center; gap: 6px; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::before {
  content: ""; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); margin: 0 4px 0 2px; flex: none;
}
details[open] > summary::before { transform: rotate(45deg); }
.card details summary { min-height: var(--control-h); }
.card details + details { border-top: 1px solid var(--sep); }
details.skipped > summary { color: var(--label-2); }
.inline-details { display: inline-block; vertical-align: middle; }
.inline-details[open] { display: block; margin-top: 8px; text-align: left; }
.inline-details form { min-width: 220px; }
.inline-details[open] form { margin-left: auto; max-width: 280px; }
.inline-details .stack > * + * { margin-top: 8px; }
.inline-details input { width: 100%; }

pre {
  font-family: var(--mono); background: var(--code-bg); border-radius: var(--r-control); padding: 12px 16px;
  overflow: auto; font-size: 12px; line-height: 1.5; max-height: 360px; margin: 8px 0 0; white-space: pre;
}

/* =====================================================================
   9. Moduli
   ===================================================================== */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 500; font-size: 13px; line-height: 16px; color: var(--label-2); margin-bottom: 8px; }
.field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea { width: 100%; }
.field .hint { font-size: 13px; line-height: 16px; color: var(--label-3); margin-top: 8px; }
.errors { color: var(--bad); font-size: 13px; }
.form-actions { margin-top: 24px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.form-note { margin: 16px 0 0; }
.check-row { display: flex; align-items: center; gap: 8px; min-height: 40px; margin: 8px 0 0; font-size: 15px; color: var(--label); }
.check-row input[type=checkbox], .check-row input[type=radio] { margin: 0; }
.confirm-row { margin: 0; }
.confirm-row > input[type=text] { flex: 0 1 200px; }
.stack > label:has(> input[type=radio]) { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-height: 40px; }
.stack > label:has(> input[type=radio]) + label { margin-top: 0; }
.form-card .field > label.check-row { display: flex; margin: 8px 0 0; font-size: 15px; color: var(--label); }

/* Impostazioni: righe da 56 come in Impostazioni di iOS; gruppi a 24; colonna dei valori unica (144) */
.group-title, .card .group-title { font-size: 13px; font-weight: 600; line-height: 16px; color: var(--label-3); letter-spacing: 0; margin: 24px 0 0; padding-bottom: 8px; }
.settings-form > h2 + .group-title, .card.settings-form > h2 + .group-title { margin-top: 0; }
.settings-form .field:has(> input[type=checkbox]),
.settings-form .field:has(> input[type=number]),
.settings-form .field:has(> select) {
  display: grid; grid-template-columns: minmax(0, 1fr) 144px; align-items: center; gap: 0 16px;
  margin: 0; padding: 8px 0; min-height: 56px; border-top: 1px solid var(--sep);
}
.settings-form .group-title + .field { border-top: 0; }
.settings-form .field > label { grid-column: 1; grid-row: 1; margin: 0; font-size: 15px; line-height: 20px; color: var(--label); }
.settings-form .field > input[type=checkbox],
.settings-form .field > input[type=number],
.settings-form .field > select { grid-column: 2; grid-row: 1 / span 2; justify-self: end; align-self: center; }
.settings-form .field > input[type=number], .settings-form .field > select { width: 144px; }
.settings-form .field > input[type=number] { text-align: right; }
.settings-form .field > .hint { grid-column: 1; grid-row: 2; margin: 0; }
.settings-form .field:has(> textarea) { margin: 0; padding: 12px 0 0; border-top: 1px solid var(--sep); }
.settings-form .field:has(> textarea) > label { display: block; margin-bottom: 8px; }
.settings-form .form-actions { margin-top: 16px; }
.settings-form .form-actions > .gbtn { flex: 1 1 100%; justify-content: center; min-height: 44px; }

/* Interruttore stile iOS per le caselle booleane delle impostazioni */
.field > input[type=checkbox] {
  -webkit-appearance: none; appearance: none; width: 51px; height: 31px; border-radius: 999px; margin: 0;
  background: var(--fill-2); position: relative; cursor: pointer; flex: none; box-shadow: inset 0 1px 2px rgba(0, 0, 0, .1);
}
.field > input[type=checkbox]::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, .15), 0 1px 1px rgba(0, 0, 0, .16); transition: transform .2s ease;
}
.field > input[type=checkbox]:checked { background: var(--ok-dot); }
.field > input[type=checkbox]:checked::after { transform: translateX(20px); }

/* Moduli impilati (utenti, password, feed, associazione): etichetta sopra, campo a tutta larghezza */
.form-card .field, .card:not(.settings-form) .field:has(> select) { display: block; border-top: 0; padding-top: 0; min-height: 0; margin: 0 0 16px; }
.form-card .field > select, .form-card .field > input:not([type=checkbox]):not([type=radio]),
.card:not(.settings-form) .field:has(> select) > select { width: 100%; }
.card:not(.settings-form) .field > label { margin: 0 0 8px; font-size: 13px; color: var(--label-2); }
.card form > .gbtn:last-child, .card form > button:last-child { margin-top: 8px; }

/* Logo */
.logo-preview { max-height: 64px; background: var(--surface-2); padding: 8px; border-radius: var(--r-control); border: 1px solid var(--sep); }
label.file-pick {
  position: relative; cursor: pointer; background: var(--surface); border: 1px solid var(--sep-strong); color: var(--label);
  font: 600 13px/16px var(--font); letter-spacing: 0;
}
label.file-pick:hover { background: var(--surface); border-color: var(--label); }
.file-pick:focus-within { outline: 2px solid var(--ring); outline-offset: 3px; }
.file-name { font-size: 13px; line-height: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }

/* =====================================================================
   10. Pagine
   ===================================================================== */
/* Coda */
.control { display: flex; flex-direction: column; gap: 0; }
.control-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-height: 24px; }
.control-key { font-size: 17px; font-weight: 600; }
.control .banner { margin: 16px 0 0; }
.control .toolbar { margin: 16px 0; }
.rec-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.rec-title { min-width: 0; overflow-wrap: anywhere; }
.rec-meta { margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 4px 8px; }
.rec .toolbar { margin: 16px 0 0; }
.rec details { margin-top: 8px; }

/* Articolo */
.checks-title { font-size: 13px; font-weight: 600; line-height: 16px; color: var(--label-3); margin: 0 0 8px; }
.checks { list-style: none; padding: 0; margin: 0 0 24px; columns: 2 220px; column-gap: 24px; }
.checks li { display: flex; align-items: baseline; gap: 8px; margin: 0; padding: 4px 0; line-height: 20px; break-inside: avoid; font-size: 15px; }
.checks .mark { width: 16px; flex: none; font-weight: 700; text-align: center; }
.checks li.yes .mark { color: var(--ok); }
.checks li.no { color: var(--bad); }
.checks li.no .mark { color: var(--bad-dot); }
.evidence-shot { max-width: 100%; border: 1px solid var(--sep); border-radius: var(--r-control); margin-top: 8px; display: block; }

/* Sessione */
.state-head { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; color: var(--label-3); }
.state-head h2 { margin: 0; }
.state-head.ok { color: var(--ok); } .state-head.warn { color: var(--warn); } .state-head.bad { color: var(--bad); } .state-head.info { color: var(--info); }
.state-head .state-art { width: 56px; height: 56px; }
.qr { background: #fff; padding: 16px; border-radius: var(--r-container); display: inline-block; margin: 0 0 16px; box-shadow: var(--shadow-tile); border: 1px solid var(--sep); }
.qr img { width: 264px; height: 264px; image-rendering: pixelated; display: block; max-width: 100%; }

/* Stati vuoti illustrati */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 24px 16px 16px; color: var(--label-2); }
.empty svg.ill { width: 160px; height: 120px; }
.empty p { margin: 8px 0 0; line-height: 20px; }

/* Paginazione */
.pager { display: flex; gap: 8px; margin-top: 16px; min-height: 40px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

/* Accesso */
.auth-body { min-height: 100vh; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.auth-panel { width: 100%; max-width: 400px; }
.auth-brand { align-items: center; padding: 0 0 16px; gap: 4px; position: relative; isolation: isolate; }
/* Accesso: solo un alone di raggi corti dietro il logo, al 4% */
.auth-brand::before {
  content: ""; position: absolute; z-index: -1; pointer-events: none;
  left: 50%; top: 30%; width: 220px; height: 220px; transform: translate(-50%, -50%);
  background: repeating-conic-gradient(from 2deg, var(--brand) 0deg 3deg, transparent 3deg 18deg);
  -webkit-mask: radial-gradient(closest-side, transparent 42%, #000 46%, #000 74%, transparent 100%);
          mask: radial-gradient(closest-side, transparent 42%, #000 46%, #000 74%, transparent 100%);
  opacity: .04;
}
@media (prefers-contrast: more), (forced-colors: active) { .auth-brand::before { display: none; } }
.auth-brand .brand-logo { height: 48px; max-width: 200px; }
.auth-brand .wordmark { font-size: 15px; }
.auth-ill { display: block; width: 120px; height: 90px; margin: 0 auto 16px; color: var(--label); }
.auth-card { padding: 32px; border-radius: var(--r-container); box-shadow: inset 0 1px 0 var(--surface-hi), var(--shadow-raised); }
.auth-card h1 { font-size: 28px; line-height: 32px; margin: 0 0 24px; }
.auth-card form { margin-top: 8px; }
.auth-card input { width: 100%; min-height: 44px; font-size: 17px; }
.auth-card .field:last-of-type { margin-bottom: 24px; }
.auth-card button.primary { width: 100%; min-height: 44px; font-size: 17px; margin-top: 0; border-radius: var(--r-control); }
.auth-card .banner { margin-bottom: 24px; }
.auth-card .qr { display: block; width: fit-content; margin: 0 auto 16px; }
.auth .qr img { width: 220px; height: 220px; }
.auth-foot { text-align: center; color: var(--label-3); font-size: 13px; line-height: 16px; margin: 16px 0 0; }

/* Barra a schede: solo su telefono */
.tabbar { display: none; }

/* Utilità */
.mt { margin-top: 8px; }
.mt-1 { margin-top: 16px; }
.mt-2 { margin-top: 24px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.wrap { white-space: normal; }
.danger-text { color: var(--bad) !important; }

/* =====================================================================
   11. Tablet (≤1180): margini di 32, metriche 4+3
   ===================================================================== */
@media (max-width: 1180px) {
  :root { --gutter: 32px; }
  .board-row { grid-template-columns: 40px 120px minmax(96px, max-content) minmax(0, 1fr) 16px; }
}

/* Tablet (861–1100): colonna compatta da 72, sola icona da 22 (etichetta nel tooltip e per i lettori di schermo) */
@media (min-width: 861px) and (max-width: 1100px) {
  :root { --side-w: 72px; }
  .side { padding: 16px 12px; align-items: stretch; }
  .brand { align-items: center; padding: 0 0 16px; }
  .brand-logo { max-width: 48px; height: auto; }
  .brand .wordmark { display: none; }
  .nav a.ntile { justify-content: center; padding: 0; min-height: 44px; }
  .nav-label { display: none; }
  .nav a.ntile .count { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; font-size: 10px; margin: 0; }
  .brand picture, .brand > .brand-logo { display: none; }
  .brand-mark { display: block; }
  .side .who { display: none; }
  .who-compact { display: block; margin-top: auto; position: relative; align-self: center; }
  .who-btn { width: 44px; height: 44px; min-height: 44px; display: grid; place-items: center; border-radius: 999px; color: var(--label-2); cursor: pointer; }
  .who-btn::before { display: none; }
  .who-btn:hover, .who-compact[open] .who-btn { background: var(--fill); }
  .who-btn svg.ui { width: 24px; height: 24px; }
  .who-btn .ui-accent { display: none; }
  .who-menu {
    position: absolute; left: 52px; bottom: 0; z-index: 40; width: 240px; padding: 4px; border-radius: var(--r-element);
    background: var(--surface); border: 1px solid var(--surface-edge); box-shadow: var(--shadow-raised);
  }
  .who-menu-head { display: flex; flex-direction: column; padding: 8px 12px; border-bottom: 1px solid var(--sep); margin-bottom: 4px; min-width: 0; }
  .who-menu-head small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .who-menu form { margin: 0; }
  .who-menu-row { display: flex; align-items: center; width: 100%; min-height: 44px; padding: 0 12px; border-radius: var(--r-control); background: none; box-shadow: none; color: var(--label); font: 400 15px/1.2 var(--font); text-decoration: none; justify-content: flex-start; }
  .who-menu-row:hover { background: var(--fill); text-decoration: none; }
  /* Coda e articoli: colonna «Inviato» nascosta quando nessuna riga ne ha una */
  table.pubtable:not(:has(td.c-inv:not(:empty))) th:nth-child(7), table.pubtable:not(:has(td.c-inv:not(:empty))) td.c-inv { display: none; }
}

/* =====================================================================
   12. Telefono e tablet stretti (≤860): gutter 16, target ≥ 44, barra a schede
   ===================================================================== */
@media (max-width: 860px) {
  :root { --gutter: 16px; --control-h: 44px; --control-h-s: 44px; }
  .app { display: block; }
  .side { display: none; }
  .brand-compact { display: flex; }

  /* Barra superiore compatta: logo + Stop, poi una riga di stato scorrevole */
  .topbar { flex-wrap: wrap; min-height: 60px; padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top)); }
  /* Una sola pillola di stato; quando la pagina scorre (html.is-scrolled) lo spazio si chiude,
     opacità e traslazione le gestisce motion.css */
  .topbar { row-gap: 0; }
  .topbar .pills { order: 3; flex-basis: 100%; flex-wrap: nowrap; max-height: 32px; margin-top: 8px; overflow: hidden; transition: max-height .18s ease, margin-top .18s ease; }
  html.is-scrolled .topbar .pills { max-height: 0; margin-top: 0; }
  .topbar .pill { height: 24px; padding: 0 8px; font-size: 13px; }
  .topbar .pill-full, .topbar .pill-queue { display: none; }
  .topbar .pill-summary { display: inline-flex; }
  .stop, .stop-active { min-height: 44px; padding: 0 16px 0 12px; font-size: 15px; gap: 8px; }
  .stop svg.ui { width: 20px; height: 20px; }
  .stop-long { display: none; }
  .stop-short { display: inline; }

  .main { padding: 24px 16px calc(var(--tabbar-h) + 40px + env(safe-area-inset-bottom)); }
  h1 { font-size: 34px; line-height: 40px; }
  h1 small { display: block; font-size: 15px; margin-top: 4px; }
  h2 { font-size: 20px; line-height: 24px; margin: 32px 0 16px; }
  .lead { font-size: 15px; }
  .page-head.split { display: block; }
  .page-head.split .stamp { margin-top: 8px; }
  .back { min-height: 44px; }
  .backline { margin: -8px 0 0; }

  .grid { gap: 16px; }
  .grid.k { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { padding: 16px; }
  .card.kpi { padding: 16px; }
  .kpi .value { font-size: 24px; }

  .board-row { grid-template-columns: 36px minmax(0, 1fr) auto 16px; grid-template-areas: "g k v c" "g s s c"; gap: 4px 12px; padding: 12px 16px; }
  .b-glyph { grid-area: g; align-self: start; margin-top: 2px; }
  .b-glyph, .b-glyph svg.ui { width: 36px; height: 36px; }
  .b-key { grid-area: k; }
  .b-val { grid-area: v; font-size: 20px; line-height: 24px; text-align: right; }
  .b-sub { grid-area: s; }
  .board-row .chev { grid-area: c; }

  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* Ultima casella dispari: riga compatta, etichetta a sinistra e valore a destra */
  .metrics .kpi:last-child:nth-child(odd) {
    grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "l v" "s v";
    align-items: center; column-gap: 16px; padding-top: 12px; padding-bottom: 12px;
  }
  .metrics .kpi:last-child:nth-child(odd) .label { grid-area: l; margin: 0; }
  .metrics .kpi:last-child:nth-child(odd) .sub { grid-area: s; }
  .metrics .kpi:last-child:nth-child(odd) .value { grid-area: v; }
  /* Filtri: data e Cerca metà e metà */
  .toolbar.filters > input[type=date], .toolbar.filters > input[type=date] ~ button { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .toolbar.filters > select { flex: 1 1 100%; }


  .banner { padding: 12px 16px 12px 44px; }
  .banner::before { left: 14px; }

  /* Liste inset: etichetta sopra il valore */
  dl.kv { grid-template-columns: minmax(0, 1fr); }
  dl.kv dt { padding: 12px 16px 0; min-height: 0; font-size: 13px; line-height: 16px; color: var(--label-3); }
  dl.kv dd { padding: 4px 16px 12px; min-height: 0; border-top: 0; text-align: left; }
  .card dl.kv { margin: 0 -16px; }
  .card dl.kv dt { padding-left: 16px; }
  .card dl.kv dd { padding-left: 16px; padding-right: 16px; }
  .card > dl.kv:last-child, .card > dl.kv:has(+ .toolbar:not(:has(*)):last-child) { margin-bottom: -16px; }

  /* Allarmi recenti: gravità e tempo sulla prima riga, titolo a tutta larghezza */
  .list-row:has(> .sev) { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: baseline; }
  .list-row:has(> .sev) > .list-main { grid-column: 1 / -1; grid-row: 2; }

  /* Controlli */
  .btn, button, input[type=text], input[type=search], input[type=email], input[type=password], input[type=number], input[type=date], input[type=file], select { font-size: 16px; }
  .btn.small, button.small { font-size: 15px; padding: 0 16px; }
  .gbtn.small, button.gbtn.small, summary.gbtn.small { padding-right: 12px; }
  details summary { min-height: 44px; }
  input[type=search] { min-width: 0; width: 100%; }
  .toolbar > form.inline, .toolbar > input[type=search], form.toolbar > input[type=search] { flex: 1 1 100%; }
  .toolbar > select { flex: 1 1 auto; }
  .toolbar.actions { gap: 8px; margin-bottom: 16px; }
  .toolbar.actions > form.inline, .toolbar.actions > .gtile { flex: 1 1 0; min-width: 0; }
  /* Azioni principali di Canali: pulsanti da 50 con icona da 22 */
  .toolbar.actions .gtile { width: 100%; min-height: 50px; flex-direction: row; align-items: center; justify-content: center; gap: 8px; padding: 0 8px; }
  .toolbar.actions .gtile svg.ui { width: 22px; height: 22px; }
  .gtile, button.gtile { width: auto; flex: 1 1 140px; min-height: 88px; }
  .control .toolbar > form.inline { flex: 1 1 140px; }
  .control .toolbar button.gtile { width: 100%; }
  /* Azioni affiancate dentro le schede: stessa larghezza */
  .card .toolbar > form.inline:has(> .gbtn) { flex: 1 1 0; min-width: 136px; }
  .card .toolbar > form.inline > .gbtn { width: 100%; }
  .confirm-row > input[type=text] { flex: 1 1 100%; }
  .confirm-row > button { flex: 1 1 auto; }
  .form-actions > button, .form-actions > .btn, .form-actions > .gbtn { flex: 1 1 auto; justify-content: center; }
  .inline-details[open] form { max-width: none; }
  .truncate { max-width: 240px; }
  .pager { justify-content: space-between; }

  /* Filtri a segmenti: 3 + 2, mai tagliati */
  .segmented { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); width: 100%; overflow: visible; }
  .segmented label { grid-column: span 2; }
  .segmented label:nth-child(n+4) { grid-column: span 3; }
  .segmented span { justify-content: center; min-height: 40px; padding: 0 8px; font-size: 15px; }

  .tally { display: flex; }

  /* Impostazioni: colonna dei valori da 112; Salva fisso in fondo alla scheda, sopra la barra a schede */
  .settings-form .field:has(> input[type=checkbox]),
  .settings-form .field:has(> input[type=number]),
  .settings-form .field:has(> select) { grid-template-columns: minmax(0, 1fr) 112px; gap: 0 12px; }
  .settings-form .field > input[type=number], .settings-form .field > select { width: 112px; }
  .settings-form .form-actions {
    position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); z-index: 5;
    margin: 16px -16px -16px; padding: 12px 16px; background: var(--surface);
    border-top: 1px solid var(--sep); border-radius: 0 0 var(--r-container) var(--r-container);
  }

  /* Tabella pubblicazioni → righe a due livelli: titolo e stato sempre visibili, senza scorrere */
  th, td { padding: 12px; }
  .pubtable thead { display: none; }
  .pubtable tbody tr {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px 8px; padding: 12px 16px;
    grid-template-areas: "art art prov" "st st st" "tent ric inv"; border-top: 1px solid var(--sep);
  }
  .pubtable td.c-id { display: none; }
  .pubtable .c-art-id { display: inline; }
  .pubtable tbody tr:first-child { border-top: 0; }
  .pubtable td { padding: 0; border: 0; min-width: 0; }
  .pubtable td:only-child { grid-column: 1 / -1; }
  .pubtable .c-art { grid-area: art; white-space: normal; max-width: none; }
  .pubtable .c-prov { grid-area: prov; text-align: right; } .pubtable .c-st { grid-area: st; }
  .pubtable .c-tent { grid-area: tent; text-align: left; } .pubtable .c-ric { grid-area: ric; } .pubtable .c-inv { grid-area: inv; }
  .pubtable .c-tent, .pubtable .c-ric, .pubtable .c-inv { font-size: 13px; color: var(--label-2); }
  .pubtable .c-tent::before, .pubtable .c-ric::before, .pubtable .c-inv::before { content: attr(data-label); display: block; font-size: 12px; line-height: 16px; color: var(--label-3); }
  .pubtable .c-art a { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .pubtable .c-art br { display: none; }
  .pubtable .c-art small { display: block; overflow: hidden; text-overflow: ellipsis; }
  .pubtable tbody tr:hover td { background: none; }

  .auth-card { padding: 24px 16px; }
  .auth-ill { width: 96px; height: 72px; }

  /* Barra a schede */
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding: 0 4px env(safe-area-inset-bottom);
    background: var(--bg); border-top: 1px solid var(--sep);
  }
  .tab, .tab-more { flex: 1 1 0; min-width: 0; }
  .tab {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; height: var(--tabbar-h);
    color: var(--label-3); text-decoration: none; font-size: 11px; font-weight: 500; letter-spacing: 0; cursor: pointer;
  }
  .tab:hover { text-decoration: none; color: var(--label-2); }
  .tab.on { color: var(--label); }
  .tab.on .tab-label { color: var(--brand); font-weight: 700; }
  .tab-more > summary.tab { min-height: 0; color: var(--label-3); font-weight: 500; }
  .tab-more > summary.tab.on, .tab-more[open] > summary.tab { color: var(--label); }
  .tab-more > summary::before { display: none; }
  .tab-more .ui-red { fill: currentColor; }   /* «Altro»: nessun accento rosso */
  .tab-ic { position: relative; display: block; }
  .tab-ic .ic { width: 25px; height: 25px; }
  .tab-ic svg.ui { width: 30px; height: 30px; }
  .tab .ui-accent { display: none; }
  .tab.on .ui-accent { display: inline; }
  .tab-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  /* Bollini: un solo stile, 18px, bordo di 2px del colore di fondo, in alto a destra dell'icona */
  .tab-badge {
    position: absolute; top: -4px; right: -8px; left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
    background: var(--bad-dot); color: #fff; font-size: 11px; font-weight: 600; line-height: 18px; text-align: center;
    box-shadow: 0 0 0 2px var(--bg);
  }
  /* Non letti: alone sobrio e continuo attorno allo stesso bollino (sostituisce l'onda che cambiava forma) */
  .tabbar .tab-badge.motion-badge:not(.motion-badge--seen)::after {
    content: ""; position: absolute; inset: 0; border: 0; border-radius: inherit; transform: none; opacity: 1;
    animation: badge-halo 2.4s ease-out 600ms infinite;
  }
  .tabbar .tab-badge.motion-badge--queue:not(.motion-badge--seen)::after { animation-duration: 3.2s; animation-delay: 1.8s; }
  .tab:focus-visible { outline-offset: -4px; border-radius: 12px; }
  .tab-badge.dot { min-width: 10px; width: 10px; height: 10px; padding: 0; top: -1px; right: -3px; }

  /* Foglio «Altro» */
  .sheet {
    position: fixed; left: 8px; right: 8px; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px);
    max-height: calc(100vh - var(--tabbar-h) - 96px); overflow-y: auto;
    /* Foglio «Altro»: l'unico vetro dell'interfaccia */
    background: color-mix(in srgb, var(--bg) 82%, transparent); border-radius: 16px; padding: 8px; border: 1px solid var(--surface-edge);
    box-shadow: inset 0 1px 0 var(--glass-hi), var(--shadow-raised);
    -webkit-backdrop-filter: saturate(180%) blur(30px); backdrop-filter: saturate(180%) blur(30px);
    animation: sheet-in .2s ease-out;
  }
  @supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .sheet { background: var(--bg); } }
  @media (prefers-reduced-transparency: reduce) { .sheet { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; } }
  .sheet-group { background: var(--surface); border-radius: var(--r-element); overflow: hidden; box-shadow: inset 0 1px 0 var(--surface-hi), 0 0 0 .5px var(--surface-edge); }
  .sheet-group + .sheet-group { margin-top: 8px; }
  .sheet-group form { margin: 0; }
  .sheet-row {
    position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 8px 16px;
    color: var(--label); font: 400 17px/1.3 var(--font); text-decoration: none; text-align: left;
    background: transparent; border-radius: 0; border-top: 1px solid var(--sep); justify-content: flex-start;
  }
  .sheet-group > :first-child, .sheet-group > :first-child .sheet-row { border-top: 0; }
  .sheet-row span { flex: 1; min-width: 0; }
  .sheet-row .ic { color: var(--label-3); }
  .sheet-row svg.ui { width: 30px; height: 30px; }
  .sheet-row .ui-accent { display: none; }
  .sheet-row.on .ui-accent { display: inline; }
  .sheet-row svg.chev, .sheet-row .chev { width: 14px; height: 14px; opacity: .6; color: var(--label-3); }
  .sheet-row.on { background: var(--fill); }
  .sheet-row:hover { text-decoration: none; background: var(--fill); }
  .sheet-row.static { min-height: 60px; }
  .sheet-row.danger-text .ic, .sheet-row.danger-text svg.ui { color: var(--bad); }
}
@media (max-width: 860px) and (prefers-color-scheme: dark) {
  .tab.on .tab-label { color: #ff6961; }
}
@keyframes sheet-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* =====================================================================
   13. Tabelle su telefono (< 600): righe a due livelli, mai scorrimento orizzontale.
   .rt-main titolo (riga 1), .rt-aside stato a destra, .rt-sub riga secondaria in grigio,
   celle con data-label su righe brevi «Etichetta valore», .rt-hide nascosta, .rt-chev freccia.
   ===================================================================== */
.rt-chev { display: none; }
@media (max-width: 600px) {
  /* Filtri a segmenti con più di tre voci: menu a tendina nativo (con JavaScript; senza, restano i segmenti) */
  .js .segmented:has(+ .seg-select) { display: none; }
  .js .seg-select { display: block; width: 100%; font-weight: 500; }
  /* Coda, blocco «Invii»: campo di conferma a tutta larghezza, sotto un pulsante pieno da 50 */
  .control .toolbar > form.inline { flex: 1 1 100%; flex-direction: column; align-items: stretch; gap: 8px; }
  .control .toolbar > form.inline > input[type=text] { width: 100%; align-self: stretch; }
  .control .gtile, .control button.gtile {
    width: 100%; min-height: 50px; flex: none; flex-direction: row; align-items: center; justify-content: center; gap: 8px;
    padding: 0 16px; border-radius: var(--r-control); border: 0; background: var(--fill); box-shadow: none; font-size: 17px; line-height: 20px;
  }
  .control .gtile:hover { background: var(--fill-2); }
  .control .gtile.primary { background: var(--primary); color: var(--primary-ink); }
  .control .gtile.danger { background: var(--brand); color: #fff; }
  .control .gtile svg.ui { display: none; }
  .control .gtile .gcap { font-size: 17px; }
  .tally-key { flex-basis: 100%; padding: 4px 8px 2px; }
  .table-wrap:has(> table.rt) { overflow-x: visible; }
  table.rt, table.rt tbody { display: block; }
  table.rt thead, table.rt .rt-hide { display: none; }
  table.rt tr {
    position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 2px 12px;
    padding: 12px 16px; border-top: 1px solid var(--sep);
  }
  table.rt tbody tr:first-child { border-top: 0; }
  table.rt tr:has(> .rt-chev) { grid-template-columns: minmax(0, 1fr) auto 16px; }
  table.rt td { display: block; padding: 0; border: 0; min-width: 0; grid-column: 1 / span 2; font-size: 13px; color: var(--label-2); white-space: normal; }
  table.rt td.rt-main { grid-column: 1; grid-row: 1; font-size: 15px; color: var(--label); overflow-wrap: anywhere; }
  table.rt td.rt-aside { grid-column: 2; grid-row: 1; max-width: 50vw; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 8px; text-align: right; font-size: 13px; }
  table.rt td.rt-aside .pill + .pill { margin-left: 0; }
  table.rt td.rt-aside:empty { display: none; }
  table.rt td.rt-sub { color: var(--label-3); overflow-wrap: anywhere; }
  table.rt td.truncate { max-width: none; white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
  table.rt td[data-label]::before { content: attr(data-label) " "; color: var(--label-3); }
  table.rt td.num { text-align: left; }
  table.rt td.right { text-align: left; margin-top: 8px; }
  table.rt td:only-child { grid-column: 1 / -1; }
  table.rt td.rt-chev { display: block; grid-column: 3; grid-row: 1 / span 2; align-self: center; }
  table.rt td.rt-chev svg { width: 14px; height: 14px; color: var(--label-3); opacity: .6; }
  /* Riga intera toccabile: il collegamento del titolo copre la riga */
  table.rt tr.rt-link .rt-main a::after { content: ""; position: absolute; inset: 0; }
  table.rt tr.rt-link .rt-main a { color: var(--label); }
  table.rt tbody tr:hover td { background: none; }
  table.rt td details pre { max-width: 100%; }
}

/* =====================================================================
   14. Separatori hairline sugli schermi ad alta densità
   ===================================================================== */
@media (min-resolution: 2dppx) {
  td, th, .board-row, .list-row, dl.kv dt, dl.kv dd, .side .who, .topbar, .tabbar, table.rt tr,
  .field:has(> input[type=checkbox]), .field:has(> input[type=number]), .field:has(> select), .field:has(> textarea),
  .card dl.kv, .sheet-row, .card details + details, .settings-form .form-actions { border-width: .5px; }
  td, th, .board-row, .list-row, dl.kv dt, dl.kv dd, .card dl.kv, .sheet-row, table.rt tr { border-color: var(--sep-strong); }
  .board-row:first-child, .list-row:first-child, thead + tbody tr:first-child td, table.rt tbody tr:first-child,
  dl.kv dt:first-of-type, dl.kv dd:first-of-type { border-top-width: 0; }
}

@keyframes badge-halo {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad-dot) 45%, transparent); }
  70%, 100% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--bad-dot) 0%, transparent); }
}
.c-art-id { display: none; }

/* =====================================================================
   15. Movimento ridotto
   ===================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Pagine d'errore (resources/views/errors) */
.error-card h1 { margin: 0 0 8px; }
.error-code { margin: 0 0 8px; font-size: 13px; font-weight: 600; line-height: 16px; color: var(--label-3); letter-spacing: .02em; }
.error-card .form-actions { margin-top: 24px; }
.error-card .form-actions > .btn { flex: 1 1 auto; min-height: 44px; }

/* =====================================================================
   16. Manuale (/manuale, resources/views/manual): testo lungo leggibile (≤ 72ch), indice laterale
   da 1181px (menu a scomparsa sotto), schema a blocchi del flusso, tabelle compatte, callout = .banner.
   ===================================================================== */
.manual { display: grid; grid-template-columns: minmax(0, 1fr) 208px; gap: 48px; align-items: start; }
.manual-body { grid-column: 1; grid-row: 1; min-width: 0; max-width: 920px; container-type: inline-size; }
.manual-toc { grid-column: 2; grid-row: 1; position: sticky; top: 88px; max-height: calc(100vh - 112px); overflow-y: auto; font-size: 13px; }
.manual-toc-title { margin: 0 0 8px; padding-left: 14px; font-size: 12px; line-height: 16px; font-weight: 600; color: var(--label-3); }
.manual-toc-list { list-style: none; padding: 0; margin: 0; counter-reset: toc; border-left: 1px solid var(--sep); }
.manual-toc-list li { counter-increment: toc; margin: 0; }
.manual-toc-list li + li { margin-top: 0; }
.manual-toc-list a { display: flex; gap: 8px; margin-left: -1px; padding: 6px 12px; border-left: 2px solid transparent; color: var(--label-2); line-height: 18px; }
.manual-toc-list a::before { content: counter(toc); min-width: 16px; color: var(--label-3); font-variant-numeric: tabular-nums; }
.manual-toc-list a:hover { color: var(--label); text-decoration: none; border-left-color: var(--brand); }
.manual-toc-mobile { display: none; }

.manual-sec { scroll-margin-top: 88px; }
.manual-sec + .manual-sec { margin-top: 48px; padding-top: 40px; border-top: 1px solid var(--sep); }
.manual-sec h2 { display: flex; align-items: center; gap: 12px; margin: 0 0 16px; }
.manual-n {
  display: inline-grid; place-items: center; flex: none; min-width: 28px; height: 28px; padding: 0 6px; border-radius: var(--r-inner);
  background: var(--brand-tint); color: var(--brand); font-size: 15px; line-height: 1; font-weight: 700; font-variant-numeric: tabular-nums;
}
.manual-sec h3 { margin: 32px 0 8px; font-size: 17px; line-height: 24px; }
.manual-body p, .manual-body li, .manual-body dd { line-height: 1.6; }
.manual-body p, .manual-sec > ul, .manual-sec > ol:not(.manual-flow), .manual-body .banner, .manual-body pre { max-width: 72ch; }
.manual-sec > ul li + li, .manual-sec > ol li + li { margin-top: 6px; }
.manual-body .banner { margin: 16px 0; }
.manual-body code { word-break: normal; overflow-wrap: anywhere; padding: 1px 4px; border-radius: 4px; background: var(--code-bg); }
.manual-body pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: none; margin: 8px 0 16px; font-size: 13px; border: 1px solid var(--sep); }
.manual-body pre code { padding: 0; background: none; color: var(--label); font-size: inherit; }
.manual-body table code { white-space: nowrap; }

/* Tabelle compatte (su telefono diventano righe a due livelli, sistema .rt) */
.manual-table { margin: 16px 0; }
.manual-table td { font-size: 14px; line-height: 1.5; vertical-align: top; padding-top: 10px; padding-bottom: 10px; }
.manual-table td.rt-main { width: 30%; color: var(--label); font-weight: 500; }
.manual-table td.rt-aside { white-space: nowrap; }
.manual-table td .pill { white-space: nowrap; }

/* Coppie termine/definizione: principi, interruttori, sicurezza, glossario */
.manual-principles, .manual-glossary {
  display: grid; grid-template-columns: minmax(150px, 210px) minmax(0, 1fr); margin: 16px 0; max-width: 820px;
  background-color: var(--surface); border: 1px solid var(--surface-edge); border-radius: var(--r-container); overflow: hidden;
  background-image: var(--surface-sheen); box-shadow: inset 0 1px 0 var(--surface-hi), var(--shadow-surface);
}
.manual-principles dt, .manual-glossary dt, .manual-principles dd, .manual-glossary dd { padding: 12px 16px; border-top: 1px solid var(--sep); min-width: 0; }
.manual-principles dt, .manual-glossary dt { font-weight: 600; color: var(--label); line-height: 1.5; }
.manual-principles dd, .manual-glossary dd { margin: 0; padding-left: 0; color: var(--label-2); }
.manual-principles dt:first-of-type, .manual-glossary dt:first-of-type, .manual-principles dd:first-of-type, .manual-glossary dd:first-of-type { border-top: 0; }

/* Schema del flusso: sei blocchi con freccia; in colonna quando lo spazio è poco */
.manual-flow { list-style: none; padding: 0; margin: 24px 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; }
.manual-flow li.manual-step { margin: 0; }
.manual-step {
  position: relative; display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 12px;
  background: linear-gradient(180deg, var(--face-top), var(--face-bot)); border: 1px solid var(--surface-edge);
  border-radius: var(--r-element); box-shadow: var(--shadow-tile);
}
.manual-step-k { font-size: 12px; line-height: 16px; font-weight: 600; color: var(--label-3); letter-spacing: .02em; }
.manual-step strong { font-size: 14px; line-height: 18px; overflow-wrap: break-word; }
.manual-step small { font-size: 12px; line-height: 16px; color: var(--label-3); overflow-wrap: break-word; }
.manual-step.is-red { border-color: color-mix(in srgb, var(--brand) 45%, transparent); }
.manual-step.is-red .manual-step-k { color: var(--brand); }
.manual-step:not(:last-child)::after {
  content: ""; position: absolute; top: 50%; right: -12px; width: 8px; height: 8px;
  border-top: 2px solid var(--label-3); border-right: 2px solid var(--label-3); transform: translateY(-50%) rotate(45deg);
}
@container (max-width: 760px) {
  .manual-flow { grid-template-columns: minmax(0, 1fr); gap: 20px; max-width: 520px; }
  .manual-step { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 2px 12px; align-items: baseline; }
  .manual-step-k { grid-row: 1 / span 2; }
  .manual-step:not(:last-child)::after { top: auto; right: auto; left: 28px; bottom: -15px; transform: rotate(135deg); }
}
@media (prefers-color-scheme: dark) {
  .manual-n { color: #ff6961; }
  .manual-step.is-red .manual-step-k { color: #ff6961; }
}

/* Senza spazio per l'indice laterale: menu a scomparsa in cima */
@media (max-width: 1180px) {
  .manual { display: block; }
  .manual-toc { display: none; }
  .manual-toc-mobile {
    display: block; margin: 0 0 32px; padding: 0 16px; max-width: 520px;
    background-color: var(--surface); border: 1px solid var(--surface-edge); border-radius: var(--r-container);
    box-shadow: inset 0 1px 0 var(--surface-hi), var(--shadow-surface);
  }
  .manual-toc-mobile summary { min-height: 48px; }
  .manual-toc-mobile .manual-toc-list { border-left: 0; margin: 0 -16px; padding: 0 0 8px; }
  .manual-toc-mobile .manual-toc-list a { min-height: 44px; align-items: center; margin: 0; padding: 0 16px; border-left: 0; border-top: 1px solid var(--sep); font-size: 15px; color: var(--label); }
  .manual-toc-mobile .manual-toc-list a:hover { background: var(--fill); }
}
@media (max-width: 860px) {
  .manual-sec { scroll-margin-top: 128px; }
  .manual-sec + .manual-sec { margin-top: 40px; padding-top: 32px; }
  .manual-toc-mobile { max-width: none; }
  .manual-principles, .manual-glossary { grid-template-columns: minmax(0, 1fr); }
  .manual-principles dd, .manual-glossary dd { padding: 0 16px 12px; border-top: 0; }
  .manual-table td.rt-main { width: auto; }
}
@media (max-width: 600px) {
  .manual-table table.rt td { font-size: 14px; color: var(--label-2); margin-top: 2px; }
  .manual-table table.rt td.rt-main { font-size: 15px; color: var(--label); }
  .manual-table table.rt td.rt-aside { white-space: normal; font-size: 13px; }
  .manual-body table code { white-space: normal; }
}
