/* Variabili (colori, raggi, ombre), base, login, struttura dell'app. */
:root {
  /* Neutri senza tinta, come il sito di riferimento (thecolorsofmotion.com):
     il colore resta ai dati (verde, rosso, ambra, blu). */
  --bg: #FAFAFA;
  --surface: #FFFFFF;
  --surface2: #F5F5F5;
  --border: #E5E5E5;
  --text: #0A0A0A;
  --text2: #636363;
  --accent: #1D4ED8;
  --accent-light: #EFF4FF;
  --green: #166534;
  --green-light: #F0FDF4;
  --red: #B91C1C;
  --red-light: #FEF2F2;
  --amber: #92400E;
  --amber-light: #FFFBEB;
  --purple: #7C3AED;
  --purple-light: #F5F3FF;
  --radius: 12px;             /* schede, finestre */
  --radius-sm: 8px;           /* pulsanti, campi, avvisi */
  --radius-xs: 6px;           /* voci di menu, piccoli controlli */
  --shadow: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
  /* Pulsanti pieni e selezioni attive: quasi nero con testo chiaro. */
  --primary: #171717;
  --on-primary: #FAFAFA;
  --ring: #0A0A0A;            /* contorno del fuoco da tastiera */
  --ring-soft: rgba(10,10,10,0.08);
  --scroll: #D4D4D4;
  --scroll-hover: #A3A3A3;
  /* Tinte usate nelle pagine (prima scritte a mano nei singoli elementi). */
  --accent-fill: #1D4ED8;      /* sfondo dei pulsanti pieni, con testo bianco */
  --accent-border: #BFDBFE;
  --info-text: #1E40AF;
  --green-border: #BBF7D0;
  --red-border: #FECACA;
  --red-strong: #991B1B;
  --amber-border: #FDE68A;
  --purple-strong: #5B21B6;
  --purple-border: #DDD6FE;
  --teal: #0E7490;
  --teal-light: #CFFAFE;
  /* Grafici (js/core/grafici.js): colori verificati per il daltonismo. */
  --g-entrate: #2A78D6;
  --g-uscite: #EB6834;
  --g-prev: #1BAF7A;
  --g-negativo: #E34948;
  --g-griglia: #EDEDED;
  --g-asse: #C4C4C4;
  --g-tenue: 38%;            /* quanto colore resta nelle parti "previste" */
  color-scheme: light;
}

/* Tema scuro: stessi nomi, valori per lo sfondo scuro. Vale con "Scuro" scelto
   nel pulsante 🌓, oppure con "Automatico" se il dispositivo è in modalità scura
   (js/core/tema.js imposta data-theme su <html>). Testi e sfondi verificati con
   il controllo di contrasto WCAG AA. */
:root[data-theme="dark"] {
  --bg: #0B0B0C;
  --surface: #161618;
  --surface2: #1F1F22;
  --border: #303035;
  --text: #FAFAFA;
  --text2: #A1A1AA;
  --primary: #FAFAFA;
  --on-primary: #171717;
  --ring: #D4D4D4;
  --ring-soft: rgba(250,250,250,0.10);
  --scroll: #3F3F46;
  --scroll-hover: #5A5A63;
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.6), 0 4px 6px -4px rgba(0,0,0,0.5);
  --accent: #7EA7DD;
  --accent-light: #272D38;
  --accent-fill: #2563EB;
  --accent-border: #3A495D;
  --info-text: #ADC8EB;
  --green: #6DBA94;
  --green-light: #24302C;
  --green-border: #344F43;
  --red: #DD8178;
  --red-light: #362727;
  --red-border: #5C3B3A;
  --red-strong: #F0AEA8;
  --amber: #DAB262;
  --amber-light: #352F24;
  --amber-border: #5B4D32;
  --purple: #AE9DDD;
  --purple-light: #2E2C38;
  --purple-strong: #CCC0ED;
  --purple-border: #4B455D;
  --g-entrate: #3987E5;
  --g-uscite: #D95926;
  --g-prev: #199E70;
  --g-negativo: #E66767;
  --g-griglia: #26262A;
  --g-asse: #45454C;
  --g-tenue: 62%;
  --teal: #64B7C4;
  --teal-light: #223034;
  --shadow: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.5), 0 2px 4px -2px rgba(0,0,0,0.4);
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Geist', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; min-height: 100vh; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
* { -webkit-tap-highlight-color: transparent; }

/* --- LOGIN --- */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.login-card { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-md); padding: 2rem 1.5rem; width: 100%; max-width: 400px; }
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 2rem; }
.login-logo-icon { width: 44px; height: 44px; background: var(--accent-fill); border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.login-logo-icon svg { width: 24px; height: 24px; fill: white; }
.login-logo h1 { font-size: 1.25rem; font-weight: 700; color: var(--text); }
.login-logo p { font-size: 12px; color: var(--text2); }
.login-card h2 { font-size: 1.4rem; font-weight: 700; margin-bottom: 0.4rem; }
.login-card p.sub { color: var(--text2); font-size: 14px; margin-bottom: 1.5rem; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 13px; font-weight: 500; color: var(--text2); margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; background: var(--surface); color: var(--text); outline: none; transition: border-color .15s; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 20px; border-radius: var(--radius-sm); border: none; cursor: pointer; font-size: 14px; font-weight: 500; transition: all .15s; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.btn-primary { background: var(--accent-fill); color: white; width: 100%; }
.btn-primary:hover { background: var(--accent-fill); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--red-light); color: var(--red); border: 1px solid var(--red-border); }
.btn-danger:hover { background: var(--red-border); }
.btn-success { background: var(--green-light); color: var(--green); border: 1px solid var(--green-border); }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* --- APP SHELL --- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; transition: transform .25s; }
.sidebar-logo { padding: 1.25rem 1rem; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); }
.sidebar-logo .icon { width: 36px; height: 36px; background: var(--accent-fill); border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.sidebar-logo .icon svg { width: 20px; height: 20px; fill: white; }
.sidebar-logo .label { font-weight: 700; font-size: 15px; }
.sidebar-logo .sub { font-size: 11px; color: var(--text2); }
nav { flex: 1; padding: 0.75rem 0; overflow-y: auto; }
nav .section-label { padding: 0.5rem 1rem 0.25rem; font-size: 11px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .05em; }
nav a { display: flex; align-items: center; gap: 10px; padding: 8px 1rem; font-size: 14px; color: var(--text2); cursor: pointer; border-radius: 0; transition: all .12s; margin: 1px 0; text-decoration: none; }
nav a:hover { background: var(--surface2); color: var(--text); }
nav a.active { background: var(--accent-light); color: var(--accent); font-weight: 500; }
nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-user { padding: 1rem; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.user-info { flex: 1; min-width: 0; }
.user-info .name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info .role { font-size: 11px; color: var(--text2); }
.logout-btn { background: none; border: none; cursor: pointer; color: var(--text2); padding: 4px; border-radius: 4px; }
.logout-btn:hover { color: var(--red); }
.main { flex: 1; margin-left: 240px; min-height: 100vh; overflow-x: auto; }
.topbar { display: none; }
.page { padding: 1.5rem 2rem; max-width: 1400px; }
.page.page-full-width { max-width: none; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; flex-wrap: wrap; gap: .75rem; }
.page-title { font-size: 1.4rem; font-weight: 700; }
.page-sub { font-size: 14px; color: var(--text2); margin-top: 2px; }

