/* ============================================================
   Sistema di interfaccia — token
   Unica fonte di verità per colore, tipografia, spazio e forma.
   Regole:
     · nessun valore letterale nei componenti o nelle pagine: sempre var(--…)
     · il tenant può cambiare solo --brand e --brand-2
     · i colori di stato non si personalizzano mai
   ============================================================ */

:root {
  /* Marchio del cliente: sovrascritto a runtime dalla tabella branding.
     Tutto il resto è derivato, così un cliente non può rendersi illeggibile. */
  --brand: #3B82F6;
  --brand-2: #22D3EE;
  --brand-grad: linear-gradient(140deg, var(--brand), var(--brand-2));
  --brand-soft: color-mix(in srgb, var(--brand) 16%, transparent);
  --brand-edge: color-mix(in srgb, var(--brand) 45%, transparent);

  /* Tipografia: una sola famiglia, pesi e crenatura fanno la gerarchia. */
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --t-micro: 11px;
  --t-meta: 12.5px;
  --t-body: 13.5px;
  --t-strong: 15px;
  --t-title: 18px;
  --t-head: 25px;
  --t-figure: 29px;
  --t-hero: 38px;
  --track-tight: -0.02em;
  --track-figure: -0.025em;
  --leading-body: 1.55;

  /* Spazio: scala a 4. Non esistono margini fuori scala. */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 26px; --s7: 34px; --s8: 48px;

  /* Forma */
  --r-xs: 5px; --r-sm: 9px; --r-md: 13px; --r-lg: 18px; --r-pill: 999px;
  --rail-w: 218px;
  --row-h: 46px;          /* densità ufficio */
  --row-h-touch: 62px;    /* densità cantiere: tablet, con i guanti */
  --page-max: 1320px;

  /* Movimento: solo in risposta a un'azione */
  --ease: cubic-bezier(.3, .7, .4, 1);
  --fast: .13s;
  --slow: .24s;

  --z-rail: 10; --z-top: 20; --z-overlay: 40; --z-toast: 50;
}

/* ── Tema scuro: pannelli, apertura, campo ─────────────────── */
[data-theme="scuro"] {
  --bg: #080D16;
  --shell: #0C1420;
  --surface: #111C2C;
  --surface-2: #16223A;
  --line: #1E2C42;
  --line-soft: #172236;
  --ink: #E8EFF8;
  --ink-soft: #8CA2BC;
  --ink-faint: #5F748F;
  --on-brand: #FFFFFF;
  --pos: #34D399;
  --warn: #FBBF24;
  --neg: #FB7185;
  --info: #60A5FA;
  --wash: linear-gradient(160deg, rgba(255,255,255,.055), rgba(255,255,255,0) 62%);
  --shadow: 0 1px 0 rgba(255,255,255,.04) inset;
  --shadow-lift: 0 18px 40px rgba(0,0,0,.45);
  color-scheme: dark;
}

/* ── Tema chiaro: inserimento dati, otto ore al giorno ─────── */
[data-theme="chiaro"] {
  --bg: #EEF2F7;
  --shell: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F5F8FB;
  --line: #DCE3EC;
  --line-soft: #E7ECF3;
  --ink: #101A28;
  --ink-soft: #5A6B80;
  --ink-faint: #8494A6;
  --on-brand: #FFFFFF;
  --pos: #15803D;
  --warn: #A16207;
  --neg: #BE2F3B;
  --info: #1D4ED8;
  --wash: linear-gradient(160deg, rgba(15,26,40,.035), rgba(15,26,40,0) 62%);
  --shadow: 0 1px 2px rgba(16,26,40,.06);
  --shadow-lift: 0 18px 40px rgba(16,26,40,.14);
  color-scheme: light;
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--t-body);
  line-height: var(--leading-body);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; letter-spacing: var(--track-tight); line-height: 1.25; }
h1 { font-size: var(--t-head); font-weight: 700; }
h2 { font-size: var(--t-strong); font-weight: 600; }
h3 { font-size: var(--t-body); font-weight: 600; }
a { color: var(--brand); }
[data-theme="chiaro"] a { color: color-mix(in srgb, var(--brand) 78%, #000); }
:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; border-radius: var(--r-xs); }
::selection { background: var(--brand-soft); }

/* Cifre: sempre a larghezza fissa, altrimenti le colonne ballano */
.num, td.num, th.num, .kpi .v, .figure { font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
