/* ========================================================================== *
 * CronDeck — design system
 *
 * Derivato dal sistema HashiCorp: fondo nero, superfici in carbone, hairline
 * traslucide, nessuna ombra. La tipografia è una sola famiglia (Inter, come
 * sostituto documentato di hashicorpSans) con il contrasto di interlinea che
 * regge la gerarchia: stretta sul display (1.17–1.21), rilassata sul corpo
 * (1.50–1.71).
 *
 * Adattamento: nel sistema originale gli accent identificano il prodotto
 * (Terraform viola, Vault giallo...). Qui identificano il MODULO, con la stessa
 * regola di non mescolarli nella stessa viewport:
 *
 *   viola   → scheduler interno (Modulo A)
 *   ciano   → inventario legacy e scanner (Modulo B)
 *   corallo → eventi e alert
 *
 * L'accento di pagina si imposta con data-accent sul <body>.
 *
 * Deroga consapevole: il sistema originale non usa monospace perché è una
 * superficie marketing. Questa è una superficie di prodotto, e comandi,
 * espressioni cron e output di shell devono essere monospazi per essere letti
 * senza ambiguità.
 * ========================================================================== */

/* -------------------------------------------------------------------------- *
 * Font
 * -------------------------------------------------------------------------- */

@font-face {
  font-family: "Inter";
  src: url("../fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* -------------------------------------------------------------------------- *
 * Token
 * -------------------------------------------------------------------------- */

:root {
  /* Superfici */
  --canvas: #000000;
  --surface-1: #15181e;
  --surface-2: #1f232b;
  --surface-3: #3b3d45;
  --hairline: rgba(178, 182, 189, 0.16);
  --hairline-soft: #252830;
  --inverse-canvas: #ffffff;
  --inverse-ink: #000000;

  /* Inchiostro */
  --ink: #ffffff;
  --ink-muted: #b2b6bd;
  --ink-subtle: #656a76;

  /* Accenti di identità */
  --accent-blue: #2b89ff;
  --scheduler: #7b42bc;
  --scheduler-bright: #911ced;
  --legacy: #14c6cb;
  --legacy-deep: #12b6bb;
  --alertish: #f24c53;

  /* Semantica */
  --ok: #00ca8e;
  --warn: #ffcf25;
  --err: #e62b1e;
  --info: #2b89ff;

  /* Accento della pagina corrente: sovrascritto da [data-accent] */
  --accent: var(--scheduler);

  /* Raggi */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-xxl: 24px;
  --r-pill: 9999px;

  /* Spaziature */
  --s-xxs: 4px;
  --s-xs: 8px;
  --s-sm: 12px;
  --s-md: 16px;
  --s-lg: 24px;
  --s-xl: 32px;
  --s-xxl: 48px;

  --nav-h: 64px;
  --content-max: 1440px;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

body[data-accent="legacy"] { --accent: var(--legacy); }
body[data-accent="events"] { --accent: var(--alertish); }
body[data-accent="neutral"] { --accent: var(--ink-muted); }

/* -------------------------------------------------------------------------- *
 * Reset e base
 * -------------------------------------------------------------------------- */

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

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

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.5;
  font-feature-settings: "cv05" 1, "ss03" 1, "tnum" 0;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; }
h1 { font-size: 40px; line-height: 1.19; letter-spacing: -1px; }
h2 { font-size: 28px; line-height: 1.21; letter-spacing: -0.6px; }
h3 { font-size: 22px; line-height: 1.18; letter-spacing: -0.4px; }
h4 { font-size: 18px; line-height: 1.3; letter-spacing: -0.2px; }
p { margin: 0 0 var(--s-md); }
p:last-child { margin-bottom: 0; }

a { color: var(--accent-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

hr {
  border: 0;
  border-top: 1px solid var(--hairline-soft);
  margin: var(--s-lg) 0;
}

code, pre, .mono { font-family: var(--mono); font-feature-settings: "tnum" 1; }

::selection { background: var(--accent); color: #fff; }

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

/* Sostituisce gli stili indicatore che htmx inietterebbe inline
   (disattivati via meta htmx-config, per non allentare la CSP). */
.htmx-indicator { opacity: 0; transition: opacity 160ms ease-in; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }

/* Utility di spaziatura: usate con parsimonia, solo dove un componente
   dedicato sarebbe sovradimensionato. */
.mt-xs { margin-top: var(--s-xs); }
.mt-sm { margin-top: var(--s-sm); }
.mt-md { margin-top: var(--s-md); }
.mt-lg { margin-top: var(--s-lg); }
.mt-xl { margin-top: var(--s-xl); }
.mb-xs { margin-bottom: var(--s-xs); }
.mb-sm { margin-bottom: var(--s-sm); }
.mb-md { margin-bottom: var(--s-md); }
.mb-lg { margin-bottom: var(--s-lg); }

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

/* -------------------------------------------------------------------------- *
 * Tipografia di sistema
 * -------------------------------------------------------------------------- */

.eyebrow {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.23;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--s-xs);
}
.eyebrow--muted { color: var(--ink-subtle); }

.lead { font-size: 18px; line-height: 1.69; color: var(--ink-muted); }
.muted { color: var(--ink-muted); }
.subtle { color: var(--ink-subtle); }
.small { font-size: 14px; line-height: 1.71; }
.caption { font-size: 13px; line-height: 1.38; letter-spacing: 0.2px; color: var(--ink-subtle); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------------------------- *
 * Navigazione
 * -------------------------------------------------------------------------- */

.topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  background: var(--canvas);
  border-bottom: 1px solid var(--hairline-soft);
  display: flex;
  align-items: center;
  gap: var(--s-lg);
  padding: 0 var(--s-lg);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s-xs);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--ink);
}
.brand:hover { text-decoration: none; }
.brand__mark {
  width: 22px; height: 22px;
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--scheduler) 0%, var(--scheduler-bright) 100%);
  display: grid; place-items: center;
  flex: none;
}
.brand__mark svg { display: block; }

.navlinks {
  display: flex;
  align-items: center;
  gap: var(--s-xxs);
  margin-left: var(--s-md);
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.navlinks::-webkit-scrollbar { display: none; }

.navlink {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.29;
  color: var(--ink-muted);
  white-space: nowrap;
}
.navlink:hover { background: var(--surface-1); color: var(--ink); text-decoration: none; }
.navlink[aria-current="page"] { background: var(--surface-2); color: var(--ink); }

.navlink__count {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--r-pill);
  background: var(--err);
  color: #fff;
}

.navright { display: flex; align-items: center; gap: var(--s-xs); flex: none; }

/* -------------------------------------------------------------------------- *
 * Layout
 * -------------------------------------------------------------------------- */

.page {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--s-xl) var(--s-lg) 96px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-lg);
  flex-wrap: wrap;
  margin-bottom: var(--s-xl);
}
.page-head__actions { display: flex; gap: var(--s-xs); flex-wrap: wrap; }

.section { margin-top: var(--s-xxl); }
.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-md);
  margin-bottom: var(--s-md);
  flex-wrap: wrap;
}

.grid { display: grid; gap: var(--s-md); }
/* Senza questo un elemento di griglia usa `min-width: auto` e non scende mai
   sotto la larghezza del proprio contenuto: un comando lungo dentro un blocco
   monospazio sfonderebbe la card invece di far comparire lo scorrimento. */
.grid > *, .stack > * { min-width: 0; }
.grid--kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
/* Due colonne fisse sopra i 900px. Con `auto-fit` su schermi larghi si
   arriverebbe a tre o quattro colonne, e una card di testo lunga diventerebbe
   una colonna stretta e altissima. */
.grid--2 { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) {
  .grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* Per gruppi di card compatte (pannelli dell'editor, riquadri di stato), dove
   riempire la riga è meglio che imporre due colonne. */
.grid--auto { grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }
.grid--form { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--s-md) var(--s-lg); }

.stack { display: flex; flex-direction: column; gap: var(--s-md); }
.row { display: flex; align-items: center; gap: var(--s-xs); flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.row--tight { gap: var(--s-xxs); }
.spacer { flex: 1; }

/* -------------------------------------------------------------------------- *
 * Superfici
 * -------------------------------------------------------------------------- */

.card {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: var(--s-lg);
}
.card--flush { padding: 0; overflow: hidden; }
.card--lift { background: var(--surface-2); }
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-md);
  padding: var(--s-md) var(--s-lg);
  border-bottom: 1px solid var(--hairline-soft);
}
.card__body { padding: var(--s-lg); }
.card__title { font-size: 22px; font-weight: 600; line-height: 1.18; letter-spacing: -0.4px; }

/* Tessera KPI: il numero è il protagonista, l'etichetta è un eyebrow. */
.kpi {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: var(--s-md) var(--s-lg);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.kpi__label {
  font-size: 12px; font-weight: 600; letter-spacing: 0.6px;
  text-transform: uppercase; color: var(--ink-subtle);
}
.kpi__value {
  font-size: 34px; font-weight: 700; line-height: 1.15; letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}
/* Quando il valore è testuale ("3 ore fa") e non numerico, la scala display
   è troppo grande: si scende alla misura headline. */
.kpi__value[data-small] { font-size: 20px; letter-spacing: -0.3px; line-height: 1.35; }
.kpi__hint { font-size: 13px; color: var(--ink-muted); }
.kpi--ok .kpi__value { color: var(--ok); }
.kpi--warn .kpi__value { color: var(--warn); }
.kpi--err .kpi__value { color: var(--err); }
.kpi--accent .kpi__value { color: var(--accent); }

/* Banda di identità del modulo: sostituisce le "product card" cromatiche. */
.identity {
  border-radius: var(--r-lg);
  border: 1px solid var(--hairline);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent) 16%, transparent) 0%, transparent 70%),
    var(--surface-1);
  padding: var(--s-lg);
}

.banner {
  border-radius: var(--r-lg);
  padding: var(--s-md) var(--s-lg);
  border: 1px solid var(--hairline);
  background: var(--surface-1);
  display: flex;
  align-items: flex-start;
  gap: var(--s-sm);
}
.banner__icon { flex: none; margin-top: 7px; }
/* Il testo del banner è un elemento flex: senza `min-width: 0` un percorso
   lungo non si accorcia e sfonda la card che lo contiene. */
.banner > div { min-width: 0; }
.banner .code--inline { max-width: 100%; }
.banner.flash { margin-bottom: var(--s-lg); }
.banner--err { border-color: color-mix(in srgb, var(--err) 45%, transparent); background: color-mix(in srgb, var(--err) 10%, var(--surface-1)); }
.banner--warn { border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: color-mix(in srgb, var(--warn) 8%, var(--surface-1)); }
.banner--ok { border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: color-mix(in srgb, var(--ok) 8%, var(--surface-1)); }
.banner--info { border-color: color-mix(in srgb, var(--info) 40%, transparent); background: color-mix(in srgb, var(--info) 8%, var(--surface-1)); }

/* -------------------------------------------------------------------------- *
 * Bottoni — angoli 8px, mai pillole: lettura da strumento, non da consumer.
 * -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.29;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, opacity 120ms ease;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }

.btn--primary { background: var(--inverse-canvas); color: var(--inverse-ink); }
.btn--primary:hover { background: #e8e8e8; }

.btn--accent { background: var(--accent); color: #fff; }
.btn--accent:hover { background: color-mix(in srgb, var(--accent) 82%, #fff); }

.btn--ghost { background: transparent; border-color: var(--hairline); color: var(--ink); }
.btn--ghost:hover { background: var(--surface-1); }

.btn--danger { background: transparent; border-color: color-mix(in srgb, var(--err) 55%, transparent); color: #ff7a70; }
.btn--danger:hover { background: color-mix(in srgb, var(--err) 14%, transparent); }

.btn--sm { min-height: 32px; padding: 5px 10px; font-size: 13px; }
.btn--icon { padding: 8px; min-width: 36px; min-height: 36px; }
.btn--block { width: 100%; }

.btngroup { display: inline-flex; gap: var(--s-xxs); }

/* -------------------------------------------------------------------------- *
 * Pill, badge, stato
 * -------------------------------------------------------------------------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.38;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.pill--accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--ink-subtle); }
.dot--ok { background: var(--ok); }
.dot--err { background: var(--err); }
.dot--warn { background: var(--warn); }
.dot--info { background: var(--info); }
.dot--run { background: var(--scheduler-bright); animation: pulse 1.6s ease-in-out infinite; }
.dot--off { background: var(--surface-3); }

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 color-mix(in srgb, var(--scheduler-bright) 55%, transparent); }
  50% { opacity: 0.65; box-shadow: 0 0 0 5px transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .dot--run { animation: none; }
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--r-xs);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  background: var(--surface-2);
  color: var(--ink-muted);
  white-space: nowrap;
}
.badge--ok { background: color-mix(in srgb, var(--ok) 16%, var(--surface-1)); color: var(--ok); }
.badge--err { background: color-mix(in srgb, var(--err) 18%, var(--surface-1)); color: #ff8a80; }
.badge--warn { background: color-mix(in srgb, var(--warn) 16%, var(--surface-1)); color: var(--warn); }
.badge--info { background: color-mix(in srgb, var(--info) 16%, var(--surface-1)); color: #86bcff; }
.badge--run { background: color-mix(in srgb, var(--scheduler-bright) 20%, var(--surface-1)); color: #c79bff; }
.badge--off { background: var(--surface-2); color: var(--ink-subtle); }
.badge--legacy { background: color-mix(in srgb, var(--legacy) 16%, var(--surface-1)); color: var(--legacy); }

/* -------------------------------------------------------------------------- *
 * Tabelle — righe su canvas, separatori hairline-soft
 * -------------------------------------------------------------------------- */

/* Rete di sicurezza per schermi molto stretti: sopra i 1100px la tabella è a
   colonne fisse e non sfora mai, quindi lo scorrimento non compare. */
.table-wrap { overflow-x: auto; }

/* `table-layout: fixed` è la scelta centrale: senza, il browser dimensiona le
   colonne sul contenuto e un comando lungo — che nei cron è la norma — allarga
   la tabella oltre la pagina, spingendo fuori vista le colonne di destra e
   facendo comparire la barra di scorrimento orizzontale. Con le larghezze
   dichiarate, il testo che non ci sta viene troncato con i puntini e resta
   leggibile per intero nel tooltip. */
table.data {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.45;
}
table.data th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--ink-subtle);
  padding: 8px 10px;
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
table.data td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--hairline-soft);
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
table.data tbody tr:hover td { background: var(--surface-1); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.right, table.data th.right { text-align: right; }
/* Le celle che devono poter andare a capo (messaggi, note) lo dichiarano. */
table.data td.wrap { white-space: normal; overflow: visible; text-overflow: clip; }

/* Larghezze di colonna. Vanno dichiarate in CSS e non con l'attributo style
   perché la Content-Security-Policy vieta gli stili inline. */
.w-dot { width: 34px; }
.w-2xs { width: 74px; }
.w-xs  { width: 96px; }
.w-sm  { width: 118px; }
.w-md  { width: 146px; }
.w-lg  { width: 172px; }
.w-xl  { width: 210px; }
/* Data completa più tempo relativo: sotto questa misura si tronca. */
.w-2xl { width: 250px; }
/* Due bottoni affiancati: sotto questa misura l'etichetta si tronca. */
.w-actions { width: 176px; }

@media (max-width: 1100px) {
  /* Sotto questa soglia le colonne fisse diventerebbero illeggibili: si torna
     al dimensionamento automatico con scorrimento, dando alla tabella una
     larghezza minima perché le colonne non si schiaccino. */
  table.data { table-layout: auto; min-width: 900px; }
}

.group-head td {
  background: var(--surface-1) !important;
  border-top: 1px solid var(--hairline);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding: 8px var(--s-sm);
}

/* Nome e comando impilati dentro una cella a larghezza fissa: entrambi devono
   troncare per conto proprio, altrimenti il più lungo dei due allarga la cella. */
.jobname { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.jobname > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.jobname a { color: var(--ink); font-weight: 600; font-size: 13.5px; }
.jobname a:hover { color: var(--accent-blue); }
.jobname__meta { font-size: 11.5px; line-height: 1.4; color: var(--ink-subtle); font-family: var(--mono); }

/* -------------------------------------------------------------------------- *
 * Form
 * -------------------------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field--wide { grid-column: 1 / -1; }

label, .label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
  letter-spacing: 0.2px;
}

input[type="text"], input[type="password"], input[type="number"],
input[type="email"], input[type="search"], select, textarea {
  width: 100%;
  padding: 10px 14px;
  min-height: 42px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.5;
}
input::placeholder, textarea::placeholder { color: var(--ink-subtle); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 1px var(--accent-blue);
}
input:disabled, select:disabled, textarea:disabled { opacity: 0.5; cursor: not-allowed; }
textarea { resize: vertical; min-height: 92px; }
textarea.mono, input.mono { font-family: var(--mono); font-size: 14px; }

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23656a76' d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.hint { font-size: 12px; line-height: 1.5; color: var(--ink-subtle); }
.error-text { font-size: 13px; color: #ff8a80; }

.check { display: flex; align-items: flex-start; gap: var(--s-xs); cursor: pointer; }
.check input[type="checkbox"], .check input[type="radio"] {
  width: 18px; height: 18px; margin: 2px 0 0; flex: none;
  accent-color: var(--accent);
}
/* Etichetta e didascalia sono due span dentro lo stesso contenitore: senza
   `display: block` la seconda proseguirebbe sulla riga della prima. */
.check__text { display: block; font-size: 14px; font-weight: 500; color: var(--ink); }
.check__hint { display: block; margin-top: 3px; font-size: 12px; line-height: 1.5; color: var(--ink-subtle); }
.check > span:not([class]) { min-width: 0; }

fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend {
  padding: 0 0 var(--s-xs);
  font-size: 12px; font-weight: 600; letter-spacing: 0.6px;
  text-transform: uppercase; color: var(--accent);
}

.form-actions {
  display: flex;
  gap: var(--s-xs);
  align-items: center;
  padding-top: var(--s-lg);
  margin-top: var(--s-lg);
  border-top: 1px solid var(--hairline-soft);
}

.filters {
  display: flex;
  gap: var(--s-xs);
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: var(--s-md);
}
.filters input[type="search"] { min-width: 240px; flex: 1; max-width: 420px; }
.filters select { width: auto; min-width: 150px; }

/* -------------------------------------------------------------------------- *
 * Codice, output, diff
 * -------------------------------------------------------------------------- */

.code {
  display: block;
  background: var(--canvas);
  border: 1px solid var(--hairline-soft);
  border-radius: var(--r-md);
  padding: var(--s-sm) var(--s-md);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-muted);
  overflow-x: auto;
  white-space: pre;
}
.code--inline {
  display: inline-block;
  padding: 1px 6px;
  font-size: 12.5px;
  border-radius: var(--r-xs);
  color: var(--ink-muted);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.output {
  background: var(--canvas);
  border: 1px solid var(--hairline-soft);
  border-radius: var(--r-md);
  padding: var(--s-md);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-muted);
  max-height: 460px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}
.output--err { color: #ffb3ad; border-color: color-mix(in srgb, var(--err) 30%, transparent); }
.output:empty::after { content: "(nessun output)"; color: var(--ink-subtle); font-style: italic; }

.diff {
  background: var(--canvas);
  border: 1px solid var(--hairline-soft);
  border-radius: var(--r-md);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  overflow-x: auto;
  margin: 0;
  padding: var(--s-sm) 0;
}
.diff .l { display: block; padding: 0 var(--s-md); white-space: pre; }
.diff .l--add { background: color-mix(in srgb, var(--ok) 14%, transparent); color: #7ef0c8; }
.diff .l--del { background: color-mix(in srgb, var(--err) 14%, transparent); color: #ff9d95; }
.diff .l--hunk { color: var(--ink-subtle); background: var(--surface-1); }
.diff .l--ctx { color: var(--ink-subtle); }

/* -------------------------------------------------------------------------- *
 * Timeline eventi
 * -------------------------------------------------------------------------- */

.timeline { display: flex; flex-direction: column; }

.tl {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: var(--s-md);
  padding: var(--s-md) 0;
  border-bottom: 1px solid var(--hairline-soft);
}
.tl:last-child { border-bottom: 0; }
.tl__rail { display: flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 5px; }
.tl__line { flex: 1; width: 1px; background: var(--hairline-soft); min-height: 8px; }
.tl__body { min-width: 0; }
.tl__title { font-size: 15px; font-weight: 600; line-height: 1.35; }
.tl__meta { font-size: 12px; color: var(--ink-subtle); margin-top: 2px; }
.tl__msg {
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-muted);
  margin-top: var(--s-xs);
  white-space: pre-wrap;
  word-break: break-word;
}
.tl--ack { opacity: 0.55; }

/* -------------------------------------------------------------------------- *
 * Grafici
 * -------------------------------------------------------------------------- */

.chart { position: relative; height: 260px; }
.chart--short { height: 190px; }
.chart canvas { display: block; }

/* -------------------------------------------------------------------------- *
 * Stati vuoti, paginazione, misc
 * -------------------------------------------------------------------------- */

.empty {
  text-align: center;
  padding: var(--s-xxl) var(--s-lg);
  color: var(--ink-subtle);
  border: 1px dashed var(--hairline);
  border-radius: var(--r-lg);
}
.empty__title { font-size: 18px; font-weight: 600; color: var(--ink-muted); margin-bottom: var(--s-xxs); }

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-md);
  padding-top: var(--s-md);
  margin-top: var(--s-md);
  border-top: 1px solid var(--hairline-soft);
  font-size: 13px;
  color: var(--ink-subtle);
}

.preview-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
/* Riga singola: nel pannello dell'editor la colonna è stretta, e un ritorno a
   capo che spezza data e ora rende l'elenco illeggibile. */
.preview-list li {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-muted);
  display: flex;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.preview-list li::before { content: "→"; color: var(--accent); flex: none; }

.dl { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: var(--s-xs) var(--s-md); margin: 0; }
.dl dt { font-size: 13px; color: var(--ink-subtle); }
.dl dd { margin: 0; font-size: 14px; min-width: 0; word-break: break-word; }

/* -------------------------------------------------------------------------- *
 * Login
 * -------------------------------------------------------------------------- */

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--s-lg);
  background:
    radial-gradient(1000px 500px at 50% -10%, color-mix(in srgb, var(--scheduler) 22%, transparent), transparent 70%),
    var(--canvas);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xl);
  padding: var(--s-xl);
}
.auth-card__brand {
  display: flex; align-items: center; gap: var(--s-xs);
  font-size: 20px; font-weight: 700; letter-spacing: -0.5px;
  margin-bottom: var(--s-lg);
}
.auth-card h1 { font-size: 24px; letter-spacing: -0.5px; margin-bottom: var(--s-xxs); }

.otp-input {
  font-family: var(--mono);
  font-size: 26px;
  letter-spacing: 10px;
  text-align: center;
  padding: 12px;
}

/* -------------------------------------------------------------------------- *
 * Responsive
 * -------------------------------------------------------------------------- */

@media (max-width: 1024px) {
  h1 { font-size: 32px; letter-spacing: -0.8px; }
  .page { padding: var(--s-lg) var(--s-md) 64px; }
  table.data th { position: static; }
}

@media (max-width: 768px) {
  .topnav {
    height: auto;
    flex-wrap: wrap;
    padding: var(--s-sm) var(--s-md);
    gap: var(--s-sm);
    position: static;
  }
  .navlinks { order: 3; width: 100%; margin-left: 0; }
  h1 { font-size: 28px; }
  .kpi__value { font-size: 28px; }
  .dl { grid-template-columns: 1fr; gap: 2px var(--s-md); }
  .dl dd { margin-bottom: var(--s-xs); }
  .filters input[type="search"] { max-width: none; }
}

/* Griglia KPI annidata dentro una card: colonne più strette, il contenitore
   è già ristretto e i valori sono numeri brevi. */
.grid--kpi-compact { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.grid--kpi-compact .kpi { padding: var(--s-sm); }
.grid--kpi-compact .kpi__value { font-size: 24px; }


/* Densità dentro le tabelle: gli stessi componenti usati altrove qui devono
   stare in una riga alta 30px senza farla crescere. */
table.data .badge { padding: 1px 6px; font-size: 11px; }
table.data .code--inline { padding: 0 5px; font-size: 11.5px; }
table.data .btn--sm { min-height: 26px; padding: 3px 8px; font-size: 12px; }
table.data .dot { width: 7px; height: 7px; }
table.data .subtle { font-size: 11.5px; }
.group-head td { padding: 6px 10px; font-size: 11px; }


/* -------------------------------------------------------------------------- *
 * QR code del secondo fattore
 * -------------------------------------------------------------------------- */

/* Fondo bianco anche nell'interfaccia scura: molti lettori faticano con i QR
   invertiti, e un codice che non si scansiona rende inutile tutto il passaggio. */
.qr-panel {
  background: #fff;
  padding: 10px;
  border-radius: var(--r-md);
  display: inline-block;
  flex: none;
  line-height: 0;
}
.qr { width: 176px; height: 176px; display: block; }

/* -------------------------------------------------------------------------- *
 * Traduzione in parole di un'espressione cron
 * -------------------------------------------------------------------------- */

/* È la cosa che si legge per prima quando si scrive o si importa una
   schedulazione: la sintassi resta sotto, come conferma. */
.cronsay {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  padding: var(--s-sm) var(--s-md);
}
.cronsay__text {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.2px;
  color: var(--ink);
  margin: 0 0 var(--s-sm);
}

/* -------------------------------------------------------------------------- *
 * Esploratore dei file del server
 * -------------------------------------------------------------------------- */

.browser {
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  overflow: hidden;
}
.browser__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-xs);
  padding: 7px var(--s-sm);
  border-bottom: 1px solid var(--hairline-soft);
  background: var(--surface-1);
}
.browser__path {
  font-size: 11.5px;
  color: var(--ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: rtl;        /* con un percorso lungo conta la fine, non l'inizio */
  text-align: left;
}

.browser__list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
}
.browser__row {
  display: flex;
  align-items: center;
  gap: var(--s-xs);
  width: 100%;
  padding: 5px var(--s-sm);
  background: transparent;
  border: 0;
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
}
.browser__row:hover { background: var(--surface-1); color: var(--ink); }
.browser__row--script { color: var(--ink); }
.browser__icon { flex: none; width: 12px; color: var(--ink-subtle); }
.browser__icon--dir { color: var(--accent); }
.browser__row--script .browser__icon { color: var(--ok); }
.browser__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.browser__size { flex: none; font-size: 11px; color: var(--ink-subtle); }
.browser__empty { padding: var(--s-sm); font-size: 13px; color: var(--ink-subtle); }
