/* ============================================================
   K'unclic App — Styles globaux
   ============================================================ */

/* --- Police Onest (self-hosted, CSP-safe : font-src 'self') ---
   Variable font servie par Google Fonts mais hébergée localement dans
   assets/fonts/onest/ — le CDN serait bloqué par la CSP stricte.
   Sous-ensembles latin + latin-ext (accents FR). Une seule déclaration
   par sous-ensemble couvre toute la plage de graisses 400→800. */
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("../fonts/onest/onest-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("../fonts/onest/onest-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* --- Variables de marque ---------------------------------- */
:root {
  --brand:          #00A295;   /* couleur principale */
  --brand-hover:    #008F85;   /* survol */
  --brand-dark:     #007A70;   /* texte sur fond clair (contraste AA) */
  --brand-soft:     #E6F7F6;   /* fond doux pour badges/chips */
  --brand-light:    #00B5A5;   /* avatars, début de dégradé */
  --brand-gradient-end: #00D4C2; /* fin de dégradé */

  /* --- Neutres chauds (fusion Onest + rail latéral, 2026-06) --- */
  --bg:            #F6F4EF;  /* fond contenu (remplace bg-gray-50) */
  --sidebar:       #E9E3D7;  /* rail latéral : un cran + foncé que le contenu */
  --sidebar-border:#DAD3C4;
  --surface:       #FFFFFF;  /* cartes */
  --surface-border:#ECE6DC;  /* bord des cartes */
  --fill:          #F7F5F0;  /* champs / sous-cartes */
  --fill-border:   #EFEAE0;
  --divider:       #F4F0E8;  /* séparateurs de lignes */
  --divider-strong:#F0ECE4;

  --ink:           #1C1D1A;  /* texte principal */
  --ink-2:         #3A382F;  /* texte secondaire fort */
  --muted:         #7D7A70;  /* texte secondaire */
  --muted-2:       #9A9488;  /* libellés / placeholders */
  --muted-3:       #A8A294;  /* méta / uppercase labels */

  /* --- Sémantiques --- */
  --ok:        #2F9E6E;
  --ok-bar:    #2F9E6E;
  --warn:      #C2643F;
  --warn-bar:  #D89B2E;
  --danger:    #C24F4F;
  --gold:      #E0A93C;

  /* --- Couleurs par module (wayfinding) --- */
  --m-societes:#00A295; --m-societes-soft:#E6F7F6;
  --m-membres:#6B4FA8;  --m-membres-soft:#EEEAF8;
  --m-admins:#2E6F8E;   --m-admins-soft:#E5EFF6;
  --m-mail:#C2643F;     --m-mail-soft:#FBEADE;
  --m-materiel:#2F7D52; --m-materiel-soft:#E5F2EA;
  --m-projets:#4655B8;  --m-projets-soft:#E7E9F7;
  --m-tickets:#C24F6B;  --m-tickets-soft:#F8E6EC;
  --m-licences:#9333C4; --m-licences-soft:#F4EAFA;
}

/* --- Police globale + fond chaud -------------------------- */
body {
  font-family: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

/* Chiffres alignés (stats, tableaux, montants, dates) */
.tnum { font-variant-numeric: tabular-nums; }

/* --- Texte & accents marque ------------------------------- */
.text-brand   { color: var(--brand); }
.bg-brand     { background: var(--brand); }
.border-brand { border-color: var(--brand); }
.brand-gradient {
  background: linear-gradient(90deg, var(--brand-light), var(--brand-gradient-end));
}

/* Pilule / badge ton marque (rôle, "admin", timer 🔓…) */
.chip-brand {
  background: var(--brand-soft);
  color: var(--brand);
}

/* Encart d'aide / astuce (doc/*) — fond doux + texte foncé pour le contraste */
.tip-brand {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

/* Pastille avatar (initiales utilisateur) — ton marque clair */
.avatar-brand { background: var(--brand-light); color: #fff; }

/* --- Boutons --------------------------------------------- */
/* Les classes .btn-* gèrent uniquement couleurs + survol.
   Les tailles (px-*, py-*, text-*, rounded-*) restent côté Tailwind. */
.btn-primary {
  background: var(--brand);
  color: #fff;
}
.btn-primary:hover { background: var(--brand-hover); }

.btn-secondary {
  background: #fff;
  color: #4b5563;        /* gray-600 */
  border: 1px solid #e5e7eb; /* gray-200 */
}
.btn-secondary:hover { background: #f9fafb; } /* gray-50 */

.btn-danger {
  background: #dc2626;   /* red-600 */
  color: #fff;
}
.btn-danger:hover { background: #b91c1c; } /* red-700 */

/* --- Nav links -------------------------------------------- */
.nav-link {
  display: inline-block;
  padding: 4px 12px;
  font-size: 13.5px;
  color: #6b7280;
  border-radius: 6px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}
.nav-link:hover,
.nav-link.active {
  background: var(--brand-soft);
  color: var(--brand);
}

/* ============================================================
   Recettes de composants — design « Fusion » (Onest + rail)
   Classes additives : couleurs/structure ici, tailles via Tailwind.
   Inertes tant qu'elles ne sont pas posées sur le markup.
   ============================================================ */

/* ---------- Carte ---------- */
.kc-card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(28,29,26,.03);
}

/* ---------- Tuile de stat ---------- */
.kc-tile { padding: 15px 18px; display: flex; align-items: center; gap: 13px; }
.kc-tile__ico { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex: none; }
.kc-tile__num { font-size: 24px; font-weight: 700; line-height: 1; color: var(--ink); }

/* ---------- Monogramme société ---------- */
.kc-mono { border-radius: 9px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; }

/* ---------- Badge / pastille couleur module ---------- */
.kc-pill {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 24px; padding: 0 7px; border-radius: 7px;
  font-size: 12.5px; font-weight: 700;
}

/* ---------- Barre de progression (complétude / crédits) ---------- */
.kc-bar { height: 6px; border-radius: 999px; background: var(--divider-strong); overflow: hidden; }
.kc-bar__fill { height: 100%; border-radius: 999px; }

/* ---------- Tableau ---------- */
.kc-thead { background: #FBFAF6; border-bottom: 1px solid var(--divider-strong); }
.kc-th { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted-3); }
.kc-tr { border-bottom: 1px solid var(--divider); transition: background .12s; }
.kc-tr:hover { background: #FAF8F3; }
.kc-tr:hover .kc-acts { opacity: 1; }
.kc-acts { display: flex; align-items: center; gap: 8px; opacity: .35; transition: opacity .12s; color: var(--muted-2); }

/* ---------- Rail latéral (prêt pour la bascule structurelle §6) ---------- */
.kc-side {
  width: 250px; flex: none;
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-border);
  display: flex; flex-direction: column;
  padding: 20px 14px;
  position: sticky; top: 0; height: 100vh;
}
.kc-side__group {
  font-size: 10.5px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: #A89F8E; padding: 0 11px 8px;
}
.kc-navi {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 11px; border-radius: 11px;
  font-size: 14px; font-weight: 500; color: var(--ink-2);
  text-decoration: none; position: relative;
}
.kc-navi:hover { background: rgba(255,255,255,.55); }
.kc-navi--active {
  background: #fff; font-weight: 600; color: var(--ink);
  box-shadow: 0 1px 2px rgba(28,29,26,.06);
}
.kc-navi--active::before {
  content: ""; position: absolute; left: -14px; top: 50%;
  transform: translateY(-50%);
  width: 4px; height: 22px; border-radius: 0 4px 4px 0;
  background: var(--brand);
}
.kc-navi__ico {
  width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; flex: none;
}

/* ---------- Topbar fine ---------- */
.kc-topbar {
  height: 64px; flex: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px; border-bottom: 1px solid #E7E1D6;
  background: rgba(246,244,239,.85); position: sticky; top: 0; z-index: 5;
  backdrop-filter: blur(8px);
}
.kc-content { padding: 30px 32px 40px; max-width: 1280px; width: 100%; }

/* ---------- Layout app (rail + contenu) — pour la bascule §6 ---------- */
.kc-app  { display: flex; min-height: 100vh; background: var(--bg); }
.kc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- Rail : sous-éléments ---------- */
.kc-side__logo { font-weight: 800; font-size: 22px; letter-spacing: -.02em; padding: 4px 8px 22px; }
.kc-side__logo .a { color: var(--brand); }
.kc-side__logo .b { color: var(--ink); }
.kc-side__group:first-of-type { padding-top: 0; }
.kc-side__nav { display: flex; flex-direction: column; gap: 2px; }
.kc-navi__badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.kc-side__user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: rgba(255,255,255,.5); }

/* Couleurs des pastilles d'icône (à poser sur .kc-navi__ico ou .kc-tile__ico) */
.kc-ico-societes{background:var(--m-societes-soft);color:var(--m-societes);}
.kc-ico-membres {background:var(--m-membres-soft); color:var(--m-membres);}
.kc-ico-admins  {background:var(--m-admins-soft);  color:var(--m-admins);}
.kc-ico-mail    {background:var(--m-mail-soft);    color:var(--m-mail);}
.kc-ico-materiel{background:var(--m-materiel-soft);color:var(--m-materiel);}
.kc-ico-projets {background:var(--m-projets-soft); color:var(--m-projets);}
.kc-ico-tickets {background:var(--m-tickets-soft); color:var(--m-tickets);}
.kc-ico-licences{background:var(--m-licences-soft);color:var(--m-licences);}
.kc-ico-neutral {background:#EFEDE6;               color:var(--muted);}

/* ---------- Tuile : libellé ---------- */
.kc-tile__lbl { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

/* ---------- Barre de progression : variantes par seuil (cf. helper kc_health §5) ---------- */
.kc-bar--ok     .kc-bar__fill { background: var(--ok); }
.kc-bar--warn   .kc-bar__fill { background: var(--warn-bar); }
.kc-bar--danger .kc-bar__fill { background: var(--danger); }

/* ---------- Boutons (compléments rayon 11px + halo teal) ---------- */
.kc-btn-primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px -8px rgba(0,162,149,.7); border-radius: 11px; }
.kc-btn-primary:hover { background: var(--brand-hover); }
.kc-btn-secondary { background: #fff; border: 1px solid #E2DDD2; color: var(--ink-2); border-radius: 11px; }
.kc-btn-secondary:hover { background: var(--fill); }

/* ---------- Tableau : conteneur arrondi ---------- */
.kc-table { background: var(--surface); border: 1px solid var(--surface-border); border-radius: 18px; overflow: hidden; }
.kc-tr:last-child { border-bottom: 0; }

/* ---------- Sections repliables (fiche) ---------- */
.kc-sec { display: flex; align-items: center; gap: 13px; padding: 16px 22px; border-bottom: 1px solid var(--divider); cursor: pointer; transition: background .12s; }
.kc-sec:last-child { border-bottom: 0; }
.kc-sec:hover { background: #FAF8F3; }
.kc-sec__ico { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex: none; }
.kc-sec__count { font-size: 12.5px; border-radius: 6px; padding: 2px 8px; background: var(--divider); color: var(--muted-3); }

/* ---------- Responsive : rail off-canvas < md (767px) ----------
   Calé sur le breakpoint Tailwind `md` (768px) : c'est là que le hamburger
   de la topbar et la bottom-nav (md:hidden) apparaissent pour ouvrir le rail.
   Au-delà, le rail est un panneau statique. */
.kc-burger { display: none; }  /* visible uniquement < md (cf. media query) */
@media (max-width: 767px) {
  .kc-side {
    position: fixed; z-index: 60; left: 0; top: 0;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: 0 20px 60px -20px rgba(0,0,0,.4);
  }
  .kc-side.is-open { transform: translateX(0); }
  .kc-topbar { padding: 0 16px; }
  .kc-content { padding: 20px 16px 32px; }
  .kc-burger { display: inline-flex; }
}

/* --- Scrollbar subtile ------------------------------------ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* --- Focus ring global ------------------------------------ */
input:focus, select:focus, textarea:focus, button:focus {
  outline: none;
}

/* --- Transitions globales --------------------------------- */
a { transition: color 0.15s, opacity 0.15s; }
button { transition: background 0.15s, opacity 0.15s; }

/* ============================================================
   Highlight des termes recherchés (helper highlight() PHP)
   ============================================================ */
mark.kc-hl {
  background: #fef3c7;        /* amber-100 */
  color: inherit;
  padding: 0 2px;
  border-radius: 3px;
  font-weight: 600;
}

/* ============================================================
   Bouton "copier" inline (helper copy_btn() PHP)
   ============================================================ */
.kc-copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  margin-left: 4px;
  padding: 2px;
  border-radius: 4px;
  color: #9ca3af;       /* gray-400 */
  background: transparent;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}
/* Visible quand on survole le conteneur parent OU directement le bouton */
:hover > .kc-copy-btn,
.kc-copy-btn:hover,
.kc-copy-btn:focus-visible {
  opacity: 1;
}
.kc-copy-btn:hover {
  color: var(--brand);
  background: var(--brand-soft);
}
.kc-copy-btn.text-green-500 {
  color: #22c55e;
  opacity: 1;
}
/* Sur mobile (pas de hover), on garde le bouton visible en permanence */
@media (hover: none) {
  .kc-copy-btn { opacity: 0.6; }
}

/* ============================================================
   Header sticky intelligent (hide on scroll-down / show on scroll-up)
   ============================================================ */
.kc-header {
  position: sticky;
  top: 0;
  z-index: 50;
  transition: transform 220ms ease, box-shadow 220ms ease;
  will-change: transform;
}
.kc-header.kc-nav-hidden {
  transform: translateY(-100%);
}
/* Ombre subtile renforcée quand le header est sticky en haut (effet de profondeur) */
.kc-header.kc-nav-scrolled nav {
  box-shadow: 0 2px 8px -2px rgba(0,0,0,0.06);
}

/* Pour que les ancres (#section-accounts, etc.) ne se cachent pas sous le header */
html { scroll-padding-top: 80px; scroll-behavior: smooth; }
/* Respecte la préférence système "réduire les animations" */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* ============================================================
   Documentation (views/doc/*)
   ============================================================ */
/* Encart "attention" amber (doc warnings) — pendant de .tip-brand */
.doc-warn {
  background: #FFF8E1;
  color: #92710A;
}
/* Encart "note" gris neutre (info contextuelle) */
.doc-note {
  background: #F9FAFB;
  color: #4B5563;
  border-left: 3px solid #D1D5DB;
}
/* Flèche teal des listes "→ étape" (helper PHP doc_step) */
.doc-arrow {
  color: var(--brand);
  font-weight: 700;
  flex-shrink: 0;
}
/* Sommaire : carte d'entrée cliquable du grid en haut de page */
.doc-toc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #4B5563;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.doc-toc-item:hover {
  background: var(--brand-soft);
  color: var(--brand);
}
.doc-toc-icon {
  font-size: 18px;
  line-height: 1;
}
/* Pastille numérotée en tête de section */
.doc-num {
  background: var(--brand);
  color: #fff;
  width: 28px; height: 28px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ============================================================
   Modale de confirmation (Kunclic.confirm)
   ============================================================ */
.kc-modal {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 16px;
  background: rgba(17, 24, 39, 0.45); /* gray-900 / 45 % */
  opacity: 0;
  transition: opacity 0.18s ease-out;
}
.kc-modal.kc-open { opacity: 1; }

.kc-modal__dialog {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 48px -16px rgba(0,0,0,.25), 0 4px 12px -4px rgba(0,0,0,.1);
  width: 100%;
  max-width: 420px;
  padding: 22px 22px 18px;
  transform: translateY(8px) scale(0.98);
  transition: transform 0.18s ease-out;
}
.kc-modal.kc-open .kc-modal__dialog { transform: translateY(0) scale(1); }

.kc-modal__title {
  font-size: 16px;
  font-weight: 600;
  color: #111827; /* gray-900 */
  margin-bottom: 6px;
}
.kc-modal__msg {
  font-size: 14px;
  color: #4b5563; /* gray-600 */
  line-height: 1.45;
  margin-bottom: 18px;
  white-space: pre-line;
}
.kc-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.kc-modal__btn {
  font-size: 13.5px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
}
.kc-modal__btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ============================================================
   Toasts (notifications haut-droite)
   - Pile verticale, auto-dismiss, click pour fermer
   - Couleurs par type (success / error / warning / info)
   - Respecte prefers-reduced-motion
   ============================================================ */
.kc-toasts {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: calc(100vw - 32px);
  width: 360px;
  pointer-events: none; /* les toasts eux-mêmes redeviennent cliquables */
}
@media (max-width: 480px) {
  .kc-toasts {
    width: auto;
    left: 16px;
    right: 16px;
    top: 12px;
  }
}
.kc-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid;
  background: #fff;
  box-shadow: 0 8px 24px -8px rgba(0,0,0,0.15), 0 2px 6px -2px rgba(0,0,0,0.08);
  font-size: 13.5px;
  line-height: 1.4;
  transform: translateX(110%);
  opacity: 0;
  transition: transform .25s cubic-bezier(.2,.7,.3,1), opacity .2s ease;
  will-change: transform, opacity;
}
.kc-toast--enter { transform: translateX(0); opacity: 1; }
.kc-toast--leave { transform: translateX(110%); opacity: 0; }
.kc-toast__icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  border-radius: 50%;
  margin-top: 1px;
}
.kc-toast__msg { flex: 1; color: #1f2937; }
.kc-toast__close {
  flex-shrink: 0;
  background: transparent;
  border: 0;
  color: #9ca3af;
  cursor: pointer;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  margin-top: 1px;
}
.kc-toast__close:hover { color: #374151; }
.kc-toast__close:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Types */
.kc-toast--success { border-color: #a7f3d0; }
.kc-toast--success .kc-toast__icon { background: #10b981; color: #fff; }
.kc-toast--error   { border-color: #fecaca; }
.kc-toast--error   .kc-toast__icon { background: #ef4444; color: #fff; }
.kc-toast--warning { border-color: #fde68a; }
.kc-toast--warning .kc-toast__icon { background: #f59e0b; color: #fff; }
.kc-toast--info    { border-color: #CCEEED; }
.kc-toast--info    .kc-toast__icon { background: #00A295; color: #fff; }

@media (prefers-reduced-motion: reduce) {
  .kc-toast {
    transition: opacity .15s ease;
    transform: none;
  }
  .kc-toast--enter, .kc-toast--leave { transform: none; }
}

/* ============================================================
   Raccourcis clavier
   - badge <kbd>, modale d'aide, indicator de préfixe (g…)
   ============================================================ */
.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 11.5px;
  font-weight: 600;
  color: #374151;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-bottom-width: 2px;
  border-radius: 5px;
  line-height: 1;
  white-space: nowrap;
}

/* Menu utilisateur de la barre (desktop) — <details> natif.
   Avatar → profil, pages outils (selon rôle), déconnexion. */
.kc-usermenu {
  position: relative;
}
.kc-usermenu__summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  list-style: none;                 /* masque le marqueur natif (Firefox) */
  padding: 4px 6px;
  border-radius: 8px;
}
.kc-usermenu__summary::-webkit-details-marker { display: none; } /* Safari/Chrome */
.kc-usermenu__summary:hover { background: #f3f4f6; }
.kc-usermenu__chevron {
  width: 14px;
  height: 14px;
  color: #9ca3af;
  transition: transform .15s ease;
}
.kc-usermenu[open] .kc-usermenu__chevron { transform: rotate(180deg); }
.kc-usermenu__panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 12px 28px -12px rgba(0,0,0,.22);
  padding: 6px;
  z-index: 50;
  display: flex;
  flex-direction: column;
}
.kc-usermenu__header { padding: 8px 12px 10px; }
.kc-usermenu__name { font-size: 14px; font-weight: 600; color: #111827; }
.kc-usermenu__meta {
  font-size: 12px;
  color: #9ca3af;
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}
.kc-usermenu__sep { height: 1px; background: #f3f4f6; margin: 4px 0; }
.kc-usermenu__logout { margin: 0; }
.kc-usermenu__item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 14px;
  color: #374151;
  text-decoration: none;
  white-space: nowrap;
  background: transparent;
  border: 0;
  cursor: pointer;
}
.kc-usermenu__item:hover { background: #f3f4f6; color: #111827; }
.kc-usermenu__item--danger { color: #dc2626; }
.kc-usermenu__item--danger:hover { background: #fef2f2; color: #b91c1c; }

/* Déclencheur d'un menu d'actions (réutilise kc-usermenu pour le panneau).
   Pill secondaire libellée + chevron unique. Le marqueur natif du <summary>
   (triangle ► Safari, puce Firefox) est tué de façon bulletproof pour ne JAMAIS
   doubler le chevron. Aligné sur les autres boutons du header (rounded-lg). */
.kc-actionsbtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  list-style: none;                 /* masque le marqueur (Firefox) */
  padding: 8px 16px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  transition: background .15s ease, border-color .15s ease;
  -webkit-user-select: none;
  user-select: none;
}
.kc-actionsbtn::-webkit-details-marker { display: none; } /* Safari/Chrome */
.kc-actionsbtn::marker { content: ""; font-size: 0; }     /* standard (Firefox) */
.kc-actionsbtn:hover { background: #f9fafb; border-color: #cbd5e1; }
.kc-usermenu[open] .kc-actionsbtn { background: #f3f4f6; border-color: #cbd5e1; }
.dark .kc-actionsbtn { border-color: #2c323d; background: #181b22; color: #cbd1d9; }
.dark .kc-actionsbtn:hover { background: #20242d; border-color: #3a414d; }
.dark .kc-usermenu[open] .kc-actionsbtn { background: #20242d; border-color: #3a414d; }

/* Compat : .hidden si pas couvert par Tailwind (déjà compilé dans le projet,
   mais safety net si purge le retire un jour) */
.kc-modal.hidden { display: none; }

/* ============================================================
   Autocomplete recherche (header) — 2026-05-21
   ============================================================ */
.kc-suggest__wrap   { position: relative; }
.kc-suggest         {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 320px;
    max-width: 480px;
    max-height: 60vh;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,.1), 0 8px 10px -6px rgba(0,0,0,.05);
    z-index: 1000;
    padding: 4px 0;
    display: none;
}
.kc-suggest--open   { display: block; }
.kc-suggest__group  { padding: 4px 0; }
.kc-suggest__group + .kc-suggest__group { border-top: 1px solid #f3f4f6; margin-top: 2px; padding-top: 6px; }
.kc-suggest__title  {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 600;
    color: #9ca3af;
    padding: 4px 14px 4px;
}
.kc-suggest__item   {
    display: block;
    padding: 8px 14px;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: background .08s;
}
.kc-suggest__item:hover,
.kc-suggest__item--active { background: #f3f4f6; }
.kc-suggest__label  { font-size: 13px; font-weight: 500; color: #1f2937; line-height: 1.3; }
.kc-suggest__sub    { font-size: 11px; color: #6b7280; margin-top: 1px; line-height: 1.3; word-break: break-word; }
.kc-suggest__badge  {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    background: #E6F7F6;
    color: #008F85;
    margin-left: 6px;
    vertical-align: middle;
}
.kc-suggest__footer {
    border-top: 1px solid #f3f4f6;
    padding: 8px 14px;
    font-size: 11px;
    color: #6b7280;
    text-align: center;
    text-decoration: none;
    display: block;
    background: #fafafa;
    border-radius: 0 0 10px 10px;
}
.kc-suggest__footer:hover { color: #008F85; background: #f3f4f6; }
.kc-suggest__empty {
    padding: 16px 14px;
    text-align: center;
    font-size: 12px;
    color: #9ca3af;
}
.kc-suggest__loading {
    padding: 16px 14px;
    text-align: center;
    font-size: 12px;
    color: #9ca3af;
}

/* ============================================================
   Command palette (⌘K / Ctrl+K)
   ============================================================ */
.kc-cmdk {
    position: fixed;
    inset: 0;
    z-index: 1001; /* au-dessus de .kc-modal (1000) */
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 12vh 16px 16px;
    background: rgba(17, 24, 39, 0.45);
    opacity: 0;
    transition: opacity 0.16s ease-out;
}
.kc-cmdk.hidden { display: none; }
.kc-cmdk.kc-open { opacity: 1; }
.kc-cmdk__panel {
    width: 100%;
    max-width: 560px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 24px 56px -16px rgba(0,0,0,.32), 0 6px 16px -6px rgba(0,0,0,.12);
    overflow: hidden;
    transform: translateY(-8px) scale(0.985);
    transition: transform 0.16s ease-out;
    display: flex;
    flex-direction: column;
    max-height: 70vh;
}
.kc-cmdk.kc-open .kc-cmdk__panel { transform: translateY(0) scale(1); }
.kc-cmdk__inputwrap {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid #f3f4f6;
    flex-shrink: 0;
}
.kc-cmdk__searchicon { width: 18px; height: 18px; color: #9ca3af; flex-shrink: 0; }
.kc-cmdk__input {
    flex: 1 1 auto;
    border: 0;
    outline: none;
    font-size: 15px;
    color: #111827;
    background: transparent;
    padding: 2px 0;
}
.kc-cmdk__input::placeholder { color: #9ca3af; }
.kc-cmdk__esc {
    flex-shrink: 0;
    font-size: 10px;
    font-weight: 600;
    color: #9ca3af;
    background: #f3f4f6;
    border-radius: 6px;
    padding: 3px 7px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.kc-cmdk__results { overflow-y: auto; padding: 6px 0; }
.kc-cmdk__group  { padding: 2px 0; }
.kc-cmdk__group + .kc-cmdk__group { border-top: 1px solid #f3f4f6; margin-top: 2px; padding-top: 4px; }
.kc-cmdk__title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 600;
    color: #9ca3af;
    padding: 4px 16px;
}
.kc-cmdk__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}
.kc-cmdk__item--active { background: #f3f4f6; }
.kc-cmdk__item-ico { width: 16px; height: 16px; color: #6b7280; flex-shrink: 0; }
.kc-cmdk__item-body { min-width: 0; }
.kc-cmdk__item-label { font-size: 13.5px; font-weight: 500; color: #1f2937; line-height: 1.3; }
.kc-cmdk__item-sub   { font-size: 11px; color: #6b7280; margin-top: 1px; line-height: 1.3; word-break: break-word; }
.kc-cmdk__badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    background: #E6F7F6;
    color: #008F85;
    margin-left: 6px;
    vertical-align: middle;
}
.kc-cmdk__empty,
.kc-cmdk__loading {
    padding: 18px 16px;
    text-align: center;
    font-size: 12px;
    color: #9ca3af;
}
.kc-cmdk__footer {
    display: block;
    border-top: 1px solid #f3f4f6;
    padding: 8px 16px;
    font-size: 11px;
    color: #6b7280;
    text-align: center;
    text-decoration: none;
    background: #fafafa;
}
.kc-cmdk__footer:hover { color: #008F85; background: #f3f4f6; }
@media (prefers-reduced-motion: reduce) {
    .kc-cmdk, .kc-cmdk__panel { transition: none; }
}

/* ============================================================
   Bouton flottant — Remonter en haut de page
   ============================================================ */
.kc-scrolltop {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 60;
    width: 48px;
    height: 48px;
    border-radius: 9999px;
    border: 0;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(135deg, var(--brand-light) 0%, var(--brand) 55%, var(--brand-hover) 100%);
    box-shadow:
        0 10px 24px -8px rgba(0, 162, 149, 0.55),
        0 4px 10px -2px rgba(0, 0, 0, 0.10),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px) scale(0.92);
    transition:
        opacity 0.25s ease,
        visibility 0.25s ease,
        transform 0.3s cubic-bezier(.34, 1.56, .64, 1),
        box-shadow 0.2s ease,
        background 0.2s ease;
}
.kc-scrolltop.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}
.kc-scrolltop:hover {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-hover) 55%, var(--brand-dark) 100%);
    box-shadow:
        0 14px 30px -8px rgba(0, 162, 149, 0.65),
        0 6px 14px -2px rgba(0, 0, 0, 0.14),
        inset 0 1px 0 rgba(255, 255, 255, 0.30);
    transform: translateY(-2px) scale(1.04);
}
.kc-scrolltop:active {
    transform: translateY(0) scale(0.96);
    transition-duration: 0.08s;
}
.kc-scrolltop:focus-visible {
    outline: none;
    box-shadow:
        0 0 0 4px rgba(0, 162, 149, 0.25),
        0 10px 24px -8px rgba(0, 162, 149, 0.55),
        0 4px 10px -2px rgba(0, 0, 0, 0.10);
}
.kc-scrolltop__icon {
    width: 20px;
    height: 20px;
    transition: transform 0.25s cubic-bezier(.34, 1.56, .64, 1);
    filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.08));
}
.kc-scrolltop:hover .kc-scrolltop__icon {
    transform: translateY(-2px);
}
/* Halo pulsé subtil au repos pour attirer l'œil sans agresser */
.kc-scrolltop__ring {
    position: absolute;
    inset: 0;
    border-radius: 9999px;
    pointer-events: none;
    box-shadow: 0 0 0 0 rgba(0, 181, 165, 0.45);
    animation: kc-scrolltop-pulse 2.6s ease-out infinite;
}
@keyframes kc-scrolltop-pulse {
    0%   { box-shadow: 0 0 0 0    rgba(0, 181, 165, 0.40); }
    70%  { box-shadow: 0 0 0 14px rgba(0, 181, 165, 0);    }
    100% { box-shadow: 0 0 0 0    rgba(0, 181, 165, 0);    }
}

/* Mobile : un peu plus compact et collé au coin */
@media (max-width: 640px) {
    .kc-scrolltop {
        right: 16px;
        bottom: 16px;
        width: 44px;
        height: 44px;
    }
    .kc-scrolltop__icon { width: 18px; height: 18px; }
}

/* Respect des préférences de réduction de mouvement */
@media (prefers-reduced-motion: reduce) {
    .kc-scrolltop,
    .kc-scrolltop__icon { transition: opacity 0.2s ease, visibility 0.2s ease; }
    .kc-scrolltop.is-visible { transform: none; }
    .kc-scrolltop:hover { transform: none; }
    .kc-scrolltop:hover .kc-scrolltop__icon { transform: none; }
    .kc-scrolltop__ring { animation: none; }
}

/* Cache à l'impression */
@media print {
    .kc-scrolltop { display: none !important; }
}

/* ============================================================
   Mode sombre — `html.dark` (toggle persistant, cf. header + app.js)
   ------------------------------------------------------------
   Stratégie : remapper les utilitaires Tailwind les plus courants sous
   `.dark` (app.css est chargé après tailwind.css). `!important` pour battre
   de façon fiable les utilitaires simples ET leurs variantes (hover:, etc.).
   Couvre le chrome (fonds, textes, bordures), les badges d'état, les champs
   et les composants maison (modale, palette, suggest, bottom-nav…).
   ============================================================ */

/* Logo : variante claire (texte blanc) réservée au mode sombre. Règle de base
   HORS @media screen → l'impression conserve toujours le logo standard. */
.kc-logo-dark { display: none; }

/* Scopé à l'écran : à l'impression, on reste toujours en clair. */
@media screen {

/* Bascule du logo en mode sombre */
html.dark .kc-logo-light { display: none; }
html.dark .kc-logo-dark  { display: inline-block; }

/* Icônes du bouton thème : lune en clair, soleil en sombre */
.kc-theme-icon-sun   { display: none; }
html.dark .kc-theme-icon-moon { display: none; }
html.dark .kc-theme-icon-sun  { display: inline-block; }
/* Libellés mobiles du bouton thème */
.kc-theme-label-light { display: none; }
html.dark .kc-theme-label-dark  { display: none; }
html.dark .kc-theme-label-light { display: inline; }

html.dark { color-scheme: dark; background: #0f1217; }
html.dark, :root.dark { --brand-soft: rgba(0, 181, 165, 0.16); }

/* Tokens chauds remappés en sombre (design « Fusion » §7) */
html.dark, :root.dark {
  --bg:#0F1413; --sidebar:#141C1A; --sidebar-border:#1F2C29;
  --surface:#111917; --surface-border:#1F2C29;
  --fill:#141C1A; --fill-border:#233330;
  --divider:#1B2624; --divider-strong:#1F2C29;
  --ink:#F1F5F4; --ink-2:#C9D4D1; --muted:#8A9794; --muted-2:#6B7A77; --muted-3:#5E6E6B;
}
.dark .kc-thead { background:#141C1A; }
.dark .kc-tr:hover, .dark .kc-sec:hover { background:#161E1C; }
.dark .kc-navi--active { background:#1B2624; color:#F1F5F4; }
.dark .kc-navi--active::before { background: var(--brand-light); }
.dark .kc-topbar { background: rgba(15,20,19,.85); border-bottom-color:#1F2C29; }
.dark .kc-btn-secondary { background:#141C1A; border-color:#233330; color:#C9D4D1; }
.dark .kc-side__user { background: rgba(255,255,255,.04); }

/* --- Fonds --- */
.dark .bg-white   { background-color: #181b22 !important; }
.dark .bg-gray-50 { background-color: #0f1217 !important; }
.dark .bg-gray-100{ background-color: #20242d !important; }
.dark .bg-gray-200{ background-color: #272c36 !important; }

/* --- Textes --- */
.dark .text-gray-900 { color: #f1f3f5 !important; }
.dark .text-gray-800 { color: #e3e6ea !important; }
.dark .text-gray-700 { color: #cbd1d9 !important; }
.dark .text-gray-600 { color: #aab2bf !important; }
.dark .text-gray-500 { color: #9aa3b0 !important; }
.dark .text-gray-400 { color: #7b8290 !important; }
.dark .text-gray-300 { color: #5c636f !important; }

/* --- Bordures & séparateurs --- */
.dark .border-gray-100 { border-color: #242932 !important; }
.dark .border-gray-200 { border-color: #2c323d !important; }
.dark .border-gray-300 { border-color: #39414e !important; }
.dark .divide-gray-100 > * + *, .dark .divide-gray-50 > * + * { border-color: #242932 !important; }
.dark .divide-gray-200 > * + * { border-color: #2c323d !important; }

/* --- Survols courants --- */
.dark .hover\:bg-gray-50:hover  { background-color: #20242d !important; }
.dark .hover\:bg-gray-100:hover { background-color: #272c36 !important; }
.dark .hover\:bg-gray-200:hover { background-color: #2f3540 !important; }
.dark .hover\:text-gray-900:hover { color: #f1f3f5 !important; }
.dark .hover\:text-gray-700:hover { color: #cbd1d9 !important; }
.dark .hover\:text-gray-600:hover { color: #aab2bf !important; }

/* --- Champs de formulaire --- */
.dark input, .dark select, .dark textarea {
    background-color: #1b1f27 !important;
    color: #e3e6ea !important;
    border-color: #39414e !important;
}
.dark input::placeholder, .dark textarea::placeholder { color: #6b7280 !important; }

/* --- Badges / accents d'état (contraste relevé) --- */
.dark .bg-green-50  { background-color: rgba(34,197,94,0.14) !important; }
.dark .bg-red-50    { background-color: rgba(239,68,68,0.14) !important; }
.dark .bg-amber-50  { background-color: rgba(245,158,11,0.14) !important; }
.dark .bg-blue-50   { background-color: rgba(59,130,246,0.14) !important; }
.dark .bg-purple-50 { background-color: rgba(168,85,247,0.14) !important; }
.dark .bg-orange-50 { background-color: rgba(249,115,22,0.14) !important; }
.dark .bg-green-100 { background-color: rgba(34,197,94,0.18) !important; }
.dark .bg-blue-100  { background-color: rgba(59,130,246,0.18) !important; }
.dark .bg-red-100   { background-color: rgba(239,68,68,0.18) !important; }
.dark .text-green-700, .dark .text-green-800, .dark .text-green-600 { color: #4ade80 !important; }
.dark .text-red-700, .dark .text-red-800, .dark .text-red-600, .dark .text-red-500 { color: #f87171 !important; }
.dark .text-amber-700, .dark .text-amber-800, .dark .text-amber-900, .dark .text-amber-600 { color: #fbbf24 !important; }
.dark .text-blue-700, .dark .text-blue-600, .dark .text-blue-800 { color: #60a5fa !important; }
.dark .text-purple-700 { color: #c084fc !important; }
.dark .text-orange-600, .dark .text-orange-500 { color: #fb923c !important; }

/* --- Accents marque --- */
.dark .tip-brand  { color: #5fd9cd !important; }
.dark .chip-brand { color: #3fd6c8 !important; }
.dark .btn-secondary { background: #1b1f27; color: #cbd1d9; border-color: #39414e; }
.dark .btn-secondary:hover { background: #20242d; }

/* --- Composants maison (couleurs littérales dans app.css) --- */
.dark .kc-modal__dialog { background: #181b22; }
.dark .kc-modal__title  { color: #f1f3f5; }
.dark .kc-modal__msg    { color: #aab2bf; }
.dark .kc-cmdk__panel      { background: #181b22; }
.dark .kc-cmdk__inputwrap  { border-bottom-color: #2c323d; }
.dark .kc-cmdk__input      { color: #e3e6ea; }
.dark .kc-cmdk__esc        { background: #272c36; color: #9aa3b0; }
.dark .kc-cmdk__item--active { background: #20242d; }
.dark .kc-cmdk__item-label { color: #e3e6ea; }
.dark .kc-cmdk__group + .kc-cmdk__group { border-top-color: #242932; }
.dark .kc-suggest        { background: #181b22; border-color: #2c323d; }
.dark .kc-suggest__item:hover, .dark .kc-suggest__item--active { background: #20242d; }
.dark .kc-suggest__label { color: #e3e6ea; }
.dark .kc-suggest__footer { background: #15181e; border-top-color: #242932; }
.dark .kc-bnav { background: #181b22; border-top-color: #2c323d; }
.dark .kc-usermenu__summary:hover { background: #20242d; }
.dark .kc-usermenu__panel { background: #181b22; border-color: #2c323d; box-shadow: 0 12px 28px -12px rgba(0,0,0,.6); }
.dark .kc-usermenu__name { color: #f1f3f5; }
.dark .kc-usermenu__sep { background: #242932; }
.dark .kc-usermenu__item { color: #cbd1d9; }
.dark .kc-usermenu__item:hover { background: #20242d; color: #f1f3f5; }
.dark .kc-usermenu__item--danger { color: #f87171; }
.dark .kc-usermenu__item--danger:hover { background: #2a1416; color: #fca5a5; }
.dark .kbd { background: #272c36; color: #cbd1d9; border-color: #39414e; }
.dark ::-webkit-scrollbar-thumb { background: #39414e; }
.dark ::-webkit-scrollbar-thumb:hover { background: #4a5260; }

} /* fin @media screen (mode sombre) */
