/* ============================================
   Portail Réseau Agences — Style principal
   ============================================ */

/* --------------------------------------------------------------------------
   Jetons de design — nommés par RÔLE, pas par couleur.
   Pour changer une couleur, modifier le jeton de rôle ci-dessous : la valeur se
   propage partout. Les anciens noms (--blue-royal, --gray-500, …) restent
   disponibles en fin de bloc comme alias, le temps que les gabarits migrent.
   -------------------------------------------------------------------------- */
:root {
  /* Identité — l'indigo du réseau */
  --indigo-deep: #0f2d5e;   /* fond du menu latéral, dégradés d'en-tête */
  --indigo: #1a56db;        /* action primaire, lien, élément actif */
  --indigo-light: #3b82f6;  /* survol et variantes claires */
  --indigo-soft: #dbeafe;   /* fond doux : pastilles d'icônes, puces */

  /* Neutres — du fond de page vers l'encre */
  --bg: #f9fafb;            /* fond de page */
  --surface: #ffffff;       /* fond des cartes et panneaux */
  --surface-2: #f3f4f6;     /* remplissage discret, survol de ligne */
  --line: #e5e7eb;          /* bordures et séparateurs */
  --line-strong: #d1d5db;   /* bordures de champs de formulaire */
  --faint: #9ca3af;         /* texte de remplacement, état désactivé */
  --muted: #6b7280;         /* texte secondaire */
  --ink-soft: #4b5563;      /* texte courant atténué */
  --ink: #374151;           /* texte courant */
  --ink-strong: #1f2937;    /* titres */
  --white: #ffffff;         /* blanc littéral (texte sur fond coloré) — ne suit pas le thème */

  /* États — sens métier, jamais décoratif */
  --ok: #10b981;            --ok-soft: #d1fae5;
  --warn: #f59e0b;          --warn-soft: #fef3c7;
  --danger: #ef4444;        --danger-soft: #fee2e2;

  /* Accents catégoriels — pastilles d'icônes, familles de modules */
  --accent-cyan: #06b6d4;   --accent-cyan-soft: #e0f7fa;
  --accent-violet: #8b5cf6; --accent-violet-soft: #ede9fe;

  /* Alias de compatibilité — anciens noms, à retirer une fois les gabarits migrés */
  --blue-deep: var(--indigo-deep);
  --blue-royal: var(--indigo);
  --blue-light: var(--indigo-light);
  --cyan: var(--accent-cyan);
  --cyan-light: var(--accent-cyan-soft);
  --gray-50: var(--bg);
  --gray-100: var(--surface-2);
  --gray-200: var(--line);
  --gray-300: var(--line-strong);
  --gray-400: var(--faint);
  --gray-500: var(--muted);
  --gray-600: var(--ink-soft);
  --gray-700: var(--ink);
  --gray-800: var(--ink-strong);
  --green: var(--ok);
  --green-light: var(--ok-soft);
  --orange: var(--warn);
  --orange-light: var(--warn-soft);
  --red: var(--danger);
  --red-light: var(--danger-soft);
  --purple: var(--accent-violet);
  --purple-light: var(--accent-violet-soft);

  --sidebar-width: 260px;
  --sidebar-width-collapsed: 68px;
  --header-height: 64px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --transition: all 0.2s ease;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
}

a { color: var(--indigo); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================
   LAYOUT
   ============================================ */

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

/* ============================================
   SIDEBAR
   ============================================ */

.sidebar {
  width: var(--sidebar-width);
  background: var(--indigo-deep);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-brand .brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--indigo), var(--accent-cyan));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: white;
  flex-shrink: 0;
}

.sidebar-brand .brand-icon-logo {
  background: transparent;
  padding: 2px;
}

.sidebar-brand .brand-icon-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.sidebar-brand .brand-text {
  display: flex;
  flex-direction: column;
}

.sidebar-brand .brand-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--white);
  line-height: 1.2;
}

.sidebar-brand .brand-sub {
  font-size: 10px;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-toggle-btn {
  margin-left: auto;
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: rgba(255,255,255,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  transition: var(--transition);
}

.sidebar-toggle-btn:hover {
  background: rgba(255,255,255,0.1);
  color: var(--white);
}

.sidebar-toggle-btn i { transition: transform 0.2s ease; }

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
}

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

.nav-section-label {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(255,255,255,0.6);
  padding: 12px 0 6px 12px;
}

.nav-section-toggle span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  text-align: left;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.7);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  margin-bottom: 2px;
  text-decoration: none;
}

.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: var(--white);
  text-decoration: none;
}

.nav-item.active {
  background: linear-gradient(135deg, var(--indigo), #1e40af);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(26,86,219,0.4);
}

.nav-item i {
  font-size: 15px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item .badge {
  margin-left: auto;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 600;
}

.nav-item-soon {
  cursor: default;
  color: rgba(255,255,255,0.35);
}

.nav-item-soon:hover {
  background: none;
  color: rgba(255,255,255,0.35);
}

.nav-item-soon .badge {
  margin-left: auto;
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.nav-item-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-item-row .nav-item {
  flex: 1;
  margin-bottom: 0;
  min-width: 0;
}

.nav-fav-star {
  background: none;
  border: none;
  color: rgba(255,255,255,0.25);
  font-size: 12px;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--transition);
  margin-bottom: 2px;
}

.nav-fav-star:hover {
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.8);
}

.nav-fav-star.active {
  color: #fbbf24;
}

.nav-section-toggle {
  width: 100%;
  background: none;
  border: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font: inherit;
  padding-right: 6px;
}

.nav-section-toggle i {
  font-size: 10px;
  transition: transform 0.2s ease;
}

.nav-section.collapsed .nav-section-toggle i {
  transform: rotate(-90deg);
}

.nav-section.collapsed #favoritesList {
  display: none;
}

/* ---- Sections accordéon épinglables (nav_sections) ---- */
.nav-section-header {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-section-header .nav-section-label { flex: 1; min-width: 0; }

.nav-section-pin {
  flex-shrink: 0;
  background: none;
  border: none;
  width: 20px;
  height: 20px;
  margin-right: 2px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 10px;
  transition: var(--transition);
}

.nav-section-pin:hover { background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.75); }
.nav-section-pin.active { color: #fbbf24; }

.nav-section.collapsed .nav-section-items { display: none; }

/* Épinglée : toujours ouverte, peu importe l'état replié */
.nav-section.pinned .nav-section-items { display: block !important; }
.nav-section.pinned .nav-section-toggle i { transform: none !important; }

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.06);
}

.sidebar-user .avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--indigo), var(--accent-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.sidebar-user .user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user .user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user .user-role {
  font-size: 10px;
  color: rgba(255,255,255,0.45);
}

.sidebar-user .logout-btn {
  color: rgba(255,255,255,0.4);
  font-size: 14px;
  transition: var(--transition);
  flex-shrink: 0;
}
.sidebar-user .logout-btn:hover {
  color: var(--danger);
  text-decoration: none;
}

/* ============================================
   MAIN CONTENT
   ============================================ */

.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;   /* un élément flex ne descend pas sous la largeur minimale de
                     son contenu tant que ceci n'est pas posé : sans lui, une
                     ligne large (tableau, en-tête) élargit toute la page et
                     provoque un défilement horizontal sur téléphone */
}

/* ============================================
   HEADER
   ============================================ */

.header {
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;   /* sans ceci, le contenu impose sa largeur et pousse les
                     boutons de droite hors de l'écran sur téléphone */
}

.page-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink-strong);
}

.header-search {
  max-width: 320px;
  width: 100%;
}

.header-search input {
  width: 100%;
  padding: 8px 14px 8px 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  background: var(--bg);
  color: var(--ink);
  transition: var(--transition);
}

.header-search input:focus {
  outline: none;
  border-color: var(--indigo);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(26,86,219,0.1);
}

.search-wrapper {
  position: relative;
}

.search-wrapper i {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  font-size: 14px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;   /* les actions restent toujours atteignables */
}

.header-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: var(--surface-2);
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 16px;
  position: relative;
  text-decoration: none;
}

.header-btn:hover {
  background: var(--line);
  color: var(--ink-strong);
  text-decoration: none;
}

.header-btn .notif-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--surface);
}

/* ============================================
   MENU OUTILS (grille dans l'en-tête)
   ============================================ */

.tools-menu-wrap { position: relative; }

.tools-menu-panel {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 300px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 120;
  overflow: hidden;
}

.tools-menu-panel.show { display: block; }

.tools-menu-header {
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  border-bottom: 1px solid var(--surface-2);
}

.tools-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--surface-2);
  transition: var(--transition);
}

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

.tools-menu-item:hover {
  background: var(--bg);
  text-decoration: none;
}

.tools-menu-item.is-soon {
  cursor: default;
  opacity: 0.55;
}

.tools-menu-item.is-soon:hover { background: none; }

.tools-menu-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  color: var(--indigo);
  font-size: 17px;
}

.tools-menu-text { min-width: 0; }

.tools-menu-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-strong);
  display: flex;
  align-items: center;
  gap: 6px;
}

.tools-menu-desc {
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}

.tools-menu-empty {
  padding: 24px 16px;
  text-align: center;
}

.tools-menu-empty i {
  font-size: 22px;
  color: var(--line-strong);
  display: block;
  margin-bottom: 8px;
}

.tools-menu-empty p {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}

/* ---- Recherche IA (en-tête) ---- */
.ai-search-panel {
  width: 420px;
  max-height: 70vh;
  display: none;
  flex-direction: column;
}

.ai-search-panel.show { display: flex; }

.ai-search-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--faint);
}

.ai-search-input-row input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  background: transparent;
  color: var(--ink-strong);
}

.ai-search-body {
  overflow-y: auto;
  padding: 4px 0;
}

.ai-search-suggestions { padding: 4px 0; }

.ai-search-suggestion {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 16px;
  border: none;
  background: none;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
}

.ai-search-suggestion:hover { background: var(--bg); }

.ai-search-loading {
  padding: 20px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.ai-search-answer {
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-strong);
  white-space: pre-wrap;
}

.ai-search-sources {
  padding: 0 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-search-source-link {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
}

.ai-search-source-link:hover { background: var(--bg); text-decoration: none; }

.ai-search-error {
  padding: 14px 16px;
  font-size: 13px;
  color: var(--danger, #dc2626);
}

.header-agency {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--surface-2);
  border-radius: 8px;
  font-size: 12px;
  color: var(--ink-soft);
}

.header-agency .agency-name {
  font-weight: 600;
  color: var(--ink-strong);
}

.agency-switch-form select {
  border: none;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-strong);
  cursor: pointer;
  max-width: 180px;
}

.agency-switch-form select:focus {
  outline: none;
}

/* ============================================
   SÉLECTEUR DE CONTEXTE UNIFIÉ (en-tête)
   ============================================ */

/* Réseau / Agence / Rôle réunis dans une seule pastille. Les deux <select>
   restent des formulaires distincts : c'est la présentation qui est unifiée. */
.context-switcher {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;              /* autorise l'ellipsis des enfants */
  padding: 6px 12px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 12px;
  color: var(--ink-soft);
}

.context-switcher:hover { border-color: var(--line-strong); }

.context-icon { color: var(--indigo); flex-shrink: 0; }

.context-form { display: flex; min-width: 0; }

.context-form select,
.context-value {
  border: none;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-strong);
  font-family: inherit;
  max-width: 190px;
  min-width: 0;
  text-overflow: ellipsis;
}

.context-form select { cursor: pointer; padding: 2px 4px; border-radius: 5px; }

/* Le focus doit rester visible : on ne supprime pas le contour, on le remplace
   par un anneau lisible (l'ancien contrôle faisait outline:none, invisible au
   clavier). */
.context-form select:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: 1px;
}

.context-sep { color: var(--faint); flex-shrink: 0; }

.context-role {
  flex-shrink: 0;
  padding-left: 6px;
  margin-left: 2px;
  border-left: 1px solid var(--line-strong);
  color: var(--muted);
  white-space: nowrap;
}

/* Utilitaire : visible pour les lecteurs d'écran uniquement. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================
   PAGE CONTENT
   ============================================ */

.page-content {
  flex: 1;
  padding: 28px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header-title h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink-strong);
  margin-bottom: 2px;
}

.page-header-title p {
  font-size: 13px;
  color: var(--muted);
}

/* ============================================
   CARDS
   ============================================ */

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--surface-2);
  overflow: hidden;
}

/* Carte cliquable (fiche enveloppée dans un <a>) : remplace les
   onmouseover/onmouseout inline par un :hover CSS pur, thème-compatible. */
.card-clickable {
  cursor: pointer;
  transition: var(--transition);
}

.card-clickable:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--indigo);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h2,
.card-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-strong);
}

.card-body {
  padding: 20px;
}

.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--surface-2);
  background: var(--bg);
}

/* Stat Cards */
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--surface-2);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: var(--transition);
}

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

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.stat-icon.blue { background: #dbeafe; color: var(--indigo); }
.stat-icon.green { background: var(--ok-soft); color: var(--ok); }
.stat-icon.orange { background: var(--warn-soft); color: var(--warn); }
.stat-icon.red { background: var(--danger-soft); color: var(--danger); }
.stat-icon.purple { background: var(--accent-violet-soft); color: var(--accent-violet); }
.stat-icon.cyan { background: var(--accent-cyan-soft); color: var(--accent-cyan); }

.stat-info { flex: 1; }

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--ink-strong);
  line-height: 1.2;
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.stat-change {
  font-size: 11px;
  font-weight: 600;
  margin-top: 4px;
}

.stat-change.up { color: var(--ok); }
.stat-change.down { color: var(--danger); }

/* ============================================
   GRIDS
   ============================================ */

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* ============================================
   TABLES
   ============================================ */

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--surface-2);
  /* Indice de défilement horizontal en CSS pur (sans JS) : deux couches "local"
     masquent le bord tant qu'il reste du contenu cette-direction, deux couches
     "scroll" dessinent une ombre fixe par-dessus quand ce n'est pas le cas —
     l'ombre n'apparaît donc que si la table dépasse réellement du conteneur. */
  background:
    linear-gradient(to right, var(--surface) 30%, rgba(0,0,0,0)) 0 0,
    linear-gradient(to left, var(--surface) 30%, rgba(0,0,0,0)) 100% 0,
    linear-gradient(to right, rgba(0,0,0,.12), rgba(0,0,0,0)) 0 0,
    linear-gradient(to left, rgba(0,0,0,.12), rgba(0,0,0,0)) 100% 0;
  background-repeat: no-repeat;
  background-color: var(--surface);
  background-size: 24px 100%, 24px 100%, 10px 100%, 10px 100%;
  background-attachment: local, local, scroll, scroll;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

th {
  background: var(--bg);
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--surface-2);
  color: var(--ink);
  font-size: 13px;
}

tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg); }

/* ============================================
   BADGES
   ============================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.badge-success { background: var(--ok-soft); color: #065f46; }
.badge-warning { background: var(--warn-soft); color: #92400e; }
.badge-danger { background: var(--danger-soft); color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e3a8a; }
.badge-secondary { background: var(--surface-2); color: var(--ink-soft); }
.badge-purple { background: var(--accent-violet-soft); color: #5b21b6; }
.badge-cyan { background: var(--accent-cyan-soft); color: #0e7490; }

/* Priority badges */
.badge-urgente { background: var(--danger-soft); color: #991b1b; }
.badge-importante { background: var(--warn-soft); color: #92400e; }
.badge-normale { background: var(--ok-soft); color: #065f46; }
.badge-basse { background: var(--surface-2); color: var(--ink-soft); }

/* Status badges */
.badge-publie, .badge-active, .badge-disponible, .badge-complete, .badge-paye, .badge-approuve { background: var(--ok-soft); color: #065f46; }
.badge-brouillon, .badge-nouveau, .badge-recue { background: var(--surface-2); color: var(--ink-soft); }
.badge-en_traitement, .badge-en_integration, .badge-beta { background: #dbeafe; color: #1e3a8a; }
.badge-en_attente, .badge-en_revision, .badge-demande { background: var(--warn-soft); color: #92400e; }
.badge-archive, .badge-inactive, .badge-suspendue, .badge-ferme, .badge-refuse { background: var(--danger-soft); color: #991b1b; }
.badge-expediee { background: var(--accent-violet-soft); color: #5b21b6; }
.badge-bientot { background: var(--accent-cyan-soft); color: #0e7490; }

/* ============================================
   BUTTONS
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { text-decoration: none; }
.btn:focus { outline: none; }

.btn-sm { padding: 5px 10px; font-size: 12px; gap: 5px; }
.btn-lg { padding: 11px 22px; font-size: 14px; }
.btn-icon { padding: 8px; gap: 0; }

.btn-primary { background: var(--indigo); color: var(--white); border-color: var(--indigo); }
.btn-primary:hover { background: #1e40af; border-color: #1e40af; color: var(--white); }

.btn-success { background: var(--ok); color: var(--white); border-color: var(--ok); }
.btn-success:hover { background: #059669; color: var(--white); }

.btn-danger { background: var(--danger); color: var(--white); border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; color: var(--white); }

.btn-warning { background: var(--warn); color: var(--white); border-color: var(--warn); }
.btn-warning:hover { background: #d97706; color: var(--white); }

.btn-secondary { background: var(--surface); color: var(--ink-soft); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--bg); color: var(--ink-strong); }

.btn-outline { background: transparent; color: var(--indigo); border-color: var(--indigo); }
.btn-outline:hover { background: var(--indigo); color: var(--white); }

.btn-ghost { background: transparent; color: var(--ink-soft); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink-strong); }

/* ============================================
   FORMS
   ============================================ */

.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-control {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--ink);
  background: var(--surface);
  transition: var(--transition);
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(26,86,219,0.08);
}

.form-control::placeholder { color: var(--faint); }

select.form-control { cursor: pointer; }

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

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.form-check input { cursor: pointer; }
.form-check label { font-size: 13px; color: var(--ink-soft); cursor: pointer; }

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

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

/* ============================================
   ALERTS
   ============================================ */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}

.alert i { margin-top: 1px; flex-shrink: 0; font-size: 15px; }

.alert-success { background: var(--ok-soft); color: #065f46; border: 1px solid #a7f3d0; }
.alert-warning { background: var(--warn-soft); color: #92400e; border: 1px solid #fcd34d; }
.alert-danger { background: var(--danger-soft); color: #991b1b; border: 1px solid #fca5a5; }
.alert-info { background: #dbeafe; color: #1e3a8a; border: 1px solid #93c5fd; }

/* ============================================
   FILTERS BAR
   ============================================ */

.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  background: var(--surface);
  padding: 14px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--surface-2);
}

.filter-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.filters-bar select,
.filters-bar input {
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--ink);
  background: var(--bg);
  transition: var(--transition);
  min-width: 140px;
}

.filters-bar select:focus,
.filters-bar input:focus {
  outline: none;
  border-color: var(--indigo);
  background: var(--surface);
}

.view-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.view-toggle-btn {
  background: none;
  border: none;
  width: 30px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  color: var(--faint);
  cursor: pointer;
  font-size: 13px;
  transition: var(--transition);
}

.view-toggle-btn:hover {
  color: var(--ink);
}

.view-toggle-btn.active {
  background: var(--surface);
  color: var(--indigo);
  box-shadow: var(--shadow);
}

/* ============================================
   NEWS CARDS
   ============================================ */

.news-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 18px;
  transition: var(--transition);
  cursor: pointer;
  display: block;
}

.news-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--indigo);
  text-decoration: none;
}

.news-card.pinned { border-left: 4px solid var(--indigo); }
.news-card.urgente { border-left: 4px solid var(--danger); }
.news-card.importante { border-left: 4px solid var(--warn); }

.news-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.news-date {
  font-size: 11px;
  color: var(--muted);
}

.news-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-strong);
  margin-bottom: 8px;
  line-height: 1.4;
}

.news-excerpt {
  font-size: 13px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================================
   TOOL CARDS
   ============================================ */

.tool-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 20px;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tool-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--indigo);
}

.tool-fav-star {
  background: none;
  border: none;
  color: var(--line-strong);
  font-size: 15px;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--transition);
}

.tool-fav-star:hover { background: var(--surface-2); color: var(--muted); }
.tool-fav-star.active { color: #f59e0b; }

.tool-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #dbeafe, var(--accent-cyan-soft));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--indigo);
}

.tool-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-strong);
}

.tool-description {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  flex: 1;
}

.tool-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ============================================
   GROUP CARDS
   ============================================ */

.group-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  overflow: hidden;
  transition: var(--transition);
}

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

.group-card-image {
  height: 160px;
  background: linear-gradient(135deg, var(--indigo-deep), var(--indigo));
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.group-card-image .destination-icon {
  font-size: 60px;
  opacity: 0.3;
}

.group-card-image .destination-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px;
  background: linear-gradient(transparent, rgba(0,0,0,0.6));
  color: white;
}

.group-card-image .destination-name {
  font-size: 16px;
  font-weight: 700;
  color: white;
}

.group-card-body {
  padding: 16px;
}

.group-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-strong);
  margin-bottom: 8px;
  line-height: 1.4;
}

.group-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.group-meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.group-meta-item i { color: var(--indigo); font-size: 12px; width: 14px; }

.group-price {
  font-size: 18px;
  font-weight: 700;
  color: var(--indigo);
}

.group-price span {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
}

.spots-bar {
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  margin: 8px 0;
  overflow: hidden;
}

.spots-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ok), var(--accent-cyan));
  border-radius: 2px;
}

/* ============================================
   SUPPLIER CARD
   ============================================ */

.supplier-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 16px;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.supplier-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--indigo);
}

.supplier-logo {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--indigo);
}

/* ============================================
   PRODUCT CARDS (Shop)
   ============================================ */

.product-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  overflow: hidden;
  transition: var(--transition);
}

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

.product-image {
  height: 180px;
  background: linear-gradient(135deg, var(--surface-2), var(--line));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  color: var(--faint);
}

.product-body {
  padding: 16px;
}

.product-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-strong);
  margin-bottom: 6px;
}

.product-description {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-price {
  font-size: 20px;
  font-weight: 700;
  color: var(--indigo);
}

/* ============================================
   CHART CONTAINER
   ============================================ */

.chart-container {
  position: relative;
  height: 220px;
  width: 100%;
}

/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.empty-state i {
  font-size: 48px;
  margin-bottom: 16px;
  display: block;
  color: var(--line-strong);
}

.empty-state p {
  font-size: 14px;
  color: var(--muted);
  margin-top: 8px;
}

/* ============================================
   COMMISSION TABLE
   ============================================ */

.commission-total-row td {
  font-weight: 700;
  background: var(--bg);
}

/* ============================================
   MODAL (simple)
   ============================================ */

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-backdrop.show {
  display: flex;
}

.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 520px;
  width: 90%;
  box-shadow: var(--shadow-lg);
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink-strong);
  margin-bottom: 20px;
}

/* ============================================
   LOGIN PAGE
   ============================================ */

.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--indigo-deep) 0%, #0a1628 50%, #071020 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 40%, rgba(26,86,219,0.12) 0%, transparent 50%),
              radial-gradient(circle at 70% 60%, rgba(6,182,212,0.08) 0%, transparent 50%);
}

.login-container {
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .logo-box {
  width: min(260px, 80vw);
  height: 96px;
  background: transparent;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.login-logo .logo-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.login-logo h1 {
  font-size: 20px;
  font-weight: 800;
  color: var(--white);
  margin-bottom: 4px;
}

.login-logo p {
  font-size: 13px;
  color: rgba(255,255,255,0.5);
}

.login-card {
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 36px;
}

.login-card .form-label {
  color: rgba(255,255,255,0.7);
}

.login-card .form-control {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.15);
  color: var(--white);
}

.login-card .form-control::placeholder { color: rgba(255,255,255,0.3); }
.login-card .form-control:focus {
  background: rgba(255,255,255,0.12);
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(26,86,219,0.25);
}

.login-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--indigo), #1e40af);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 8px;
  letter-spacing: 0.3px;
}

.login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(26,86,219,0.4);
}

.login-footer {
  text-align: center;
  margin-top: 24px;
}

.login-footer p {
  font-size: 12px;
  color: rgba(255,255,255,0.3);
}

/* ============================================
   AGENT CARD
   ============================================ */

.agent-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: var(--transition);
}

.agent-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--indigo);
}

.agent-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--indigo), var(--accent-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

/* ============================================
   DOCUMENT CARD
   ============================================ */

.doc-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: var(--transition);
}

.doc-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--indigo);
}

.doc-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--danger-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--danger);
  flex-shrink: 0;
}

/* ============================================
   MARKETING CARD
   ============================================ */

.marketing-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  overflow: hidden;
  transition: var(--transition);
}

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

.marketing-preview {
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  position: relative;
}

.marketing-body { padding: 14px; }

/* ============================================
   INFO ROW — ligne icône + libellé + valeur.
   Remplace le motif répété en style="display:flex;gap:10px;..."
   (fiches fournisseur, agence, mon agence).
   ============================================ */

.info-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  font-size: 13px;
}

.info-row + .info-row { border-top: 1px solid var(--surface-2); }

.info-row i {
  flex: none;
  width: 18px;
  text-align: center;
  margin-top: 1px;
  color: var(--indigo);
}

.info-row-label {
  flex: none;
  width: 110px;
  color: var(--muted);
}

.info-row-value {
  flex: 1;
  min-width: 0;
  color: var(--ink-strong);
  font-weight: 500;
  word-break: break-word;
}

/* ============================================
   LIST ROW — ligne cliquable (icône/point + texte + méta) utilisée pour
   les listes "dernières nouvelles / demandes récentes / documents" des
   tableaux de bord. :hover en CSS pur (remplace les onmouseover inline).
   ============================================ */

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 20px;
  color: inherit;
  text-decoration: none;
  transition: var(--transition);
}

.list-row + .list-row { border-top: 1px solid var(--surface-2); }

.list-row:hover {
  background: var(--bg);
  text-decoration: none;
}

.list-row-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.list-row-body { flex: 1; min-width: 0; }

.list-row-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-row-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}

/* ============================================
   CELL PRICE / STRONG — cellules de tableau mises en avant
   (montants, taux) : remplace les style="font-weight:700;color:..."
   répétés dans groupes / commissions / statistiques.
   ============================================ */

.cell-price {
  font-weight: 700;
  color: var(--indigo);
  font-variant-numeric: tabular-nums;
}

.cell-strong {
  font-weight: 700;
  color: var(--ink-strong);
}

/* ============================================
   SECTION DIVIDER — séparateur fin + titre optionnel, remplace les
   <div style="flex:1;height:1px;background:var(--line);"> répétés.
   ============================================ */

.section-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}

.section-divider::before,
.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.section-divider:empty { color: transparent; }
.section-divider:empty::before,
.section-divider:empty::after { flex: 1; }

/* ============================================
   EVENT ITEM / THREAD — liste d'événements horodatés (commentaires,
   journal d'audit, historique de points).
   ============================================ */

.event-thread { display: flex; flex-direction: column; gap: 0; }

.event-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--surface-2);
}

.event-thread .event-item:first-child { border-top: none; padding-top: 0; }

.event-item-icon {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.event-item-body { flex: 1; min-width: 0; }

.event-item-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.event-item-author { font-size: 13px; font-weight: 600; color: var(--ink-strong); }
.event-item-time { font-size: 11px; color: var(--muted); white-space: nowrap; }
.event-item-text { font-size: 13px; color: var(--ink); margin-top: 3px; }

/* ============================================
   REP CARD / ROW CARD — fiches représentant fournisseur, lignes de
   commission et de document dans un panneau (fiche fournisseur).
   ============================================ */

.row-card {
  padding: 16px 20px;
  border-bottom: 1px solid var(--surface-2);
}

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

.rep-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.rep-card-head .agent-avatar,
.rep-card-head img {
  width: 40px;
  height: 40px;
  font-size: 14px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
}

.rep-card-body { flex: 1; min-width: 0; }
.rep-card-name { font-weight: 600; font-size: 14px; color: var(--ink-strong); }
.rep-card-title,
.rep-card-location { font-size: 12px; color: var(--muted); }

.rep-card-actions { display: flex; gap: 4px; margin-left: auto; flex: none; }

.rep-card-contacts { display: flex; flex-direction: column; gap: 5px; }

.rep-card-contacts a {
  font-size: 12px;
  color: var(--indigo);
  display: flex;
  gap: 6px;
  align-items: center;
}

.rep-card-notes {
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 12px;
  color: var(--ink-soft);
}

.commission-row-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.commission-row-name { font-weight: 600; font-size: 13px; color: var(--ink-strong); }
.commission-row-rate { font-weight: 700; color: var(--ok); font-size: 14px; }
.commission-row-year { font-size: 11px; color: var(--muted); }
.commission-row-condition { font-size: 13px; color: var(--ink); margin-bottom: 4px; }
.commission-row-notes { font-size: 12px; color: var(--muted); }

.cart-line {
  display: flex;
  align-items: center;
  gap: 14px;
}

.cart-line-icon {
  width: 48px;
  height: 48px;
  background: var(--surface-2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--muted);
  flex: none;
}

.cart-line-body { flex: 1; min-width: 0; }
.cart-line-name { font-weight: 600; font-size: 14px; color: var(--ink-strong); }
.cart-line-meta { font-size: 12px; color: var(--muted); }
.cart-line-price { font-weight: 700; font-size: 16px; color: var(--indigo); }

.doc-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.doc-row-body { flex: 1; min-width: 0; }
.doc-row-title { font-size: 13px; font-weight: 600; }
.doc-row-meta { font-size: 11px; color: var(--muted); }

/* ============================================
   MISC
   ============================================ */

.btn-block { width: 100%; }
.flex-divider { flex: 1; height: 1px; background: var(--line); }
.text-muted { color: var(--muted); }
.text-small { font-size: 12px; }
.text-truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 20px; }
.mb-6 { margin-bottom: 24px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }

.fw-bold { font-weight: 700; }
.fw-600 { font-weight: 600; }

.color-blue { color: var(--indigo); }
.color-green { color: var(--ok); }
.color-orange { color: var(--warn); }
.color-red { color: var(--danger); }

.divider {
  height: 1px;
  background: var(--line);
  margin: 20px 0;
}

/* Urgent banner */
.urgent-banner {
  background: linear-gradient(135deg, #fee2e2, #fef2f2);
  border: 1px solid #fca5a5;
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.urgent-banner i { color: var(--danger); font-size: 18px; }
.urgent-banner strong { color: #991b1b; }
.urgent-banner p { color: #7f1d1d; font-size: 13px; }

/* Bannière "épinglé" — variante calme de urgent-banner, sur les tokens
   de couleur (donc thème-compatible), pour les nouvelles épinglées. */
.pinned-banner {
  background: var(--accent-cyan-soft);
  border: 1px solid var(--indigo-light);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.pinned-banner i { color: var(--indigo); font-size: 16px; }
.pinned-banner strong { color: var(--indigo-deep); font-size: 13px; }
.pinned-banner p { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Stats breakdown */
.stats-breakdown {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.stats-breakdown-item {
  flex: 1;
  min-width: 120px;
  text-align: center;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

/* Les requêtes de largeur (RESPONSIVE) vivent désormais en fin de feuille —
   voir le commentaire au-dessus de @media (max-width: 1200px). */

/* ============================================
   PALETTE DE COMMANDE (Ctrl+K)
   ============================================ */

/* z-index : au-dessus de l'en-tête collant (50) et du tiroir mobile (100),
   la palette est l'élément le plus haut de l'interface quand elle est ouverte. */
.palette-veil {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  z-index: 200;
}

.palette {
  position: fixed;
  left: 50%;
  top: 12vh;
  transform: translateX(-50%);
  width: min(640px, calc(100vw - 32px));
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 201;
  overflow: hidden;
}

.palette[hidden], .palette-veil[hidden] { display: none; }

.palette-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.palette-input-row i { color: var(--indigo); font-size: 17px; }

.palette-input-row input {
  flex: 1;
  min-width: 0;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-strong);
  outline: none;
}

.palette-input-row input::placeholder { color: var(--faint); }

.palette-esc {
  flex-shrink: 0;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  padding: 2px 6px;
}

.palette-results { overflow-y: auto; padding: 6px 0 10px; }

.palette-hint { margin: 0; padding: 14px 18px; font-size: 12.5px; color: var(--muted); }
.palette-hint kbd {
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--ink-soft);
}

.palette-group {
  padding: 10px 18px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--faint);
}

.palette-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 18px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink-strong);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.palette-item i { color: var(--muted); flex-shrink: 0; }
.palette-item:hover, .palette-item.is-active { background: var(--surface-2); text-decoration: none; }
.palette-item.is-active i { color: var(--indigo); }

.palette-item-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.palette-item-context { flex-shrink: 0; font-size: 12px; color: var(--faint); }

/* Question en langage naturel : action distincte des résultats directs. */
.palette-ask {
  margin: 8px 14px 4px;
  border: 1px dashed color-mix(in srgb, var(--indigo) 45%, var(--line));
  background: var(--surface-2);
  border-radius: 10px;
  padding: 0;
}

.palette-ask .palette-item { border-radius: 10px; }
.palette-ask .palette-item i { color: var(--indigo); }

.palette-state { padding: 14px 18px; font-size: 13px; color: var(--muted); }
.palette-state.is-error { color: var(--danger); }

.palette-answer { padding: 14px 18px; font-size: 13.5px; line-height: 1.55; color: var(--ink); white-space: pre-wrap; }

@media (max-width: 768px) {
  .palette { top: 6vh; max-height: 80vh; }
  .palette-esc { display: none; }
  .palette-item-context { display: none; }
}

/* ============================================
   FILE « À TRAITER » (tableau de bord)
   ============================================ */

.action-queue {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  overflow: hidden;
}

.action-queue-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.action-queue-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-strong);
}

.action-queue-head h2 i { color: var(--warn); margin-right: 4px; }
.action-queue-count { font-size: 12px; color: var(--muted); }
.action-queue-more { margin-left: auto; font-size: 12px; color: var(--faint); }

.action-queue-list { list-style: none; margin: 0; padding: 0; }

.action-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}

.action-item:last-child { border-bottom: none; }
.action-item:hover { background: var(--surface-2); }

.action-badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
}

/* Sévérité : le sens vient des jetons d'état, pas d'une couleur arbitraire. */
.action-badge.warn { background: var(--warn-soft); color: var(--warn); }
.action-badge.danger { background: var(--danger-soft); color: var(--danger); }
.action-badge.info { background: var(--accent-cyan-soft); color: var(--accent-cyan); }

.action-text { min-width: 0; flex: 1; }

.action-title {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-strong);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.action-title:hover { color: var(--indigo); text-decoration: underline; }

.action-subtitle {
  display: block;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.action-cta { flex-shrink: 0; }

/* ============================================
   BARRE D'ONGLETS MOBILE
   ============================================ */

.tabbar {
  display: none;   /* activée par la media query < 768 px ci-dessus */
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 98;     /* sous le tiroir (100) et son voile (99) */
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
}

.tabbar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 2px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  min-height: 48px;   /* cible tactile confortable */
  justify-content: center;
}

.tabbar-item:hover { text-decoration: none; color: var(--ink); }
.tabbar-item.active { color: var(--indigo); }

.tabbar-icon { position: relative; font-size: 19px; line-height: 1; }

.tabbar-badge {
  position: absolute;
  top: -4px;
  left: 11px;
  background: var(--warn);
  color: #1a1400;
  font-size: 9.5px;
  font-weight: 700;
  line-height: 15px;
  min-width: 15px;
  padding: 0 4px;
  border-radius: 10px;
  text-align: center;
}

.tabbar-label { line-height: 1.2; }

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 4px;
}

/* ============================================
   SIDEBAR RÉDUITE (icônes seulement)
   ============================================ */

:is(body.sidebar-collapsed, body.sidebar-rail) { --sidebar-width: var(--sidebar-width-collapsed); }

:is(body.sidebar-collapsed, body.sidebar-rail) .sidebar-brand {
  flex-direction: column;
  gap: 8px;
  padding: 16px 8px;
}

:is(body.sidebar-collapsed, body.sidebar-rail) .brand-text { display: none; }

:is(body.sidebar-collapsed, body.sidebar-rail) .sidebar-toggle-btn { margin-left: 0; }
:is(body.sidebar-collapsed, body.sidebar-rail) .sidebar-toggle-btn i { transform: rotate(180deg); }

:is(body.sidebar-collapsed, body.sidebar-rail) .sidebar-nav { padding: 12px 6px; }

:is(body.sidebar-collapsed, body.sidebar-rail) .nav-section-header { display: none; }
:is(body.sidebar-collapsed, body.sidebar-rail) .nav-section-items { display: block !important; }
:is(body.sidebar-collapsed, body.sidebar-rail) #favoritesList { display: block !important; }

:is(body.sidebar-collapsed, body.sidebar-rail) .nav-item-row { justify-content: center; }
:is(body.sidebar-collapsed, body.sidebar-rail) .nav-item {
  justify-content: center;
  padding: 10px;
}
:is(body.sidebar-collapsed, body.sidebar-rail) .nav-item .nav-label,
:is(body.sidebar-collapsed, body.sidebar-rail) .nav-item .badge,
:is(body.sidebar-collapsed, body.sidebar-rail) .nav-item-soon .nav-label,
:is(body.sidebar-collapsed, body.sidebar-rail) .nav-item-soon .badge {
  display: none;
}
:is(body.sidebar-collapsed, body.sidebar-rail) .nav-fav-star { display: none; }

:is(body.sidebar-collapsed, body.sidebar-rail) .sidebar-footer { padding: 14px 8px; }
:is(body.sidebar-collapsed, body.sidebar-rail) .sidebar-user {
  flex-direction: column;
  gap: 8px;
  padding: 8px 4px;
}
:is(body.sidebar-collapsed, body.sidebar-rail) .sidebar-user .user-info { display: none; }

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

.sidebar-overlay.show { display: block; }

/* ============================================
   VOCABULAIRE DE FORMULAIRE RICHE — centralisé depuis group_form.html,
   qui les avait définies en <style> local (invisible du reste de l'app).
   Réutilisable pour tout formulaire à sections/onglets/choix multiples.
   ============================================ */

.form-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  margin: 28px 0 14px;
  padding-top: 20px;
  border-top: 1px solid var(--surface-2);
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-section-title:first-of-type { margin-top: 0; padding-top: 0; border-top: none; }
.form-help { font-size: 12px; color: var(--muted); margin-top: 4px; }

.checkbox-grid { display: flex; flex-wrap: wrap; gap: 8px; }

.checkbox-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  background: var(--bg);
  transition: var(--transition);
}

.checkbox-pill:has(input:checked) { background: var(--indigo); border-color: var(--indigo); color: white; }

.lang-tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }

.lang-tab {
  background: none;
  border: none;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: var(--transition);
}

.lang-tab:hover { color: var(--ink-strong); }
.lang-tab.active { color: var(--indigo); border-bottom-color: var(--indigo); }

/* Commission summary cards */
.commission-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  background: var(--bg);
  border-radius: 10px;
  padding: 16px;
  margin: 8px 0 20px;
}

.commission-summary-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 4px;
}

.commission-summary-value { font-size: 20px; font-weight: 800; color: var(--ink-strong); }

@media (max-width: 768px) {
  .commission-summary { grid-template-columns: 1fr; }
}

/* Admin cards */
.admin-module-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: var(--transition);
  text-decoration: none;
  color: inherit;
}

.admin-module-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--indigo);
  text-decoration: none;
}

.admin-module-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

/* Scrollbar global */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--faint); }

/* Print */
/* Requêtes de largeur — placées en FIN de feuille, après toutes les
   règles de base : à spécificité égale, c'est la dernière déclaration
   qui gagne. Remonter ces blocs plus haut ferait réapparaître le bug
   où .mobile-menu-btn { display: none } annulait son propre affichage
   sur téléphone. */

@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-5 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
  :root { --sidebar-width: 220px; }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-5 { grid-template-columns: repeat(2, 1fr); }
  .page-content { padding: 20px; }
}

@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }
  .sidebar { transform: translateX(-260px); width: 260px; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
  .header { padding: 0 16px; }
  .mobile-menu-btn { display: flex; }
  .sidebar-toggle-btn { display: none; }

  /* La barre d'onglets est fixée en bas : on réserve sa hauteur sous le
     contenu, sinon elle masque la fin de page (et les boutons de formulaire).
     safe-area-inset-bottom = barre gestuelle des iPhone récents. */
  .tabbar { display: grid; }
  .page-content { padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }

  /* En-tête étroit : on garde l'agence active, l'information la plus utile,
     et on masque le rôle, le réseau et le séparateur plutôt que de laisser
     déborder (le réseau reste changeable depuis un écran plus large). */
  .context-switcher { padding: 5px 8px; gap: 4px; }
  .context-role,
  .context-network,
  .context-sep { display: none; }
  .context-form select, .context-value { max-width: 150px; font-size: 11.5px; }

  /* File à traiter : le bouton passe sous le texte au lieu de l'écraser. */
  .action-item { flex-wrap: wrap; gap: 8px 10px; }
  .action-text { flex-basis: 100%; order: 2; }
  .action-cta { order: 3; margin-left: auto; }
}

@media print {
  .sidebar, .header, .tabbar { display: none; }
  .main-content { margin-left: 0; }
  .page-content { padding: 0; }
}
