/* ============================================================
   F|FIRST — Design System
   ============================================================ */

:root {
  --purple-50:  #EEEDFE;
  --purple-100: #D8D6FD;
  --purple-600: #534AB7;
  --purple-700: #3C3489;
  --purple-900: #1E1A55;

  --teal-50:  #E1F5EE;
  --teal-100: #C2EBD9;
  --teal-600: #0F6E56;
  --teal-700: #085041;

  --amber-50:  #FAEEDA;
  --amber-600: #854F0B;
  --amber-700: #633806;

  --blue-50:  #E6F1FB;
  --blue-600: #185FA5;
  --blue-700: #0C447C;

  --red-50:   #FAECE7;
  --red-600:  #C0392B;
  --red-700:  #712B13;

  --neutral-0:   #FFFFFF;
  --neutral-50:  #F8F7F4;
  --neutral-100: #F0EFE9;
  --neutral-200: #E2E0D8;
  --neutral-300: #C8C6BB;
  --neutral-500: #73726C;
  --neutral-700: #3D3D3A;
  --neutral-900: #1A1A18;

  --sidebar-w: 224px;
  --header-h:  52px;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.14);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "SF Mono", "Fira Code", monospace;
}

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

/* Garantit que l'attribut HTML hidden l'emporte sur tout display CSS */
[hidden] { display: none !important; }

html { font-size: 14px; }

body {
  font-family: var(--font);
  color: var(--neutral-700);
  background: var(--neutral-50);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── LOGIN ─────────────────────────────────────────────────── */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--neutral-50);
}

.login-card {
  background: var(--neutral-0);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-md);
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2rem;
}

.login-logo-img {
  height: 48px;
  width: auto;
  margin-bottom: 6px;
}

.logo-text {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--purple-700);
  letter-spacing: -0.03em;
}

.logo-sep { color: var(--teal-600); }

.login-subtitle {
  font-size: .75rem;
  color: var(--neutral-500);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-top: 2px;
}

.form-error {
  background: var(--red-50);
  color: var(--red-600);
  border-radius: var(--radius-sm);
  padding: .5rem .75rem;
  font-size: .8125rem;
  margin-bottom: .75rem;
}

/* ── APP SHELL ─────────────────────────────────────────────── */

.app-body {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── SIDEBAR ───────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--neutral-0);
  border-right: 1px solid var(--neutral-200);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  transition: transform .2s ease;
}

.sidebar-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--neutral-100);
  flex-shrink: 0;
}

.sidebar-header .logo-text { font-size: 1.25rem; }

.sidebar-logo {
  height: 32px;
  width: auto;
  display: block;
}

.sidebar-nav {
  flex: 1;
  padding: .75rem 0;
  overflow-y: auto;
}

.nav-section-label {
  font-size: .6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--neutral-300);
  padding: .75rem 1.25rem .25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .5rem 1.25rem;
  color: var(--neutral-700);
  text-decoration: none;
  border-radius: 0;
  font-size: .8125rem;
  transition: background .12s, color .12s;
  position: relative;
}

.nav-item:hover { background: var(--neutral-50); }

.nav-item.active {
  color: var(--purple-700);
  background: var(--purple-50);
  font-weight: 500;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: var(--purple-600);
  border-radius: 0 2px 2px 0;
}

.nav-item svg { flex-shrink: 0; opacity: .7; }
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  padding: .875rem 1rem;
  border-top: 1px solid var(--neutral-100);
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}

.user-chip { display: flex; align-items: center; gap: .5rem; flex: 1; min-width: 0; }

.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--purple-50);
  color: var(--purple-700);
  font-size: .75rem;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.user-info { min-width: 0; }
.user-name { font-size: .8125rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .6875rem; color: var(--neutral-500); text-transform: capitalize; }

/* ── MAIN ──────────────────────────────────────────────────── */

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.app-header {
  height: var(--header-h);
  background: var(--neutral-0);
  border-bottom: 1px solid var(--neutral-200);
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 0 1.5rem;
  flex-shrink: 0;
}

.page-title {
  font-size: .9375rem;
  font-weight: 600;
  color: var(--neutral-900);
}

.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

/* ── BUTTONS ───────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .5rem 1rem;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: .8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s, opacity .12s;
  white-space: nowrap;
  text-decoration: none;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary   { background: var(--purple-600); color: #fff; }
.btn-primary:hover:not(:disabled)   { background: var(--purple-700); }

.btn-secondary { background: var(--neutral-100); color: var(--neutral-700); }
.btn-secondary:hover:not(:disabled) { background: var(--neutral-200); }

.btn-success   { background: var(--teal-600); color: #fff; }
.btn-success:hover:not(:disabled)   { background: var(--teal-700); }

.btn-danger    { background: var(--red-600); color: #fff; }
.btn-danger:hover:not(:disabled)    { background: var(--red-700); }

.btn-ghost { background: transparent; color: var(--neutral-700); }
.btn-ghost:hover:not(:disabled) { background: var(--neutral-100); }

.btn-sm { padding: .3125rem .625rem; font-size: .75rem; }
.btn-full { width: 100%; justify-content: center; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--neutral-500);
  cursor: pointer;
  transition: background .12s;
}
.btn-icon:hover { background: var(--neutral-100); color: var(--neutral-700); }

/* ── FORMS ─────────────────────────────────────────────────── */

.field { margin-bottom: 1rem; }
.field:last-child { margin-bottom: 0; }

label {
  display: block;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--neutral-700);
  margin-bottom: .3125rem;
}

input, select, textarea {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: .875rem;
  color: var(--neutral-900);
  background: var(--neutral-0);
  transition: border-color .12s, box-shadow .12s;
  outline: none;
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  padding: 0;
  flex-shrink: 0;
  cursor: pointer;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--purple-600);
  box-shadow: 0 0 0 3px rgba(83,74,183,.12);
}

input::placeholder, textarea::placeholder { color: var(--neutral-300); }
textarea { resize: vertical; min-height: 80px; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.field-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .75rem; }

/* ── CARDS ─────────────────────────────────────────────────── */

.card {
  background: var(--neutral-0);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.card-title {
  font-size: .9375rem;
  font-weight: 600;
  color: var(--neutral-900);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: .75rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--neutral-0);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
}

.stat-label { font-size: .75rem; color: var(--neutral-500); margin-bottom: .25rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--neutral-900); }
.stat-sub   { font-size: .75rem; color: var(--neutral-500); margin-top: .125rem; }

/* ── TABLE ─────────────────────────────────────────────────── */

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--neutral-200);
  background: var(--neutral-0);
}

table { width: 100%; border-collapse: collapse; }

thead { border-bottom: 1px solid var(--neutral-200); }

th {
  text-align: left;
  padding: .625rem 1rem;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--neutral-500);
  white-space: nowrap;
}

td {
  padding: .75rem 1rem;
  font-size: .8125rem;
  color: var(--neutral-700);
  border-bottom: 1px solid var(--neutral-100);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

tbody tr:hover td { background: var(--neutral-50); }

.table-toolbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .875rem;
  flex-wrap: wrap;
}

.table-toolbar input[type=search] {
  width: 220px;
  padding: .4rem .75rem;
}

.table-toolbar select { width: auto; padding: .4rem .75rem; }

/* ── BADGES ────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: .1875rem .5rem;
  border-radius: 99px;
  font-size: .6875rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-purple { background: var(--purple-50);  color: var(--purple-700); }
.badge-teal   { background: var(--teal-50);    color: var(--teal-700); }
.badge-amber  { background: var(--amber-50);   color: var(--amber-700); }
.badge-blue   { background: var(--blue-50);    color: var(--blue-700); }
.badge-red    { background: var(--red-50);     color: var(--red-700); }
.badge-neutral{ background: var(--neutral-100);color: var(--neutral-500); }

/* ── PAGINATION ────────────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1rem;
  font-size: .8125rem;
  color: var(--neutral-500);
}

.pagination-btns { display: flex; gap: .375rem; }

/* ── MODAL ─────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-overlay.is-open {
  display: flex;
}

/* ── Glass modal — light mode ── */
.modal {
  background: rgba(255, 255, 255, 0.80);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.90);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18), 0 4px 16px rgba(0, 0, 0, 0.10);
  margin: 1rem;
}

.modal-lg { max-width: 800px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.07);
  flex-shrink: 0;
}

.modal-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--neutral-900);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(0, 0, 0, 0.07);
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  flex-shrink: 0;
}

/* ── TOAST ─────────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  z-index: 200;
}

.toast {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .75rem 1rem;
  border-radius: var(--radius-md);
  background: var(--neutral-900);
  color: #fff;
  font-size: .8125rem;
  box-shadow: var(--shadow-md);
  animation: slide-in .2s ease;
  min-width: 240px;
  max-width: 360px;
}

.toast-success { background: var(--teal-700); }
.toast-error   { background: var(--red-700); }
.toast-warning { background: var(--amber-600); }

@keyframes slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── LOADING ───────────────────────────────────────────────── */

.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

.spinner {
  width: 28px; height: 28px;
  border: 2.5px solid var(--neutral-200);
  border-top-color: var(--purple-600);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--neutral-500);
  gap: .75rem;
}

.empty-state svg { opacity: .3; }
.empty-state p { font-size: .875rem; }

/* ── PAGE LAYOUT ───────────────────────────────────────────── */

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

.page-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--neutral-900);
}

.section { margin-bottom: 1.5rem; }
.section-title {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--neutral-500);
  margin-bottom: .75rem;
}

/* ── DETAIL LAYOUT ─────────────────────────────────────────── */

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1rem;
  align-items: start;
}

.detail-field { margin-bottom: .875rem; }
.detail-label { font-size: .75rem; color: var(--neutral-500); margin-bottom: .1875rem; }
.detail-value { font-size: .875rem; color: var(--neutral-900); font-weight: 500; }

.checklist-item {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--neutral-100);
  font-size: .8125rem;
}
.checklist-item:last-child { border-bottom: none; }

.check-icon { width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.check-ok  { background: var(--teal-50); color: var(--teal-600); }
.check-nok { background: var(--neutral-100); color: var(--neutral-300); }

/* ── TABS ──────────────────────────────────────────────────── */

.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--neutral-200); margin-bottom: 1.25rem; }

.tab {
  padding: .625rem 1rem;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--neutral-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .12s, border-color .12s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: var(--font);
}
.tab:hover { color: var(--neutral-700); }
.tab.active { color: var(--purple-700); border-bottom-color: var(--purple-600); }

/* ── PIPELINE ──────────────────────────────────────────────── */

.pipeline {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .75rem;
  margin-bottom: 1.5rem;
}

.pipeline-col {
  background: var(--neutral-50);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.pipeline-col-header {
  padding: .625rem 1rem;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--neutral-200);
}

.pipeline-col-body { padding: .75rem; display: flex; flex-direction: column; gap: .5rem; }

.pipeline-card {
  background: var(--neutral-0);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
  padding: .75rem;
  cursor: pointer;
  transition: box-shadow .12s;
}
.pipeline-card:hover { box-shadow: var(--shadow-sm); }
.pipeline-card-name { font-size: .8125rem; font-weight: 500; color: var(--neutral-900); }
.pipeline-card-sub  { font-size: .75rem; color: var(--neutral-500); margin-top: 2px; }

/* ── UTILS ─────────────────────────────────────────────────── */

.text-right { text-align: right; }
.text-mono  { font-family: var(--font-mono); font-size: .8125rem; }
.text-muted { color: var(--neutral-500); }
.text-danger{ color: var(--red-600); }
.text-success{color: var(--teal-600); }
.fw-600     { font-weight: 600; }
.mt-1       { margin-top: .5rem; }
.mt-2       { margin-top: 1rem; }
.gap-1      { gap: .5rem; }
.flex       { display: flex; }
.flex-ac    { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }

/* ── SIDEBAR TOGGLE — mobile only ──────────────────────────── */

.sidebar-toggle-mobile { display: none; }

@media (max-width: 768px) {
  .sidebar-toggle-mobile { display: inline-flex; }
}

/* ── RESPONSIVE ────────────────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .detail-grid { grid-template-columns: 1fr; }
  .pipeline { grid-template-columns: 1fr 1fr; }
  .field-row, .field-row-3 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .page-content { padding: 1rem; }
  .card { padding: 1rem; }
  .modal { margin: .5rem; max-height: 95vh; }
  .table-toolbar input[type=search] { width: 100%; }
  .pagination { flex-direction: column; align-items: flex-start; gap: .5rem; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .pipeline { grid-template-columns: 1fr; }
  .app-header { padding: 0 1rem; }
  .page-title { font-size: .875rem; }
  .btn { font-size: .75rem; padding: .4rem .75rem; }
  .btn-sm { font-size: .6875rem; padding: .25rem .5rem; }
}

/* ── DARK THEME (carbon fibre) ─────────────────────────────── */

body.theme-dark {
  --neutral-0:   #1e1e1e;
  --neutral-50:  #252525;
  --neutral-100: #2e2e2e;
  --neutral-200: #3a3a3a;
  --neutral-300: #555;
  --neutral-500: #999;
  --neutral-700: #d4d4d4;
  --neutral-900: #f0f0f0;

  /* Carbon fibre weave — SVG tile 4×4px */
  background-color: #1a1a1a;
  background-image: url("../img/bgd.jpg");
  color: var(--neutral-700);
}

body.theme-dark .sidebar {
  background: #1c1c1c;
  border-right-color: #333;
}

body.theme-dark .app-header {
  background: #1c1c1c;
  border-bottom-color: #333;
}

body.theme-dark .card,
body.theme-dark .stat-card,
body.theme-dark .table-wrapper {
  background: #222;
  border-color: #3a3a3a;
}

/* ── Glass modal — dark mode ── */
body.theme-dark .modal-overlay {
  background: rgba(0, 0, 0, 0.60);
}
body.theme-dark .modal {
  background: rgba(20, 18, 35, 0.82);
  border-color: rgba(255, 255, 255, 0.10);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55), 0 4px 16px rgba(0, 0, 0, 0.30);
}
body.theme-dark .modal-header {
  border-bottom-color: rgba(255, 255, 255, 0.07);
}
body.theme-dark .modal-footer {
  border-top-color: rgba(255, 255, 255, 0.07);
}
body.theme-dark .modal-title {
  color: #f0f0f0;
}

body.theme-dark .nav-item:hover { background: #2a2a2a; }
body.theme-dark .nav-item.active { background: #2a2040; color: #a99fe8; }

body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea {
  background: #2a2a2a;
  border-color: #444;
  color: var(--neutral-900);
}

body.theme-dark thead { border-bottom-color: #3a3a3a; }
body.theme-dark td    { border-bottom-color: #2e2e2e; }
body.theme-dark tbody tr:hover td { background: #2a2a2a; }

/* ── VARIABLES SÉMANTIQUES — surfaces contextuelles ────────── */
/* Définies dans :root pour le light mode, redéfinies pour le dark */

:root {
  --surface-danger:     #fef2f2;
  --surface-warning:    rgba(250,238,218,.55);
  --surface-success:    #f0fdf4;
  --surface-info:       #eff6ff;
  --border-danger-s:    rgba(192,57,43,.22);
  --border-warning-s:   rgba(186,117,23,.22);
  --border-success-s:   rgba(15,110,86,.22);
}

body.theme-dark {
  --surface-danger:    rgba(192,57,43,.14);
  --surface-warning:   rgba(186,117,23,.14);
  --surface-success:   rgba(15,110,86,.12);
  --surface-info:      rgba(24,95,165,.12);
  --border-danger-s:   rgba(192,57,43,.45);
  --border-warning-s:  rgba(186,117,23,.45);
  --border-success-s:  rgba(15,110,86,.35);
}

/* ── PIPELINE KANBAN — dark mode overrides ──────────────────── */

body.theme-dark .kcard-item {
  background: var(--neutral-100);
  border-color: var(--neutral-200);
}
body.theme-dark .kcard-item:hover {
  box-shadow: 0 2px 10px rgba(0,0,0,.35);
}
body.theme-dark .kanban-col-body    { background: var(--neutral-50); }
body.theme-dark .kanban-col-neutral { background: var(--neutral-200); color: var(--neutral-700); }
body.theme-dark .kanban-col-blue    { background: var(--surface-info); color: #7ab5e8; }
body.theme-dark .kanban-col-purple  { background: rgba(83,74,183,.18); color: #b8b3f5; }
body.theme-dark .kanban-col-teal    { background: rgba(15,110,86,.18); color: #6ed4b0; }
body.theme-dark .kanban-col-muted   { background: var(--neutral-300); color: var(--neutral-900); }
body.theme-dark .kav-purple { background: rgba(83,74,183,.25);  color: #b8b3f5; }
body.theme-dark .kav-teal   { background: rgba(15,110,86,.25);  color: #6ed4b0; }
body.theme-dark .kav-muted  { background: var(--neutral-200);   color: var(--neutral-500); }
body.theme-dark .kanban-detail      { background: var(--neutral-100); border-color: var(--neutral-200); }
body.theme-dark .pl-filter-pill {
  background: var(--neutral-100);
  border-color: var(--neutral-200);
  color: var(--neutral-700);
}
body.theme-dark .pl-filter-pill:hover  { border-color: var(--purple-600); color: #b8b3f5; }
body.theme-dark .pl-filter-pill.active { background: var(--purple-600); color: #fff; }

/* ── CEO / SUPERVISION — dark mode component overrides ──────── */

/* Cartes KPI et agents (classes injectées par ceo-dashboard.js) */
body.theme-dark .kpi-card,
body.theme-dark .ceo-agent-card {
  background: var(--neutral-100);
  border-color: var(--neutral-200);
}

body.theme-dark .ceo-agent-card.has-alert {
  border-left-color: var(--color-amber, #BA7517);
}

body.theme-dark .ceo-agent-card:hover {
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
}

/* Barre de progression (fond piste) */
body.theme-dark .ceo-progress-bar { background: var(--neutral-200); }

/* Pilules de filtre (alertes.js) */
body.theme-dark .al-filter-pill {
  background: var(--neutral-100);
  border-color: var(--neutral-200);
  color: var(--neutral-700);
}
body.theme-dark .al-filter-pill:hover {
  border-color: var(--purple-600);
  color: var(--purple-50);
}
body.theme-dark .al-filter-pill.active {
  background: var(--purple-600);
  color: #fff;
  border-color: var(--purple-600);
}

/* Lignes d'alerte accordéon (alertes.js) */
body.theme-dark .alerte-header:hover { background: var(--neutral-100); }

/* Barre workflow cron */
body.theme-dark .cron-status-bar {
  background: var(--neutral-100);
  border-color: var(--neutral-200);
}

/* Stats résumé alertes */
body.theme-dark .alerte-stat-card { background: var(--neutral-100); border-color: var(--neutral-200); }

/* ── LIGHT THEME (white carbon) ────────────────────────────── */

body.theme-light {
  /* White carbon weave — SVG tile 4×4px */
  background-color: #f5f5f5;
  background-image: url("../img/bgw.jpg");
}

/* ── IMPRESSION DOCUMENTS ──────────────────────────────────── */

@media print {
  .sidebar, .app-header, .page-header .btn,
  .btn, #toast-container, #modal-overlay { display: none !important; }

  .app-body { display: block; }
  .app-main  { margin: 0; padding: 0; }
  .page-content { padding: 0; overflow: visible; }

  .print-document {
    max-width: 210mm;
    margin: 0 auto;
    padding: 12mm 16mm;
    font-size: 10pt;
    color: #000;
  }

  .print-document .doc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 8mm;
    margin-bottom: 8mm;
    border-bottom: 2px solid #1E1A55;
  }

  .print-document .doc-header img { height: 36pt; width: auto; }

  .print-document .doc-header-right {
    text-align: right;
    font-size: 8pt;
    color: #555;
    line-height: 1.6;
  }

  .print-document .doc-title {
    font-size: 16pt;
    font-weight: 700;
    color: #1E1A55;
    margin-bottom: 1mm;
  }

  .print-document .doc-ref {
    font-size: 9pt;
    color: #555;
    letter-spacing: .03em;
  }

  .print-document table { width: 100%; border-collapse: collapse; margin: 6mm 0; }
  .print-document th { background: #1E1A55; color: #fff; padding: 3mm 4mm; font-size: 8.5pt; text-align: left; }
  .print-document td { padding: 2.5mm 4mm; border-bottom: 1px solid #ddd; font-size: 9pt; }
  .print-document tr:nth-child(even) td { background: #f7f7f9; }

  .print-document .doc-total {
    text-align: right;
    font-size: 12pt;
    font-weight: 700;
    color: #1E1A55;
    margin-top: 4mm;
  }

  .print-document .doc-footer {
    position: fixed;
    bottom: 10mm;
    left: 16mm;
    right: 16mm;
    font-size: 7pt;
    color: #888;
    border-top: 1px solid #ccc;
    padding-top: 3mm;
    display: flex;
    justify-content: space-between;
  }
}

/* En-tête visible aussi en aperçu avant impression (classe .print-preview) */
.print-preview .doc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 1.25rem;
  margin-bottom: 1.25rem;
  border-bottom: 2px solid var(--purple-900);
}

.print-preview .doc-header img { height: 36px; width: auto; }

.print-preview .doc-header-right {
  text-align: right;
  font-size: .75rem;
  color: var(--neutral-500);
  line-height: 1.6;
}

.print-preview .doc-title {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--purple-900);
  margin-bottom: .25rem;
}

.print-preview .doc-ref {
  font-size: .8125rem;
  color: var(--neutral-500);
  letter-spacing: .02em;
}

/* ── DARK MODE — composants espace FDE & messagerie ─────────── */

/* Bulletins */
body.theme-dark .bull-acc-item   { background: var(--neutral-100); border-color: var(--neutral-200); }
body.theme-dark .bull-filter-btn { background: var(--neutral-100); border-color: var(--neutral-200); color: var(--neutral-700); }
body.theme-dark .bull-acc-body   { background: var(--neutral-50);  }
body.theme-dark .bull-detail-col h4 { color: var(--neutral-700); }
body.theme-dark .bull-net-verse  { background: rgba(83,74,183,.15); border-color: rgba(83,74,183,.3); }
body.theme-dark .bull-cumuls-grid .bull-cumul-item { background: var(--neutral-100); border-color: var(--neutral-200); }

/* NDF */
body.theme-dark .ndf-form-group input,
body.theme-dark .ndf-form-group select { background: var(--neutral-100); border-color: var(--neutral-200); color: var(--neutral-900); }
body.theme-dark .ndf-toggle-track { background: #444; }
body.theme-dark .ndf-item        { background: var(--neutral-100); border-color: var(--neutral-200); }

/* CRA */
body.theme-dark .cal-libre  { background: var(--neutral-100) !important; border-color: var(--neutral-200) !important; }
body.theme-dark .cal-futur  { background: var(--neutral-50)  !important; border-color: var(--neutral-200) !important; }
body.theme-dark .cal-coche  { background: rgba(83,74,183,.25) !important; border-color: rgba(83,74,183,.5) !important; color: #c4b5fd !important; }

/* Simulateur */
body.theme-dark .sim-card   { background: var(--neutral-100); border-color: var(--neutral-200); }
body.theme-dark .sim-chip   { border-color: var(--neutral-200); color: var(--neutral-500); }
body.theme-dark .mini-stat,
body.theme-dark .detail-block,
body.theme-dark .proj-stat  { background: var(--neutral-100); }
body.theme-dark input[type=range].sim-slider {
  background: linear-gradient(to right, var(--purple-600) 0%, var(--purple-600) var(--pct, 50%), var(--neutral-200) var(--pct, 50%), var(--neutral-200) 100%);
}

/* Messagerie */
body.theme-dark .msg-layout    { background: var(--neutral-100); border-color: var(--neutral-200); }
body.theme-dark .msg-left      { border-right-color: var(--neutral-200); background: var(--neutral-50); }
body.theme-dark .msg-header    { border-bottom-color: var(--neutral-200); background: var(--neutral-100); }
body.theme-dark .msg-body      { background: var(--neutral-50); }
body.theme-dark .msg-input-area{ background: var(--neutral-100); border-top-color: var(--neutral-200); }
body.theme-dark .msg-input     { background: var(--neutral-50); border-color: var(--neutral-200); color: var(--neutral-900); }
body.theme-dark .msg-item:hover{ background: var(--neutral-200) !important; }
body.theme-dark .msg-item.active{ background: rgba(83,74,183,.22) !important; }

/* Compte d'activité — KPI cards inline */
body.theme-dark .cpte-filter-btn { background: var(--neutral-100); border-color: var(--neutral-200); color: var(--neutral-700); }

/* Services */
body.theme-dark .svc-card { background: var(--neutral-100); border-color: var(--neutral-200); }

/* ── SCROLLBAR FINE — light + dark ─────────────────────────── */

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,.18) transparent;
}

/* Chromium / Safari */
::-webkit-scrollbar {
  width:  6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background-color: rgba(0,0,0,.18);
  border-radius: 99px;
  border: 1px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background-color: rgba(0,0,0,.30);
}
::-webkit-scrollbar-corner {
  background: transparent;
}

/* Dark theme — pouce plus clair sur fond sombre */
body.theme-dark {
  scrollbar-color: rgba(255,255,255,.18) transparent;
}
body.theme-dark ::-webkit-scrollbar-thumb {
  background-color: rgba(255,255,255,.18);
}
body.theme-dark ::-webkit-scrollbar-thumb:hover {
  background-color: rgba(255,255,255,.30);
}
