/* Design system — superfici in vetro su fondo sfumato.
   Layout: telefono = barra flottante in basso + schede a una colonna; tablet = barra laterale a icone +
   elenco/dettaglio; PC = barra laterale completa + tabelle. Ogni dato resta raggiungibile a ogni larghezza.
   Tipografia e spaziature sono fluide (clamp) per mantenere le proporzioni tra le larghezze. */

:root {
  --bg: #e9eef6;
  --bg-a: #cfe1ff;            /* macchie di colore del fondo */
  --bg-b: #d9f1ee;
  --bg-c: #e6dcfb;
  --glass: rgb(255 255 255 / .58);         /* pannelli */
  --glass-strong: rgb(255 255 255 / .84);  /* barre, menu, campi */
  --glass-solid: #f7f9fc;                  /* dove il vetro non è disponibile */
  --glass-edge: rgb(255 255 255 / .75);    /* bordo luminoso */
  --hairline: rgb(18 34 64 / .10);
  --fill: rgb(18 34 64 / .06);             /* riempimenti tenui: hover, tracce, codice */
  --fg: #0d1626;
  --muted: #4f5d73;
  --accent: #0a5fc7;
  --accent-fg: #ffffff;
  --accent-soft: rgb(10 95 199 / .12);
  --ok: #146c43;   --ok-soft: rgb(20 108 67 / .13);
  --warn: #8a5300; --warn-soft: rgb(196 126 0 / .17);
  --bad: #b3261e;  --bad-soft: rgb(179 38 30 / .12);
  --shadow: 0 1px 1px rgb(18 34 64 / .04), 0 12px 32px rgb(18 34 64 / .08);
  --shadow-float: 0 2px 4px rgb(18 34 64 / .06), 0 18px 44px rgb(18 34 64 / .16);
  --blur: saturate(180%) blur(22px);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --gutter: clamp(16px, 3.2vw, 36px);
  --r-panel: clamp(18px, 1.2vw + 12px, 24px);
  --r-control: 13px;
  --tap: 44px;
  --side: 280px;
  --rail: 76px;
  --topbar: 60px;
  --tabbar: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #070b13; --bg-a: #0d2a55; --bg-b: #0b3340; --bg-c: #271a4a;
    --glass: rgb(30 39 56 / .52); --glass-strong: rgb(27 35 51 / .82); --glass-solid: #151c2a;
    --glass-edge: rgb(255 255 255 / .11); --hairline: rgb(255 255 255 / .10); --fill: rgb(255 255 255 / .07);
    --fg: #eef2f9; --muted: #a3b0c4;
    --accent: #6bb1ff; --accent-fg: #04162c; --accent-soft: rgb(107 177 255 / .17);
    --ok: #62d39a; --ok-soft: rgb(98 211 154 / .15);
    --warn: #f0bd5e; --warn-soft: rgb(240 189 94 / .15);
    --bad: #ff8a80; --bad-soft: rgb(255 138 128 / .15);
    --shadow: 0 1px 1px rgb(0 0 0 / .25), 0 12px 32px rgb(0 0 0 / .32);
    --shadow-float: 0 2px 4px rgb(0 0 0 / .3), 0 18px 44px rgb(0 0 0 / .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #070b13; --bg-a: #0d2a55; --bg-b: #0b3340; --bg-c: #271a4a;
  --glass: rgb(30 39 56 / .52); --glass-strong: rgb(27 35 51 / .82); --glass-solid: #151c2a;
  --glass-edge: rgb(255 255 255 / .11); --hairline: rgb(255 255 255 / .10); --fill: rgb(255 255 255 / .07);
  --fg: #eef2f9; --muted: #a3b0c4;
  --accent: #6bb1ff; --accent-fg: #04162c; --accent-soft: rgb(107 177 255 / .17);
  --ok: #62d39a; --ok-soft: rgb(98 211 154 / .15);
  --warn: #f0bd5e; --warn-soft: rgb(240 189 94 / .15);
  --bad: #ff8a80; --bad-soft: rgb(255 138 128 / .15);
  --shadow: 0 1px 1px rgb(0 0 0 / .25), 0 12px 32px rgb(0 0 0 / .32);
  --shadow-float: 0 2px 4px rgb(0 0 0 / .3), 0 18px 44px rgb(0 0 0 / .5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh;
  background: var(--bg); color: var(--fg);
  font: clamp(15px, .2vw + 14.4px, 16px)/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
/* Fondo: macchie di colore fisse, sopra cui il vetro prende profondità. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60vmax 50vmax at 8% -5%, var(--bg-a), transparent 62%),
    radial-gradient(55vmax 45vmax at 105% 12%, var(--bg-c), transparent 60%),
    radial-gradient(60vmax 50vmax at 60% 115%, var(--bg-b), transparent 62%);
}
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(24px, 1.5vw + 18px, 34px); line-height: 1.15; font-weight: 700; letter-spacing: -.022em; text-wrap: balance; }
h2 { font-size: 17px; line-height: 1.3; font-weight: 600; letter-spacing: -.01em; }
h3 { font-size: 15px; font-weight: 600; }
a { color: var(--accent); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.label { font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.icon { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* Superficie in vetro, riusata da pannelli, barre e menu */
.panel, .kpis, .side, .bottombar, .actionbar, .menu > div, .tabs {
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}

/* ---------- Struttura ---------- */
.shell { min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--s3);
  height: var(--topbar); padding: 0 var(--gutter);
}
.topbar::before {  /* la barra sfuma nel contenuto invece di tagliarlo con una riga */
  content: ""; position: absolute; inset: 0 0 -14px; z-index: -1; pointer-events: none;
  background: linear-gradient(var(--bg) 35%, transparent);
  opacity: .82;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.015em; white-space: nowrap; line-height: 1.2; color: var(--fg); text-decoration: none; }
.logo { height: 28px; width: auto; flex: none; }
.brand small { display: block; font-weight: 400; font-size: 12px; letter-spacing: 0; color: var(--muted); }
.topbar .grow { flex: 1; min-width: 0; }

.side {
  position: fixed; z-index: 30; display: none; overflow-y: auto;
  inset: calc(var(--topbar) + 4px) 12px calc(var(--tabbar) + 24px + env(safe-area-inset-bottom, 0px)) 12px;
  padding: var(--s3); border-radius: var(--r-panel);
  background: var(--glass-strong); border: 1px solid var(--glass-edge); box-shadow: var(--shadow-float);
}
.side.open { display: block; }
.side .brand { display: none; padding: var(--s3) var(--s3) var(--s4); font-size: 16px; }
.side a.brand, .side a.brand:hover { min-height: 0; background: none; font-weight: 700; }
.side a.brand { font-size: 15px; gap: 9px; }
.side a.brand .logo { height: 26px; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side .label { padding: var(--s4) var(--s3) var(--s1); }
.side a {
  display: flex; align-items: center; gap: var(--s3);
  min-height: var(--tap); padding: 0 var(--s3);
  border-radius: var(--r-control); color: var(--fg); text-decoration: none; font-weight: 500;
}
.side a .icon { color: var(--muted); }
.side a span { flex: 1; min-width: 0; }
.side a:hover { background: var(--fill); }
.side a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side a[aria-current="page"] .icon { color: var(--accent); }
.count {
  flex: none; min-width: 22px; padding: 1px 7px; border-radius: 999px; text-align: center;
  background: var(--accent); color: var(--accent-fg); font: 600 12px/18px var(--font);
}

.bottombar {
  position: fixed; z-index: 40;
  inset: auto 12px calc(12px + env(safe-area-inset-bottom, 0px)) 12px;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  height: var(--tabbar); padding: 6px; border-radius: 999px;
  background: var(--glass-strong); border: 1px solid var(--glass-edge); box-shadow: var(--shadow-float);
}
.bottombar a, .bottombar button {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: 0; border: 0; border-radius: 999px; background: none; color: var(--muted);
  font: 600 11px/1.2 var(--font); text-decoration: none; cursor: pointer;
}
.bottombar [aria-current="page"], .bottombar [aria-expanded="true"] { background: var(--accent-soft); color: var(--accent); }
.bottombar .count { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; padding: 0 5px; font-size: 11px; line-height: 17px; }

.main {
  display: flex; flex-direction: column; gap: clamp(16px, 1.6vw + 8px, 28px);
  padding: var(--s3) var(--gutter) calc(var(--tabbar) + 48px + env(safe-area-inset-bottom, 0px));
  max-width: 1360px; margin: 0 auto; width: 100%;
}
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s3) var(--s5); }
.page-head > div:first-child { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.page-head p { color: var(--muted); max-width: 68ch; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.stack { display: flex; flex-direction: column; gap: var(--s3); }
.grid { display: grid; gap: clamp(14px, 1.2vw + 6px, 22px); grid-template-columns: minmax(0, 1fr); }

/* Menu dell'account */
.menu { position: relative; }
.menu > summary { list-style: none; min-height: 0; padding: 0; color: inherit; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.avatar {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(140deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--bg-c)));
  color: var(--accent-fg); font: 700 14px/1 var(--font); letter-spacing: .02em;
  box-shadow: 0 0 0 2px var(--glass-edge), var(--shadow);
}
.menu > div {
  position: absolute; right: 0; top: calc(100% + 10px); z-index: 50;
  width: min(300px, calc(100vw - 24px)); padding: var(--s2);
  display: flex; flex-direction: column; gap: 2px;
  background: var(--glass-strong); border: 1px solid var(--glass-edge); border-radius: var(--r-panel); box-shadow: var(--shadow-float);
}
.menu .who { padding: var(--s3); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.menu .who strong, .menu .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu a.entry, .menu button.entry {
  display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: var(--tap); padding: 0 var(--s3);
  border: 0; border-radius: var(--r-control); background: none; color: var(--fg);
  font: 500 15px var(--font); text-decoration: none; text-align: left; cursor: pointer;
}
.menu .entry:hover { background: var(--fill); }
.menu hr { width: 100%; height: 1px; margin: 4px 0; border: 0; background: var(--hairline); }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 3px; border-radius: 999px; background: var(--fill); }
.segmented button {
  min-height: 36px; border: 0; border-radius: 999px; background: none; color: var(--muted);
  font: 600 13px var(--font); cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: var(--glass-solid); color: var(--fg); box-shadow: var(--shadow); }

/* ---------- Componenti ---------- */
.panel {
  background: var(--glass); border: 1px solid var(--glass-edge); border-radius: var(--r-panel);
  box-shadow: var(--shadow); min-width: 0; overflow: clip;
}
.panel > header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2);
  padding: var(--s3) clamp(16px, 1.4vw + 8px, 22px); min-height: 56px; border-bottom: 1px solid var(--hairline);
}
.panel > .body { padding: clamp(16px, 1.4vw + 8px, 22px); }

.kpis {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px;
  background: var(--hairline); border: 1px solid var(--glass-edge); border-radius: var(--r-panel);
  box-shadow: var(--shadow); overflow: clip;
}
.kpi { background: var(--glass); padding: clamp(14px, 1.2vw + 8px, 22px); min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.kpi .num { font-family: var(--font); font-size: clamp(26px, 1.6vw + 18px, 38px); line-height: 1.1; font-weight: 700; letter-spacing: -.03em; }
.kpi .small { color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--tap); padding: 0 18px;
  border: 1px solid var(--glass-edge); border-radius: 999px;
  background: var(--glass-strong); color: var(--fg); box-shadow: 0 1px 2px rgb(18 34 64 / .08);
  font: 600 15px/1 var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: transform .12s ease, filter .12s ease, background .12s ease;
}
.btn:hover { filter: brightness(1.04); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-fg); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.sm { min-height: 36px; padding: 0 14px; font-size: 13px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  background: var(--fill); color: var(--muted);
  font-size: 12px; font-weight: 600; line-height: 1.35;
}
.pill::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--accent-soft); color: var(--accent); }
.table td .pill, .table td.r { white-space: nowrap; }
/* Tag delle fonti */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.table td .chips { justify-content: flex-end; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--hairline); background: var(--glass-strong); color: var(--fg);
  font-size: 12px; font-weight: 500; line-height: 1.4; white-space: nowrap; text-decoration: none;
}
.chip.primary { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chip.agent { border-style: dashed; }
.chip.agent::before { content: "✦"; font-size: 10px; color: var(--accent); }
.chip.disputed { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.chip.filter { padding: 6px 12px; font-size: 13px; }
.chip.filter b { font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip.filter[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.chip.filter[aria-current="page"] b { color: inherit; opacity: .8; }
.tag-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-option {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 12px; border-radius: var(--r-control);
  border: 1px solid var(--hairline); background: var(--glass-strong); cursor: pointer; font-size: 14px;
}
.tag-option small { display: block; color: var(--muted); font-size: 11px; }
.tag-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.tag { display: inline-block; padding: 2px 9px; border: 1px solid var(--hairline); border-radius: 8px; font-size: 12px; font-weight: 500; color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; }
.field > small { color: var(--muted); line-height: 1.4; }
input[type="text"], input[type="url"], input[type="email"], input[type="tel"], input[type="password"], input[type="number"],
input[type="search"], input[type="date"], select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 14px;
  border: 1px solid var(--hairline); border-radius: var(--r-control);
  background: var(--glass-strong); color: var(--fg); font: inherit;
  transition: border-color .12s ease, box-shadow .12s ease;
}
/* Tutti i campi a riga singola hanno la stessa altezza dei pulsanti. */
input[type="text"], input[type="url"], input[type="email"], input[type="tel"], input[type="password"], input[type="number"],
input[type="search"] { height: var(--tap); padding-block: 0; }
/* Menu a tendina e date: senza questo Safari li disegna con il suo aspetto, più bassi degli altri campi. */
select, input[type="date"] { -webkit-appearance: none; appearance: none; height: var(--tap); line-height: 1.3; }
select {
  padding-right: 40px; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%237d8aa0' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 12px;
}
input[type="date"] { min-width: 150px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
input[readonly] { background: var(--fill); color: var(--muted); }
input[type="range"] { width: 100%; min-height: 32px; accent-color: var(--accent); }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.switch { position: relative; display: inline-flex; align-items: center; min-height: var(--tap); cursor: pointer; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch i { width: 51px; height: 31px; border-radius: 999px; background: var(--fill); box-shadow: inset 0 0 0 1px var(--hairline); transition: background .18s; position: relative; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgb(0 0 0 / .25); transition: transform .18s; }
.switch input:checked + i { background: var(--ok); box-shadow: none; }
.switch input:checked + i::after { transform: translateX(20px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Schede: controllo segmentato */
.tabs {
  display: flex; gap: 2px; padding: 4px; overflow-x: auto; align-self: flex-start; max-width: 100%;
  border-radius: 999px; background: var(--glass); border: 1px solid var(--glass-edge); scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a, .tabs button {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 16px; border: 0; border-radius: 999px;
  background: none; color: var(--muted); font: 600 14px var(--font); text-decoration: none; white-space: nowrap; cursor: pointer;
}
.tabs [aria-current="page"], .tabs [aria-selected="true"] { background: var(--glass-solid); color: var(--fg); box-shadow: var(--shadow); }

/* Tabelle: su telefono ogni riga diventa una scheda, nessuna colonna viene nascosta. */
.table { width: 100%; border-collapse: collapse; }
.table thead { display: none; }
.table tr { display: block; padding: var(--s3) clamp(16px, 1.4vw + 8px, 22px); border-bottom: 1px solid var(--hairline); }
.table tr:last-child { border-bottom: 0; }
.table td { display: flex; justify-content: space-between; gap: var(--s4); padding: 4px 0; text-align: right; overflow-wrap: anywhere; }
.table td::before { content: attr(data-l); flex: 0 1 auto; max-width: 60%; overflow-wrap: break-word; color: var(--muted); font: 13px var(--font); text-align: left; }
.table td.lead { display: block; text-align: left; font-weight: 600; padding-bottom: var(--s2); }
.table td.lead::before { content: none; }
.table td.lead small { display: block; font-weight: 400; color: var(--muted); overflow-wrap: anywhere; }
.table td.acts { justify-content: flex-end; flex-wrap: wrap; gap: var(--s2); padding-top: var(--s2); }
.table td.acts::before { content: none; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--hairline); }
.list > li:last-child { border-bottom: 0; }
.item { display: flex; flex-direction: column; gap: 6px; padding: var(--s3) clamp(16px, 1.4vw + 8px, 22px); color: inherit; text-decoration: none; }
a.item { transition: background .12s ease; }
a.item:hover { background: var(--fill); }
.item[aria-current="true"] { background: var(--accent-soft); }
.item strong { font-weight: 600; line-height: 1.35; }

/* Flusso: linea temporale verticale dei passi */
.flow { list-style: none; margin: 0; padding: clamp(16px, 1.4vw + 8px, 22px); display: flex; flex-direction: column; }
.flow > li { position: relative; padding: 0 0 var(--s5) 34px; min-width: 0; }
.flow > li:last-child { padding-bottom: 0; }
.flow > li::before { content: ""; position: absolute; left: 9px; top: 24px; bottom: 2px; width: 2px; border-radius: 2px; background: var(--hairline); }
.flow > li:last-child::before { content: none; }
.flow > li::after { content: ""; position: absolute; left: 2px; top: 4px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 4px var(--fill); }
.flow > li.ok::after { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.flow > li.wait::after { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.flow > li.human::after { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.flow .step-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--s2); }
.flow .meta { color: var(--muted); font-size: 13px; }
details { margin-top: var(--s2); }
details.panel { margin-top: 0; }
summary { cursor: pointer; color: var(--accent); font-size: 14px; font-weight: 600; min-height: 32px; display: inline-flex; align-items: center; }
details.panel > summary { display: flex; min-height: 56px; }
pre.io { margin: var(--s2) 0 0; padding: var(--s3); overflow-x: auto; background: var(--fill); border-radius: var(--r-control); font: 12px/1.55 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }

/* Barre: altezza proporzionale al valore (style="--v: valore; --max: massimo") */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: var(--s4); }
.bars > div { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; height: 100%; }
.bars i { display: block; width: 100%; max-width: 34px; height: calc(var(--v) / var(--max) * 100%); min-height: 3px; background: linear-gradient(var(--accent), color-mix(in srgb, var(--accent) 60%, transparent)); border-radius: 8px 8px 3px 3px; }
.bars span { font-size: 11px; color: var(--muted); min-height: 14px; }
.bars b { font: 600 11px var(--font); font-variant-numeric: tabular-nums; color: var(--fg); min-height: 14px; }
.meter { height: 8px; border-radius: 999px; background: var(--fill); overflow: hidden; }
.meter i { display: block; height: 100%; width: calc(var(--v) * 1%); border-radius: 999px; background: var(--accent); }

.actionbar {
  position: sticky; bottom: calc(var(--tabbar) + 24px + env(safe-area-inset-bottom, 0px)); z-index: 10;
  display: grid; grid-template-columns: 1fr 1.4fr; gap: var(--s2);
  padding: var(--s2); background: var(--glass-strong); border: 1px solid var(--glass-edge); border-radius: 999px;
  box-shadow: var(--shadow-float);
}
/* Avanzamento di un lavoro in sottofondo */
.job { display: flex; flex-direction: column; gap: 8px; padding: var(--s3) var(--s4); border-radius: var(--r-control); background: var(--accent-soft); }
.job .row { justify-content: space-between; gap: var(--s2) var(--s4); }
.progress { position: relative; height: 8px; border-radius: 999px; background: var(--fill); overflow: hidden; }
.progress i { display: block; height: 100%; width: calc(var(--v, 0) * 1%); border-radius: 999px; background: var(--accent); transition: width .4s ease; }
.progress.unknown i { width: 34%; animation: slide 1.5s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-110%); } 100% { transform: translateX(310%); } }
@media (prefers-reduced-motion: reduce) { .progress.unknown i { animation: none; width: 100%; opacity: .45; } }
.note { padding: var(--s3) var(--s4); border-radius: var(--r-control); background: var(--accent-soft); color: var(--fg); font-size: 14px; }
.note.warn { background: var(--warn-soft); }
.proto-bar { display: flex; align-items: center; gap: var(--s2); }
.proto-bar label { display: none; }
.proto-bar select { width: auto; min-height: 36px; height: 36px; padding: 4px 34px 4px var(--s2); font-size: 13px; }
/* Pulsante per ridurre la barra laterale (solo su PC) e pulsante per ridurre i riquadri */
.side-toggle {
  display: none; align-items: center; justify-content: center; gap: var(--s3); width: 100%; min-height: var(--tap); margin-top: var(--s3);
  padding: 0 var(--s3); border: 1px solid var(--hairline); border-radius: var(--r-control); background: none; color: var(--muted);
  font: 500 14px var(--font); cursor: pointer;
}
.side-toggle:hover { background: var(--fill); color: var(--fg); }
.shell:not(.collapsed) .side-toggle { justify-content: flex-start; }
.shell.collapsed .side-toggle span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.shell.collapsed .side-toggle .icon { transform: scaleX(-1); }
.panel > header h2 { flex: 1 1 12rem; min-width: 0; }   /* i titoli lunghi vanno a capo senza spingere giù la freccia */
.panel-toggle {
  flex: none; display: inline-grid; place-items: center; width: 32px; height: 32px; margin-left: auto; padding: 0;
  border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer;
}
.panel-toggle:hover { background: var(--fill); color: var(--fg); }
.panel-toggle .icon { width: 18px; height: 18px; transition: transform .15s ease; }
/* Ridotto, accanto a un altro riquadro non resta alto quanto lui; in colonna resta largo quanto prima. */
.grid > .panel.collapsed { align-self: start; }
.panel.collapsed > header { border-bottom: 0; }
.panel.collapsed > header ~ * { display: none !important; }
.panel.collapsed .panel-toggle .icon { transform: rotate(-90deg); }
.back-link { display: none; align-items: center; gap: 6px; min-height: var(--tap); font-weight: 600; text-decoration: none; align-self: flex-start; }

/* Elenco/dettaglio su telefono: una cosa alla volta. Con una voce scelta si vede il dettaglio, altrimenti l'elenco. */
.actionbar.three { grid-template-columns: 1fr 1fr 1.25fr; }
.actionbar.three .btn { padding: 0 10px; white-space: normal; line-height: 1.15; text-align: center; }
@media (max-width: 767px) {
  /* I pulsanti di decisione restano sempre a portata di pollice, sopra la barra di navigazione. */
  .actionbar { position: fixed; left: 12px; right: 12px; bottom: calc(var(--tabbar) + 22px + env(safe-area-inset-bottom, 0px)); }
  .main:has(.actionbar) { padding-bottom: calc(var(--tabbar) + 130px + env(safe-area-inset-bottom, 0px)); }
  .split.picked > .list-col { display: none; }
  .split:not(.picked) > .detail-col { display: none; }
  .split.picked .back-link { display: inline-flex; }
}

/* ---------- Tablet: barra laterale a icone ---------- */
@media (min-width: 768px) {
  .proto-bar label { display: inline; }
  .shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .topbar { grid-column: 2; }
  .topbar > .brand { display: none; }
  .side {
    position: sticky; top: 12px; inset: auto; display: block; grid-row: 1 / -1; align-self: start;
    height: calc(100dvh - 24px); margin: 12px 0 12px 12px; padding: var(--s2);
    background: var(--glass); box-shadow: var(--shadow);
  }
  .side a.brand { display: flex; justify-content: center; padding: var(--s2) 0 var(--s3); }
  .side a.brand span { display: none; }
  .side .label { height: 1px; margin: 10px 14px; padding: 0; overflow: hidden; background: var(--hairline); color: transparent; }
  .side nav > .label:first-child { display: none; }
  .side a { justify-content: center; padding: 0; position: relative; }
  .side a span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .side a .count { position: absolute; top: 3px; right: 6px; min-width: 18px; padding: 0 5px; font-size: 11px; line-height: 17px; }
  .bottombar { display: none; }
  .main { padding: var(--s2) var(--gutter) var(--s6); grid-column: 2; }
  .actionbar { bottom: var(--s4); grid-template-columns: auto auto; justify-content: end; align-self: flex-end; }
  .actionbar.three { grid-template-columns: auto auto auto; }
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .grid.split { grid-template-columns: minmax(260px, 2fr) minmax(0, 3fr); align-items: start; }
  .grid.split.main-first { grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); }
  .grid.topic-row { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) minmax(0, 1fr); }
  .grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- PC: barra laterale completa, tabelle vere ---------- */
@media (min-width: 1100px) {
  /* Barra laterale completa, salvo se ridotta con il pulsante «Riduci menu» (resta a sole icone, come su tablet). */
  .shell:not(.collapsed) { grid-template-columns: var(--side) minmax(0, 1fr); }
  .shell:not(.collapsed) .side { padding: var(--s3); }
  .shell:not(.collapsed) .side a.brand { justify-content: flex-start; padding: var(--s3) var(--s3) var(--s4); }
  .shell:not(.collapsed) .side a.brand span { display: block; position: static; width: auto; height: auto; clip-path: none; }
  .shell:not(.collapsed) .side .label { height: auto; margin: 0; padding: var(--s4) var(--s3) var(--s1); overflow: visible; background: none; color: var(--muted); }
  .shell:not(.collapsed) .side nav > .label:first-child { display: block; padding-top: var(--s1); }
  .shell:not(.collapsed) .side a { justify-content: flex-start; padding: 0 var(--s3); }
  .shell:not(.collapsed) .side a span { position: static; width: auto; height: auto; overflow: visible; clip-path: none; }
  .shell:not(.collapsed) .side a .count { position: static; min-width: 22px; padding: 1px 7px; font-size: 12px; line-height: 18px; }
  .side-toggle { display: flex; }

}

/* Dove il vetro non è disponibile o non è gradito, le superfici diventano piene: la leggibilità non dipende dalla sfocatura. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root { --glass: var(--glass-solid); --glass-strong: var(--glass-solid); }
}
@media (prefers-reduced-transparency: reduce) {
  :root { --glass: var(--glass-solid); --glass-strong: var(--glass-solid); }
  body::before { display: none; }
}
@media (prefers-contrast: more) {
  :root { --glass: var(--glass-solid); --glass-strong: var(--glass-solid); --hairline: color-mix(in srgb, var(--fg) 45%, transparent); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }

/* Mappa del flusso in testata */
.flowmap { background: var(--glass); border: 1px solid var(--glass-edge); border-radius: var(--r-panel); padding: var(--s3) var(--s4);
  box-shadow: var(--shadow); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); display: grid; gap: var(--s2); }
.flowmap > summary { cursor: pointer; font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: var(--s2); list-style: none; min-height: 28px; }
.flowmap > summary::-webkit-details-marker { display: none; }
.flowmap > summary::after { content: "▾"; margin-left: auto; color: var(--muted); transition: transform .2s; }
.flowmap:not([open]) > summary::after { transform: rotate(-90deg); }
.flowmap > p { margin: 0; }
.flow-line { display: flex; align-items: center; gap: var(--s2) var(--s3); flex-wrap: wrap; opacity: .62; }
.flow-line.here { opacity: 1; }
.flow-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); min-width: 64px; }
.flow-line ol { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.flow-line li { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.flow-line li + li::before { content: "→"; color: var(--muted); }
.flow-line li a, .flow-line li span { padding: 4px 10px; border-radius: 999px; background: var(--fill); color: var(--fg); text-decoration: none; white-space: nowrap; }
.flow-line li a:hover { background: var(--accent-soft); }
.flow-line li.current a, .flow-line li.current span { background: var(--accent); color: var(--accent-fg); font-weight: 600; }
.flow-join { margin: -2px 0 0; padding-left: 76px; font-size: 12px; }
@media (max-width: 767px) { .flow-join { padding-left: 0; } .flow-label { min-width: 100%; } }

/* Tappa di una fonte o notizia */
.stage { display: inline-flex; align-items: center; gap: 8px; }
.stage .dots { display: inline-flex; gap: 3px; flex: none; }
.stage .dots i, .stepper li::before { width: 8px; height: 8px; border-radius: 50%; background: var(--hairline); display: inline-block; }
.stage .dots i.done, .stepper li.done::before { background: var(--ok); }
.stage .dots i.moving, .stepper li.moving::before { background: var(--accent); }
.stage .dots i.waiting, .stepper li.waiting::before { background: var(--warn); }
.stage .dots i.stopped, .stepper li.stopped::before { background: var(--bad); }
.stage.stopped > .small { color: var(--bad); }
.stage.waiting > .small { color: var(--warn); }
.stepper { display: flex; flex-wrap: wrap; gap: 6px 4px; margin: 0; padding: 0; list-style: none; font-size: 13px; }
.stepper li { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 8px; border-radius: 999px; background: var(--fill); color: var(--muted); }
.stepper li::before { content: ""; flex: none; }
.stepper li.done { color: var(--fg); }
.stepper li.moving, .stepper li.waiting, .stepper li.stopped { color: var(--fg); font-weight: 600; box-shadow: inset 0 0 0 1.5px currentColor; }
.stepper li.moving { color: var(--accent); } .stepper li.waiting { color: var(--warn); } .stepper li.stopped { color: var(--bad); }
.stage-label { margin: 6px 0 0; }
.stage-label.stopped { color: var(--bad); } .stage-label.waiting { color: var(--warn); }

/* Tabelle: di base a schede (una riga = una scheda con le etichette). Lo script della pagina prova la vista a
   colonne e la tiene solo se la tabella entra tutta nel suo riquadro: così nessuna colonna viene tagliata,
   qualunque sia lo schermo o la colonna della pagina in cui si trova. */
.table.cols:not(.kv) thead { display: table-header-group; }
.table.cols:not(.kv) tr { display: table-row; padding: 0; }
.table.cols:not(.kv) th, .table.cols:not(.kv) td { display: table-cell; padding: 14px clamp(16px, 1.4vw + 8px, 22px); text-align: left; vertical-align: middle; border-bottom: 1px solid var(--hairline); }
.table.cols:not(.kv) th { padding-block: 10px; font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); white-space: normal; }
.table.cols:not(.kv) tbody tr:last-child td { border-bottom: 0; }
.table.cols:not(.kv) td::before { content: none; }
.table.cols:not(.kv) td.lead { display: table-cell; padding: 14px clamp(16px, 1.4vw + 8px, 22px); min-width: 180px; }
.table.cols:not(.kv) td.lead small { overflow-wrap: break-word; word-break: break-all; }
.table.cols:not(.kv) td.r, .table.cols:not(.kv) th.r { text-align: right; }
.table.cols:not(.kv) td.acts { text-align: right; }
.table.cols:not(.kv) td.acts > * { margin: 2px 0 2px 4px; }
.table.cols:not(.kv) td .chips { justify-content: flex-start; }
.table.cols:not(.kv) td.tags-cell { min-width: 160px; max-width: 360px; }
/* Tabelle chiave/valore: l'etichetta resta sempre visibile */
.table.kv tr { display: block; }
.table.kv td { display: flex; justify-content: space-between; gap: var(--s4); text-align: right; border-bottom: 1px solid var(--hairline); }
.table.kv tr:last-child td { border-bottom: 0; }
.table.kv td::before { content: attr(data-l); max-width: 70%; }
.table.kv thead { display: none; }

/* Segno di lavoro */
.mark { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px var(--s3); }
.mark.busy { opacity: .6; pointer-events: none; }
.mark-label { color: var(--muted); }
.mark[data-state="starred"] .mark-label { color: var(--warn); font-weight: 600; }
.mark-btns { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--fill); }
.mark-btns button { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px; border: 0; border-radius: 999px;
  background: none; color: var(--muted); font: 600 13px var(--font); cursor: pointer; }
.mark-btns button .icon { width: 16px; height: 16px; }
.mark-btns button:hover { color: var(--fg); }
.mark-btns button[aria-pressed="true"] { background: var(--glass-solid); color: var(--fg); box-shadow: var(--shadow); }
.mark-btns button[data-set="starred"][aria-pressed="true"] { color: var(--warn); }
.mark-btns button[data-set="starred"][aria-pressed="true"] .icon { fill: currentColor; }
.mark.compact .mark-btns button { min-height: 28px; padding: 0 8px; }
.mark.compact .mark-btns button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.list > li > .mark { padding: 0 clamp(16px, 1.4vw + 8px, 22px) var(--s3); margin-top: calc(-1 * var(--s2)); }
.list > li.marked-starred, .table tr.marked-starred { background: var(--warn-soft); box-shadow: inset 3px 0 0 var(--warn); }
.list > li.marked-hidden, .table tr.marked-hidden { opacity: .55; }
.mark-filter { margin-top: calc(-1 * var(--s2)); }

/* Dettaglio accanto all'elenco: resta in vista e scorre per conto suo */
.detail-col.loading { opacity: .55; transition: opacity .15s; }
@media (min-width: 768px) {
  .grid.split > .detail-col { position: sticky; top: 12px; max-height: calc(100dvh - 24px); overflow-y: auto;
    overscroll-behavior: contain; scrollbar-width: thin; border-radius: var(--r-panel); }
}
