/* ===================================================
   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;
  --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;
  transition: transform var(--transition-base);
  z-index: 100;
}

.brand {
  margin-bottom: var(--space-xl);
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: var(--space-md);
  padding: 15px 5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-badge {
  width: 44px;
  height: 44px;
  background-color: var(--primary);
  color: var(--primary-dark);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.brand-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.brand-name {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 1px;
  line-height: 1.1;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.brand-subtitle {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.6);
  letter-spacing: 0.05em;
  margin-top: 2px;
}

.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;
  min-height: 100vh;
  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.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 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 {
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-xl);
  position: sticky;
  top: 0;
  z-index: 50;
}

.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;
}

.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-md);
  margin-bottom: var(--space-xl);
}

.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-md);
  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;
}

.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-lg); }

.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;
}

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

.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);
}

