:root {
  --sidebar-w: 230px;
  --sidebar-w-collapsed: 60px;
  --topbar-h: 58px;

  /* Light theme */
  --bg:      #f0f2f5;
  --bg2:     #ffffff;
  --bg3:     #f7f8fa;
  --border:  #e4e7ec;
  --border2: #d0d5dd;
  --text:    #101828;
  --text2:   #344054;
  --text3:   #98a2b3;

  --primary:       #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #ede9fe;
  --primary-text:  #4f46e5;

  --green:       #059669;
  --green-light: #d1fae5;
  --green-text:  #065f46;

  --red:       #dc2626;
  --red-light: #fee2e2;
  --red-text:  #991b1b;

  --orange:       #d97706;
  --orange-light: #fef3c7;
  --orange-text:  #92400e;

  --blue:       #2563eb;
  --blue-light: #dbeafe;
  --blue-text:  #1e40af;

  --purple:       #7c3aed;
  --purple-light: #ede9fe;
  --purple-text:  #5b21b6;

  --yellow:       #ca8a04;
  --yellow-light: #fef9c3;

  --teal:       #0d9488;
  --teal-light: #ccfbf1;

  --radius:    10px;
  --radius-sm: 6px;
  --shadow:    0 1px 3px rgba(16,24,40,0.10), 0 1px 2px rgba(16,24,40,0.06);
  --shadow-md: 0 4px 8px rgba(16,24,40,0.12), 0 2px 4px rgba(16,24,40,0.08);
  --transition: 0.15s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  height: 100vh;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.5;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width var(--transition);
  flex-shrink: 0;
  overflow: hidden;
  z-index: 100;
  box-shadow: 1px 0 0 var(--border);
}

.sidebar.collapsed { width: var(--sidebar-w-collapsed); }
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .nav-item span:not(.badge):not(.status-dot),
.sidebar.collapsed .sidebar-footer .pi-status span { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }
.sidebar.collapsed .badge { position: absolute; top: 4px; right: 4px; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  min-height: 58px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 17px;
  color: var(--primary);
}
.logo i { font-size: 20px; flex-shrink: 0; }

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 5px 7px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.sidebar-toggle:hover { background: var(--bg3); color: var(--text); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.nav-section { margin-bottom: 6px; }

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
  letter-spacing: 0.07em;
  padding: 6px 8px 3px;
  display: block;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  text-decoration: none;
  transition: all var(--transition);
  position: relative;
  white-space: nowrap;
  font-size: 13.5px;
}
.nav-item i { font-size: 14px; flex-shrink: 0; width: 17px; text-align: center; color: var(--text3); }
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item:hover i { color: var(--primary); }
.nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.nav-item.active i { color: var(--primary); }

.badge {
  background: var(--red);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: auto;
}
.badge.hidden { display: none; }

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text3);
  margin-left: auto;
  flex-shrink: 0;
}
.status-dot.online { background: var(--green); box-shadow: 0 0 5px var(--green); }
.status-dot.offline { background: var(--red); }

.sidebar-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg3);
}

.pi-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text3);
}

.status-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-indicator.online { background: var(--green); box-shadow: 0 0 5px var(--green); animation: pulse 2s infinite; }
.status-indicator.offline { background: var(--text3); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.clock {
  font-size: 12px;
  font-weight: 600;
  color: var(--text3);
  font-variant-numeric: tabular-nums;
}

/* ===== MAIN ===== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: var(--topbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  gap: 16px;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}

.topbar-left { display: flex; flex-direction: column; justify-content: center; flex: 1; }
.page-title { font-size: 16px; font-weight: 700; color: var(--text); }
.breadcrumb { font-size: 12px; color: var(--text3); }

.topbar-center {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}
.topbar-clock {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
  font-family: 'Courier New', monospace;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  justify-content: flex-end;
}
.topbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  flex-shrink: 0;
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 8px;
}
.month-label {
  font-weight: 600;
  font-size: 13px;
  min-width: 110px;
  text-align: center;
  color: var(--text);
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 4px 7px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  font-size: 12px;
}
.btn-icon:hover { background: var(--border); color: var(--text); }

.notify-btn { position: relative; }
.notify-badge {
  position: absolute;
  top: -2px; right: -2px;
  background: var(--red);
  color: white;
  font-size: 9px;
  font-weight: 700;
  width: 15px; height: 15px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.notify-badge.hidden { display: none; }

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  border: 2px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  cursor: pointer;
  font-size: 13px;
}

/* ===== CONTENT ===== */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 22px;
}
.content::-webkit-scrollbar { width: 6px; }
.content::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

.page { display: none; }
.page.active { display: block; }

/* ===== STATS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
}
.stat-icon.green  { background: var(--green-light);  color: var(--green); }
.stat-icon.red    { background: var(--red-light);    color: var(--red); }
.stat-icon.blue   { background: var(--blue-light);   color: var(--blue); }
.stat-icon.orange { background: var(--orange-light); color: var(--orange); }
.stat-icon.purple { background: var(--purple-light); color: var(--purple); }

.stat-value { font-size: 24px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-label { font-size: 12px; color: var(--text3); margin-top: 3px; }

/* ===== CARD ===== */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.card-header {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg3);
}
.card-header h3 {
  font-size: 13.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
}
.card-header h3 i { color: var(--primary); }
.card-body { padding: 14px 16px; }
.card-body.center { text-align: center; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 860px) { .dashboard-grid { grid-template-columns: 1fr; } }

/* ===== GRIGLIA PRESENZE ===== */
.griglia-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
  flex-wrap: wrap;
}
.griglia-filters { display: flex; gap: 7px; align-items: center; }
.griglia-actions { display: flex; gap: 7px; }

.griglia-wrapper {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 230px);
  box-shadow: var(--shadow);
}
.griglia-wrapper::-webkit-scrollbar { width: 6px; height: 6px; }
.griglia-wrapper::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

.griglia-table {
  border-collapse: collapse;
  width: 100%;
  table-layout: fixed;
  font-size: 11px;
  min-width: max-content; /* non comprime colonne oltre il minimo */
}
.griglia-table th, .griglia-table td {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 0;
}

.griglia-head-dipendente,
.griglia-cell-dipendente {
  position: sticky;
  left: 0;
  z-index: 10;
  background: var(--bg2);
  width: 145px;
  min-width: 145px;
  max-width: 145px;
}
.griglia-head-dipendente {
  background: var(--bg3);
  padding: 7px 8px;
  font-weight: 700;
  color: var(--text3);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--border2);
}

.griglia-cell-dipendente {
  padding: 4px 6px;
  cursor: pointer;
  transition: background var(--transition);
  border-right: 2px solid var(--border2);
  overflow: hidden;
}
.griglia-cell-dipendente:hover { background: var(--primary-light); }

/* Page tabs (griglia + timbrature) */
.page-tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); padding-bottom: 0; }
.page-tab {
  background: none; border: none; cursor: pointer;
  padding: 8px 18px; font-size: 13px; font-weight: 600;
  color: var(--text3); border-radius: 8px 8px 0 0;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.page-tab:hover { color: var(--primary); }
.page-tab.active { color: var(--primary); border-bottom-color: var(--primary); background: var(--primary-light); }

.dipendente-info { display: flex; align-items: center; gap: 5px; }
.dipendente-avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  color: white;
  flex-shrink: 0;
}
.dipendente-name { font-weight: 600; font-size: 11px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dipendente-sub  { font-size: 9.5px; color: var(--text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.griglia-head-giorno {
  background: var(--bg3);
  text-align: center;
  padding: 3px 0;
  font-size: 9px;
  font-weight: 600;
  color: var(--text2);
  border-bottom: 2px solid var(--border2);
  min-width: 30px;
  width: 30px;
}
.griglia-head-giorno.festivo { color: var(--red); background: #fff5f5; }
.griglia-head-giorno.oggi   { color: var(--primary); background: var(--primary-light); }

.griglia-head-stats {
  background: var(--bg3);
  text-align: center;
  padding: 4px 2px;
  font-size: 9px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  border-bottom: 2px solid var(--border2);
  border-left: 2px solid var(--border2);
  width: 28px;
}

.griglia-cell-giorno {
  text-align: center;
  padding: 2px 1px;
  cursor: pointer;
  transition: background var(--transition);
  vertical-align: middle;
  min-width: 30px;
  width: 30px;
}
.griglia-cell-giorno:hover { background: #f0f0ff; }

/* Cella con stato singolo */
.stato-dot {
  width: 28px; height: 28px;
  border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto;
  font-size: 11px;
  font-weight: 700;
  transition: transform var(--transition);
}
.griglia-cell-giorno:hover .stato-dot { transform: scale(1.1); }

/* Cella mista: ore lavorate + assenza parziale */
.stato-misto {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0 auto;
  width: 22px;
}
.stato-misto .half {
  width: 22px; height: 10px;
  border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  font-size: 8px; font-weight: 700;
}
.stato-misto .half-lavoro  { border-radius: 4px 4px 0 0; }
.stato-misto .half-assenza { border-radius: 0 0 4px 4px; }

.stato-presente   { background: var(--green-light);  color: var(--green-text); }
.stato-assente    { background: #f9fafb;              color: var(--text3); border: 1px solid var(--border); }
.stato-ferie      { background: var(--blue-light);   color: var(--blue-text); }
.stato-malattia   { background: var(--red-light);    color: var(--red-text); }
.stato-permesso   { background: var(--orange-light); color: var(--orange-text); }
.stato-festivita  { background: var(--purple-light); color: var(--purple-text); }
.stato-smart_work { background: var(--yellow-light); color: var(--yellow); }
.stato-trasferta  { background: var(--teal-light);   color: var(--teal); }

.griglia-cell-stats {
  text-align: center;
  padding: 3px 2px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  border-left: 2px solid var(--border2);
}

/* Tooltip ore nella cella */
.cell-ore {
  font-size: 9px;
  color: var(--text3);
  margin-top: 1px;
  line-height: 1;
}

/* Ore grandi + stato piccolo sotto */
.cell-ore-big {
  font-size: 11px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text);
}
.cell-stato-small {
  font-size: 7px;
  font-weight: 700;
  border-radius: 2px;
  padding: 0 2px;
  margin: 0 auto;
  display: inline-block;
  line-height: 1.4;
}

/* ===== BUTTONS ===== */
.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all var(--transition);
  box-shadow: 0 1px 2px rgba(79,70,229,0.3);
}
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 2px 6px rgba(79,70,229,0.4); }

.btn-secondary {
  background: var(--bg2);
  color: var(--text2);
  border: 1px solid var(--border2);
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all var(--transition);
}
.btn-secondary:hover { background: var(--bg3); border-color: var(--text3); }

.btn-danger {
  background: var(--red-light);
  color: var(--red);
  border: 1px solid transparent;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-danger:hover { background: var(--red); color: white; }

.btn-sm { padding: 5px 11px; font-size: 12px; }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-outline:hover { background: var(--primary); color: white; }

/* ===== FORMS ===== */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; }
.form-group label { font-size: 12.5px; font-weight: 500; color: var(--text2); }
.form-group:last-child { margin-bottom: 0; }

.form-input, .form-select {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 11px;
  font-size: 13px;
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-input:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}
.form-input::placeholder { color: var(--text3); }
.form-select { cursor: pointer; }
.form-select.sm { padding: 5px 9px; font-size: 12px; width: auto; }

.form-color {
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  background: var(--bg2);
  cursor: pointer;
  padding: 2px;
  width: 60px;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }

.input-group { display: flex; align-items: center; }
.input-group .form-input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-suffix {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-left: none;
  padding: 8px 10px;
  color: var(--text3);
  font-size: 12px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.toggle-group { flex-direction: row; align-items: center; justify-content: space-between; }
.toggle { position: relative; display: inline-block; width: 42px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border2);
  border-radius: 22px;
  transition: var(--transition);
}
.toggle-slider:before {
  content: '';
  position: absolute;
  width: 15px; height: 15px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
input:checked + .toggle-slider { background: var(--primary); }
input:checked + .toggle-slider:before { transform: translateX(20px); }

/* ===== SECTION SEPARATOR in modal ===== */
.form-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 14px;
  background: var(--bg3);
}
.form-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.form-section-title i { color: var(--primary); }

/* ===== SEARCH BOX ===== */
.search-box {
  display: flex; align-items: center; gap: 7px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 6px 11px;
  min-width: 210px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }
.search-box i { color: var(--text3); font-size: 12.5px; }
.search-box input { background: none; border: none; color: var(--text); font-size: 13px; outline: none; width: 100%; }
.search-box input::placeholder { color: var(--text3); }

/* ===== PAGE TOOLBAR ===== */
.page-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 10px;
}

/* ===== TABLE ===== */
.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  background: var(--bg3);
  padding: 9px 13px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border2);
}
.data-table td {
  padding: 10px 13px;
  border-bottom: 1px solid var(--border);
  color: var(--text2);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg3); }

/* ===== DIPENDENTI ===== */
.dipendenti-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(245px, 1fr));
  gap: 13px;
}

.dipendente-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
  transition: all var(--transition);
  cursor: pointer;
  box-shadow: var(--shadow);
}
.dipendente-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-1px); }

.dip-card-header { display: flex; align-items: center; gap: 10px; }
.dip-avatar-lg {
  width: 42px; height: 42px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: white;
  flex-shrink: 0;
}
.dip-card-name { font-weight: 600; font-size: 14px; color: var(--text); }
.dip-card-sub  { font-size: 12px; color: var(--text3); }
.dip-card-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px; font-weight: 500;
}
.dip-card-actions { display: flex; gap: 6px; margin-top: auto; }

/* ===== REPARTI ===== */
.reparti-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(275px, 1fr)); gap: 13px; }
.reparto-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow);
}
.reparto-color { width: 10px; height: 38px; border-radius: 5px; flex-shrink: 0; }
.reparto-info { flex: 1; }
.reparto-name { font-weight: 600; font-size: 14px; }
.reparto-sub  { font-size: 12px; color: var(--text3); margin-top: 2px; }
.reparto-actions { display: flex; gap: 6px; }

/* ===== ORARI ===== */
.orari-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(295px, 1fr)); gap: 13px; }
.orario-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow);
}
.orario-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.orario-name { font-weight: 600; font-size: 14px; }
.orario-details { display: flex; gap: 10px; flex-wrap: wrap; }
.orario-item { font-size: 12px; color: var(--text2); display: flex; align-items: center; gap: 4px; }
.orario-item i { color: var(--primary); font-size: 11px; }

/* ===== DISPOSITIVI ===== */
.dispositivi-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(295px, 1fr)); gap: 13px; }
.dispositivo-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow);
}
.disp-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.disp-name { font-weight: 600; }
.disp-status { display: flex; align-items: center; gap: 5px; font-size: 12px; }
.disp-ip { font-size: 12px; color: var(--text3); font-family: monospace; }
.disp-actions { display: flex; gap: 6px; margin-top: 10px; }

.pi-info-box {
  background: var(--blue-light);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  font-size: 12px;
  color: var(--blue-text);
  display: flex; align-items: center; gap: 7px;
}
.pi-info-box code {
  font-family: monospace;
  background: rgba(37,99,235,0.1);
  padding: 1px 5px;
  border-radius: 3px;
}

/* ===== GIORNI SETTIMANA PICKER ===== */
.giorni-settimana-picker {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px;
}
.giorno-check {
  display: flex; align-items: center; gap: 4px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 10px; cursor: pointer;
  font-size: 12px; font-weight: 500; color: var(--text2);
  transition: all var(--transition); user-select: none;
}
.giorno-check:has(input:checked) {
  background: var(--primary-light); border-color: var(--primary); color: var(--primary);
}
.giorno-check input { display: none; }

/* ===== IMPOSTAZIONI ===== */
.impostazioni-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 14px;
}
.full-width { grid-column: 1 / -1; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(16,24,40,0.5);
  z-index: 200;
  display: none;
  backdrop-filter: blur(3px);
}
.modal-overlay.active { display: block; }

.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%;
  max-width: 540px;
  max-height: 88vh;
  display: flex; flex-direction: column;
  z-index: 300;
  box-shadow: 0 20px 50px rgba(16,24,40,0.25);
  opacity: 0;
  pointer-events: none;
  transition: all 0.18s ease;
}
.modal.active { opacity: 1; pointer-events: all; transform: translate(-50%, -50%) scale(1); }
.modal.modal-sm { max-width: 380px; }
.modal.modal-xl { max-width: 920px; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg3);
  border-radius: var(--radius) var(--radius) 0 0;
}
.modal-header h2 { font-size: 15px; font-weight: 600; }

.modal-close {
  background: none; border: none; color: var(--text3);
  cursor: pointer; padding: 5px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.modal-close:hover { background: var(--red-light); color: var(--red); }

.modal-body { padding: 18px; overflow-y: auto; flex: 1; }
.modal-body::-webkit-scrollbar { width: 4px; }
.modal-body::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

.modal-footer {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 8px; padding: 13px 18px;
  border-top: 1px solid var(--border); flex-shrink: 0;
  background: var(--bg3);
}

/* ===== TOAST ===== */
.toast-container {
  position: fixed; bottom: 18px; right: 18px;
  z-index: 1000;
  display: flex; flex-direction: column; gap: 7px;
}
.toast {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 15px;
  display: flex; align-items: center; gap: 9px;
  min-width: 270px; max-width: 340px;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.25s ease;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--blue); }
.toast.warning { border-left: 3px solid var(--orange); }
.toast i { font-size: 15px; flex-shrink: 0; }
.toast.success i { color: var(--green); }
.toast.error   i { color: var(--red); }
.toast.info    i { color: var(--blue); }
.toast.warning i { color: var(--orange); }
.toast-msg { font-size: 13px; color: var(--text); }

@keyframes slideIn {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ===== LOADING / EMPTY ===== */
.loading-spinner {
  display: flex; align-items: center; justify-content: center;
  gap: 9px; padding: 38px; color: var(--text3);
}
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 7px; padding: 28px;
  color: var(--text3); text-align: center;
}
.empty-state i { font-size: 26px; opacity: 0.35; }
.empty-state p { font-size: 13px; }
.empty-state.lg { padding: 55px; }
.empty-state.lg i { font-size: 44px; }
.empty-state.lg h3 { font-size: 17px; color: var(--text2); margin: 6px 0 3px; }

/* ===== TIMBRATURE ===== */
.timbratura-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.timbratura-item:last-child { border-bottom: none; }
.timbratura-type {
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px; font-weight: 600;
}
.tipo-entrata     { background: var(--green-light);  color: var(--green-text); }
.tipo-uscita      { background: var(--red-light);    color: var(--red-text); }
.tipo-pausa_inizio{ background: var(--orange-light); color: var(--orange-text); }
.tipo-pausa_fine  { background: var(--blue-light);   color: var(--blue-text); }

.timbratura-info { flex: 1; }
.timbratura-nome { font-size: 13px; font-weight: 500; color: var(--text); }
.timbratura-ora  { font-size: 11px; color: var(--text3); }

/* ===== DETTAGLIO DIPENDENTE ===== */
.dettaglio-header {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 16px; padding: 14px;
  background: var(--bg3); border-radius: var(--radius);
  border: 1px solid var(--border);
}
.dettaglio-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 9px; margin-bottom: 14px;
}
.dettaglio-stat {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px; text-align: center;
}
.dettaglio-stat-val   { font-size: 20px; font-weight: 700; }
.dettaglio-stat-label { font-size: 10px; color: var(--text3); margin-top: 2px; }

.dettaglio-giorni {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}
.giorno-box {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 7px 5px;
  text-align: center; cursor: pointer;
  transition: all var(--transition);
}
.giorno-box:hover { border-color: var(--primary); background: var(--primary-light); }
.giorno-box.festivo { opacity: 0.5; }
.giorno-box.oggi-box { border-color: var(--primary); }
.giorno-num   { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.giorno-stato { font-size: 9px; font-weight: 700; text-transform: uppercase; }
.giorno-ore   { font-size: 10px; color: var(--text3); margin-top: 2px; }

/* ===== EXPORT ===== */
.export-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.export-card {
  padding: 28px 18px; text-align: center; cursor: pointer;
  transition: all var(--transition);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.export-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.export-card i { font-size: 38px; }
.export-card i.fa-file-csv   { color: var(--green); }
.export-card i.fa-file-excel { color: var(--green); }
.export-card i.fa-file-pdf   { color: var(--red); }
.export-card h3 { font-size: 15px; }
.export-card p  { font-size: 12px; color: var(--text3); }

/* ===== LIVE DOT ===== */
.live-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
  animation: pulse 2s infinite;
  margin-right: 3px;
}

/* ===== REPORT ===== */
.report-container {}

/* ===== REPORT GRAFICI ===== */
.report-dip-header {
  display: flex; align-items: center; gap: 16px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 20px; margin-bottom: 20px;
}
.report-kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.report-kpi {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; text-align: center;
}
.report-kpi-val { font-size: 26px; font-weight: 800; line-height: 1; }
.report-kpi-label { font-size: 11px; color: var(--text3); margin-top: 4px; }
.report-charts-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 16px; margin-bottom: 20px;
}
@media (max-width: 768px) { .report-charts-grid { grid-template-columns: 1fr; } }
.chart-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 16px;
}
.chart-card-title {
  font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 14px;
  display: flex; align-items: center; gap: 6px;
}
.report-mesi-table th, .report-mesi-table td { padding: 8px 10px; font-size: 12px; }
.report-mesi-table th { background: var(--bg3); font-weight: 600; }
.perc-bar-wrap { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.perc-bar { height: 8px; border-radius: 4px; flex: 1; background: var(--bg3); overflow: hidden; }
.perc-bar-fill { height: 100%; border-radius: 4px; transition: width 0.6s ease; }
.report-annuale-filters { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.badge-perc {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 700;
}

/* Dipendenti attivo/disattivo */
.dip-disattivo { opacity: 0.65; }
.badge-stato-dip {
  font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 20px;
  margin-left: auto; flex-shrink: 0;
}
.badge-stato-dip.attivo { background: #dcfce7; color: #059669; }
.badge-stato-dip.disattivo { background: #fee2e2; color: #dc2626; }

/* Messaggi */
.messaggi-layout { display:grid; grid-template-columns:260px 1fr 220px; gap:16px; align-items:start; }
.messaggi-destinatari {}
.messaggi-compose {}
.messaggi-side {}
.dest-item:hover { background:var(--bg3) !important; }
.dest-item input[type="checkbox"] { width:16px; height:16px; flex-shrink:0; accent-color:var(--primary); }
.msg-canale-opt { display:flex; align-items:center; gap:10px; padding:8px 12px; border-radius:8px; cursor:pointer; background:var(--bg2); font-weight:600; }
.msg-canale-opt:hover { background:var(--bg3); }
.msg-canale-opt input[type="checkbox"] { width:16px; height:16px; accent-color:var(--primary); }
@media (max-width:900px) { .messaggi-layout { grid-template-columns:1fr; } }

/* Impostazioni Accordion */
.imp-accordion .card-body { display: none; overflow: hidden; }
.imp-accordion.open .card-body { display: block; }
.imp-acc-header {
  cursor: pointer; user-select: none;
  display: flex !important; align-items: center; justify-content: space-between;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
  padding: 14px 20px;
}
.imp-acc-header:hover { background: var(--bg3); }
.imp-accordion.open .imp-acc-header {
  background: rgba(79, 70, 229, 0.12);
}
.imp-accordion.open .imp-acc-header h3,
.imp-accordion.open .imp-acc-header h3 i { color: var(--primary); }
.imp-chevron { color: var(--text3); font-size: 13px; transition: transform 0.25s ease; flex-shrink: 0; }
.imp-accordion.open .imp-chevron { transform: rotate(180deg); color: var(--primary); }

/* Tab presenza (Timbrature / Inserimento Diretto) */
.presenza-tab {
  padding: 9px 18px; border: none; background: transparent; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--text2);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: color 0.18s, border-color 0.18s;
}
.presenza-tab:hover { color: var(--primary); }
.presenza-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.presenza-tab i { margin-right: 6px; }

/* Monte Ore pagina tabella */
#monteOreTable th { white-space: nowrap; font-size: 12px; }
#monteOreTable td { vertical-align: middle; }

/* Reparti multi-checkbox nel modal dipendente */
#dipRepartiCheckboxes label { transition: border-color 0.15s; }
#dipRepartiCheckboxes label:hover { background: var(--bg2) !important; }
