/* Gestionale · design token
   Stessa famiglia di "Brain" (brain.helmetcam.eu): nomi e valori in stile shadcn/ui, così i due prodotti si possono unificare.
   Tema scuro di default (come Brain); tema chiaro con <html data-theme="light"> (interruttore in alto, salvato in localStorage).
   La stampa usa sempre il tema chiaro.
   Tre livelli: (1) superfici e testo, (2) semantici del core (vendita / costo / margine, stati) uguali in tutte le edizioni,
   (3) marca della società: solo --brand (lo imposta main.js). Nessun valore di marca dentro app.css. */

/* ---------------------------------------------------------------- tema chiaro (e stampa) */
:root {
  color-scheme: light;

  /* marca della società attiva (logo nella barra), mai usata per vendita/costo/margine */
  --brand: #2457A6;
  --brand-default: #2457A6;            /* marca quando non c'è una società scelta (l'edizione lo cambia) */
  --brand-foreground: #fff;

  /* superfici e testo (nomi shadcn) */
  --background: #f5f6f8;
  --foreground: #101217;
  --foreground-2: #3c404a;              /* testo secondario forte */
  --card: #ffffff;              --card-foreground: var(--foreground);
  --popover: #ffffff;           --popover-foreground: var(--foreground);
  --sidebar: #fbfbfc;           --sidebar-foreground: var(--foreground);
  --muted: #f0f1f4;             --muted-foreground: #5d626d;     /* 5.9:1 sul bianco */
  --secondary: #eceef2;         --secondary-foreground: var(--foreground);
  --accent: #eef1ff;            --accent-foreground: #3651c9;    /* tinta pervinca: selezione, voce attiva */
  --primary: #6d8dff;           --primary-foreground: #0b1220;   /* pervinca, testo scuro sopra (6.6:1) */
  --primary-hover: #5c7ef5;
  --primary-text: #3b5bdb;              /* pervinca come testo e link: 5.6:1 sul bianco */
  --primary-line: #b9c7ff;
  --destructive: #d32f2f;       --destructive-foreground: #fff;
  --success: #2e7d32;
  --warning: #b26a00;
  --border: rgb(16 18 23 / 0.10);
  --input: rgb(16 18 23 / 0.16);
  --input-bg: #ffffff;
  --ring: #6d8dff;
  --ring-soft: rgb(109 141 255 / 0.35);
  --placeholder: #767b86;
  --faint-foreground: #8b909b;          /* solo decorativo o disabilitato */
  --row-hover: #f6f7f9;
  --topbar-glass: rgb(245 246 248 / 0.82);
  --overlay: rgb(10 12 16 / 0.36);

  /* grafici (Brain) */
  --chart-1: #6d8dff; --chart-2: #66bb6a; --chart-3: #ffa726; --chart-4: #90a4ae; --chart-5: #ef5350;

  /* stati di lavoro: testo / fondo, sempre con etichetta.
     active = pervinca · waiting = arancio · done = verde · someday = ardesia · archived = zinco */
  --grey:   #556275;  --grey-bg:   #eef1f5;
  --blue:   #3651c9;  --blue-bg:   #eaefff;
  --green:  #2e7d32;  --green-bg:  #e8f5e9;
  --amber:  #9a5600;  --amber-bg:  #fff3e0;
  --red:    #c62828;  --red-bg:    #ffebee;
  --purple: #7b1fa2;  --purple-bg: #f5e9f8;
  --teal:   #00695c;  --teal-bg:   #e0f2f1;
  --dark:   #ffffff;  --dark-bg:   #52525b;
  --warn-dot: #ffa726;

  /* le tre aree del foglio: vendita · costo · margine (mai confondibili, mai colore di marca) */
  --sale: var(--foreground);
  --cost:   #845400;  --cost-bg:   #fff8ec;  --cost-line:   #f0dcb4;
  --margin: #0d6a4f;  --margin-bg: #eefaf4;  --margin-line: #c4e8d7;

  /* tipografia: Inter se installato (come Brain), altrimenti il font di sistema. Nessun file esterno. */
  --font-sans: "Inter Variable", "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --fs-xs: 12px; --fs-sm: 12.5px; --fs-base: 14px; --fs-md: 15px; --fs-lg: 17px; --fs-xl: 20px; --fs-2xl: 24px;
  --lh: 1.5; --lh-tight: 1.3;

  /* spazi (griglia 4 px), raggi, ombre */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px;
  --radius: 10px;                       /* Brain: .625rem */
  --radius-xs: 4px; --radius-sm: 6px; --radius-md: 8px; --radius-lg: 14px;
  --shadow-xs: 0 1px 2px rgb(16 18 23 / 0.05);
  --shadow-sm: 0 1px 2px rgb(16 18 23 / 0.05), 0 1px 3px rgb(16 18 23 / 0.06);
  --shadow-md: 0 4px 12px -2px rgb(16 18 23 / 0.10), 0 2px 4px -2px rgb(16 18 23 / 0.06);
  --shadow-lg: 0 12px 32px -6px rgb(16 18 23 / 0.18), 0 4px 10px -4px rgb(16 18 23 / 0.08);
  --shadow-xl: 0 24px 56px -12px rgb(16 18 23 / 0.28), 0 8px 20px -8px rgb(16 18 23 / 0.10);

  /* movimento */
  --ease: cubic-bezier(.2, .8, .2, 1);
  --dur-1: 110ms; --dur-2: 180ms; --dur-3: 240ms;

  /* struttura */
  --side: 232px; --top: 52px; --tabs-h: 41px;
  --stick: var(--top);

  /* alias dei nomi precedenti (restano per il markup già scritto) */
  --ink: var(--foreground);
  --line: var(--border);
  --line-strong: var(--input);
  --bg: var(--muted);
  --paper: var(--card);
  --accent-soft: var(--accent);

  /* icone usate dal CSS (maschere: prendono il colore del testo) */
  --i-chevron-down: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  --i-chevron-up: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m18 15-6-6-6 6'/%3E%3C/svg%3E");
  --i-x: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 6 6 18'/%3E%3Cpath d='m6 6 12 12'/%3E%3C/svg%3E");
  --i-more: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Ccircle cx='5' cy='12' r='1.7'/%3E%3Ccircle cx='12' cy='12' r='1.7'/%3E%3Ccircle cx='19' cy='12' r='1.7'/%3E%3C/svg%3E");
  --i-menu: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 6h16M4 12h16M4 18h16'/%3E%3C/svg%3E");
  --i-lock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='16' height='11' x='4' y='11' rx='2'/%3E%3Cpath d='M8 11V7a4 4 0 0 1 8 0v4'/%3E%3C/svg%3E");
  --i-arrow-right: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14'/%3E%3Cpath d='m12 5 7 7-7 7'/%3E%3C/svg%3E");
  --i-arrow-up-right: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 7h10v10'/%3E%3Cpath d='M7 17 17 7'/%3E%3C/svg%3E");
  /* immagini di fondo (non maschere): il colore sta nell'SVG, quindi cambiano col tema */
  --bg-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7080' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  --bg-search: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a7f8c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
}

/* ---------------------------------------------------------------- tema scuro: il default a schermo, valori di Brain */
@media screen {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --background: #101216;
    --foreground: #f4f4f5;
    --foreground-2: #d4d4d8;
    --card: #17191f;
    --popover: #17191f;
    --sidebar: #17191f;
    --muted: #23262e;             --muted-foreground: #a1a1aa;
    --secondary: #23262e;
    --accent: #1c2437;            --accent-foreground: #aec4ff;
    --primary: #6d8dff;           --primary-foreground: #0b1220;
    --primary-hover: #8099ff;
    --primary-text: #8ea6ff;
    --primary-line: #3a4a85;
    --destructive: #ef5350;       --destructive-foreground: #fff;
    --success: #66bb6a;
    --warning: #ffa726;
    --border: rgb(255 255 255 / 0.10);
    --input: rgb(255 255 255 / 0.15);
    --input-bg: rgb(255 255 255 / 0.045);
    --ring: #6d8dff;
    --ring-soft: rgb(109 141 255 / 0.40);
    --placeholder: #8c8c95;
    --faint-foreground: #7c7c85;
    --row-hover: #1d2027;
    --topbar-glass: rgb(16 18 22 / 0.86);   /* Brain: #101216db */
    --overlay: rgb(0 0 0 / 0.6);

    --grey:   #a3b0c2;  --grey-bg:   rgb(148 163 184 / 0.14);
    --blue:   #9db2ff;  --blue-bg:   rgb(109 141 255 / 0.17);
    --green:  #81c784;  --green-bg:  rgb(102 187 106 / 0.15);
    --amber:  #ffb74d;  --amber-bg:  rgb(255 167 38 / 0.15);
    --red:    #f2736f;  --red-bg:    rgb(239 83 80 / 0.16);
    --purple: #d39ce0;  --purple-bg: rgb(171 71 188 / 0.20);
    --teal:   #5cc2b8;  --teal-bg:   rgb(38 166 154 / 0.17);
    --dark:   #e4e4e7;  --dark-bg:   rgb(113 113 122 / 0.34);
    --warn-dot: #ffa726;

    --cost:   #f0c27a;  --cost-bg:   #1f1d1b;  --cost-line:   #3c3325;
    --margin: #7fd4b4;  --margin-bg: #161f1f;  --margin-line: #224039;

    --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.30);
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.35);
    --shadow-md: 0 6px 16px -4px rgb(0 0 0 / 0.55);
    --shadow-lg: 0 16px 36px -8px rgb(0 0 0 / 0.60), 0 0 0 1px rgb(255 255 255 / 0.05);
    --shadow-xl: 0 28px 64px -12px rgb(0 0 0 / 0.70), 0 0 0 1px rgb(255 255 255 / 0.06);

    --bg-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
    --bg-search: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8a93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  }
}

@media (prefers-reduced-motion: reduce) {
  :root { --dur-1: 0ms; --dur-2: 0ms; --dur-3: 0ms; }
}
