/* =========================================================================
   enautomation — sistema visivo
   =========================================================================

   Direzione: quadro strumenti, non pannello di amministrazione.
   Il prodotto sorveglia processi autonomi che spendono una quota finita, e
   l'interfaccia deve somigliare a ciò che sorveglia: superfici da strumento,
   linee sottili da disegno tecnico, numeri che si leggono a colpo d'occhio.

   Tre scelte deliberate, tutte derivate dal dominio:

   1. Il monospace è il carattere DISPLAY, non solo quello del codice. Qui
      quasi ogni valore che conta è un valore macchina — id di run, branch,
      percentuali, costi, durate, esiti. Comporli in un proporzionale è ciò
      che fa somigliare un pannello operativo a un gestionale qualunque.

   2. Il blu inchiostro al posto del nero neutro, con le linee color blueprint.
      È la tavolozza del disegno tecnico, non quella del "tema scuro".

   3. L'ambra è il colore dell'attività, non un accento decorativo: nei
      sistemi di controllo reali ambra significa "in corso, tienilo d'occhio"
      e il rosso resta al guasto. Le fasce della quota seguono la stessa
      convenzione, quindi il colore porta informazione invece di gusto.

   L'elemento firma è l'indicatore di autonomia residua (`.gauge`): una scala
   con tacche, non una barra di avanzamento, perché quello che mostra non è un
   progresso ma un serbatoio che si svuota.
   ========================================================================= */

/* ------------------------------------------------------------- 1. token */

:root {
  /* Superfici: inchiostro blu, non nero neutro. */
  --ink: #0b111c;
  --panel: #131c2b;
  --panel-raised: #182234;
  --line: #223148;
  --line-strong: #2f4260;

  /* Testo */
  --text: #dce5f2;
  --text-dim: #93a4bd;
  --text-faint: #64768f;

  /* Segnali. Ambra = attività, rosso = guasto, verde = concluso bene. */
  --signal: #f0a73c;
  --signal-soft: rgba(240, 167, 60, 0.14);
  --halt: #e0574e;
  --halt-soft: rgba(224, 87, 78, 0.14);
  --go: #46b98a;
  --go-soft: rgba(70, 185, 138, 0.14);
  --info: #5b9dd9;
  --info-soft: rgba(91, 157, 217, 0.14);

  /* Alias usati dai componenti già esistenti. */
  --accent: var(--signal);
  --ok: var(--go);
  --warn: var(--signal);
  --danger: var(--halt);
  --border: var(--line);
  --bg-card: var(--panel);
  --text-muted: var(--text-dim);
  /* Alias storico usato da terminal.css: la superficie rialzata. */
  --bg-elevated: var(--panel-raised);

  /* Tipografia: il display è monospace. */
  --font-display: ui-monospace, "Cascadia Code", "JetBrains Mono", "SF Mono",
    Menlo, Consolas, monospace;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --step--1: 0.78rem;
  --step-0: 0.875rem;
  --step-1: 1rem;
  --step-2: 1.35rem;
  --step-3: 1.9rem;
  --step-4: 2.6rem;

  /* Ritmo verticale su base 4px: la densità è una scelta, non un caso. */
  --s1: 0.25rem;
  --s2: 0.5rem;
  --s3: 0.75rem;
  --s4: 1rem;
  --s5: 1.5rem;
  --s6: 2rem;
  --s7: 3rem;

  --radius: 6px;
  --radius-sm: 4px;

  /* Bordo superiore chiaro: il riflesso di una superficie lavorata. */
  --edge: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  --lift: 0 1px 2px rgba(0, 0, 0, 0.35);
}

/* Tema chiaro: carta da disegno tecnico, non "bianco generico". */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --ink: #eef2f8;
    --panel: #ffffff;
    --panel-raised: #f7f9fc;
    --line: #ccd7e6;
    --line-strong: #a9bad2;
    --text: #16202f;
    --text-dim: #4a5b74;
    --text-faint: #7386a0;
    --signal: #b06f00;
    --signal-soft: rgba(176, 111, 0, 0.12);
    --halt: #c0392f;
    --halt-soft: rgba(192, 57, 47, 0.1);
    --go: #1d7f5c;
    --go-soft: rgba(29, 127, 92, 0.1);
    --info: #2f6ea8;
    --info-soft: rgba(47, 110, 168, 0.1);
    --edge: inset 0 1px 0 rgba(255, 255, 255, 0.9);
    --lift: 0 1px 2px rgba(20, 35, 60, 0.08);
  }
}

:root[data-theme="light"] {
  --ink: #eef2f8;
  --panel: #ffffff;
  --panel-raised: #f7f9fc;
  --line: #ccd7e6;
  --line-strong: #a9bad2;
  --text: #16202f;
  --text-dim: #4a5b74;
  --text-faint: #7386a0;
  --signal: #b06f00;
  --signal-soft: rgba(176, 111, 0, 0.12);
  --halt: #c0392f;
  --halt-soft: rgba(192, 57, 47, 0.1);
  --go: #1d7f5c;
  --go-soft: rgba(29, 127, 92, 0.1);
  --info: #2f6ea8;
  --info-soft: rgba(47, 110, 168, 0.1);
  --edge: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --lift: 0 1px 2px rgba(20, 35, 60, 0.08);
}

/* --------------------------------------------------------------- 2. base */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.5;
  /* I numeri cambiano in diretta: senza cifre tabulari le colonne ballano. */
  font-variant-numeric: tabular-nums;
  /* Reticolo da carta millimetrata, appena percettibile. */
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 96px 96px, 96px 96px;
  background-position: -1px -1px;
  background-attachment: fixed;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) body { background-blend-mode: multiply; }
}

a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--line-strong);
}
a:hover { border-bottom-color: var(--signal); }

h1, h2, h3, h4 {
  margin: 0 0 var(--s3);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
h1 { font-size: var(--step-2); }
h2 { font-size: var(--step-1); }
h3 { font-size: var(--step-0); }

p { margin: 0 0 var(--s3); }

code, pre, .mono {
  font-family: var(--font-display);
  font-size: 0.92em;
}

code {
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
  background: var(--panel-raised);
  border: 1px solid var(--line);
}

hr { border: none; border-top: 1px solid var(--line); margin: var(--s5) 0; }

/* ------------------------------------------------------------- 3. layout */

.layout {
  display: grid;
  grid-template-columns: 208px 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel) 0%, var(--ink) 100%);
  padding: var(--s5) 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

/* Il marchio è un'etichetta da pannello: mono, maiuscolo, spaziato. */
.brand {
  font-family: var(--font-display);
  font-size: var(--step--1);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text);
  padding: 0 var(--s5) var(--s5);
  display: flex;
  align-items: center;
  gap: var(--s2);
}
/* Il marchio è disegnato inline (views.ts) per ereditare il colore del tema:
   le parentesi seguono currentColor, il punto resta ambra. */
.brand-mark {
  width: 20px;
  height: 20px;
  flex: none;
  overflow: visible;
}

.nav-list { list-style: none; margin: 0; padding: 0; }

.nav-link {
  display: block;
  padding: var(--s2) var(--s5);
  font-family: var(--font-display);
  font-size: var(--step--1);
  letter-spacing: 0.06em;
  color: var(--text-dim);
  border: none;
  border-left: 2px solid transparent;
}
.nav-link:hover { color: var(--text); background: var(--panel-raised); }
.nav-link.active {
  color: var(--text);
  border-left-color: var(--signal);
  background: linear-gradient(90deg, var(--signal-soft), transparent 60%);
}

.main { display: flex; flex-direction: column; min-width: 0; }

/* Barra di stato: sta sempre in vista perché porta il dato che governa
   tutto il resto — quanta autonomia resta. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--s4);
  padding: var(--s3) var(--s5);
  background: color-mix(in srgb, var(--ink) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.page-title {
  font-family: var(--font-display);
  font-size: var(--step--1);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  margin: 0;
  font-weight: 500;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--s3);
}

.current-user {
  font-family: var(--font-display);
  font-size: var(--step--1);
  color: var(--text-dim);
}

.content { padding: var(--s5); max-width: 1400px; width: 100%; }

.proxy-banner {
  padding: var(--s2) var(--s5);
  background: var(--info-soft);
  border-bottom: 1px solid var(--line);
  font-size: var(--step--1);
}

/* Prima del login non c'e' niente da sorvegliare: niente griglia, niente
   barra laterale, una sola scheda centrata sul reticolo. */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--s5);
}

.auth-card {
  width: 100%;
  max-width: 30rem;
  padding: var(--s6) var(--s5);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--edge), var(--lift);
}
/* Il marchio qui non e' la testata della barra laterale: perde il rientro. */
.auth-card .brand { padding: 0 0 var(--s5); }
/* La larghezza la detta la scheda, non il limite di lettura dei form lunghi. */
.auth-card .stack-form { max-width: none; }
.auth-card h2 { margin-bottom: var(--s4); }
.auth-card > p { color: var(--text-dim); font-size: var(--step--1); }

/* ------------------------------------------------ 4. firma: indicatore quota

   Non è una barra di avanzamento: è una scala con tacche che si svuota.
   Un progresso cresce verso un traguardo, una quota cala verso un muro, e
   le due cose non devono somigliarsi.                                      */

.gauge {
  --gauge-fill: 100%;
  display: block;
}

.gauge-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s3);
  margin-bottom: var(--s2);
}

.gauge-label {
  font-family: var(--font-display);
  font-size: var(--step--1);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
}

.gauge-value {
  font-family: var(--font-display);
  font-size: var(--step-2);
  font-weight: 600;
  letter-spacing: -0.02em;
}
.gauge-value .gauge-unit {
  font-size: var(--step-0);
  color: var(--text-dim);
  margin-left: 0.1em;
}

.gauge-track {
  position: relative;
  height: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background:
    repeating-linear-gradient(
      90deg,
      var(--line) 0 1px,
      transparent 1px 10%
    ),
    var(--panel);
  overflow: hidden;
}

.gauge-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--gauge-fill);
  background: linear-gradient(90deg, var(--tone, var(--go)), color-mix(in srgb, var(--tone, var(--go)) 65%, transparent));
  transition: width 600ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* Le tacche restano visibili sopra il riempimento: è una scala, non un blocco. */
.gauge-track::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.35) 0 1px,
    transparent 1px 10%
  );
}

.gauge-foot {
  display: flex;
  justify-content: space-between;
  margin-top: var(--s1);
  font-family: var(--font-display);
  font-size: var(--step--1);
  color: var(--text-faint);
}

.gauge-ok { --tone: var(--go); }
.gauge-warn { --tone: var(--signal); }
.gauge-error { --tone: var(--halt); }

/* Versione compatta nella barra di stato. */
.usage-slot { display: flex; align-items: center; }

.usage-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s1) var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--panel);
  box-shadow: var(--edge);
  font-family: var(--font-display);
  font-size: var(--step--1);
  color: var(--text);
  white-space: nowrap;
}
.usage-indicator .usage-dot {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--text-faint);
}
.usage-indicator .usage-pct { font-weight: 600; letter-spacing: -0.01em; }
.usage-indicator .usage-label { color: var(--text-dim); letter-spacing: 0.06em; text-transform: uppercase; }
.usage-ok .usage-dot { background: var(--go); box-shadow: 0 0 0 3px var(--go-soft); }
.usage-warn .usage-dot { background: var(--signal); box-shadow: 0 0 0 3px var(--signal-soft); }
.usage-error .usage-dot { background: var(--halt); box-shadow: 0 0 0 3px var(--halt-soft); }
.usage-unknown { border-style: dashed; color: var(--text-dim); }

/* Consumo della macchina: stessa scatola del consumo del piano, tre numeri
   invece di uno. Le etichette sono minuscole di proposito — il numero è il
   dato, la sigla serve solo a non doverlo indovinare. */
.host-indicator { gap: var(--s2); }
.host-indicator .host-metric { display: inline-flex; align-items: baseline; gap: 4px; }
.host-indicator .host-key {
  color: var(--text-faint);
  font-size: 0.72em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.host-indicator .host-val { font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------- 5. pannelli */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--edge), var(--lift);
  padding: var(--s5);
  margin-bottom: var(--s4);
}
.card-tone-warn { border-color: color-mix(in srgb, var(--signal) 45%, var(--line)); }
.card-tone-danger { border-color: color-mix(in srgb, var(--halt) 45%, var(--line)); }

.card-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  margin-bottom: var(--s4);
}
.card-head-row h2 { margin: 0; }

/* Occhiello: etichetta di sezione con riga guida, come su una tavola. */
.eyebrow {
  display: flex;
  align-items: center;
  gap: var(--s3);
  font-family: var(--font-display);
  font-size: var(--step--1);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-faint);
  margin-bottom: var(--s3);
}
.eyebrow::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--s4);
  margin-bottom: var(--s4);
}

.stat-card { padding: var(--s4); margin: 0; }
.stat-value {
  font-family: var(--font-display);
  font-size: var(--step-3);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
}
.stat-label {
  margin-top: var(--s2);
  font-family: var(--font-display);
  font-size: var(--step--1);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}
.stat-hint { margin-top: var(--s1); font-size: var(--step--1); color: var(--text-faint); }
.tone-ok .stat-value { color: var(--go); }
.tone-warn .stat-value { color: var(--signal); }
.tone-error .stat-value { color: var(--halt); }

/* --------------------------------------------------------- 6. tipografia */

.muted { color: var(--text-dim); }
.text-error { color: var(--halt); }

.prompt-preview,
pre {
  font-family: var(--font-display);
  font-size: var(--step--1);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--s3);
  margin: 0;
  overflow-x: auto;
}
pre code { background: none; border: none; padding: 0; }

.steps { padding-left: 1.2rem; }
.steps li { margin-bottom: var(--s3); }

/* ------------------------------------------------------------ 7. tabelle */

.table-scroll { overflow-x: auto; max-width: 100%; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--step-0);
}
.table th {
  text-align: left;
  font-family: var(--font-display);
  font-size: var(--step--1);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  padding: var(--s2) var(--s3);
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
.table td {
  padding: var(--s3);
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table tbody tr:hover { background: var(--panel-raised); }
.table tbody tr:last-child td { border-bottom: none; }
.table-dense td, .table-dense th { padding: var(--s1) var(--s2); }

/* Gli identificatori sono valori macchina: si compongono in monospace. */
.table td a[href^="/runs/"],
.table td a[href^="/prompts/"],
.table td code { font-family: var(--font-display); }

.table-filter-input { max-width: 260px; }

/* Anteprima dell'output di un tool: una riga sola, il testo intero sta nel
   run. Senza troncamento una risposta lunga sfonda la tabella. */
.tc-preview {
  display: block;
  max-width: 46ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0;
  background: none;
  border: none;
  color: var(--text-dim);
}
/* Una scrittura via MCP tocca un sistema esterno: la riga si vede. */
.tc-write td:first-child { box-shadow: inset 2px 0 0 var(--signal); }

.pagination { align-items: center; gap: var(--s3); margin-top: var(--s4); }

/* ------------------------------------------------------------- 8. stati */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--panel-raised);
  font-family: var(--font-display);
  font-size: var(--step--1);
  letter-spacing: 0.04em;
  color: var(--text-dim);
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.badge-succeeded, .badge-tone-ok { color: var(--go); border-color: color-mix(in srgb, var(--go) 40%, var(--line)); background: var(--go-soft); }
.badge-failed, .badge-tone-error { color: var(--halt); border-color: color-mix(in srgb, var(--halt) 40%, var(--line)); background: var(--halt-soft); }
.badge-running, .badge-tone-warn, .badge-queued { color: var(--signal); border-color: color-mix(in srgb, var(--signal) 40%, var(--line)); background: var(--signal-soft); }
.badge-cancelled, .badge-neutral, .badge-tone-neutral { color: var(--text-dim); }
.badge-paused { color: var(--signal); border-color: color-mix(in srgb, var(--signal) 40%, var(--line)); background: var(--signal-soft); }
.badge-tone-info { color: var(--info); border-color: color-mix(in srgb, var(--info) 40%, var(--line)); background: var(--info-soft); }

/* Un run in corso è l'unica cosa che pulsa: sta succedendo adesso. */
.badge-running::before {
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-sm);
  background: var(--panel-raised);
  border: 1px solid var(--line);
  font-family: var(--font-display);
  font-size: var(--step--1);
  color: var(--text-dim);
}
.chip-small { font-size: 0.72rem; padding: 0 0.35rem; }
.outcome-chips { display: flex; flex-wrap: wrap; gap: var(--s2); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); }
.dot-ok { background: var(--go); box-shadow: 0 0 0 3px var(--go-soft); }
.dot-warn { background: var(--signal); box-shadow: 0 0 0 3px var(--signal-soft); }
.dot-error { background: var(--halt); box-shadow: 0 0 0 3px var(--halt-soft); }

/* ------------------------------------------------------------ 9. comandi */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--panel-raised);
  box-shadow: var(--edge);
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--step--1);
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease, transform 60ms ease;
}
.btn:hover { border-color: var(--text-faint); }
.btn:active { transform: translateY(1px); }

.btn-primary { border-color: color-mix(in srgb, var(--signal) 55%, var(--line)); background: var(--signal-soft); color: var(--signal); }
.btn-primary:hover { border-color: var(--signal); }
.btn-danger { border-color: color-mix(in srgb, var(--halt) 45%, var(--line)); color: var(--halt); background: var(--halt-soft); }
.btn-warn { border-color: color-mix(in srgb, var(--signal) 45%, var(--line)); color: var(--signal); background: var(--signal-soft); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); border-color: var(--line-strong); }
.btn-theme { min-width: 5.5rem; }
/* Bottone dentro una cella: la riga resta alta come le altre. */
.btn-small { padding: var(--s1) var(--s2); letter-spacing: 0.02em; }

.btn-row { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.inline-form { display: inline-flex; gap: var(--s2); align-items: center; margin: 0; }

/* ------------------------------------------------------------- 10. form */

.stack-form { display: flex; flex-direction: column; gap: var(--s4); max-width: 46rem; }
.stack-form label { display: flex; flex-direction: column; gap: var(--s2); font-size: var(--step--1); color: var(--text-dim); }
.stack-form .checkbox-label { flex-direction: row; align-items: center; gap: var(--s2); }

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
select,
textarea {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--step-0);
}
textarea, input[name="key"], input[name="slug"], input[name="image_tag"], select { font-family: var(--font-display); }
textarea { resize: vertical; line-height: 1.5; }

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--signal);
  box-shadow: 0 0 0 3px var(--signal-soft);
}

input[type="checkbox"] { accent-color: var(--signal); width: 1rem; height: 1rem; }

/* QR per l'app authenticator: l'SVG porta con sé sfondo bianco e zona
   quieta, qui solo dimensione e centratura. Bianco anche in tema scuro:
   la fotocamera vuole contrasto, non coerenza estetica. */
.totp-qr {
  display: flex;
  justify-content: center;
  margin-bottom: var(--s4);
}
.totp-qr svg {
  width: min(240px, 70vw);
  height: auto;
  border-radius: var(--radius-sm);
}

/* Il segreto TOTP si mostra una volta sola: riquadro rialzato e monospace,
   perche' chi lo copia a mano deve distinguere 0 da O. */
.secret-box {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  padding: var(--s4);
  margin-bottom: var(--s4);
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.secret-box label { display: flex; flex-direction: column; gap: var(--s2); font-size: var(--step--1); color: var(--text-dim); }
.secret-box input { font-family: var(--font-display); }
.input-small { max-width: 12rem; }

.flash-error, .flash-warning {
  padding: var(--s3);
  border-radius: var(--radius-sm);
  border-left: 3px solid;
  font-size: var(--step--1);
  margin-bottom: var(--s3);
}
.flash-error { border-color: var(--halt); background: var(--halt-soft); }
.flash-warning { border-color: var(--signal); background: var(--signal-soft); }

/* --------------------------------------------------------- 11. contenuti */

.meta-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--s2) var(--s5);
  margin: 0 0 var(--s4);
  font-size: var(--step-0);
}
.meta-grid dt {
  font-family: var(--font-display);
  font-size: var(--step--1);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
}
.meta-grid dd { margin: 0; font-family: var(--font-display); }

.empty-state {
  padding: var(--s6) var(--s4);
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}
.empty-state-title { font-family: var(--font-display); color: var(--text); margin-bottom: var(--s2); }
.empty-state-hint { color: var(--text-dim); font-size: var(--step--1); max-width: 34rem; margin-inline: auto; }
.empty-state-action { margin-top: var(--s4); }

.meter { margin-bottom: var(--s4); }
.meter-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); margin-bottom: var(--s2); }
.meter-label { font-family: var(--font-display); font-size: var(--step--1); text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-dim); }
.meter-value { font-family: var(--font-display); font-size: var(--step-0); }
.meter-track {
  height: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px 10%), var(--panel);
  overflow: hidden;
  position: relative;
}
.meter-fill { height: 100%; background: var(--text-faint); transition: width 600ms cubic-bezier(0.22, 1, 0.36, 1); }
.meter-ok .meter-fill { background: var(--go); }
.meter-warn .meter-fill { background: var(--signal); }
.meter-error .meter-fill { background: var(--halt); }

.bar-chart { display: flex; flex-direction: column; gap: var(--s1); }
.bar-row { display: grid; grid-template-columns: 4rem 1fr auto; gap: var(--s3); align-items: center; font-family: var(--font-display); font-size: var(--step--1); }
.bar-label { color: var(--text-faint); }
.bar-track { height: 8px; background: var(--panel-raised); border: 1px solid var(--line); border-radius: 2px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--info); }
.bar-value { color: var(--text-dim); }

.tabs { display: flex; gap: var(--s1); border-bottom: 1px solid var(--line); margin-bottom: var(--s4); flex-wrap: wrap; }
.tab {
  padding: var(--s2) var(--s4);
  font-family: var(--font-display);
  font-size: var(--step--1);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  border: none;
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--text); border-bottom-color: var(--signal); }

/* ------------------------------------------------------ 12. credenziali */

.cred-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--s4); margin-bottom: var(--s4); }
.cred-card { border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s4); background: var(--panel-raised); }
.cred-card-head { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s2); }
.cred-secret { font-family: var(--font-display); font-size: var(--step--1); word-break: break-all; }
.cred-fingerprint { font-size: 0.75rem; opacity: 0.8; }
.cred-check { margin-top: var(--s3); padding: var(--s2) var(--s3); border-radius: var(--radius-sm); border-left: 3px solid; font-size: var(--step--1); }
.cred-check-ok { border-color: var(--go); background: var(--go-soft); }
.cred-check-error { border-color: var(--halt); background: var(--halt-soft); }
.cred-check-msg { margin: var(--s2) 0 0; white-space: pre-wrap; word-break: break-word; font-size: var(--step--1); background: none; border: none; padding: 0; }

/* Elenco di stato: pallino allineato al testo, niente punto elenco. */
.cred-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.cred-list li { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2); font-size: var(--step--1); }
.cred-list .dot { flex: none; }

.copy-row { display: flex; gap: var(--s2); align-items: center; }
.btn-copy { flex: none; }

/* ------------------------------------------------------------- 13. diff */

.diff-view { font-family: var(--font-display); font-size: var(--step--1); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: auto; }
.diff-line { padding: 0 var(--s3); white-space: pre-wrap; }
.diff-marker { display: inline-block; width: 1.2em; color: var(--text-faint); }
.diff-add { background: var(--go-soft); }
.diff-del { background: var(--halt-soft); }

/* --------------------------------------------------- 14. documentazione */

.doc-index { list-style: none; padding: 0; margin: 0; }
.doc-index li { padding: var(--s3) 0; border-bottom: 1px solid var(--line); display: flex; align-items: baseline; gap: var(--s3); }
.doc-index li:last-child { border-bottom: none; }
.doc-index a { font-weight: 600; border: none; }
.doc-index .muted { font-family: var(--font-display); font-size: var(--step--1); }

.doc-body { line-height: 1.65; max-width: 62rem; }
.doc-body h2 { margin-top: var(--s6); }
.doc-body h3 { margin-top: var(--s5); }
.doc-body ul, .doc-body ol { margin: var(--s3) 0 var(--s3) 1.4rem; }
.doc-body li { margin: var(--s1) 0; }
.doc-body blockquote { margin: var(--s4) 0; padding: var(--s2) var(--s4); border-left: 3px solid var(--signal); background: var(--signal-soft); }
.doc-code { overflow-x: auto; }

/* ---------------------------------------------------------- 15. reattivo */

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: var(--s3) 0;
  }
  .brand { padding: 0 var(--s4) var(--s3); }
  .nav-list { display: flex; overflow-x: auto; padding: 0 var(--s3); gap: var(--s1); }
  .nav-link { border-left: none; border-bottom: 2px solid transparent; white-space: nowrap; padding: var(--s2) var(--s3); }
  .nav-link.active { border-left-color: transparent; border-bottom-color: var(--signal); background: none; }
  .content { padding: var(--s4); }
  .meta-grid { grid-template-columns: 1fr; }
  .meta-grid dt { margin-top: var(--s3); }

  /* Il consumo NON sparisce mai: è il vincolo che governa il progetto.
     A cedere sono le etichette, non il dato. */
  .usage-slot .usage-label { display: none; }
  /* Schermi stretti: resta la metrica che decide, il resto è rumore. */
  .host-indicator .host-key { display: none; }
  .host-indicator .host-metric:not(:first-of-type) { display: none; }
  .page-title { display: none; }
  .current-user { display: none; }
}

/* ---------------------------------------------------- 16. accessibilità */

a:focus-visible,
button:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

::selection { background: var(--signal); color: var(--ink); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--ink); }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 5px; border: 2px solid var(--ink); }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* --------------------------------------------------------- 17. lingua */

/* Selettore di lingua: due sigle, non una bandiera. Le bandiere indicano
   nazioni, non lingue, e la scelta qui è di lingua. */
.lang-switch {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.lang-option {
  padding: 0.2rem 0.45rem;
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  border: none;
  background: var(--panel);
}
.lang-option:hover { color: var(--text); background: var(--panel-raised); }
.lang-option.active { color: var(--ink); background: var(--signal); }

/* ------------------------------------------------------- 18. diagrammi */

/* Contenitore per ogni schema Mermaid renderizzato da mermaid-init.js.
   overflow-x è l'unico motivo per cui esiste: gli schemi sono spesso più
   larghi del pannello, e la pagina intorno non deve MAI scrollare in
   orizzontale — solo il diagramma, dentro il proprio riquadro. */
.mermaid-diagram {
  overflow-x: auto;
  margin: var(--s4) 0;
  padding: var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-raised);
}
.mermaid-diagram .mermaid-svg { display: flex; justify-content: center; }
/* Niente max-width sull'svg: costringerlo a stare nel riquadro lo
   rimpicciolirebbe invece di lasciarlo scorrere, vanificando l'overflow-x
   sopra su qualunque schema davvero largo. */
.mermaid-diagram svg { height: auto; }

/* Fallback quando il render fallisce (mermaid-init.js lo marca esplicito,
   non lo nasconde mai): la sorgente resta leggibile come un blocco di
   codice qualunque. */
.mermaid-diagram--error { background: var(--panel); }
.mermaid-error {
  margin: 0 0 var(--s3);
  padding: var(--s2) var(--s3);
  border-left: 3px solid var(--halt);
  background: var(--halt-soft);
  border-radius: var(--radius-sm);
  font-size: var(--step--1);
}
.mermaid-source {
  display: block;
  overflow-x: auto;
  font-family: var(--font-display);
  font-size: var(--step--1);
  color: var(--text-dim);
  white-space: pre;
}

/* ------------------------------------------------------- 19. controlli */

/* I controlli nativi arrivano disegnati dal sistema operativo: altro
   carattere, altri angoli, altri colori. In un quadro strumenti sono la cosa
   che stona per prima, quindi qui vengono ridisegnati per intero. La forma
   segue la regola del resto: superficie incassata, linea sottile, ambra solo
   dove c'è attività. */

::selection { background: color-mix(in srgb, var(--signal) 35%, transparent); color: var(--text); }

::placeholder { color: var(--text-faint); opacity: 1; }

/* Barre di scorrimento: sottili, dello stesso grigio delle linee. Senza
   questa regola il pannello scuro convive con una barra chiara di sistema. */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: padding-box; }
::-webkit-scrollbar-corner { background: transparent; }

/* Il riempimento automatico del browser dipinge il campo di giallo e cambia
   il colore del testo: si riporta alla superficie del tema. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--ink) inset;
  caret-color: var(--text);
  transition: background-color 100000s ease-in-out 0s;
}

input[type="text"]:hover,
input[type="password"]:hover,
input[type="number"]:hover,
input[type="email"]:hover,
input[type="search"]:hover,
textarea:hover { border-color: var(--text-faint); }

input:disabled,
textarea:disabled,
select:disabled,
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn:focus-visible,
.xselect-button:focus-visible,
summary:focus-visible {
  outline: none;
  border-color: var(--signal);
  box-shadow: var(--edge), 0 0 0 3px var(--signal-soft);
}

/* ------------------------------------------------ casella di spunta */

input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 1.05rem;
  height: 1.05rem;
  margin: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--ink);
  box-shadow: var(--edge);
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}
input[type="checkbox"]:hover { border-color: var(--text-faint); }
input[type="checkbox"]:checked {
  background: var(--signal-soft);
  border-color: color-mix(in srgb, var(--signal) 60%, var(--line));
}
/* Il segno di spunta è disegnato, non un glifo di sistema: due tratti che
   seguono il colore del segnale. */
input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 0.3rem;
  top: 0.12rem;
  width: 0.28rem;
  height: 0.58rem;
  border: solid var(--signal);
  border-width: 0 2px 2px 0;
  transform: rotate(42deg);
}
input[type="checkbox"]:focus-visible {
  outline: none;
  border-color: var(--signal);
  box-shadow: 0 0 0 3px var(--signal-soft);
}

/* ---------------------------------------------------------- ricerca */

input[type="search"] { appearance: none; -webkit-appearance: none; }
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button { appearance: none; -webkit-appearance: none; display: none; }

/* ----------------------------------------------------------- numeri */

/* Le frecce native sono minuscole e cambiano forma da un browser all'altro:
   spente, e sostituite da una coppia di tacche disegnata qui. */
input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { appearance: none; -webkit-appearance: none; margin: 0; }

.xnumber { position: relative; display: block; }
.xnumber input[type="number"] { padding-right: 2.1rem; }
.xnumber-stepper {
  position: absolute;
  top: 1px;
  right: 1px;
  bottom: 1px;
  width: 1.7rem;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  overflow: hidden;
}
.xnumber-step {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  background: var(--panel-raised);
  color: var(--text-dim);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.xnumber-step:hover { background: var(--signal-soft); color: var(--signal); }
.xnumber-step:active { background: color-mix(in srgb, var(--signal) 22%, transparent); }
.xnumber-up { border-bottom: 1px solid var(--line); }
/* Le tacche: triangolini disegnati con i bordi, nessun glifo tipografico. */
.xnumber-step::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
}
.xnumber-up::before { border-bottom: 5px solid currentColor; }
.xnumber-down::before { border-top: 5px solid currentColor; }
.xnumber input[type="number"]:disabled + .xnumber-stepper { opacity: 0.55; pointer-events: none; }

/* ------------------------------------------------------ menu a tendina */

/* Fallback senza JS: il select nativo resta, ma perde la freccia di sistema
   e prende la superficie del tema. */
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 1.05rem) 50%, calc(100% - 0.65rem) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  cursor: pointer;
}

/* Con JS il nativo sparisce dalla vista ma resta nel form: è lui a portare il
   valore al submit, quindi non va né rimosso né disabilitato. */
.xselect { position: relative; width: 100%; }
.xselect-native {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.xselect-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  width: 100%;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--step-0);
  text-align: left;
  cursor: pointer;
  transition: border-color 120ms ease;
}
.xselect-button:hover { border-color: var(--text-faint); }
.xselect.is-open .xselect-button { border-color: var(--signal); }
.xselect-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xselect-placeholder { color: var(--text-faint); }

.xselect-chevron {
  flex: none;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--text-dim);
  transition: transform 140ms ease;
}
.xselect.is-open .xselect-chevron { transform: rotate(180deg); border-top-color: var(--signal); }

.xselect-list {
  position: absolute;
  z-index: 40;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 15rem;
  overflow-y: auto;
  padding: var(--s1);
  background: var(--panel-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--edge), 0 8px 24px rgba(0, 0, 0, 0.35);
}
.xselect.is-up .xselect-list { top: auto; bottom: calc(100% + 4px); }

.xselect-option {
  padding: var(--s2) var(--s3);
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: var(--step--1);
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.xselect-option.is-active { background: var(--panel); color: var(--text); }
.xselect-option[aria-selected="true"] { color: var(--signal); }
.xselect-option[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }

/* -------------------------------------------------- blocchi richiudibili */

details {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-raised);
  padding: var(--s2) var(--s3);
}
details + details { margin-top: var(--s2); }
summary {
  display: flex;
  align-items: center;
  gap: var(--s2);
  list-style: none;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: var(--step--1);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
}
summary::-webkit-details-marker { display: none; }
summary::before {
  content: "";
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid currentColor;
  transition: transform 140ms ease;
}
details[open] > summary { color: var(--text); margin-bottom: var(--s2); }
details[open] > summary::before { transform: rotate(90deg); }

/* ---------------------------------------------------------- tooltip */

/* Il `title` nativo compare in ritardo, con il carattere del sistema e senza
   modo di allinearlo al resto: ui.js lo sposta su data-tip e lo disegna qui. */
.has-tip { cursor: help; }
.xtip {
  position: absolute;
  z-index: 60;
  max-width: 22rem;
  padding: var(--s2) var(--s3);
  background: var(--panel-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--edge), 0 6px 18px rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: var(--step--1);
  line-height: 1.4;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 120ms ease, transform 120ms ease;
}
.xtip.is-visible { opacity: 1; transform: translateY(0); }

/* --------------------------------------------------------- dialoghi */

.xdialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s5);
  background: color-mix(in srgb, var(--ink) 78%, transparent);
  backdrop-filter: blur(2px);
  animation: xfade 140ms ease;
}
body.xdialog-open { overflow: hidden; }

.xdialog {
  width: 100%;
  max-width: 28rem;
  padding: var(--s5);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--edge), 0 18px 48px rgba(0, 0, 0, 0.45);
  animation: xrise 160ms ease;
}
.xdialog-danger { border-color: color-mix(in srgb, var(--halt) 45%, var(--line-strong)); }
.xdialog-title {
  margin: 0 0 var(--s3);
  font-family: var(--font-display);
  font-size: var(--step--1);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-faint);
}
.xdialog-body { margin: 0 0 var(--s5); color: var(--text); }
.xdialog-actions { display: flex; justify-content: flex-end; gap: var(--s2); }

@keyframes xfade { from { opacity: 0; } to { opacity: 1; } }
@keyframes xrise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------ toast */

.xtoast-host {
  position: fixed;
  z-index: 70;
  right: var(--s5);
  bottom: var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  pointer-events: none;
}
.xtoast {
  padding: var(--s3) var(--s4);
  background: var(--panel-raised);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--signal);
  border-radius: var(--radius-sm);
  box-shadow: var(--edge), 0 8px 24px rgba(0, 0, 0, 0.35);
  font-size: var(--step--1);
  animation: xrise 160ms ease;
}
.xtoast-ok { border-left-color: var(--go); }
.xtoast-error { border-left-color: var(--halt); }
.xtoast-out { opacity: 0; transition: opacity 200ms ease; }

@media (prefers-reduced-motion: reduce) {
  .xdialog, .xdialog-backdrop, .xtoast { animation: none; }
  .xselect-chevron, summary::before, .xtip { transition: none; }
}

/* ------------------------------------------------- 20. attività del run */

/* Un run "running" può stare lavorando o essere appeso: il badge di stato non
   distingue i due casi. Questi due componenti mostrano l'unica cosa che li
   separa davvero — da quanto tempo il container non scrive — accanto a cosa
   stava facendo quando ha scritto l'ultima volta. */

.run-activity {
  display: inline-flex;
  align-items: baseline;
  gap: var(--s1);
  max-width: 28ch;
  font-family: var(--font-display);
  font-size: var(--step--1);
}
.run-activity-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.run-activity-age { flex: none; font-size: 0.75rem; }

.run-pulse {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s3);
  margin-bottom: var(--s4);
  padding: var(--s3) var(--s4);
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-left: 3px solid var(--go);
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: var(--step--1);
}
/* Il colore segue la convenzione del resto: verde scrive, ambra tace da un
   po', rosso tace abbastanza da avvicinarsi al kill. */
.run-pulse.is-quiet { border-left-color: var(--signal); }
.run-pulse.is-stalled { border-left-color: var(--halt); }
.run-pulse.is-done { border-left-color: var(--line-strong); }

.run-pulse-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--go);
  box-shadow: 0 0 0 3px var(--go-soft);
  animation: pulse-beat 1.8s ease-in-out infinite;
}
.run-pulse.is-quiet .run-pulse-dot { background: var(--signal); box-shadow: 0 0 0 3px var(--signal-soft); }
.run-pulse.is-stalled .run-pulse-dot { background: var(--halt); box-shadow: 0 0 0 3px var(--halt-soft); }
.run-pulse.is-done .run-pulse-dot { background: var(--text-faint); box-shadow: none; animation: none; }

.run-pulse-activity { color: var(--text); font-weight: 600; }
.run-pulse-silence, .run-pulse-res { font-size: 0.75rem; }
.run-pulse-res { margin-left: auto; }

@keyframes pulse-beat {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@media (prefers-reduced-motion: reduce) {
  .run-pulse-dot { animation: none; }
}

/* ------------------------------------------ 21. piede con la versione */

/* Discreto per costruzione: serve a chi lo cerca dopo un aggiornamento
   automatico, e non deve rubare attenzione a chi sta guardando un run. */
.app-footer {
  padding: 0.75rem 1.5rem 1.25rem;
  color: var(--text-faint);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  cursor: default;
}

/* ------------------------------------------------------- tabelle scorrevoli
 * Tabelle potenzialmente lunghissime (es. tool calls del run): altezza
 * limitata con scrollbar propria e intestazione fissa, invece di allungare
 * la pagina fino a rendere irraggiungibile quello che sta sotto.
 */
.table-scroll {
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.table-scroll .table {
  margin: 0;
}
.table-scroll .table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
  z-index: 1;
}
