:root, [data-theme="sombre"] {
  --bg: #0f1419;
  --bg-card: #1a2332;
  --bg-sidebar: #141c27;
  --bg-hover: #243044;
  --border: #2a3a4f;
  --text: #e8eef6;
  --text-muted: #8b9cb3;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;
  --radius: 10px;
  --shadow: 0 4px 20px rgba(0,0,0,0.35);
  --sidebar-w: 260px;
  --sidebar-collapsed: 72px;
  --input-bg: #0f1419;
}

[data-theme="clair"] {
  --bg: #f0f2f5;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-hover: #e8eef6;
  --border: #d0d7e2;
  --text: #1a2332;
  --text-muted: #5a6a7e;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0891b2;
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
  --input-bg: #f8fafc;
}

[data-theme="ocean"] {
  --bg: #0a1628;
  --bg-card: #0f2744;
  --bg-sidebar: #0c1f36;
  --bg-hover: #163556;
  --border: #1e4a6e;
  --text: #e0f0ff;
  --text-muted: #7ba3c7;
  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --info: #22d3ee;
  --shadow: 0 4px 24px rgba(0,40,80,0.45);
  --input-bg: #0a1628;
}

[data-theme="forest"] {
  --bg: #0c1410;
  --bg-card: #15241c;
  --bg-sidebar: #101c16;
  --bg-hover: #1c3228;
  --border: #2a4a3a;
  --text: #e6f4ec;
  --text-muted: #7a9e8a;
  --primary: #4ade80;
  --primary-hover: #22c55e;
  --success: #86efac;
  --warning: #facc15;
  --danger: #f87171;
  --info: #2dd4bf;
  --shadow: 0 4px 20px rgba(0,30,15,0.4);
  --input-bg: #0c1410;
}

[data-theme="sunset"] {
  --bg: #1a1010;
  --bg-card: #2a1818;
  --bg-sidebar: #221414;
  --bg-hover: #3a2222;
  --border: #5a3030;
  --text: #fce8e8;
  --text-muted: #c49090;
  --primary: #fb7185;
  --primary-hover: #f43f5e;
  --success: #4ade80;
  --warning: #fb923c;
  --danger: #ef4444;
  --info: #f472b6;
  --shadow: 0 4px 20px rgba(40,0,0,0.4);
  --input-bg: #1a1010;
}

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

body {
  font-family: "Century Gothic", CenturyGothic, AppleGothic, "Gill Sans", "Trebuchet MS", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.25s ease, color 0.25s ease;
}

#app {
  display: flex;
  min-height: 100vh;
}

/* ========== SIDEBAR ========== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width 0.25s ease;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-section,
.sidebar.collapsed .sidebar-footer small {
  opacity: 0;
  width: 0;
  overflow: hidden;
  white-space: nowrap;
}

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

.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.15rem;
}

.logo-icon { font-size: 1.4rem; }

.nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.5rem;
}

.nav-section {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 1rem 0.75rem 0.4rem;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  text-align: left;
  transition: all 0.15s;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.nav-item.active {
  background: rgba(59, 130, 246, 0.15);
  color: var(--primary);
  font-weight: 600;
}

.nav-icon { font-size: 1.15rem; flex-shrink: 0; width: 1.4rem; text-align: center; }

.sidebar-footer {
  padding: 0.9rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

/* ========== MAIN ========== */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.25s ease;
}

.sidebar.collapsed ~ .main {
  margin-left: var(--sidebar-collapsed);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar h1 {
  font-size: 1.35rem;
  font-weight: 700;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.15rem;
}

.content {
  padding: 1.5rem 1.75rem 2.5rem;
  flex: 1;
}

/* ========== BUTTONS ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: 2px;
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

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

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

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.3); }

.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.3rem;
  border-radius: 6px;
}
.btn-icon:hover { color: var(--text); background: var(--bg-hover); }

/* ========== CARDS & KPIs ========== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  text-align: center;
  transition: transform 0.15s, box-shadow 0.15s, background 0.25s;
  position: relative;
  overflow: hidden;
}

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

.kpi-icon {
  font-size: 1.35rem;
  margin-bottom: 0.45rem;
  opacity: 0.9;
  display: block;
}

.kpi-value {
  font-size: 1.9rem;
  font-weight: 800;
  line-height: 1.1;
}

.kpi-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-total .kpi-value, .kpi-total .kpi-icon { color: var(--primary); }
.kpi-termine .kpi-value, .kpi-termine .kpi-icon { color: var(--success); }
.kpi-cours .kpi-value, .kpi-cours .kpi-icon { color: var(--info); }
.kpi-retard .kpi-value, .kpi-retard .kpi-icon { color: var(--danger); }
.kpi-afaire .kpi-value, .kpi-afaire .kpi-icon { color: var(--warning); }
.kpi-taux .kpi-value, .kpi-taux .kpi-icon { color: #a78bfa; }
[data-theme="clair"] .kpi-taux .kpi-value,
[data-theme="clair"] .kpi-taux .kpi-icon { color: #7c3aed; }

/* ========== FILTERS ========== */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.filter-group label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

.filter-group select,
.filter-group input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.45rem 0.7rem;
  border-radius: 6px;
  font-size: 0.9rem;
  min-width: 140px;
}

.filter-group select:focus,
.filter-group input:focus {
  outline: none;
  border-color: var(--primary);
}

/* ========== TABLES ========== */
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.table-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th {
  text-align: left;
  padding: 0.7rem 1rem;
  background: rgba(0,0,0,0.25);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

td {
  padding: 0.7rem 1rem;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}

tr:hover td {
  background: rgba(59, 130, 246, 0.05);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 2px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-afaire { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.badge-encours { background: rgba(6, 182, 212, 0.2); color: #22d3ee; }
.badge-termine { background: rgba(34, 197, 94, 0.2); color: #4ade80; }
.badge-retard { background: rgba(239, 68, 68, 0.2); color: #f87171; }
.badge-annule { background: rgba(139, 156, 179, 0.2); color: #94a3b8; }

.badge-basse { background: rgba(139, 156, 179, 0.2); color: #94a3b8; }
.badge-moyenne { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.badge-haute { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.badge-urgente { background: rgba(239, 68, 68, 0.25); color: #f87171; }

.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  min-width: 60px;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s;
}

/* ========== GRID LAYOUTS ========== */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
}

.card h3 {
  font-size: 0.95rem;
  margin-bottom: 1rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

/* Status list */
.status-list, .dept-list, .emp-charge-list {
  list-style: none;
}

.status-list li, .dept-list li, .emp-charge-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.status-list li:last-child,
.dept-list li:last-child,
.emp-charge-list li:last-child {
  border-bottom: none;
}

.bar-mini {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  margin: 0 1rem;
}

.bar-mini .track {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.bar-mini .fill {
  height: 100%;
  border-radius: 4px;
}

/* ========== MODAL ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1rem;
}
.modal-overlay[hidden] { display: none; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

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

.modal-header h2 { font-size: 1.15rem; }

.modal-body {
  padding: 1.3rem 1.4rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.9rem;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-group input,
.form-group select,
.form-group textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 0.75rem;
  border-radius: 2px;
  font-size: 0.9rem;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

#newDept
{
  border-radius: 2px !important;
}

#newPrefix
{
  border-radius: 2px !important;
}

.form-group textarea { resize: vertical; }

/* ========== TOAST ========== */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.85rem 1.3rem;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 300;
  font-size: 0.9rem;
  animation: slideIn 0.25s ease;
}

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

@keyframes slideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ========== EMPTY STATE ========== */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 2.5rem;
  margin-bottom: 0.8rem;
}

/* ========== ACTIONS ========== */
.actions {
  display: flex;
  gap: 0.35rem;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  .sidebar {
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform 0.25s ease, width 0.25s ease;
  }
  .sidebar.open {
    transform: translateX(0);
    width: var(--sidebar-w);
  }
  /* Labels TOUJOURS visibles quand le menu mobile est ouvert */
  .sidebar.open .logo-text,
  .sidebar.open .nav-label,
  .sidebar.open .nav-section,
  .sidebar.open .sidebar-footer small,
  .sidebar.open .user-info strong,
  .sidebar.open .user-info .badge {
    opacity: 1 !important;
    width: auto !important;
    overflow: visible !important;
    white-space: normal;
  }
  .sidebar.open .nav-item {
    justify-content: flex-start;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
  }
  .sidebar.open .nav-label {
    display: inline !important;
    font-size: 0.92rem;
  }
  .sidebar.open .sidebar-footer {
    padding: 1rem;
  }
  .sidebar.open .sidebar-footer .btn {
    font-size: 0.85rem;
  }
  .sidebar.open .logo-text {
    display: inline !important;
  }
  .main { margin-left: 0 !important; }
  .form-row { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 0.8rem; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3a4a5f; }

/* Alert banner */
.alert {
  padding: 0.75rem 1.1rem;
  border-radius: 8px;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.alert-success {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #4ade80;
}

.alert-danger {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
}

.alert-info {
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #60a5fa;
}

/* Charge badges */
.charge-sous { color: var(--success); }
.charge-equilibre { color: var(--info); }
.charge-sur { color: var(--danger); font-weight: 700; }

/* ========== LOGIN ========== */
.login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 1rem;
}
.login-screen[hidden] { display: none; }

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2rem 2.2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

.login-logo {
  font-size: 1.5rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 0.3rem;
}

.login-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.login-error {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
  text-align: center;
}

.login-hints {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.8;
}

.login-hints p { margin: 0; }

.user-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
}

.user-info strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item[hidden],
.nav-section[hidden],
.btn[hidden] {
  display: none !important;
}

/* Font Awesome spacing */
.nav-icon i, .btn i, .login-logo i, label i { margin-right: 0.35rem; }
.logo-icon i { font-size: 1.25rem; }

/* Chart evolution */
.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  height: 160px;
  padding: 0.5rem 0;
}
.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  gap: 0.35rem;
}
.chart-col .bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  width: 100%;
  height: 120px;
}
.chart-col .bar {
  flex: 1;
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: height 0.4s ease;
}
.chart-col .bar.created { background: var(--primary); }
.chart-col .bar.done { background: var(--success); }
.chart-col .label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
}
.chart-legend {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.chart-legend span::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 0.35rem;
  vertical-align: middle;
}
.chart-legend .leg-created::before { background: var(--primary); }
.chart-legend .leg-done::before { background: var(--success); }

.export-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Responsive enhancements */
@media (max-width: 1024px) {
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar.collapsed { width: var(--sidebar-w); }
  .main { margin-left: 0 !important; }
  .mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 90;
  }
  .mobile-overlay.show { display: block; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar { padding: 1rem; }
  .content { padding: 1rem; }
  .filters { flex-direction: column; align-items: stretch; }
  .filter-group select, .filter-group input { min-width: 0; width: 100%; }
  table { font-size: 0.8rem; }
  th, td { padding: 0.5rem 0.6rem; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 1.4rem; }
  .modal { max-width: 100%; border-radius: 12px 12px 0 0; max-height: 95vh; }
}

.login-screen { display: flex; }


/* Theme switcher */
.theme-switcher {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}
.theme-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s, border-color 0.15s;
}
.theme-btn:hover { transform: scale(1.15); }
.theme-btn.active { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg-sidebar); }
.theme-btn[data-theme-set="sombre"] { background: linear-gradient(135deg, #0f1419, #3b82f6); }
.theme-btn[data-theme-set="clair"] { background: linear-gradient(135deg, #f0f2f5, #2563eb); }
.theme-btn[data-theme-set="ocean"] { background: linear-gradient(135deg, #0a1628, #38bdf8); }
.theme-btn[data-theme-set="forest"] { background: linear-gradient(135deg, #0c1410, #4ade80); }
.theme-btn[data-theme-set="sunset"] { background: linear-gradient(135deg, #1a1010, #fb7185); }

/* Inputs respect theme */
input, select, textarea {
  background: var(--input-bg, var(--bg)) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
  font-family: inherit;
}

/* Activity log */
.log-list { list-style: none; display: flex; flex-direction: column; gap: 0.6rem; }
.log-item {
  display: flex; gap: 0.85rem; align-items: flex-start;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.85rem 1rem;
}
.log-icon {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 0.95rem;
}
.log-icon.create { background: rgba(34,197,94,0.15); color: var(--success); }
.log-icon.update { background: rgba(59,130,246,0.15); color: var(--primary); }
.log-icon.delete { background: rgba(239,68,68,0.15); color: var(--danger); }
.log-icon.login { background: rgba(168,85,247,0.15); color: #a78bfa; }
.log-icon.import { background: rgba(6,182,212,0.15); color: var(--info); }
.log-icon.other { background: rgba(139,156,179,0.15); color: var(--text-muted); }
.log-body { flex: 1; min-width: 0; }
.log-msg { font-size: 0.92rem; }
.log-meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.25rem; }


/* Notification pop-up (création tâche) */
.notify-popup {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  min-width: 280px;
  max-width: min(380px, calc(100vw - 2rem));
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--success);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
  padding: 1rem 1.1rem;
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  animation: notifyIn 0.35s ease;
  font-family: inherit;
}
.notify-popup.hide {
  animation: notifyOut 0.3s ease forwards;
}
.notify-popup .np-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.notify-popup .np-body { flex: 1; min-width: 0; }
.notify-popup .np-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.2rem;
}
.notify-popup .np-msg {
  font-size: 0.85rem;
  color: var(--text-muted);
  word-break: break-word;
}
.notify-popup .np-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0 0.2rem;
  line-height: 1;
}
.notify-popup .np-close:hover { color: var(--text); }
@keyframes notifyIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes notifyOut {
  to { opacity: 0; transform: translateX(40px); }
}
@media (max-width: 480px) {
  .notify-popup {
    left: 1rem;
    right: 1rem;
    min-width: 0;
    max-width: none;
  }
}


/* Global search */
.global-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 0.35rem 0.6rem;
  min-width: 180px;
  max-width: 280px;
}
.global-search-wrap i { color: var(--text-muted); margin-right: 0.4rem; font-size: 0.85rem; }
.global-search-wrap input {
  border: none;
  background: transparent;
  color: var(--text);
  width: 100%;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
}
.global-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 320px;
  max-height: 360px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.25);
  z-index: 3000;
  padding: 0.35rem;
}
.global-search-results .gs-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.7rem;
  border: none;
  background: transparent;
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.88rem;
}
.global-search-results .gs-item:hover { background: var(--bg); }
.global-search-results .gs-type {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-right: 0.4rem;
}

/* Filters */
.filters-bar {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.filter-input {
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.35rem 0.5rem;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  max-width: 160px;
}
.sort-btn.active {
  border-color: var(--primary);
  color: var(--primary);
}

.attach-list, .history-list {
  font-size: 0.85rem;
  max-height: 140px;
  overflow-y: auto;
}
.attach-item, .history-item {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}
.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  margin-right: 0.35rem;
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
@media (max-width: 768px) {
  .global-search-wrap { min-width: 120px; max-width: 160px; }
  .global-search-results { min-width: 260px; right: auto; }
  .filter-input { max-width: 100%; flex: 1 1 120px; }
}

/* Calendar partagé */
.cal-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.cal-title { margin: 0; font-size: 1.1rem; }
.cal-subtitle { display: block; font-size: 0.8rem; color: var(--text-muted); margin-top: 0.15rem; }
.cal-toolbar-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.cal-check {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
}
.cal-legend-item { display: inline-flex; align-items: center; gap: 0.3rem; color: var(--text-muted); }
.cal-legend-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.cal-layout { display: grid; grid-template-columns: 1fr 300px; gap: 1rem; }
.cal-sidebar { display: flex; flex-direction: column; gap: 1rem; }
@media (max-width: 900px) { .cal-layout { grid-template-columns: 1fr; } }
.cal-grid-head, .cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-grid-head { font-size: 0.75rem; color: var(--text-muted); text-align: center; margin-bottom: 0.35rem; }
.cal-cell {
  min-height: 88px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.3rem;
  font-size: 0.75rem;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.cal-cell:hover { border-color: var(--primary); }
.cal-cell.empty { background: transparent; border: none; cursor: default; }
.cal-cell.today { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.cal-cell.selected { border-color: var(--primary); background: rgba(59, 130, 246, 0.08); }
.cal-cell.has-tasks .cal-day { color: var(--text); }
.cal-day {
  font-weight: 700;
  margin-bottom: 0.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.cal-count {
  font-size: 0.65rem;
  font-weight: 600;
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  padding: 0.05rem 0.35rem;
}
.cal-task {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  width: 100%;
  text-align: left;
  margin: 1px 0;
  padding: 0.15rem 0.3rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.68rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
  opacity: 0.95;
}
.cal-task:hover { opacity: 1; filter: brightness(1.08); }
.cal-task-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
  padding: 0 !important;
  min-width: 6px;
}
.cal-more { color: var(--text-muted); font-size: 0.7rem; }
.cal-side-list { list-style: none; margin: 0; padding: 0; }
.cal-side-item {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.cal-side-item:hover { background: rgba(59, 130, 246, 0.06); }
.cal-side-bar {
  width: 4px;
  border-radius: 2px;
  flex-shrink: 0;
  align-self: stretch;
}
.cal-side-body { flex: 1; min-width: 0; font-size: 0.88rem; }
.cal-side-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  line-height: 1.35;
}
.cal-day-panel { margin-bottom: 0; }

/* Import dropzone (style zone de dépôt) */
.import-dropzone-form { margin-top: 0.5rem; }
.import-dropzone {
  border: 2px dashed rgba(100, 116, 139, 0.55);
  border-radius: 6px;
  padding: 1.75rem 1.25rem;
  text-align: center;
  background: rgba(15, 23, 42, 0.35);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
[data-theme="clair"] .import-dropzone,
html.theme-clair .import-dropzone {
  background: #f8fafc;
  border-color: #cbd5e1;
}
.import-dropzone.dragover {
  border-color: #22d3ee;
  background: rgba(34, 211, 238, 0.08);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12);
}
.import-dropzone-icon {
  font-size: 1.85rem;
  color: var(--text-muted);
  margin-bottom: 0.55rem;
  opacity: 0.9;
}
.import-dropzone-title {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 0.95rem;
  font-weight: 500;
}
.import-dropzone-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}
.import-file-name {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.import-dropzone label.btn {
  cursor: pointer;
  margin: 0;
  background: red;
  color: #fff;
  border-radius: 3px;
  padding: 0.45rem 1.1rem;
  font-weight: 600;
}
.import-dropzone label.btn:hover {
  filter: brightness(1.08);
}

.brand-tagline {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  max-width: 140px;
  line-height: 1.2;
}
.logo { align-items: flex-start; }

/* Global loading spinner */
.global-loader {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.global-loader[hidden] { display: none !important; }
.global-loader-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem 1.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
  font-family: inherit;
  color: var(--text);
  font-size: 0.95rem;
}
.global-loader-box i {
  font-size: 1.35rem;
  color: var(--primary);
}

.tab-loading {
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: var(--text-muted);
}
.tab-loading i { font-size: 1.75rem; color: var(--primary); }

/* Gestion départements */
.dept-manage-list { gap: 0.35rem; }
.dept-manage-item {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.55rem 0.35rem !important;
}
.dept-manage-info { display: flex; align-items: center; flex-wrap: wrap; gap: 0.25rem; flex: 1; min-width: 0; }
.dept-prefix-badge {
  background: var(--primary);
  color: #fff;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
}
.dept-manage-actions { display: flex; gap: 0.35rem; flex-shrink: 0; }

/* Modal confirmation visuelle */
.confirm-modal .confirm-modal-header h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.05rem;
  color: var(--danger);
}
.confirm-icon-wrap {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  margin: 0 auto 1rem;
}
.confirm-icon-wrap.warn {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}
.confirm-message {
  text-align: center;
  font-size: 1rem;
  line-height: 1.45;
  margin: 0 0 0.5rem;
}
.confirm-detail {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.4;
}
.confirm-footer {
  justify-content: center;
  gap: 0.65rem;
}
.role-card-users {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

/* Indicateur force mot de passe */
.pwd-meter { margin-top: 0.4rem; }
.pwd-meter-bar {
  height: 6px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.pwd-meter-fill {
  height: 100%;
  width: 0%;
  border-radius: 4px;
  transition: width 0.2s ease, background 0.2s ease;
  background: #ef4444;
}
.pwd-meter-fill.s1 { width: 25%; background: #ef4444; }
.pwd-meter-fill.s2 { width: 50%; background: #f59e0b; }
.pwd-meter-fill.s3 { width: 75%; background: #3b82f6; }
.pwd-meter-fill.s4 { width: 100%; background: #22c55e; }
.pwd-hint {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Associés multi-personnes */
.assoc-checklist {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.assoc-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.2rem;
  cursor: pointer;
  font-size: 0.9rem;
  border-radius: 4px;
}
.assoc-item:hover { background: rgba(59, 130, 246, 0.08); }
.assoc-item input { accent-color: var(--primary); }
.assoc-empty {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.assoc-group-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0.45rem 0 0.2rem;
  font-weight: 600;
}
.assoc-group-label:first-child { margin-top: 0; }
.assoc-checklist { max-height: 220px; }
.assoc-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.12);
}
[data-theme="clair"] .assoc-block { background: rgba(0, 0, 0, 0.03); }
.assoc-chip {
  display: inline-block;
  background: rgba(59, 130, 246, 0.15);
  color: var(--primary);
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
  font-size: 0.75rem;
  margin: 0.1rem 0.1rem 0.1rem 0;
  white-space: nowrap;
}
.assoc-chip-resp {
  background: rgba(34, 197, 94, 0.18);
  color: #16a34a;
  font-weight: 600;
}
.assoc-chip i { margin-right: 0.2rem; font-size: 0.7em; opacity: 0.85; }
.cell-desc, .cell-comment {
  max-width: 180px;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.35;
}
.cell-resp { min-width: 110px; white-space: nowrap; }
.cell-assoc { max-width: 240px; min-width: 100px; }
.text-muted-dash { color: var(--text-muted); font-size: 0.9rem; }
.tasks-table td { vertical-align: middle; }
.tasks-table th i { margin-right: 0.25rem; opacity: 0.75; }

/* Conflits de permissions */
.perm-mode-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.65rem;
}
.perm-mode-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  background: var(--bg);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.perm-mode-card input { margin-bottom: 0.2rem; accent-color: var(--primary); }
.perm-mode-card span { font-size: 0.8rem; color: var(--text-muted); line-height: 1.35; }
.perm-mode-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
  background: rgba(59, 130, 246, 0.08);
}
.perm-conflict-box {
  margin-top: 0.65rem;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.08);
  font-size: 0.85rem;
}
.perm-conflict-header { font-weight: 600; margin-bottom: 0.35rem; }
.perm-conflict-list {
  margin: 0.25rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.perm-conflict-ok { color: #16a34a; margin: 0.25rem 0 0; }
.perm-conflict-hint { margin: 0.4rem 0 0; font-size: 0.8rem; }
