/* ============================================================
   GI-AO — Design system (traduit depuis src/index.css)
   Tous les tokens en HSL. Aucune couleur en dur dans les composants.
   ============================================================ */

/* ── Thème par défaut (QIG bleu) ────────────────────────────────────────── */
:root {
  --background: 210 25% 96%;
  --foreground: 215 35% 14%;
  --surface: 0 0% 100%;
  --surface-foreground: 215 35% 14%;
  --card: 0 0% 100%;
  --card-foreground: 215 35% 14%;
  --popover: 0 0% 100%;
  --popover-foreground: 215 35% 14%;
  --muted: 210 25% 94%;
  --muted-foreground: 215 16% 42%;
  --faint: 215 12% 58%;

  --primary: 209 71% 41%;
  --primary-foreground: 0 0% 100%;
  --primary-light: 209 79% 95%;
  --primary-dark: 215 60% 18%;

  --filiale-quatorze: 205 100% 35%;
  --filiale-qcc:      209 71% 35%;
  --filiale-qme:      203 73% 56%;
  --filiale-cube2:    185 100% 31%;
  --filiale-sofid:    199 78% 64%;
  --filiale-epione:   80 68% 44%;
  --filiale-basalte:  0 0% 24%;
  --filiale-mars:     17 81% 46%;

  --success: 158 64% 40%;
  --success-foreground: 0 0% 100%;
  --success-bg: 158 60% 94%;
  --warning: 33 90% 55%;
  --warning-foreground: 0 0% 10%;
  --warning-bg: 38 95% 94%;
  --destructive: 0 75% 55%;
  --destructive-foreground: 0 0% 100%;
  --destructive-bg: 0 80% 96%;
  --gold: 43 78% 56%;
  --gold-foreground: 0 0% 10%;

  --border: 215 22% 90%;
  --border-strong: 215 18% 80%;
  --input: 215 22% 90%;
  --ring: 209 71% 41%;

  --radius: 0.875rem;
  --radius-sm: 0.5rem;

  --shadow-sm: 0 1px 2px 0 hsl(215 30% 20% / 0.04);
  --shadow-md: 0 6px 20px -6px hsl(215 30% 20% / 0.08);
  --shadow-lg: 0 20px 40px -12px hsl(215 30% 20% / 0.12);

  --secondary: 210 25% 94%;
  --secondary-foreground: 215 35% 14%;
  --accent: 209 79% 95%;
  --accent-foreground: 209 71% 31%;

  --sidebar-background: 215 55% 11%;
  --sidebar-foreground: 210 30% 88%;
  --sidebar-primary: 209 85% 58%;
  --sidebar-primary-foreground: 0 0% 100%;
  --sidebar-accent: 215 45% 20%;
  --sidebar-accent-foreground: 0 0% 100%;
  --sidebar-border: 215 40% 20%;
  --sidebar-ring: 209 85% 58%;
}

/* ── Thème : Bord de mer ─────────────────────────────────────────────────── */
:root[data-theme="bord-de-mer"] {
  --background: 38 60% 96%;
  --foreground: 205 50% 14%;
  --surface: 38 70% 99%;
  --surface-foreground: 205 50% 14%;
  --card: 38 70% 99%;
  --card-foreground: 205 50% 14%;
  --popover: 38 70% 99%;
  --popover-foreground: 205 50% 14%;
  --muted: 38 45% 92%;
  --muted-foreground: 205 25% 36%;
  --faint: 205 15% 58%;
  --primary: 195 70% 38%;
  --primary-foreground: 0 0% 100%;
  --primary-light: 195 75% 93%;
  --primary-dark: 200 80% 24%;
  --success: 165 55% 38%;
  --success-foreground: 0 0% 100%;
  --success-bg: 165 50% 92%;
  --warning: 33 90% 58%;
  --warning-foreground: 0 0% 10%;
  --warning-bg: 38 95% 90%;
  --destructive: 5 75% 52%;
  --destructive-foreground: 0 0% 100%;
  --destructive-bg: 8 80% 94%;
  --gold: 38 85% 60%;
  --gold-foreground: 0 0% 10%;
  --border: 38 30% 86%;
  --border-strong: 38 25% 76%;
  --input: 38 30% 86%;
  --ring: 195 70% 38%;
  --secondary: 38 45% 92%;
  --secondary-foreground: 205 50% 14%;
  --accent: 195 75% 93%;
  --accent-foreground: 200 80% 24%;
  --sidebar-background: 200 60% 12%;
  --sidebar-foreground: 200 25% 88%;
  --sidebar-primary: 195 80% 55%;
  --sidebar-primary-foreground: 0 0% 100%;
  --sidebar-accent: 200 50% 20%;
  --sidebar-accent-foreground: 0 0% 100%;
  --sidebar-border: 200 40% 20%;
  --sidebar-ring: 195 80% 55%;
}

/* ── Thème : Coucher de soleil ──────────────────────────────────────────── */
:root[data-theme="coucher-de-soleil"] {
  --background: 30 50% 97%;
  --foreground: 15 40% 14%;
  --surface: 30 60% 99%;
  --surface-foreground: 15 40% 14%;
  --card: 30 60% 99%;
  --card-foreground: 15 40% 14%;
  --popover: 30 60% 99%;
  --popover-foreground: 15 40% 14%;
  --muted: 28 40% 93%;
  --muted-foreground: 15 25% 36%;
  --faint: 15 18% 56%;
  --primary: 16 78% 50%;
  --primary-foreground: 0 0% 100%;
  --primary-light: 22 90% 94%;
  --primary-dark: 8 70% 32%;
  --success: 145 40% 38%;
  --success-foreground: 0 0% 100%;
  --success-bg: 145 38% 92%;
  --warning: 38 90% 56%;
  --warning-foreground: 0 0% 10%;
  --warning-bg: 38 95% 92%;
  --destructive: 350 70% 48%;
  --destructive-foreground: 0 0% 100%;
  --destructive-bg: 350 75% 95%;
  --gold: 38 85% 58%;
  --gold-foreground: 0 0% 10%;
  --border: 28 30% 86%;
  --border-strong: 28 25% 76%;
  --input: 28 30% 86%;
  --ring: 16 78% 50%;
  --secondary: 28 40% 93%;
  --secondary-foreground: 15 40% 14%;
  --accent: 22 90% 94%;
  --accent-foreground: 8 70% 32%;
  --sidebar-background: 15 50% 12%;
  --sidebar-foreground: 28 30% 88%;
  --sidebar-primary: 16 85% 58%;
  --sidebar-primary-foreground: 0 0% 100%;
  --sidebar-accent: 15 40% 22%;
  --sidebar-accent-foreground: 0 0% 100%;
  --sidebar-border: 15 35% 22%;
  --sidebar-ring: 16 85% 58%;
}

/* ── Thème : Ardoise (sombre) ───────────────────────────────────────────── */
:root[data-theme="ardoise"] {
  --background: 220 18% 10%;
  --foreground: 210 20% 92%;
  --surface: 220 16% 14%;
  --surface-foreground: 210 20% 92%;
  --card: 220 16% 14%;
  --card-foreground: 210 20% 92%;
  --popover: 220 16% 14%;
  --popover-foreground: 210 20% 92%;
  --muted: 220 14% 18%;
  --muted-foreground: 215 15% 65%;
  --faint: 215 10% 55%;
  --primary: 200 90% 55%;
  --primary-foreground: 220 30% 8%;
  --primary-light: 200 50% 22%;
  --primary-dark: 200 90% 70%;
  --success: 150 55% 48%;
  --success-foreground: 0 0% 8%;
  --success-bg: 150 40% 18%;
  --warning: 38 90% 60%;
  --warning-foreground: 0 0% 8%;
  --warning-bg: 38 40% 18%;
  --destructive: 0 70% 55%;
  --destructive-foreground: 0 0% 100%;
  --destructive-bg: 0 40% 20%;
  --gold: 43 70% 60%;
  --gold-foreground: 0 0% 8%;
  --border: 220 14% 22%;
  --border-strong: 220 14% 30%;
  --input: 220 14% 22%;
  --ring: 200 90% 55%;
  --secondary: 220 14% 18%;
  --secondary-foreground: 210 20% 92%;
  --accent: 200 50% 22%;
  --accent-foreground: 200 90% 80%;
  --sidebar-background: 220 18% 12%;
  --sidebar-foreground: 215 15% 70%;
  --sidebar-primary: 200 90% 55%;
  --sidebar-primary-foreground: 220 30% 8%;
  --sidebar-accent: 220 14% 18%;
  --sidebar-accent-foreground: 210 20% 92%;
  --sidebar-border: 220 14% 22%;
  --sidebar-ring: 200 90% 55%;
}

/* ── Reset & base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100vh;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: "Plus Jakarta Sans", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
  font-size: 14px;
  line-height: 1.5;
}

h1, h2, h3, h4 {
  font-family: "Plus Jakarta Sans", "Inter", sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ── Utilitaires ─────────────────────────────────────────────────────────── */
.font-display { font-family: "Fraunces", Georgia, serif; }
.text-faint   { color: hsl(var(--faint)); }
.truncate     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only      { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ── Toast notifications ─────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}
.toast {
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--foreground));
  min-width: 280px;
  max-width: 380px;
  animation: toast-in 0.2s ease;
}
.toast.toast-success { border-left: 4px solid hsl(var(--success)); }
.toast.toast-error   { border-left: 4px solid hsl(var(--destructive)); }
.toast.toast-warning { border-left: 4px solid hsl(var(--warning)); }
.toast.toast-info    { border-left: 4px solid hsl(var(--primary)); }
.toast-out           { animation: toast-out 0.2s ease forwards; }

@keyframes toast-in  { from { opacity: 0; transform: translateX(1rem); } to { opacity: 1; transform: none; } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; transform: translateX(1rem); } }

/* ── Layout shell ────────────────────────────────────────────────────────── */
#app {
  display: flex;
  min-height: 100vh;
  background: hsl(var(--background));
}

/* Sidebar */
#sidebar {
  width: 72px;
  flex-shrink: 0;
  background: hsl(var(--sidebar-background));
  color: hsl(var(--sidebar-foreground));
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 0;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

#sidebar .sidebar-logo {
  width: 3rem;
  height: 3rem;
  border-radius: 0.75rem;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  ring: 1px solid rgba(255,255,255,.1);
}
#sidebar .sidebar-logo img {
  width: 160%;          /* zoom — augmenter pour agrandir davantage */
  height: 160%;
  object-fit: cover;
  object-position: 50% 40%; /* décalage X Y — ajuster pour cadrer */
  padding: 0;
}

.sidebar-divider {
  width: 2rem;
  height: 1px;
  background: hsl(var(--sidebar-border));
  margin: 1rem 0;
}

#sidebar nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  overflow-y: auto;
  width: 100%;
  padding: 0 0.5rem;
  scrollbar-width: none;
}
#sidebar nav::-webkit-scrollbar { display: none; }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.75rem;
  color: hsl(var(--sidebar-foreground));
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  background: transparent;
  border: none;
}
.nav-item:hover {
  background: hsl(var(--sidebar-accent));
  color: hsl(var(--sidebar-accent-foreground));
}
.nav-item.active {
  background: hsl(var(--sidebar-primary));
  color: hsl(var(--sidebar-primary-foreground));
  box-shadow: var(--shadow-md);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -0.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 1.5rem;
  background: hsl(var(--sidebar-primary));
  border-radius: 0 2px 2px 0;
}
.nav-item svg { width: 1.25rem; height: 1.25rem; }

/* Pastille orange : notifications non lues concernant cette section */
.nav-item .nav-dot {
  position: absolute;
  top: 0.3rem;
  right: 0.3rem;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #f59e0b;
  border: 2px solid hsl(var(--sidebar-background));
  pointer-events: none;
}

/* Tooltip sidebar */
.nav-tooltip {
  position: absolute;
  left: calc(100% + 0.75rem);
  top: 50%;
  transform: translateY(-50%);
  background: hsl(var(--popover));
  color: hsl(var(--popover-foreground));
  border: 1px solid hsl(var(--border));
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
  z-index: 100;
}
.nav-item:hover .nav-tooltip { opacity: 1; }

#sidebar-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0.5rem 0;
  margin-top: 0.5rem;
  border-top: 1px solid hsl(var(--sidebar-border));
  width: 100%;
}

/* Main area */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Topbar */
#topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 4rem;
  background: hsl(var(--card) / 0.8);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid hsl(var(--border));
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  gap: 1rem;
}

#topbar-left   { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
#topbar-center { display: flex; flex: 1; justify-content: center; }
#topbar-right  { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }

#page-title {
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.02em;
  color: hsl(var(--foreground));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Content */
#content {
  flex: 1;
  overflow: auto;
  padding: 1.5rem;
}

/* ── Filiale filter bar ───────────────────────────────────────────────────── */
#filiale-filter {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}

.filiale-btn {
  height: 2.25rem;
  padding: 0 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  transition: all 0.15s;
}
.filiale-btn:hover { color: hsl(var(--foreground)); background: hsl(var(--muted)); }
.filiale-btn.active {
  background: hsl(var(--primary) / 0.15);
  color: hsl(var(--primary));
  border-color: hsl(var(--primary));
}

.filiale-icon-btn {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  cursor: pointer;
  opacity: 0.6;
  transition: all 0.15s;
  font-size: 0.6875rem;
  font-weight: 800;
  color: hsl(var(--foreground));
}
.filiale-icon-btn:hover { opacity: 1; background: hsl(var(--muted)); }
.filiale-icon-img { max-width: 1.5rem; max-height: 1.5rem; object-fit: contain; }
.filiale-icon-stack { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; line-height: 1; }
.filiale-icon-stack .filiale-icon-img { max-height: 1.1rem; }
.filiale-icon-caption { font-size: .5rem; font-weight: 800; letter-spacing: .02em; color: inherit; }
.filiale-icon-btn.active {
  opacity: 1;
  background: hsl(var(--primary) / 0.1);
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 2px hsl(var(--primary) / 0.3);
}

/* ── User menu ──────────────────────────────────────────────────────────── */
#user-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: 9999px;
  padding: 0.25rem 0.75rem 0.25rem 0.25rem;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s;
}
#user-btn:hover { background: hsl(var(--muted)); }

.user-avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 9999px;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  flex-shrink: 0;
}

.user-meta { display: none; }
@media (min-width: 640px) {
  .user-meta { display: block; text-align: left; line-height: 1.2; }
  .user-meta .user-name { font-size: 0.875rem; font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .user-meta .user-role { font-size: 0.75rem; color: hsl(var(--muted-foreground)); }
}

#user-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  width: 14rem;
  background: hsl(var(--popover));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 0.5rem;
  z-index: 100;
  display: none;
}
#user-dropdown.open { display: block; }
#user-dropdown .dropdown-header { padding: 0.375rem 0.5rem 0.625rem; }
#user-dropdown .dropdown-header .name { font-size: 0.875rem; font-weight: 600; }
#user-dropdown .dropdown-header .role { font-size: 0.75rem; color: hsl(var(--muted-foreground)); }
#user-dropdown .dropdown-divider { height: 1px; background: hsl(var(--border)); margin: 0.25rem 0; }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: calc(var(--radius-sm) / 2);
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  text-decoration: none;
  cursor: pointer;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  transition: background 0.1s;
}
.dropdown-item:hover { background: hsl(var(--muted)); }
.dropdown-item svg { width: 1rem; height: 1rem; }

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid hsl(var(--border));
  border-top-color: hsl(var(--primary));
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Mobile (portrait ≤ 767px) ───────────────────────────────────────────── */
@media (max-width: 767px) {

  /* Sidebar en tiroir */
  #sidebar {
    position: fixed;
    left: 0; top: 0;
    height: 100%;
    transform: translateX(-100%);
    transition: transform 0.2s;
  }
  #sidebar.open { transform: translateX(0); }
  #sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 39;
  }
  #sidebar-overlay.open { display: block; }
  #mobile-menu-btn { display: flex; }
  #topbar-center { display: none; }

  /* Zone de contenu */
  #content { padding: 0.75rem; }
  .card-body   { padding: 0.875rem; }
  .card-header { padding: 0.75rem 0.875rem 0.625rem; }

  /* ── Tables ── */
  /* Le card conteneur devient scrollable horizontalement */
  .card { overflow-x: auto; }
  table.data-table th {
    padding: 0.4rem 0.5rem;
    font-size: 0.65rem;
    white-space: nowrap;
  }
  table.data-table td {
    padding: 0.5rem 0.5rem;
    font-size: 0.8rem;
  }

  /* ── Tabs ── */
  /* Défilement horizontal sans retour à la ligne */
  .tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn {
    flex-shrink: 0;
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }

  /* ── Barres d'action et de filtres ── */
  /* Classe .toolbar à ajouter sur les div action/filtre dans les pages JS */
  .toolbar {
    flex-wrap: wrap;
    gap: 0.5rem !important;
  }
  .toolbar .input  { width: 100% !important; min-width: 0; }
  .toolbar select.input { width: 100% !important; }
  .toolbar .btn { flex: 1 1 auto; justify-content: center; }

  /* ── Modals ── */
  /* Apparaissent en feuille depuis le bas */
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }
  .modal, .modal.modal-lg {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92vh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: 1rem;
    border-top-right-radius: 1rem;
  }

  /* ── Topbar ── */
  #topbar { padding: 0 0.75rem; gap: 0.5rem; }
  #page-title { font-size: 1rem; }

  /* ── Badges ── */
  .badge { font-size: 0.6rem; padding: 0.1rem 0.35rem; }

  /* ── Boutons ── */
  .btn-sm { font-size: 0.75rem; padding: 0.2rem 0.5rem; }
}

@media (min-width: 768px) {
  #mobile-menu-btn { display: none; }
}

/* ══ Parcours directeur — portrait téléphone (≤ 767px) ═══════════════════════
   Classes marqueuses (.dz-*) posées sur les conteneurs des vues que les
   directeurs doivent utiliser : réponse GO/NO GO + CV/Réf (demarrer),
   fiche AO (ao-detail), fiche détail Veille (modale). Les styles inline
   d'origine restent la référence sur ≥ 768px — rien n'est modifié sur PC. */
@media (max-width: 767px) {

  /* Page : marges resserrées, pleine largeur */
  .dz-page {
    padding: 0.85rem 0 3rem !important;
    max-width: 100% !important;
  }

  /* Grille clé/valeur (Contexte de l'AO) → une colonne, valeur sous le libellé */
  .dz-kv {
    grid-template-columns: 1fr !important;
    gap: 0.1rem 0 !important;
  }
  .dz-kv dt { margin-top: 0.55rem; }
  .dz-kv dt:first-child { margin-top: 0; }

  /* Ligne clé/valeur (modale détail Veille) → empilée */
  .dz-kvrow { flex-direction: column !important; gap: 0.15rem !important; }
  .dz-kvrow > span:first-child { width: auto !important; }

  /* Recherche + panneau de sélection (1fr 340px) → une colonne */
  .dz-split { grid-template-columns: 1fr !important; }

  /* Panneau « Composition » : plus de sticky, hauteur libre, sous la recherche */
  .dz-aside {
    position: static !important;
    top: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  /* Barres de filtres corpus → champs empilés pleine largeur */
  .dz-filters { flex-direction: column !important; align-items: stretch !important; }
  .dz-filters > * {
    width: 100% !important;
    min-width: 0 !important;
    flex: none !important;
  }

  /* Grille de résultats (CV / réf) → une carte par ligne, sans scroll interne */
  .dz-cardgrid {
    grid-template-columns: 1fr !important;
    max-height: none !important;
    overflow: visible !important;
    padding-right: 0 !important;
  }

  /* Onglets internes (Références / CVs / Partenaires) → défilement horizontal */
  .dz-scrollx-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .dz-scrollx-tabs::-webkit-scrollbar { display: none; }
  .dz-scrollx-tabs > * { flex-shrink: 0; }

  /* Barre GO / NO GO (demarrer) → boutons pleine largeur */
  .dz-actions { align-items: stretch !important; }
  .dz-actions .dz-actions-row { width: 100%; }
  .dz-actions .dz-actions-row .btn { flex: 1; justify-content: center; }

  /* Boutons d'action de l'en-tête fiche AO → empilés pleine largeur */
  .dz-hdr-actions { width: 100%; flex-direction: column; align-items: stretch !important; }
  .dz-hdr-actions .btn { justify-content: center; }

  /* Pied de la modale « détail Veille » (boutons GO/NO GO groupés dans des
     sous-div) → chaque groupe passe pleine largeur, boutons répartis */
  #modal-detail .modal-footer { flex-wrap: wrap; }
  #modal-detail .modal-footer > div { display: flex; gap: 0.5rem; flex: 1 1 100%; }
  #modal-detail .modal-footer > div .btn { flex: 1; justify-content: center; }
}

/* ── Shared card/table primitives ────────────────────────────────────────── */
.card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header { padding: 1rem 1.25rem 0.75rem; border-bottom: 1px solid hsl(var(--border)); }
.card-body   { padding: 1.25rem; }

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  white-space: nowrap;
}
.badge-default  { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }
.badge-primary  { background: hsl(var(--primary-light)); color: hsl(var(--primary)); }
.badge-success  { background: hsl(var(--success-bg)); color: hsl(var(--success)); }
.badge-warning  { background: hsl(var(--warning-bg)); color: hsl(var(--warning-foreground)); }
.badge-danger   { background: hsl(var(--destructive-bg)); color: hsl(var(--destructive)); }
.badge-gold      { background: hsl(var(--gold) / .2); color: hsl(var(--gold-foreground)); }
.badge-secondary { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn svg { width: 1rem; height: 1rem; }
.btn-primary  { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); border-color: hsl(var(--primary)); }
.btn-primary:hover { filter: brightness(1.1); }
.btn-secondary{ background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); border-color: hsl(var(--border)); }
.btn-secondary:hover { background: hsl(var(--muted)); }
.btn-ghost    { background: transparent; color: hsl(var(--foreground)); border-color: transparent; }
.btn-ghost:hover { background: hsl(var(--muted)); }
.btn-danger   { background: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); }
.btn-danger:hover { filter: brightness(1.1); }
.btn-sm       { padding: 0.25rem 0.625rem; font-size: 0.8125rem; }
.btn-icon     { padding: 0.5rem; }
.btn:disabled { opacity: 0.5; pointer-events: none; }

.input {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid hsl(var(--input));
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}
.input::placeholder { color: hsl(var(--muted-foreground)); }

select.input { cursor: pointer; }

/* Éditeur de signature (contenteditable) — placeholder simulé, l'attribut
   HTML natif ne s'applique qu'aux <input>/<textarea>. */
.sig-rich-edit:empty::before {
  content: 'Collez votre signature ici…';
  color: hsl(var(--muted-foreground));
  pointer-events: none;
}
/* Le Preflight de Tailwind (chargé globalement) force `img { display:block }`,
   ce qui casse les signatures dont les images sont censées s'afficher à la
   suite (inline) — comme elles le seront réellement à la réception du mail,
   un client de messagerie n'appliquant pas ce reset. On restaure le
   comportement natif dans l'éditeur pour que l'aperçu d'édition corresponde
   à l'email réellement envoyé. */
.sig-rich-edit img { display: inline; }
textarea.input { resize: vertical; min-height: 4rem; }

.label { display: block; font-size: 0.8125rem; font-weight: 500; margin-bottom: 0.25rem; color: hsl(var(--foreground)); }

table.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
table.data-table th {
  padding: 0.625rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: hsl(var(--muted-foreground));
  border-bottom: 1px solid hsl(var(--border));
  white-space: nowrap;
}
table.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid hsl(var(--border));
  vertical-align: middle;
}
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: hsl(var(--muted) / 0.5); }

/* ── Modal ──────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal {
  background: hsl(var(--card));
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 36rem;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-lg { max-width: 52rem; }
.modal-xl { max-width: min(80vw, 100rem); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid hsl(var(--border));
}
.modal-header h2 { font-size: 1.0625rem; font-weight: 700; }
.modal-body  { padding: 1.25rem; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 0.875rem 1.25rem;
  border-top: 1px solid hsl(var(--border));
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ── Tabs ────────────────────────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 1px solid hsl(var(--border)); gap: 0; }
.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.625rem 1rem;
  border: none;
  background: transparent;
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.tab-btn:hover { color: hsl(var(--foreground)); }
.tab-btn.active { color: hsl(var(--primary)); border-bottom-color: hsl(var(--primary)); }

/* ── Colonnes mobiles masquées / tableau extensible ─────────────────────── */

/* Sur desktop : toujours visibles */
.col-m-hide { display: table-cell; }
.table-expand-btn { display: none; }

@media (max-width: 767px) {
  /* Colonnes secondaires masquées par défaut */
  .col-m-hide { display: none !important; }

  /* Table : layout auto pour les colonnes visibles seulement */
  table.data-table { table-layout: auto !important; }

  /* Quand le card est étendu : tout apparaît + scroll horizontal */
  .card.table-expanded { overflow-x: auto !important; }
  .card.table-expanded .col-m-hide { display: table-cell !important; }
  .card.table-expanded table.data-table {
    table-layout: auto !important;
    min-width: max-content;
  }

  /* Bouton expand injecté en bas du card */
  .table-expand-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .375rem;
    width: 100%;
    padding: .5rem 1rem;
    font-size: .8rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    background: hsl(var(--muted) / 0.4);
    border: none;
    border-top: 1px solid hsl(var(--border));
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
  }
  .table-expand-btn:hover {
    background: hsl(var(--muted));
    color: hsl(var(--foreground));
  }
  .table-expand-btn svg { width: .875rem; height: .875rem; }
}

/* ── Loader page ─────────────────────────────────────────────────────────── */
#page-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 60vh;
  flex-direction: column;
  gap: 1rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
}
