/* ============================================================
   GestionApp 212 — Styles v6.2 FINAL
   Fidèle au design original : sidebar bleu marine foncé,
   topbar blanche, KPI cards blanches, icônes colorées
   ============================================================ */

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

:root {
  /* Sidebar */
  --sb-bg:          #1a2332;
  --sb-bg-hover:    rgba(255,255,255,.06);
  --sb-bg-active:   rgba(99,179,237,.15);
  --sb-border:      rgba(255,255,255,.07);
  --sb-text:        rgba(255,255,255,.80);
  --sb-text-muted:  rgba(255,255,255,.38);
  --sb-active:      #63b3ed;
  --sb-width:       220px;

  /* Couleurs */
  --blue:     #3182ce;
  --blue-light:#ebf8ff;
  --green:    #38a169;
  --green-light:#f0fff4;
  --orange:   #dd6b20;
  --orange-light:#fffaf0;
  --red:      #e53e3e;
  --red-light:#fff5f5;
  --purple:   #805ad5;
  --purple-light:#faf5ff;
  --cyan:     #00b5d8;
  --teal:     #2c7a7b;
  --yellow:   #d69e2e;

  /* Contenu */
  --bg-app:   #f0f4f8;
  --bg-card:  #ffffff;

  /* Topbar */
  --topbar-bg: #ffffff;
  --topbar-h:  64px;

  /* Textes */
  --text:      #1a202c;
  --text-2:    #4a5568;
  --text-3:    #718096;
  --text-4:    #a0aec0;

  /* Bordures */
  --border:    #e2e8f0;
  --border-2:  #edf2f7;

  /* Ombres */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --shadow:    0 4px 14px rgba(0,0,0,.08);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.13);

  /* Rayons */
  --r:    10px;
  --r-sm:  7px;
  --r-xs:  5px;

  --transition: .18s ease;
}

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-app);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body[dir="rtl"] { font-family: 'Cairo', sans-serif; }

/* ══════════════════════════════════════════════════════════
   ANIMATIONS
══════════════════════════════════════════════════════════ */
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes fadeIn  { from { opacity:0; } to { opacity:1; } }
@keyframes slideUp { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
@keyframes toastIn { from { opacity:0; transform:translateX(110%); } to { opacity:1; transform:translateX(0); } }
@keyframes modalIn { from { opacity:0; transform:scale(.96) translateY(8px); } to { opacity:1; transform:scale(1) translateY(0); } }

/* ══════════════════════════════════════════════════════════
   LOADERS
══════════════════════════════════════════════════════════ */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid rgba(49,130,206,.15);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .75s linear infinite;
  margin: 0 auto;
}
.loading-screen {
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 12px;
  min-height: 200px; color: var(--text-3); font-size: 13px;
}

/* ══════════════════════════════════════════════════════════
   LAYOUT
══════════════════════════════════════════════════════════ */
#app { display: flex; height: 100vh; overflow: hidden; }

/* ══════════════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════════════ */
#sidebar {
  width: var(--sb-width);
  min-width: var(--sb-width);
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  transition: width .22s ease, min-width .22s ease;
  z-index: 100;
  flex-shrink: 0;
  position: relative;
}

/* Collapsed */
#sidebar.collapsed { width: 58px; min-width: 58px; }
#sidebar.collapsed .brand-text,
#sidebar.collapsed .nav-section-title,
#sidebar.collapsed .nav-label,
#sidebar.collapsed .badge-sa,
#sidebar.collapsed .user-info,
#sidebar.collapsed .logout-btn,
#sidebar.collapsed .sidebar-close-btn,
#sidebar.collapsed #company-selector,
#sidebar.collapsed #company-selector-display,
#sidebar.collapsed #favorites-bar       { display: none !important; }
#sidebar.collapsed .nav-item            { justify-content: center; padding: 10px 8px; }
#sidebar.collapsed .sidebar-brand       { justify-content: center; }
#sidebar.collapsed .sidebar-header      { justify-content: center; padding: 14px 8px; }
#sidebar.collapsed .user-card           { justify-content: center; }

/* ── Header sidebar ─────────────────────────────────────── */
.sidebar-header {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 9px;
  cursor: pointer;
}
.brand-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, #2b6cb0, #4299e1);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 15px; flex-shrink: 0;
}
.brand-text  { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name  { color: #fff; font-size: 13px; font-weight: 700; letter-spacing: -.1px; }
.brand-version { color: var(--sb-text-muted); font-size: 10px; }
.sidebar-close-btn {
  background: none; border: none;
  color: var(--sb-text-muted); cursor: pointer;
  padding: 4px 6px; border-radius: 4px; font-size: 13px;
  transition: color var(--transition);
}
.sidebar-close-btn:hover { color: #fff; }

/* ── Bloc société (affiché pour tous) ───────────────────── */
.company-select-btn {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; background: rgba(255,255,255,.07);
  border-radius: 7px; cursor: pointer;
  transition: background var(--transition);
}
.company-select-btn:hover { background: rgba(255,255,255,.12); }
.company-icon {
  width: 28px; height: 28px; border-radius: 6px;
  background: linear-gradient(135deg, #2b6cb0, #63b3ed);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.company-info { flex: 1; min-width: 0; }
.company-name { color: #fff; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.company-role { color: var(--sb-text-muted); font-size: 10px; }
.company-chevron { color: var(--sb-text-muted); font-size: 9px; flex-shrink: 0; }

/* ── Nav section titles ─────────────────────────────────── */
.sidebar-nav {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 6px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.07) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); }

.nav-section-title {
  padding: 12px 14px 3px;
  font-size: 9.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.1px;
  color: var(--sb-text-muted);
}

/* ── Nav items ──────────────────────────────────────────── */
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  color: var(--sb-text); cursor: pointer;
  transition: background var(--transition), color var(--transition);
  font-size: 13px; font-weight: 400;
  text-decoration: none; user-select: none;
  border-radius: 6px; margin: 1px 6px;
}
.nav-item i {
  width: 16px; text-align: center; font-size: 13px; flex-shrink: 0;
  color: var(--sb-text-muted); transition: color var(--transition);
}
.nav-item:hover { background: var(--sb-bg-hover); color: #fff; }
.nav-item:hover i { color: rgba(255,255,255,.7); }
.nav-item.active {
  background: var(--sb-bg-active);
  color: var(--sb-active); font-weight: 600;
  border-left: 3px solid var(--sb-active);
  padding-left: 9px; margin-left: 6px;
}
.nav-item.active i { color: var(--sb-active); }
.nav-label { flex: 1; }

/* Badge SA (Super Admin) */
.badge-sa {
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #ed8936, #dd6b20);
  color: #fff; font-size: 8px; font-weight: 800;
  padding: 1px 5px; border-radius: 3px; margin-left: 3px;
}

/* ── Sidebar footer ─────────────────────────────────────── */
.sidebar-footer {
  border-top: 1px solid var(--sb-border); padding: 10px 12px; flex-shrink: 0;
}
.user-card {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 5px; border-radius: 6px;
  cursor: pointer; transition: background var(--transition);
}
.user-card:hover { background: var(--sb-bg-hover); }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #ed8936, #dd6b20);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name  { color: #fff; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { color: var(--sb-text-muted); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout-btn {
  background: none; border: none; color: var(--sb-text-muted);
  cursor: pointer; padding: 5px; border-radius: 5px; font-size: 13px;
  transition: color var(--transition), background var(--transition); flex-shrink: 0;
}
.logout-btn:hover { color: #fc8181; background: rgba(252,129,129,.12); }

/* Favoris */
.fav-bar-title {
  font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .8px; color: var(--sb-text-muted); padding: 0 2px 4px;
}
.fav-item {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 7px; background: rgba(255,255,255,.07);
  border-radius: 4px; cursor: pointer; color: rgba(255,255,255,.65);
  font-size: 10px; margin-bottom: 3px; transition: background var(--transition);
}
.fav-item:hover { background: rgba(255,255,255,.13); color: #fff; }

/* ══════════════════════════════════════════════════════════
   TOPBAR
══════════════════════════════════════════════════════════ */
#main-wrapper { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

#topbar {
  height: var(--topbar-h);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,.05); z-index: 50;
}
.topbar-left  { display: flex; align-items: center; gap: 14px; }
.topbar-right { display: flex; align-items: center; gap: 6px; }

.menu-btn {
  background: none; border: none; color: var(--text-3);
  font-size: 16px; cursor: pointer; padding: 7px 8px;
  border-radius: var(--r-sm); transition: background var(--transition), color var(--transition);
  line-height: 1;
}
.menu-btn:hover { background: var(--border-2); color: var(--text); }

/* Breadcrumb */
.breadcrumb-nav {
  font-size: 14px; color: var(--text-2); font-weight: 500;
}
.breadcrumb-nav i { color: var(--blue); margin-right: 5px; }

/* Boutons topbar */
.topbar-btn {
  background: none; border: 1px solid var(--border);
  color: var(--text-3); font-size: 13px; cursor: pointer;
  padding: 6px 10px; border-radius: var(--r-sm);
  transition: all var(--transition); position: relative;
  line-height: 1; font-family: inherit;
}
.topbar-btn:hover { background: var(--border-2); color: var(--text); border-color: #cbd5e0; }

/* Notifications */
.notif-wrapper { position: relative; }
.notif-badge {
  position: absolute; top: 3px; right: 3px;
  background: var(--red); color: #fff;
  font-size: 9px; font-weight: 700;
  width: 15px; height: 15px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid #fff;
}
.notif-panel {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 330px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--r);
  box-shadow: var(--shadow-lg); z-index: 1000; overflow: hidden;
  animation: slideUp .15s ease;
}
.notif-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 600;
}
.notif-list { max-height: 340px; overflow-y: auto; }
.notif-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 16px; border-bottom: 1px solid var(--border-2);
  cursor: pointer; transition: background var(--transition);
}
.notif-item:hover { background: #f7fafc; }
.notif-item.unread { background: #fffff0; }
.notif-icon { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0; }
.notif-body { flex: 1; min-width: 0; }
.notif-title { font-size: 12px; font-weight: 600; }
.notif-text  { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.notif-time  { font-size: 10px; color: var(--text-4); margin-top: 2px; }

/* Société badge topbar */
.topbar-company {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 11px; border: 1px solid var(--border);
  border-radius: var(--r-sm); cursor: pointer; background: #fff;
  font-size: 13px; font-weight: 500; transition: all var(--transition);
}
.topbar-company:hover { border-color: var(--blue); }
.dot { width: 8px; height: 8px; background: #48bb78; border-radius: 50%; }

/* User topbar */
.topbar-user {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 9px; border-radius: var(--r-sm);
  cursor: pointer; transition: background var(--transition);
}
.topbar-user:hover { background: var(--border-2); }
.topbar-avatar {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, #ed8936, #dd6b20);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 11px; flex-shrink: 0;
}
.topbar-username { font-size: 13px; font-weight: 600; color: var(--text); }

/* ══════════════════════════════════════════════════════════
   PAGE CONTENT
══════════════════════════════════════════════════════════ */
#page-content {
  flex: 1; overflow-y: auto; padding: 24px;
  background: var(--bg-app);
  animation: fadeIn .2s ease;
}

.page-header {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-title {
  font-size: 20px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 10px;
}
.page-title i { color: var(--blue); }
.page-subtitle { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.page-actions  { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ══════════════════════════════════════════════════════════
   BOUTONS
══════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border: none; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all var(--transition); text-decoration: none;
  white-space: nowrap; font-family: inherit; line-height: 1.4;
}
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 10px 22px; font-size: 14px; }

.btn-primary  { background: #3182ce; color: #fff; }
.btn-primary:hover  { background: #2b6cb0; }
.btn-success  { background: #38a169; color: #fff; }
.btn-success:hover  { background: #2f855a; }
.btn-danger   { background: #e53e3e; color: #fff; }
.btn-danger:hover   { background: #c53030; }
.btn-warning  { background: #dd6b20; color: #fff; }
.btn-warning:hover  { background: #c05621; }
.btn-purple   { background: #805ad5; color: #fff; }
.btn-purple:hover   { background: #6b46c1; }
.btn-ghost {
  background: transparent; color: var(--text-3);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--border-2); color: var(--text); border-color: #cbd5e0; }
.btn-secondary  { background: #edf2f7; color: var(--text-2); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e2e8f0; }
.btn:disabled   { opacity: .5; cursor: not-allowed; }

/* ══════════════════════════════════════════════════════════
   KPI CARDS — Identiques au screenshot
══════════════════════════════════════════════════════════ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px; margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border-radius: var(--r);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition);
  position: relative; overflow: hidden;
}
.kpi-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }

/* Indicateur tendance (coin haut droit, comme dans le screenshot) */
.kpi-trend {
  position: absolute; top: 14px; right: 14px;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; gap: 3px;
}
.kpi-trend.up     { color: #38a169; }
.kpi-trend.down   { color: #e53e3e; }
.kpi-trend.warn   { color: #dd6b20; }

.kpi-icon {
  width: 42px; height: 42px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; margin-bottom: 12px;
}
.kpi-value  { font-size: 24px; font-weight: 800; color: var(--text); line-height: 1.1; margin-bottom: 3px; }
.kpi-label  { font-size: 12px; color: var(--text-3); font-weight: 500; }
.kpi-sub    { font-size: 11px; color: var(--text-4); margin-top: 3px; }

/* ══════════════════════════════════════════════════════════
   CARTES GÉNÉRALES
══════════════════════════════════════════════════════════ */
.card {
  background: var(--bg-card); border-radius: var(--r);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 14px;
}
.card-body   { padding: 18px; }
.card-footer { padding: 12px 18px; border-top: 1px solid var(--border); background: #fafafa; }

/* ══════════════════════════════════════════════════════════
   TABLEAUX
══════════════════════════════════════════════════════════ */
.table-wrapper {
  background: var(--bg-card); border-radius: var(--r);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm); overflow: hidden;
}
.table-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  flex-wrap: wrap; gap: 10px;
}
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead { background: #f7fafc; }
thead th {
  padding: 10px 14px; text-align: left;
  font-size: 11px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border-2); transition: background var(--transition); }
tbody tr:hover { background: #f7fafc; }
tbody tr:last-child { border-bottom: none; }
tbody td { padding: 11px 14px; vertical-align: middle; }

/* ══════════════════════════════════════════════════════════
   BADGES
══════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-blue    { background: #ebf8ff; color: #2b6cb0; }
.badge-green   { background: #f0fff4; color: #276749; }
.badge-red     { background: #fff5f5; color: #9b2c2c; }
.badge-orange  { background: #fffaf0; color: #9c4221; }
.badge-purple  { background: #faf5ff; color: #553c9a; }
.badge-gray    { background: #f7fafc; color: #4a5568; }
.badge-cyan    { background: #e6fffa; color: #234e52; }
.badge-yellow  { background: #fffff0; color: #744210; }
/* Alias */
.badge-success  { background: #f0fff4; color: #276749; }
.badge-danger   { background: #fff5f5; color: #9b2c2c; }
.badge-warning  { background: #fffaf0; color: #9c4221; }
.badge-info     { background: #ebf8ff; color: #2b6cb0; }
.badge-primary  { background: #ebf8ff; color: #2b6cb0; }
.badge-secondary{ background: #f7fafc; color: #4a5568; }

/* ══════════════════════════════════════════════════════════
   FORMULAIRES
══════════════════════════════════════════════════════════ */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 11px; font-weight: 700;
  color: var(--text-3); margin-bottom: 5px;
  text-transform: uppercase; letter-spacing: .4px;
}
.form-label.required::after { content: ' *'; color: var(--red); }
.form-control {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--border); border-radius: var(--r-sm);
  font-size: 13px; color: var(--text); background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none; font-family: inherit;
}
.form-control:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(49,130,206,.12);
}
.form-control::placeholder { color: var(--text-4); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

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

/* ══════════════════════════════════════════════════════════
   FILTRES
══════════════════════════════════════════════════════════ */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.search-box { position: relative; }
.search-box input {
  padding: 8px 12px 8px 33px; border: 1.5px solid var(--border);
  border-radius: var(--r-sm); font-size: 13px; outline: none;
  background: #fff; transition: border-color var(--transition);
  width: 230px; font-family: inherit;
}
.search-box input:focus { border-color: var(--blue); }
.search-box i {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-4); font-size: 12px; pointer-events: none;
}

/* ══════════════════════════════════════════════════════════
   MODALES
══════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000; padding: 20px;
  backdrop-filter: blur(3px);
}
.modal-box {
  background: var(--bg-card); border-radius: var(--r);
  box-shadow: var(--shadow-lg); width: 100%;
  max-width: 560px; max-height: 90vh; overflow-y: auto;
  animation: modalIn .18s ease;
}
.modal-box.modal-sm  { max-width: 400px; }
.modal-box.modal-lg  { max-width: 820px; }
.modal-box.modal-xl  { max-width: 1060px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  font-size: 15px; font-weight: 700;
}
.modal-close {
  background: none; border: none; color: var(--text-4);
  font-size: 15px; cursor: pointer; padding: 4px 8px; border-radius: 5px;
  transition: all var(--transition);
}
.modal-close:hover { color: var(--red); background: var(--red-light); }
.modal-body   { padding: 20px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px; border-top: 1px solid var(--border);
  background: #fafafa; border-radius: 0 0 var(--r) var(--r);
}

/* ══════════════════════════════════════════════════════════
   ONGLETS
══════════════════════════════════════════════════════════ */
.tabs {
  display: flex; border-bottom: 2px solid var(--border);
  margin-bottom: 20px; overflow-x: auto; flex-wrap: nowrap;
}
.tab,
.tab-btn {
  padding: 8px 18px; border: none; background: none;
  font-size: 13px; font-weight: 500; color: var(--text-3);
  cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: all var(--transition);
  white-space: nowrap; font-family: inherit; flex-shrink: 0;
}
.tab:hover, .tab-btn:hover { color: var(--text); background: rgba(99,179,237,.06); border-radius: 4px 4px 0 0; }
.tab.active, .tab-btn.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }

/* Contenu des onglets */
.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
  animation: fadeIn .15s ease;
}

/* Wrapper onglets Paramètres */
#param-tabs-wrapper .tabs {
  position: sticky;
  top: 0;
  background: var(--bg, #f0f4f8);
  z-index: 10;
  padding-top: 4px;
}

/* ══════════════════════════════════════════════════════════
   PROGRESS
══════════════════════════════════════════════════════════ */
.progress-outer { background: var(--border-2); border-radius: 4px; height: 6px; overflow: hidden; }
.progress-inner { height: 100%; border-radius: 4px; transition: width .5s ease; }

/* ══════════════════════════════════════════════════════════
   ÉTAT VIDE
══════════════════════════════════════════════════════════ */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-state i { font-size: 44px; color: #cbd5e0; margin-bottom: 14px; display: block; }
.empty-state h3 { font-size: 16px; color: var(--text-3); margin-bottom: 6px; }
.empty-state p  { font-size: 13px; color: var(--text-4); }

/* ══════════════════════════════════════════════════════════
   PAGINATION
══════════════════════════════════════════════════════════ */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 18px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-3);
}
.page-btns { display: flex; gap: 4px; }
.page-btn {
  min-width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: #fff; font-size: 12px; font-weight: 600;
  color: var(--text-3); cursor: pointer; transition: all var(--transition); font-family: inherit;
}
.page-btn:hover { border-color: var(--blue); color: var(--blue); }
.page-btn.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ══════════════════════════════════════════════════════════
   ALERTES
══════════════════════════════════════════════════════════ */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 15px; border-radius: var(--r-sm);
  font-size: 13px; margin-bottom: 16px;
}
.alert i { flex-shrink: 0; margin-top: 1px; }
.alert-success { background: #f0fff4; color: #276749; border: 1px solid #9ae6b4; }
.alert-danger  { background: #fff5f5; color: #9b2c2c; border: 1px solid #feb2b2; }
.alert-warning { background: #fffaf0; color: #9c4221; border: 1px solid #fbd38d; }
.alert-info    { background: #ebf8ff; color: #2b6cb0; border: 1px solid #90cdf4; }

/* ══════════════════════════════════════════════════════════
   TOASTS
══════════════════════════════════════════════════════════ */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 10000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg); font-size: 13px; font-weight: 500;
  min-width: 270px; max-width: 380px; animation: toastIn .25s ease; cursor: pointer;
}
.toast-success { background: #276749; color: #fff; }
.toast-error   { background: #9b2c2c; color: #fff; }
.toast-warning { background: #9c4221; color: #fff; }
.toast-info    { background: #2b6cb0; color: #fff; }

/* ══════════════════════════════════════════════════════════
   KANBAN
══════════════════════════════════════════════════════════ */
.kanban-board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.kanban-col {
  min-width: 250px; max-width: 280px; flex-shrink: 0;
  background: #f7fafc; border-radius: var(--r);
  border: 1px solid var(--border); display: flex; flex-direction: column;
}
.kanban-col-header {
  padding: 11px 13px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 3px solid; display: flex; align-items: center; justify-content: space-between;
}
.kanban-cards { padding: 8px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.kanban-card {
  background: var(--bg-card); border-radius: var(--r-sm);
  padding: 11px; border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  cursor: pointer; transition: box-shadow var(--transition);
}
.kanban-card:hover { box-shadow: var(--shadow); }

/* ══════════════════════════════════════════════════════════
   GRILLES UTILITAIRES
══════════════════════════════════════════════════════════ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ══════════════════════════════════════════════════════════
   DARK MODE
══════════════════════════════════════════════════════════ */
body.dark-mode {
  --bg-app:    #0d1117;
  --bg-card:   #161b22;
  --topbar-bg: #161b22;
  --border:    #21262d;
  --border-2:  #1c2128;
  --text:      #e6edf3;
  --text-2:    #8b949e;
  --text-3:    #6e7681;
  --text-4:    #484f58;
  --sb-bg:     #0d1117;
  background: var(--bg-app); color: var(--text);
}
body.dark-mode .form-control { background: #1c2128; color: var(--text); border-color: var(--border); }
body.dark-mode thead { background: #1c2128; }
body.dark-mode tbody tr:hover { background: #1c2128; }
body.dark-mode .modal-box { background: var(--bg-card); }
body.dark-mode .modal-footer, body.dark-mode .card-footer { background: #1c2128; }
body.dark-mode .kanban-col { background: #1c2128; }
body.dark-mode .kanban-card { background: var(--bg-card); }
body.dark-mode .btn-ghost { border-color: var(--border); color: var(--text-2); }
body.dark-mode .btn-ghost:hover { background: var(--border); }
body.dark-mode .topbar-btn { border-color: var(--border); }
body.dark-mode .topbar-company { background: var(--bg-card); border-color: var(--border); }
body.dark-mode .search-box input { background: #1c2128; color: var(--text); border-color: var(--border); }

/* ══════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  :root { --sb-width: 240px; }
  #sidebar {
    position: fixed; left: calc(-1 * var(--sb-width));
    top: 0; height: 100vh; transition: left .24s ease; z-index: 200;
  }
  #sidebar.mobile-open { left: 0; box-shadow: var(--shadow-lg); }
  #main-wrapper { width: 100%; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .form-row, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
  #page-content { padding: 14px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .kanban-board { flex-direction: column; }
  .kanban-col { min-width: 100%; max-width: 100%; }
  .modal-box { margin: 10px; }
  #topbar { padding: 0 14px; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .topbar-username { display: none; }
}

/* ══════════════════════════════════════════════════════════
   SCROLLBARS
══════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a0aec0; }
body.dark-mode ::-webkit-scrollbar-thumb { background: #30363d; }

/* ══════════════════════════════════════════════════════════
   UTILITAIRES
══════════════════════════════════════════════════════════ */
.text-muted   { color: var(--text-4) !important; }
.text-success { color: var(--green) !important; }
.text-danger  { color: var(--red) !important; }
.text-warning { color: var(--orange) !important; }
.text-info    { color: var(--blue) !important; }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.fw-bold      { font-weight: 700; }
.fw-semi      { font-weight: 600; }
.d-flex       { display: flex; }
.align-center { align-items: center; }
.gap-8        { gap: 8px; }
.mt-16        { margin-top: 16px; }
.mb-16        { margin-bottom: 16px; }
.mb-24        { margin-bottom: 24px; }
