@import url('/vendor/fonts/fonts.css');

/* =====================================================
   CORE — main.css
   Default: light minimal (ispirato a /operatore)
   Dark mode: :root.dark
   ===================================================== */

:root {
  /* Sfondo e superfici */
  --bg:        #f9fafb;
  --surface:   #ffffff;
  --surface2:  #f3f4f6;
  --surface3:  #e5e7eb;

  /* Bordi */
  --border:       #e5e7eb;
  --border-hover: #9ca3af;

  /* Testo */
  --text:   #111827;
  --muted:  #9ca3af;
  --muted2: #6b7280;

  /* Accento principale = charcoal (come operatore) */
  --accent:      #111827;
  --accent-glow: rgba(17,24,39,0.06);

  /* Colori semantici */
  --accent2: #16a34a;
  --accent3: #dc2626;
  --accent4: #d97706;
  --green:   #16a34a;
  --red:     #dc2626;
  --yellow:  #d97706;
  --blue:    #2563eb;

  /* Colori bg semantici (soft) */
  --green-bg:  #f0fdf4;
  --red-bg:    #fef2f2;
  --yellow-bg: #fffbeb;
  --blue-bg:   #eff6ff;

  /* Geometria */
  --radius:    10px;
  --radius-sm: 6px;
  --radius-lg: 16px;

  /* Ombre */
  --shadow:    0 8px 24px rgba(0,0,0,0.08);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);

  /* Transizione */
  --transition: all 0.15s ease;

  /* Layout */
  --sidebar-w: 210px;
  --topbar-h:  56px;
}

/* ---- DARK MODE ---- */
:root.dark {
  --bg:        #080810;
  --surface:   #10101a;
  --surface2:  #16162a;
  --surface3:  #1e1e32;

  --border:       rgba(255,255,255,0.07);
  --border-hover: rgba(124,106,255,0.4);

  --text:   #f0f0f8;
  --muted:  #5a5a78;
  --muted2: #8080a0;

  --accent:      #7c6aff;
  --accent-glow: rgba(124,106,255,0.15);

  --accent2: #00e5c0;
  --accent3: #ff6b6b;
  --accent4: #ffd166;
  --green:   #00e5c0;
  --red:     #ff6b6b;
  --yellow:  #ffd166;
  --blue:    #60a5fa;

  --green-bg:  rgba(0,229,192,0.08);
  --red-bg:    rgba(255,107,107,0.08);
  --yellow-bg: rgba(255,209,102,0.08);
  --blue-bg:   rgba(96,165,250,0.08);

  --shadow:    0 24px 80px rgba(0,0,0,0.5);
  --shadow-sm: 0 4px 20px rgba(0,0,0,0.3);
}

/* Dark mode: ripristina Bebas Neue per logo e KPI */
:root.dark .sidebar-logo-text {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 3px;
}

:root.dark .kpi-val {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 32px;
  font-weight: 400;
  letter-spacing: 1px;
}

/* =====================================================
   RESET & BASE
   ===================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  height: 100%;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ---- TIPOGRAFIA ---- */
.font-title {
  font-family: 'Bebas Neue', sans-serif;
  letter-spacing: 2px;
}

.label-xs {
  font-size: 10px;
  letter-spacing: 0.6px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
}

/* =====================================================
   LAYOUT
   ===================================================== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding-top: var(--topbar-h);
  min-height: 100vh;
  background: var(--bg);
  transition: margin-left 0.22s ease;
}

.page-container {
  padding: 28px 32px;
  max-width: 1600px;
}

/* =====================================================
   SIDEBAR
   ===================================================== */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  position: fixed;
  left: 0; top: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.22s ease;
}

.sidebar-logo {
  padding: 18px 20px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}

.sidebar-logo-mark {
  width: 28px;
  height: 28px;
  background: var(--gray-900, #111827);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

:root.dark .sidebar-logo-mark {
  background: var(--accent);
}

.sidebar-logo-text {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
  line-height: 1;
}

.sidebar-logo-sub {
  font-size: 9px;
  letter-spacing: 0.5px;
  color: var(--muted);
  text-transform: uppercase;
  margin-top: 1px;
}

.sidebar-section {
  padding: 14px 0 4px;
}

.sidebar-section-label {
  font-size: 9px;
  letter-spacing: 0.8px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 16px;
  margin-bottom: 4px;
}

.sidebar-nav {
  list-style: none;
  padding: 0 8px;
}

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--muted2);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
  position: relative;
}

.sidebar-nav li a:hover {
  color: var(--text);
  background: var(--surface2);
}

.sidebar-nav li a.active {
  color: var(--text);
  background: var(--surface2);
  font-weight: 600;
}

:root.dark .sidebar-nav li a.active {
  background: var(--accent-glow);
  border-left: 2px solid var(--accent);
  padding-left: 8px;
}

.sidebar-nav li a .nav-icon { opacity: 0.6; }
.sidebar-nav li a:hover .nav-icon,
.sidebar-nav li a.active .nav-icon { opacity: 1; }

.sidebar-bottom {
  margin-top: auto;
  padding: 10px 10px 14px;
  border-top: 1px solid var(--border);
}

.company-badge {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  margin-bottom: 8px;
}

.company-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.company-badge-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.company-badge-type {
  font-size: 10px;
  color: var(--muted);
}

.btn-logout {
  width: 100%;
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted2);
  font-size: 12px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: var(--transition);
}

.btn-logout:hover {
  background: var(--red-bg);
  border-color: var(--red);
  color: var(--red);
}

/* =====================================================
   SIDEBAR COLLAPSE
   ===================================================== */
.sidebar-toggle {
  position: absolute;
  top: 14px;
  right: 10px;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
  z-index: 1;
}
.sidebar-toggle:hover { background: var(--surface3, var(--surface2)); color: var(--text); }

.sidebar.collapsed { width: 52px; }
.sidebar.collapsed .sidebar-logo { padding: 18px 12px 16px; justify-content: center; }
.sidebar.collapsed .sidebar-logo-text,
.sidebar.collapsed .sidebar-logo-sub,
.sidebar.collapsed .sidebar-section-label,
.sidebar.collapsed .company-badge-name,
.sidebar.collapsed .company-badge-type,
.sidebar.collapsed .company-chevron,
.sidebar.collapsed .btn-logout span { display: none; }
.sidebar.collapsed .sidebar-toggle { right: 0; left: 50%; transform: translateX(-50%); position: absolute; top: 14px; }
.sidebar.collapsed .sidebar-nav li a { justify-content: center; padding: 8px; gap: 0; }
.sidebar.collapsed .sidebar-nav li a .nav-icon { opacity: 0.7; }
.sidebar.collapsed .sidebar-section { padding: 10px 0 2px; }
.sidebar.collapsed .sidebar-bottom { padding: 8px 6px; }
.sidebar.collapsed .company-badge { justify-content: center; padding: 8px; }
.sidebar.collapsed .company-badge .company-dot { margin: 0; }
.sidebar.collapsed .btn-logout { justify-content: center; padding: 7px; }

/* Tooltip in modalità collapsed */
.sidebar.collapsed .sidebar-nav li { position: relative; }
.sidebar.collapsed .sidebar-nav li a::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%; transform: translateY(-50%);
  background: var(--gray-900, #111827);
  color: #fff;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 200;
}
.sidebar.collapsed .sidebar-nav li a:hover::after { opacity: 1; }

/* Company switcher popup */
.company-switcher-popup {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 8px; right: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  z-index: 200;
  overflow: hidden;
  display: none;
}
.company-switcher-popup.open { display: block; }
.company-switcher-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  transition: var(--transition);
  text-decoration: none;
}
.company-switcher-item:hover { background: var(--surface2); }
.company-switcher-item.active { font-weight: 600; color: var(--accent); }
.company-switcher-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  padding: 8px 12px 4px;
}

/* =====================================================
   TOPBAR
   ===================================================== */
.topbar {
  height: var(--topbar-h);
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  z-index: 90;
  transition: left 0.22s ease;
}

.topbar-company {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text);
  line-height: 1;
}

:root.dark .topbar-company {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 20px;
  letter-spacing: 2px;
}

.topbar-date {
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}

.topbar-spacer { flex: 1; }

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Year selector */
.year-selector {
  display: flex;
  align-items: center;
  gap: 4px;
}

.year-btn {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted2);
  font-size: 12px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.year-btn:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.year-btn.active {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
}

.year-btn-current { }

/* Dropdown anni precedenti */
.year-past-wrap {
  position: relative;
}

.year-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 300;
  min-width: 80px;
  overflow: hidden;
}

.year-past-wrap.open .year-dropdown { display: block; }

.year-dropdown-item {
  display: block;
  width: 100%;
  padding: 8px 14px;
  background: none;
  border: none;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
}

.year-dropdown-item:hover { background: var(--surface2); }
.year-dropdown-item.active { color: var(--accent); font-weight: 700; }

/* AI Alert button */
.ai-alert-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted2);
  font-size: 12px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: var(--transition);
}

.ai-alert-btn:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--surface2);
}

:root.dark .ai-alert-btn {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--accent);
}

:root.dark .ai-alert-btn:hover {
  background: var(--accent);
  color: #fff;
}

.ai-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.7); }
}

/* Toggle personalizza */
.toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted2);
  font-size: 12px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: var(--transition);
}

.toggle-btn:hover, .toggle-btn.active {
  border-color: var(--text);
  color: var(--text);
  background: var(--surface2);
}

/* Theme toggle */
.theme-toggle {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted2);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.theme-toggle:hover {
  border-color: var(--text);
  color: var(--text);
  background: var(--surface2);
}

/* =====================================================
   CARDS
   ===================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  transition: var(--transition);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow);
}

.card-accent-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}

/* ---- KPI CARDS ---- */
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px 14px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  cursor: default;
  box-shadow: var(--shadow-sm);
}

.kpi-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow);
}

.kpi-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
}

.kpi-emoji { font-size: 20px; line-height: 1; }

.kpi-delta {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
}

.kpi-delta.pos { background: var(--green-bg); color: var(--green); }
.kpi-delta.neg { background: var(--red-bg); color: var(--red); }
.kpi-delta.neu { background: var(--surface2); color: var(--muted); }

.kpi-label {
  font-size: 10px;
  letter-spacing: 0.5px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.kpi-val {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1;
  color: var(--text);
}

.kpi-sub { font-size: 11px; color: var(--muted); margin-top: 4px; }

.kpi-sparkline {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 22px;
  margin-top: 10px;
}

.kpi-spark-bar {
  flex: 1;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.2;
  min-height: 3px;
  transition: var(--transition);
}

.kpi-card:hover .kpi-spark-bar { opacity: 0.5; }

/* =====================================================
   BUTTONS
   ===================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
}

.btn-primary:hover {
  opacity: 0.85;
}

:root.dark .btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

:root.dark .btn-primary:hover {
  background: #6b5ae0;
  opacity: 1;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--surface2);
  border-color: var(--border-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--muted2);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--surface2);
  color: var(--text);
}

.btn-danger {
  background: transparent;
  color: var(--red);
  border-color: transparent;
}

.btn-danger:hover {
  background: var(--red-bg);
  border-color: var(--red);
}

/* =====================================================
   PILLS / BADGES
   ===================================================== */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.pill-green  { background: var(--green-bg);  color: var(--green); }
.pill-red    { background: var(--red-bg);    color: var(--red); }
.pill-yellow { background: var(--yellow-bg); color: var(--yellow); }
.pill-gray   { background: var(--surface2);  color: var(--muted2); }
.pill-blue   { background: var(--blue-bg);   color: var(--blue); }

/* =====================================================
   TABLES
   ===================================================== */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead tr {
  background: var(--surface2);
}

.data-table th {
  font-size: 10px;
  letter-spacing: 0.6px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
  padding: 9px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tbody tr {
  transition: background 0.1s;
  cursor: pointer;
}

.data-table tbody tr:hover td { background: var(--surface2); }
.data-table tbody tr.row-selected td { background: var(--accent-glow, rgba(124,106,255,0.07)); }
.data-table tbody tr.row-selected:hover td { background: var(--accent-glow, rgba(124,106,255,0.12)); }

/* =====================================================
   INPUTS
   ===================================================== */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.input-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted);
}

.input, .select {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  transition: var(--transition);
  outline: none;
}

.input:focus, .select:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

:root.dark .input:focus,
:root.dark .select:focus {
  border-color: var(--accent);
}

.input::placeholder { color: var(--muted); }

.select option { background: var(--surface); color: var(--text); }

/* =====================================================
   MODAL
   ===================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  transform: scale(0.97) translateY(8px);
  transition: all 0.2s ease;
}

.modal-overlay.open .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text);
}

:root.dark .modal-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 22px;
  letter-spacing: 2px;
}

.modal-close {
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--surface2);
  color: var(--text);
}

/* =====================================================
   PAGE HEADER
   ===================================================== */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.4px;
  line-height: 1.2;
  color: var(--text);
}

:root.dark .page-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 36px;
  letter-spacing: 3px;
}

.page-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

/* ---- SECTION TITLE ---- */
.section-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.1px;
  color: var(--text);
  margin-bottom: 14px;
}

:root.dark .section-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 18px;
  letter-spacing: 2px;
}

/* =====================================================
   GRID
   ===================================================== */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .main-content { margin-left: 0; }
  .topbar { left: 0; }
}

/* ---- DIVIDER ---- */
.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* ---- NUMERI ---- */
.num-pos     { color: var(--green); }
.num-neg     { color: var(--red); }
.num-neutral { color: var(--text); }

/* ---- CHART WRAPPER ---- */
.chart-wrap {
  position: relative;
  width: 100%;
}

/* =====================================================
   EMPTY STATE
   ===================================================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  gap: 10px;
  color: var(--muted);
  text-align: center;
}

.empty-state-icon { font-size: 36px; }
.empty-state-text { font-size: 13px; max-width: 280px; line-height: 1.6; }

/* =====================================================
   FILTERS BAR
   ===================================================== */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-chip {
  padding: 5px 13px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted2);
  font-size: 12px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: var(--transition);
}

.filter-chip:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.filter-chip.active {
  background: var(--text);
  border-color: var(--text);
  color: var(--surface);
}

:root.dark .filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* =====================================================
   TOAST
   ===================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
  transform: translateX(120%);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}

.toast.show { transform: translateX(0); }
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--blue); }

/* =====================================================
   LOADING SPINNER
   ===================================================== */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

:root.dark .spinner { border-top-color: var(--accent); }

@keyframes spin { to { transform: rotate(360deg); } }

/* =====================================================
   AI POPUP
   ===================================================== */
.ai-popup {
  position: fixed;
  top: var(--topbar-h);
  right: 20px;
  width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 500;
  overflow: hidden;
  transform: translateY(-8px) scale(0.98);
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

.ai-popup.open {
  transform: translateY(8px) scale(1);
  opacity: 1;
  visibility: visible;
}

.ai-popup-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-popup-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

:root.dark .ai-popup-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 18px;
  letter-spacing: 2px;
}

.ai-popup-body { padding: 12px; display: flex; flex-direction: column; gap: 8px; }

.ai-consiglio {
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  border-left: 3px solid var(--blue);
  font-size: 13px;
  line-height: 1.5;
}

.ai-consiglio.warn { border-left-color: var(--yellow); }
.ai-consiglio.good { border-left-color: var(--green); }
.ai-consiglio.info { border-left-color: var(--blue); }

.ai-consiglio-meta {
  font-size: 10px;
  color: var(--muted);
  margin-top: 6px;
  display: flex;
  gap: 8px;
}

/* =====================================================
   GRIDSTACK (Dashboard)
   ===================================================== */
.grid-stack-item-content {
  border-radius: var(--radius) !important;
  overflow: hidden;
}

.widget-drag-handle {
  position: absolute;
  top: 8px; right: 8px;
  opacity: 0;
  transition: var(--transition);
  cursor: grab;
  color: var(--muted);
}

.edit-mode .widget-drag-handle { opacity: 1; }
.edit-mode .card { border-color: var(--accent) !important; }
