/* ===================================================
   BLAB — Gestione Laboratorio Test EN 60598
   Design System — Stile BLIP (Navy/Gold)
   =================================================== */

/* ─── CSS Custom Properties (Light Mode Default — come BLIP) ─── */
:root {
  /* Colori primari BLIP */
  --primary: #fccb06;
  --primary-hover: #e6b800;
  --primary-dark: #1f2a3d;
  --primary-glow: rgba(252, 203, 6, 0.3);

  /* Accenti */
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-violet: #8b5cf6;

  /* Superficie (Light Mode Default) */
  --background: #f6f7f7;
  --surface: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-input: #f6f7f7;
  --bg-modal-overlay: rgba(0, 0, 0, 0.5);

  /* Sidebar */
  --sidebar-bg: #1f2a3d;
  --sidebar-text: rgba(255, 255, 255, 0.7);
  --sidebar-active-bg: #fccb06;
  --sidebar-active-text: #1f2a3d;

  /* Testo */
  --text-main: #1f2a3d;
  --text-muted: #6B7280;

  /* Bordi */
  --border: #e5e7eb;
  --border-color: #e5e7eb;
  /* alias per Chart.js e stili JS inline */

  /* Stati */
  --success: #10B981;
  --success-bg: rgba(16, 185, 129, 0.1);
  --error: #EF4444;
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.1);
  --danger: #EF4444;
  --danger-bg: rgba(239, 68, 68, 0.1);
  --info: #06b6d4;
  --info-bg: rgba(6, 182, 212, 0.1);

  /* Tipografia */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-size-xs: 0.7rem;
  --font-size-sm: 0.8rem;
  --font-size-base: 0.875rem;
  --font-size-md: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.5rem;
  --font-size-2xl: 2rem;

  /* Spaziature */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 0.75rem;
  --space-base: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* Layout */
  --sidebar-width: 260px;
  --header-height: 60px;
  --radius: 0.75rem;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  /* Ombre */
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.06), 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);

  /* Animazioni */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Dark Mode ─── */
[data-theme="dark"] {
  --background: #111827;
  --surface: #1F2937;
  --bg-secondary: #1a2332;
  --bg-input: #374151;
  --bg-modal-overlay: rgba(0, 0, 0, 0.7);
  --text-main: #F9FAFB;
  --text-muted: #9CA3AF;
  --border: #374151;
  --border-color: #374151;
  --primary-dark: #F9FAFB;
  --sidebar-bg: #16181c;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

/* ─── Reset ─── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  background-color: var(--background);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  transition: background-color 0.3s ease;
  -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════ */

.app-container {
  display: flex;
  height: 100%;
}

/* ═══════════════════════════════════════════
   SIDEBAR (Stile BLIP)
   ═══════════════════════════════════════════ */

.sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: var(--space-lg);
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  transition: transform var(--transition-base);
  z-index: 100;
}

.sidebar::-webkit-scrollbar {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  margin-bottom: var(--space-xl);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-badge {
  width: 46px;
  height: 46px;
  background: var(--primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 1rem;
  color: #1f2a3d;
  letter-spacing: 0.5px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(252, 203, 6, 0.35);
}

.brand-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-name {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 1px;
  line-height: 1.1;
}

.brand-subtitle {
  font-size: 0.58rem;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  line-height: 1.35;
}

.nav-links {
  flex: 1;
  list-style: none;
}

.nav-section-title {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.35);
  padding: var(--space-lg) var(--space-md) var(--space-sm);
  font-weight: 600;
}

.nav-item {
  padding: 0.7rem var(--space-base);
  margin-bottom: 2px;
  border-radius: 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-md);
  transition: all 0.2s;
  font-weight: 500;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
}

.nav-item:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.nav-item.active {
  background-color: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 600;
}

.nav-item i {
  width: 20px;
  text-align: center;
  font-size: var(--font-size-md);
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: var(--primary-dark);
  font-size: var(--font-size-xs);
  padding: 2px 7px;
  border-radius: 20px;
  font-weight: 700;
  min-width: 20px;
  text-align: center;
}

/* Sidebar Footer (Logo + Theme Toggle come BLIP) */
.sidebar-footer {
  margin-top: auto;
  padding-top: var(--space-lg);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
}

.footer-logo {
  width: 60%;
  max-width: 150px;
  height: auto;
  max-height: 150px;
  object-fit: contain;
  opacity: 0.8;
  transition: opacity 0.3s ease;
  margin-bottom: 0.5rem;
}

.footer-logo:hover {
  opacity: 1;
}

.theme-toggle {
  cursor: pointer;
  padding: var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  opacity: 0.6;
  transition: opacity 0.2s;
  color: var(--sidebar-text);
  font-size: 0.85rem;
  width: 100%;
  justify-content: center;
}

.theme-toggle:hover {
  opacity: 1;
}

.app-version {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  opacity: 0.6;
}

/* ═══════════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════════ */

.main-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background-color: var(--background);
  background-image:
    linear-gradient(rgba(31, 42, 61, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31, 42, 61, 0.03) 1px, transparent 1px);
  background-size: 20px 20px;
}

[data-theme="dark"] .main-content {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
}

/* Custom Scrollbar */
.main-content::-webkit-scrollbar {
  width: 4px;
}

.main-content::-webkit-scrollbar-track {
  background: transparent;
}

.main-content::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 10px;
}

[data-theme="dark"] .main-content::-webkit-scrollbar-thumb {
  background: #4B5563;
}

/* ─── Header ─── */
.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-xl) var(--space-xl) 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-base);
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.menu-toggle:hover {
  background: var(--bg-secondary);
}

.page-title {
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--text-main);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.header-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--font-size-base);
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.header-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-main);
  border-color: var(--primary);
}

/* ─── Content Area ─── */
.content-area {
  flex: 1;
  padding: var(--space-xl);
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ═══════════════════════════════════════════
   KPI CARDS (Stile BLIP)
   ═══════════════════════════════════════════ */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-base);
  margin-bottom: var(--space-base);
}

.kpi-card {
  background: var(--surface);
  padding: var(--space-lg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
  overflow: hidden;
}

.kpi-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.kpi-card.kpi-campioni::before {
  background: linear-gradient(90deg, var(--primary-dark), #2d3e5e);
}

.kpi-card.kpi-sessioni::before {
  background: linear-gradient(90deg, var(--info), var(--accent-cyan));
}

.kpi-card.kpi-pass::before {
  background: linear-gradient(90deg, var(--success), #059669);
}

.kpi-card.kpi-fail::before {
  background: linear-gradient(90deg, var(--danger), #dc2626);
}

.kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  margin-bottom: var(--space-md);
}

.kpi-campioni .kpi-icon {
  background: rgba(31, 42, 61, 0.1);
  color: var(--primary-dark);
}

.kpi-sessioni .kpi-icon {
  background: var(--info-bg);
  color: var(--info);
}

.kpi-pass .kpi-icon {
  background: var(--success-bg);
  color: var(--success);
}

.kpi-fail .kpi-icon {
  background: var(--danger-bg);
  color: var(--danger);
}

[data-theme="dark"] .kpi-campioni .kpi-icon {
  background: rgba(252, 203, 6, 0.15);
  color: var(--primary);
}

.kpi-value {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--primary-dark);
  line-height: 1.2;
  margin-bottom: var(--space-xs);
}

[data-theme="dark"] .kpi-value {
  color: var(--text-main);
}

.kpi-label {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  font-weight: 500;
}

/* ═══════════════════════════════════════════
   GRAFICI
   ═══════════════════════════════════════════ */

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-base);
  margin-bottom: var(--space-xl);
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-lg);
  box-shadow: var(--shadow);
}

.chart-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  margin-bottom: var(--space-base);
  color: var(--text-muted);
}

.chart-canvas-wrap {
  position: relative;
  width: 100%;
  height: 260px;
}

.chart-canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ═══════════════════════════════════════════
   TOOLBAR
   ═══════════════════════════════════════════ */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  background: var(--surface);
  padding: var(--space-md);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.search-box {
  position: relative;
}

.search-box i {
  position: absolute;
  left: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

.search-box input {
  padding: var(--space-sm) var(--space-base) var(--space-sm) 2.2rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-main);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  width: 260px;
  transition: all var(--transition-fast);
}

.search-box input:focus {
  outline: 2px solid var(--primary);
  border-color: var(--primary);
}

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

.filter-select {
  padding: var(--space-sm) var(--space-base);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-main);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  cursor: pointer;
}

.filter-select:focus {
  outline: 2px solid var(--primary);
  border-color: var(--primary);
}

/* ═══════════════════════════════════════════
   BOTTONI (Stile BLIP)
   ═══════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  font-size: 0.9rem;
  font-family: var(--font-family);
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--primary-dark);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--primary);
  color: var(--primary-dark);
}

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

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

.btn-success {
  background-color: var(--success);
  color: white;
}

.btn-danger {
  background-color: var(--error);
  color: white;
}

.btn-warning {
  background-color: var(--warning);
  color: var(--primary-dark);
}

.btn-sm {
  padding: 4px var(--space-md);
  font-size: var(--font-size-sm);
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  color: var(--text-main);
  background: var(--bg-secondary);
}

/* ═══════════════════════════════════════════
   TABELLE (Stile BLIP)
   ═══════════════════════════════════════════ */

.table-container {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

.data-table th,
.data-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  background-color: rgba(0, 0, 0, 0.02);
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

[data-theme="dark"] .data-table th {
  background-color: rgba(255, 255, 255, 0.03);
}

.data-table tbody tr {
  transition: background-color 0.15s;
}

.data-table tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.02);
}

[data-theme="dark"] .data-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.03);
}

.data-table td .btn {
  padding: 4px 6px;
  font-size: 0.8rem;
}

/* ═══════════════════════════════════════════
   BADGE / STATO
   ═══════════════════════════════════════════ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0.25em 0.6em;
  border-radius: 10rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-pianificata {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-in_corso {
  background: var(--info-bg);
  color: var(--info);
  border: 1px solid rgba(6, 182, 212, 0.2);
}

.badge-completata {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-pass {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-fail {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-attivo {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-archiviato {
  background: rgba(107, 114, 128, 0.1);
  color: var(--text-muted);
  border: 1px solid rgba(107, 114, 128, 0.2);
}

.badge-cat {
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: 600;
}

.badge-cat-IP {
  background: rgba(6, 182, 212, 0.1);
  color: var(--accent-cyan);
}

.badge-cat-IK {
  background: rgba(139, 92, 246, 0.1);
  color: var(--accent-violet);
}

.badge-cat-GW {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

.badge-cat-EL {
  background: rgba(99, 102, 241, 0.1);
  color: #6366f1;
}

.badge-cat-TH {
  background: rgba(244, 63, 94, 0.1);
  color: var(--accent-rose);
}

.badge-cat-EN {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-emerald);
}

.badge-cat-CC {
  background: rgba(148, 163, 184, 0.1);
  color: #94a3b8;
}

.badge-cat-PB {
  background: rgba(236, 72, 153, 0.1);
  color: #ec4899;
}

.badge-cat-ME {
  background: rgba(120, 113, 108, 0.1);
  color: #78716c;
}

.badge-cat-EM {
  background: rgba(45, 212, 191, 0.1);
  color: #2dd4bf;
}

/* ═══════════════════════════════════════════
   MODALI (Stile BLIP)
   ═══════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-modal-overlay);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
  overflow-y: auto;
  padding: 1.5rem 0;
}

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

.modal {
  background: var(--surface);
  width: 100%;
  max-width: 640px;
  border-radius: 1rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  transform: translateY(20px);
  transition: transform 0.2s;
}

.modal-overlay.show .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: var(--font-size-lg);
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-main);
  background: var(--bg-secondary);
}

.modal-body {
  padding: var(--space-lg);
  max-height: 65vh;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-md);
  padding: var(--space-lg);
  border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════
   FORM FIELDS
   ═══════════════════════════════════════════ */

.form-group {
  margin-bottom: var(--space-base);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.form-label {
  display: block;
  margin-bottom: var(--space-sm);
  font-size: 0.9rem;
  font-weight: 500;
}

label,
.form-label {
  display: block;
  margin-bottom: var(--space-xs);
  font-size: 0.9rem;
  font-weight: 500;
}

input,
select,
textarea,
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--background);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 0.95rem;
  transition: all var(--transition-fast);
}

input:focus,
select:focus,
textarea:focus,
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: 2px solid var(--primary);
  border-color: var(--primary);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

/* ═══════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════ */

.empty-state {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--text-muted);
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: var(--space-base);
  opacity: 0.4;
}

.empty-state p {
  font-size: var(--font-size-base);
  margin-bottom: var(--space-base);
}

/* ═══════════════════════════════════════════
   ATTIVITÀ RECENTE
   ═══════════════════════════════════════════ */

.activity-list {
  list-style: none;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--font-size-sm);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.activity-dot.pass {
  background: var(--success);
}

.activity-dot.fail {
  background: var(--danger);
}

.activity-dot.in_corso {
  background: var(--info);
}

.activity-dot.pianificata {
  background: var(--warning);
}

.activity-text {
  flex: 1;
  color: var(--text-muted);
}

.activity-text strong {
  color: var(--text-main);
  font-weight: 600;
}

.activity-time {
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  white-space: nowrap;
}

/* ═══════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════ */

.toast-container {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-md) var(--space-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-width: 300px;
  animation: toastIn 0.3s ease;
  font-size: var(--font-size-sm);
}

.toast.toast-success {
  border-left: 4px solid var(--success);
}

.toast.toast-error {
  border-left: 4px solid var(--danger);
}

.toast.toast-info {
  border-left: 4px solid var(--info);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }

  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

/* ═══════════════════════════════════════════
   MISURAZIONI INLINE
   ═══════════════════════════════════════════ */

.misurazioni-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-base);
  margin-top: var(--space-md);
}

.misurazioni-panel .mis-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
  align-items: center;
}

.misurazioni-panel .mis-row input {
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
}

.misurazioni-panel .mis-row input:focus {
  outline: 2px solid var(--primary);
  border-color: var(--primary);
}

/* ═══════════════════════════════════════════
   SETTINGS
   ═══════════════════════════════════════════ */

.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-xl);
  box-shadow: var(--shadow);
  margin-bottom: var(--space-lg);
}

.settings-card h3 {
  font-size: var(--font-size-md);
  font-weight: 600;
  margin-bottom: var(--space-base);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--border);
}

.settings-row:last-child {
  border-bottom: none;
}

/* ═══════════════════════════════════════════
   HELP / GUIDA RAPIDA
   ═══════════════════════════════════════════ */

.help-card h3 {
  font-size: 1.1rem;
  margin-bottom: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.help-section {
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border);
}

.help-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.help-section h4 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: var(--space-base);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

[data-theme="dark"] .help-section h4 {
  color: var(--primary);
}

.help-section h4 i {
  color: var(--primary);
  font-size: 0.85rem;
}

/* Workflow Steps */
.help-steps {
  display: flex;
  flex-direction: column;
  gap: var(--space-base);
}

.help-step {
  display: flex;
  gap: var(--space-base);
  align-items: flex-start;
}

.help-step-num {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  background: var(--primary-dark);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
}

[data-theme="dark"] .help-step-num {
  background: var(--primary);
  color: var(--primary-dark);
}

.help-step strong {
  display: block;
  margin-bottom: 2px;
  font-size: 0.9rem;
}

.help-step p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.help-step em {
  color: var(--primary-dark);
  font-style: normal;
  font-weight: 600;
}

[data-theme="dark"] .help-step em {
  color: var(--primary);
}

/* Sections Grid */
.help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-base);
}

.help-item {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: box-shadow 0.2s;
}

.help-item:hover {
  box-shadow: var(--shadow);
}

.help-item-icon {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.help-item strong {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 2px;
}

.help-item p {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Categories */
.help-categories {
  font-size: 0.82rem;
  line-height: 2.2;
  color: var(--text-muted);
}

/* Tips */
.help-tips {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.help-tips li {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: var(--space-xs) 0;
}

.help-tips li i {
  flex-shrink: 0;
  font-size: 0.75rem;
}

/* ─── Toggle Switch ─── */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  cursor: pointer;
}

.toggle input {
  display: none;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: all var(--transition-fast);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all var(--transition-fast);
}

.toggle input:checked+.toggle-slider {
  background: var(--primary);
  border-color: var(--primary);
}

.toggle input:checked+.toggle-slider::before {
  left: 23px;
  background: white;
}

/* ─── Actions ─── */
.actions-cell {
  display: flex;
  gap: 4px;
}

/* ─── Loading ─── */
.loading-spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */

@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    z-index: 200;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .menu-toggle {
    display: block;
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}

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

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-left {
    flex-direction: column;
  }

  .search-box input {
    width: 100%;
  }

  .content-area {
    padding: var(--space-base);
  }

  .modal {
    margin: var(--space-base);
    max-width: calc(100% - var(--space-xl));
  }

  .data-table {
    font-size: var(--font-size-sm);
  }

  .data-table th,
  .data-table td {
    padding: var(--space-sm);
  }

  .misurazioni-panel .mis-row {
    grid-template-columns: 1fr 1fr;
  }
}

/* ═══════════════════════════════════════════
   FULLCALENDAR OVERRIDES
   ═══════════════════════════════════════════ */

#calendar {
  min-height: 600px;
  max-width: 100%;
}

.fc {
  font-family: var(--font-family);
  color: var(--text-main);
}

.fc-theme-standard .fc-scrollgrid,
.fc-theme-standard td,
.fc-theme-standard th {
  border-color: var(--border) !important;
}

.fc-col-header-cell-cushion,
.fc-daygrid-day-number {
  color: var(--text-main);
  text-decoration: none;
  font-weight: 500;
}

.fc-col-header-cell-cushion:hover,
.fc-daygrid-day-number:hover {
  text-decoration: none;
  color: var(--primary);
}

.fc .fc-button-primary {
  background-color: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
  text-transform: capitalize;
}

[data-theme="dark"] .fc .fc-button-primary {
  background-color: var(--surface);
  border-color: var(--border);
  color: var(--text-main);
}

.fc .fc-button-primary:not(:disabled):active,
.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:hover {
  background-color: var(--primary);
  border-color: var(--primary);
  color: var(--primary-dark);
}

.fc .fc-daygrid-day.fc-day-today {
  background-color: var(--bg-secondary) !important;
}

.fc-event {
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 2px 4px;
  font-size: 0.8rem;
  font-weight: 600;
  border: none;
  transition: transform 0.15s;
  box-shadow: var(--shadow);
}

.fc-event:hover {
  transform: scale(1.02);
  filter: brightness(1.1);
}

/* ═══════════════════════════════════════════════════════════
   ALLEGATI — DROPZONE + GALLERIA
   ═══════════════════════════════════════════════════════════ */

.allegati-section {
  margin-top: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border);
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl) var(--space-lg);
  text-align: center;
  cursor: pointer;
  transition: all 0.25s ease;
  background: var(--bg-secondary);
  color: var(--text-muted);
}

.dropzone:hover,
.dropzone.drag-over {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--bg-secondary));
}

.dropzone i {
  font-size: 2rem;
  color: var(--primary);
  margin-bottom: var(--space-sm);
  display: block;
}

.dropzone p {
  margin: 4px 0;
  font-size: var(--font-size-sm);
}

.dropzone .dropzone-hint {
  font-size: 0.75rem;
  opacity: 0.6;
}

.allegati-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--space-md);
  margin-top: var(--space-md);
}

.allegato-thumb {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
}

.allegato-thumb:hover {
  transform: scale(1.05);
}

.allegato-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.allegato-thumb .allegato-pdf-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 2.5rem;
  color: var(--danger, #ef4444);
}

.allegato-thumb .allegato-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  opacity: 0;
  transition: opacity 0.2s;
}

.allegato-thumb:hover .allegato-delete {
  opacity: 1;
}

.allegato-thumb .allegato-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px 6px;
  font-size: 0.65rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Lightbox */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}

.lightbox-overlay img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: var(--radius-md);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.5);
}

.allegato-uploading {
  opacity: 0.5;
  pointer-events: none;
}

.allegato-uploading::after {
  content: '';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-md);
}

/* Bottone "Apri Tool" — sfondo blu navy, scritta azzurra */
.btn-tool-open {
  background: #1e3a5f;
  color: #38bdf8 !important;
  border: none;
}
.btn-tool-open:hover {
  background: #1a3252;
  color: #7dd3fc !important;
}

/* ═══════════════════════════════════════════
   TOOLTIP SYSTEM
   ═══════════════════════════════════════════ */

.tip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.6rem;
  cursor: help;
  position: relative;
  vertical-align: middle;
  margin-left: 5px;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}
.tip-icon:hover {
  border-color: #06b6d4;
  color: #06b6d4;
}

/* Tooltip bubble */
.tip-icon::before {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 9px);
  left: 50%;
  transform: translateX(-50%);
  background: #1a2540;
  color: #e2e8f0;
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.55;
  padding: 0.55rem 0.8rem;
  border-radius: 0.5rem;
  width: 240px;
  white-space: normal;
  z-index: 9999;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
  text-transform: none;
  letter-spacing: normal;
  font-family: 'Inter', sans-serif;
}
/* Arrow */
.tip-icon::after {
  content: '';
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1a2540;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
}
.tip-icon:hover::before,
.tip-icon:hover::after {
  opacity: 1;
}
/* Tooltip verso destra se vicino al bordo sinistro */
.tip-icon.tip-right::before {
  left: 0;
  transform: translateX(0);
}
.tip-icon.tip-right::after {
  left: 7px;
  transform: none;
}


/* ═══════════════════════════════════════════
   BTEC — Tool Styles
   ═══════════════════════════════════════════ */

/* Tool Header */
.tool-header {
  margin-bottom: var(--space-xl);
}
.tool-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}
.tool-title i {
  color: var(--primary);
}
.tool-description {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}
.tool-norm-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(252,203,6,0.12);
  color: #b38600;
  border: 1px solid rgba(252,203,6,0.35);
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}
[data-theme="dark"] .tool-norm-badge {
  background: rgba(252,203,6,0.08);
  color: var(--primary);
}

/* Tool Layout */
.tool-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  align-items: start;
}
@media (max-width: 900px) {
  .tool-layout { grid-template-columns: 1fr; }
}

/* Tool Panel (input/result panels) */
.tool-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-lg);
  box-shadow: var(--shadow);
}
.tool-panel-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: var(--space-lg);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Result display */
.result-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-lg);
  margin-top: var(--space-base);
}
.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.result-row:last-child { border-bottom: none; }
.result-label { color: var(--text-muted); }
.result-value {
  font-weight: 700;
  color: var(--text-main);
  font-size: 1rem;
  font-feature-settings: "tnum";
}
.result-value.highlight { color: var(--primary); font-size: 1.2rem; }
.result-value.danger    { color: var(--error); }
.result-value.success   { color: var(--success); }

/* Compliance badge */
.compliance-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.9rem;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 0.85rem;
}
.compliance-pass {
  background: rgba(16,185,129,0.1);
  color: var(--success);
  border: 1px solid rgba(16,185,129,0.3);
}
.compliance-warn {
  background: rgba(245,158,11,0.1);
  color: var(--warning);
  border: 1px solid rgba(245,158,11,0.3);
}
.compliance-fail {
  background: rgba(239,68,68,0.1);
  color: var(--error);
  border: 1px solid rgba(239,68,68,0.3);
}

/* Tool Tabs */
.tool-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: var(--space-lg);
  background: var(--bg-secondary);
  padding: 4px;
  border-radius: var(--radius);
}
.tool-tab {
  flex: 1;
  padding: 0.5rem 1rem;
  border-radius: calc(var(--radius) - 3px);
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-family);
}
.tool-tab.active {
  background: var(--surface);
  color: var(--text-main);
  font-weight: 600;
  box-shadow: var(--shadow);
}
.tool-tab-panel { display: none; }
.tool-tab-panel.active { display: block; }

/* Dashboard tool cards */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-base);
  margin-top: var(--space-xl);
}
.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-lg);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.tool-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}
.tool-card.coming-soon {
  opacity: 0.55;
  cursor: default;
}
.tool-card.coming-soon:hover {
  transform: none;
  box-shadow: var(--shadow);
  border-color: var(--border);
}
.tool-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  margin-bottom: var(--space-base);
}
.tool-card-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
}
.tool-card-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: var(--space-md);
}
.tool-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tool-card-norm {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
}
.tool-card-coming {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10rem;
  border: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Tolerance stack rows */
.stack-rows { display: flex; flex-direction: column; gap: var(--space-sm); }
.stack-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: var(--space-sm);
  align-items: center;
}
.stack-row input { padding: 0.45rem 0.6rem; font-size: 0.85rem; }

/* Input with unit suffix */
.input-group {
  position: relative;
  display: flex;
  align-items: center;
}
.input-group input {
  padding-right: 2.8rem;
  width: 100%;
}
.input-suffix {
  position: absolute;
  right: 0.6rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  pointer-events: none;
}

/* Range slider with value display */
.range-group {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}
.range-group input[type="range"] {
  flex: 1;
  padding: 0;
  border: none;
  accent-color: var(--primary);
}
.range-value {
  min-width: 3.5rem;
  text-align: right;
  font-weight: 600;
  font-size: 0.9rem;
}

/* Driver operating window display */
.driver-window {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-base);
  font-family: monospace;
  font-size: 0.82rem;
  line-height: 2;
  white-space: pre;
  overflow-x: auto;
}

/* KPI Row (Dashboard) */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-base);
  margin-top: var(--space-lg);
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-base);
  box-shadow: var(--shadow);
}
.kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.kpi-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
}
.kpi-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Section title */
.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  font-weight: 500;
  min-width: 280px;
  max-width: 420px;
  pointer-events: all;
  opacity: 0;
  transform: translateX(100%);
  transition: all 0.3s ease;
}
.toast.toast-visible {
  opacity: 1;
  transform: translateX(0);
}
.toast-success { border-left: 3px solid var(--success); }
.toast-success i { color: var(--success); }
.toast-error   { border-left: 3px solid var(--error); }
.toast-error   i { color: var(--error); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-warning i { color: var(--warning); }
.toast-info    { border-left: 3px solid var(--accent-cyan); }
.toast-info    i { color: var(--accent-cyan); }
.toast-close {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0 0.2rem;
  font-size: 0.8rem;
  line-height: 1;
}
.toast span { flex: 1; }

/* Mobile menu button */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--sidebar-text);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0.5rem;
  margin-left: auto;
}
@media (max-width: 768px) {
  .mobile-menu-btn { display: flex; align-items: center; }
  .nav-links       { display: none; }
  .nav-links.mobile-open { display: flex; }
}

/* Theme toggle button */
.theme-toggle {
  width: 100%;
  justify-content: center;
  gap: 0.5rem;
  margin-top: var(--space-sm);
  font-size: 0.82rem;
}

/* Form hints */
.form-hint {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Small button variant */
.btn-sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}

/* Page header */
.page-header {
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border);
}
.page-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}
.page-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
}