/* ==========================================================================
   Delomid CONNECT — base et composants réutilisables
   Toutes les couleurs proviennent de tokens.css.
   ========================================================================== */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

/* Un élément masqué l'est toujours, quel que soit son display */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: var(--leading);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 var(--space-3); line-height: 1.25; font-weight: var(--weight-bold); color: var(--color-text); }
h1 { font-size: var(--text-3xl); letter-spacing: -0.02em; }
h2 { font-size: var(--text-2xl); letter-spacing: -0.01em; }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
p { margin: 0 0 var(--space-4); }
small, .text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-muted { color: var(--color-text-secondary); }
.text-center { text-align: center; }
code, kbd { font-family: var(--font-mono); font-size: 0.9em; background: var(--color-navy-50); color: var(--color-text); padding: 0.1em 0.4em; border-radius: var(--radius-sm); }

img, svg { max-width: 100%; }

/* Liens : magenta uniquement sur surfaces blanches */
a { color: var(--color-text); text-underline-offset: 3px; }
.surface a:not(.btn), .card a:not(.btn), .modal a:not(.btn) { color: var(--color-link); }
a:hover { text-decoration-thickness: 2px; }

/* Focus visible partout */
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 2px; border-radius: var(--radius-sm); }
.on-dark :focus-visible { outline-color: var(--brand-white); }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: var(--space-4); top: -100px; z-index: var(--z-toast);
  background: var(--brand-navy); color: var(--color-text-on-dark); padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md); font-weight: var(--weight-semibold);
}
.skip-link:focus { top: var(--space-4); }

/* Icônes (sprite) */
.icon {
  width: 1.25em; height: 1.25em; flex-shrink: 0; vertical-align: -0.25em;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.icon--fill { fill: currentColor; }
.icon--lg { width: 1.75rem; height: 1.75rem; }
.icon--xl { width: 2.5rem; height: 2.5rem; }

/* ---------- Mise en page ---------- */
.container { width: 100%; max-width: var(--content-max); margin-inline: auto; padding-inline: var(--space-5); }
.stack > * + * { margin-top: var(--space-4); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.grid { display: grid; gap: var(--space-5); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.spread { display: flex; justify-content: space-between; align-items: center; gap: var(--space-4); flex-wrap: wrap; }

/* Surfaces de marque : texte blanc obligatoire */
.on-dark, .bg-navy, .bg-magenta, .bg-gradient { color: var(--color-text-on-dark); }
.on-dark h1, .on-dark h2, .on-dark h3, .on-dark h4,
.on-dark a:not(.btn):not(.menu__item) { color: var(--color-text-on-dark); }
.bg-navy { background: var(--brand-navy); }
.bg-magenta { background: var(--brand-magenta); }
.bg-gradient { background: var(--brand-gradient); }

/* ---------- Boutons ---------- */
.btn {
  --btn-bg: var(--color-surface);
  --btn-fg: var(--color-text);
  --btn-border: var(--color-border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px; padding: 0 var(--space-5);
  font: inherit; font-size: var(--text-sm); font-weight: var(--weight-semibold); line-height: 1;
  color: var(--btn-fg); background: var(--btn-bg); border: 1px solid var(--btn-border);
  border-radius: var(--radius-md); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform var(--duration-fast) var(--ease), box-shadow var(--duration) var(--ease),
              background-color var(--duration) var(--ease), filter var(--duration) var(--ease);
}
.btn:hover { box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; box-shadow: none; transform: none; }

.btn--primary { --btn-bg: var(--brand-gradient); --btn-fg: var(--brand-white); --btn-border: transparent; background: var(--brand-gradient); }
.btn--primary:hover { filter: brightness(1.08); }
.btn--navy { --btn-bg: var(--brand-navy); --btn-fg: var(--brand-white); --btn-border: var(--brand-navy); }
.btn--secondary { --btn-bg: var(--color-surface-muted); --btn-fg: var(--color-text); --btn-border: var(--color-border); }
.btn--ghost { --btn-bg: transparent; --btn-fg: var(--color-text); --btn-border: transparent; }
.btn--ghost:hover { --btn-bg: var(--color-navy-50); box-shadow: none; }
.btn--danger { --btn-bg: var(--color-danger-solid); --btn-fg: var(--brand-white); --btn-border: var(--color-danger-solid); }
.btn--on-dark { --btn-bg: var(--brand-white); --btn-fg: var(--brand-navy); --btn-border: var(--brand-white); }

.btn--sm { min-height: 36px; padding: 0 var(--space-3); }
.btn--lg { min-height: 52px; padding: 0 var(--space-6); font-size: var(--text-md); }
.btn--block { width: 100%; }
.btn--icon { padding: 0; width: 44px; }
.btn--icon.btn--sm { width: 36px; }

/* État de chargement */
.btn[aria-busy="true"] { position: relative; color: transparent !important; pointer-events: none; }
.btn[aria-busy="true"]::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--btn-fg); border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Formulaires ---------- */
.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field + .field { margin-top: var(--space-4); }
.label { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--color-text); }
.label .req { color: var(--color-danger); margin-left: 2px; }
.hint { font-size: var(--text-xs); color: var(--color-text-secondary); margin: 0; }
.field-error { display: flex; gap: var(--space-1); align-items: center; font-size: var(--text-xs); color: var(--color-danger); font-weight: var(--weight-medium); margin: 0; }

.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: var(--space-2) var(--space-3);
  font: inherit; font-size: var(--text-md); color: var(--color-text);
  background: var(--color-input); border: 1px solid var(--color-border-strong); border-radius: var(--radius-md);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--color-text-secondary); opacity: 1; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--color-text-secondary); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: none; border-color: var(--brand-magenta); box-shadow: var(--ring); }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--color-danger); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--color-surface-muted); color: var(--color-text-secondary); cursor: not-allowed; }
.textarea { min-height: 120px; resize: vertical; }
.select {
  appearance: none; padding-right: var(--space-6);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239caac1' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px;
}

.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-right: 48px; }
.input-group .input-icon-left { position: absolute; left: 12px; color: var(--color-text-secondary); pointer-events: none; }
.input-group .input-icon-left + .input { padding-left: 40px; }
.input-group .input-action { position: absolute; right: 4px; }

.counter { font-size: var(--text-xs); color: var(--color-text-secondary); text-align: right; }
.counter.is-over { color: var(--color-danger); font-weight: var(--weight-semibold); }

/* Cases à cocher, boutons radio */
.check { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; font-size: var(--text-sm); min-height: 32px; }
.check input { width: 18px; height: 18px; accent-color: var(--brand-magenta); margin: 0; cursor: pointer; }

/* Interrupteur */
.switch { display: inline-flex; align-items: center; gap: var(--space-3); cursor: pointer; font-size: var(--text-sm); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track {
  position: relative; width: 44px; height: 24px; border-radius: var(--radius-pill);
  background: var(--color-border-strong); transition: background var(--duration) var(--ease); flex-shrink: 0;
}
.switch__track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--brand-white); box-shadow: var(--shadow-sm); transition: transform var(--duration) var(--ease);
}
.switch input:checked + .switch__track { background: var(--brand-magenta); }
.switch input:checked + .switch__track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch__track { outline: 3px solid var(--color-focus); outline-offset: 2px; }

/* Robustesse du mot de passe */
.strength { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: var(--space-1); }
.strength span { height: 6px; border-radius: var(--radius-pill); background: var(--color-border); transition: background var(--duration) var(--ease); }
.strength[data-score="1"] span:nth-child(-n+1) { background: var(--color-danger); }
.strength[data-score="2"] span:nth-child(-n+2) { background: var(--color-warning); }
.strength[data-score="3"] span:nth-child(-n+3) { background: var(--brand-navy); }
.strength[data-score="4"] span { background: var(--color-success); }
.strength-label { font-size: var(--text-xs); color: var(--color-text-secondary); margin: 0; }

/* Saisie du code OTP */
.otp { display: flex; gap: var(--space-2); justify-content: center; }
.otp__digit {
  width: 52px; height: 60px; text-align: center; font-size: var(--text-2xl); font-weight: var(--weight-bold);
  font-family: var(--font-mono); color: var(--color-text);
  border: 1px solid var(--color-border-strong); border-radius: var(--radius-md); background: var(--color-input);
}
.otp__digit:focus-visible { outline: none; border-color: var(--brand-magenta); box-shadow: var(--ring); }
@media (max-width: 420px) { .otp__digit { width: 42px; height: 52px; font-size: var(--text-xl); } }

/* Zone de dépôt de fichiers */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-2);
  padding: var(--space-6); border: 2px dashed var(--color-border-strong); border-radius: var(--radius-lg);
  background: var(--color-surface); text-align: center; color: var(--color-text-secondary); cursor: pointer;
  transition: border-color var(--duration) var(--ease), background var(--duration) var(--ease);
}
.dropzone .icon { color: var(--brand-magenta); }
.dropzone.is-dragover { border-color: var(--brand-magenta); background: var(--color-navy-50); }

/* ---------- Cartes ---------- */
.card {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: var(--space-5);
}
.card__header { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); margin-bottom: var(--space-4); }
.card__title { font-size: var(--text-lg); font-weight: var(--weight-bold); margin: 0; }
.card__subtitle { font-size: var(--text-sm); color: var(--color-text-secondary); margin: var(--space-1) 0 0; }
.card__footer { margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--color-border); }
.card--interactive { transition: box-shadow var(--duration) var(--ease), transform var(--duration) var(--ease); }
.card--interactive:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

/* Carte d'indicateur */
.kpi__label { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--color-text-secondary); font-weight: var(--weight-medium); }
.kpi__value { font-size: var(--text-3xl); font-weight: var(--weight-bold); letter-spacing: -0.02em; margin: var(--space-2) 0 var(--space-1); }
.kpi__delta { display: inline-flex; align-items: center; gap: 2px; font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.kpi__delta--up { color: var(--color-success); }
.kpi__delta--down { color: var(--color-danger); }
.sparkline { display: block; width: 100%; height: 40px; margin-top: var(--space-3); }
.sparkline path { fill: none; stroke: var(--brand-magenta); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 2px var(--space-2); border-radius: var(--radius-pill);
  font-size: var(--text-xs); font-weight: var(--weight-semibold); line-height: 1.6; white-space: nowrap;
  background: var(--color-navy-50); color: var(--color-text);
}
.badge .icon { width: 0.95em; height: 0.95em; vertical-align: 0; }
.badge--success { background: var(--color-success-bg); color: var(--color-success); }
.badge--warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge--danger { background: var(--color-danger-bg); color: var(--color-danger); }
.badge--brand { background: var(--brand-magenta); color: var(--brand-white); }
.badge--navy { background: var(--brand-navy); color: var(--brand-white); }

.count {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: var(--radius-pill); background: var(--brand-magenta); color: var(--brand-white);
  font-size: var(--text-xs); font-weight: var(--weight-bold);
}

/* Étoiles */
.stars { display: inline-flex; gap: 1px; color: var(--color-star); }
.stars .icon { width: 1rem; height: 1rem; }
.stars .is-empty { color: var(--color-border-strong); }

/* ---------- Alertes ---------- */
.alert {
  display: flex; gap: var(--space-3); align-items: flex-start;
  padding: var(--space-4); border-radius: var(--radius-md); border: 1px solid transparent;
  background: var(--color-info-bg); color: var(--color-info); font-size: var(--text-sm);
}
.alert > .icon { margin-top: 1px; }
.alert__title { font-weight: var(--weight-bold); margin: 0 0 2px; }
.alert p { margin: 0; }
.alert a:not(.btn) { color: inherit; font-weight: var(--weight-semibold); }
.alert--success { background: var(--color-success-bg); color: var(--color-success); border-color: rgba(48, 211, 169, 0.3); }
.alert--warning { background: var(--color-warning-bg); color: var(--color-warning); border-color: rgba(246, 197, 111, 0.3); }
.alert--danger { background: var(--color-danger-bg); color: var(--color-danger); border-color: rgba(255, 122, 133, 0.3); }

/* Bandeau pleine largeur (ex. « Reconnexion nécessaire ») */
.banner { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; padding: var(--space-3) var(--space-5); background: var(--hero-gradient); color: var(--color-text-on-dark); }
.banner p { margin: 0; flex: 1; min-width: 200px; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th, .table td { padding: var(--space-3) var(--space-4); text-align: left; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.table th { font-size: var(--text-xs); font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-text-secondary); background: var(--color-surface-muted); white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--color-surface-muted); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.th-sort { display: inline-flex; align-items: center; gap: var(--space-1); background: none; border: 0; padding: 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; }

@media (max-width: 640px) {
  .table--stack thead { display: none; }
  .table--stack tr { display: block; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border); }
  .table--stack td { display: flex; justify-content: space-between; gap: var(--space-3); padding: var(--space-1) 0; border: 0; }
  .table--stack td::before { content: attr(data-label); font-weight: var(--weight-semibold); color: var(--color-text-secondary); }
  .table--stack .num { text-align: right; }
}

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; gap: var(--space-1); flex-wrap: wrap; }
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center; min-width: 40px; height: 40px; padding: 0 var(--space-2);
  border-radius: var(--radius-md); font-size: var(--text-sm); font-weight: var(--weight-semibold); text-decoration: none; color: var(--color-text);
}
.pagination a:hover { background: var(--color-navy-50); }
.pagination [aria-current="page"] { background: var(--brand-navy); color: var(--brand-white); }
.pagination .is-disabled { color: var(--color-text-secondary); opacity: 0.6; }

/* ---------- Onglets ---------- */
.tabs__list { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--color-border); overflow-x: auto; scrollbar-width: thin; }
.tabs__tab {
  position: relative; padding: var(--space-3) var(--space-4); background: none; border: 0; cursor: pointer;
  font: inherit; font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--color-text-secondary); white-space: nowrap;
  display: inline-flex; align-items: center; gap: var(--space-2);
}
.tabs__tab:hover { color: var(--color-text); }
.tabs__list a.tabs__tab { text-decoration: none; }
.tabs__tab[aria-selected="true"], .tabs__tab[aria-current="page"] { color: var(--color-text); }
.tabs__tab[aria-current="page"]::after, .tabs__tab[aria-selected="true"]::after { content: ""; position: absolute; left: var(--space-3); right: var(--space-3); bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--brand-gradient); }
.tabs__panel { padding-top: var(--space-5); }
.tabs__panel[hidden] { display: none; }

/* ---------- Modales (élément <dialog>) ---------- */
.modal {
  width: min(560px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); padding: 0;
  border: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  background: var(--color-surface); color: var(--color-text);
}
.modal::backdrop { background: var(--backdrop); backdrop-filter: blur(2px); }
.modal[open] { animation: modal-in var(--duration-slow) var(--ease); }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
.modal__header { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); padding: var(--space-5) var(--space-5) 0; }
.modal__title { font-size: var(--text-xl); margin: 0; }
.modal__body { padding: var(--space-4) var(--space-5); color: var(--color-text-secondary); }
.modal__body strong { color: var(--color-text); }
.modal__footer { display: flex; justify-content: flex-end; gap: var(--space-3); flex-wrap: wrap; padding: var(--space-4) var(--space-5) var(--space-5); }
.modal__icon { display: inline-flex; width: 48px; height: 48px; border-radius: 50%; align-items: center; justify-content: center; background: var(--color-danger-bg); color: var(--color-danger); margin-bottom: var(--space-3); }

/* ---------- Notifications (toasts) ---------- */
.toasts {
  position: fixed; z-index: var(--z-toast); right: var(--space-5); bottom: var(--space-5);
  display: flex; flex-direction: column; gap: var(--space-3); width: min(400px, calc(100vw - 2rem)); pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; gap: var(--space-3); align-items: flex-start;
  padding: var(--space-4); border-radius: var(--radius-md); background: var(--color-surface); color: var(--color-text);
  border: 1px solid var(--color-border); border-left: 4px solid var(--brand-blue); box-shadow: var(--shadow-lg);
  font-size: var(--text-sm); animation: toast-in var(--duration-slow) var(--ease);
}
.toast p { margin: 0; flex: 1; }
.toast > .icon { margin-top: 1px; }
.toast--success { border-left-color: var(--color-success); }
.toast--success > .icon { color: var(--color-success); }
.toast--danger { border-left-color: var(--color-danger); }
.toast--danger > .icon { color: var(--color-danger); }
.toast--warning { border-left-color: var(--color-warning); }
.toast--warning > .icon { color: var(--color-warning); }
.toast.is-leaving { opacity: 0; transform: translateX(16px); transition: all var(--duration) var(--ease); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }
@media (max-width: 640px) { .toasts { left: var(--space-4); right: var(--space-4); bottom: var(--space-4); width: auto; } }

/* ---------- Squelettes de chargement ---------- */
.skeleton {
  display: block; border-radius: var(--radius-sm); min-height: 1em;
  background: linear-gradient(90deg, var(--color-navy-50) 25%, var(--color-surface-muted) 50%, var(--color-navy-50) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite;
}
.skeleton--text { height: 0.9em; margin: 0.4em 0; }
.skeleton--title { height: 1.6em; width: 60%; }
.skeleton--circle { border-radius: 50%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- État vide ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-3);
  padding: var(--space-7) var(--space-5); background: var(--color-surface);
  border: 1px dashed var(--color-border-strong); border-radius: var(--radius-lg);
}
.empty__icon { display: inline-flex; align-items: center; justify-content: center; width: 72px; height: 72px; border-radius: 50%; background: var(--brand-gradient); color: var(--brand-white); }
.empty__title { font-size: var(--text-xl); margin: 0; }
.empty__text { color: var(--color-text-secondary); max-width: 440px; margin: 0; }

/* ---------- Avatars / logos d'entreprise ---------- */
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 40px; height: 40px; border-radius: var(--radius-md); overflow: hidden;
  background: var(--brand-gradient); color: var(--brand-white); font-weight: var(--weight-bold); font-size: var(--text-sm);
}
.avatar img { width: 100%; height: 100%; object-fit: contain; background: var(--brand-white); }
.avatar--round { border-radius: 50%; }
.avatar--lg { width: 56px; height: 56px; font-size: var(--text-lg); }

/* ---------- Menu déroulant ---------- */
.menu { position: relative; }
.menu__panel {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; z-index: var(--z-drawer);
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); padding: var(--space-2); color: var(--color-text);
}
.menu__panel[hidden] { display: none; }
.menu__item {
  display: flex; align-items: center; gap: var(--space-3); width: 100%; padding: var(--space-2) var(--space-3);
  border: 0; background: none; border-radius: var(--radius-sm); font: inherit; font-size: var(--text-sm);
  color: var(--color-text); text-decoration: none; cursor: pointer; text-align: left;
}
.menu__item:hover, .menu__item:focus-visible { background: var(--color-navy-50); }
.on-dark .menu__panel :focus-visible { outline-color: var(--color-focus); }
.menu__sep { height: 1px; background: var(--color-border); margin: var(--space-2) 0; border: 0; }

/* ---------- Tuiles d'application (lanceur) ---------- */
.app-tile {
  position: relative; display: flex; flex-direction: column; gap: var(--space-3);
  padding: var(--space-5); border-radius: var(--radius-xl); text-decoration: none;
  background: var(--color-surface); border: 1px solid var(--color-border); color: var(--color-text);
  transition: box-shadow var(--duration) var(--ease), transform var(--duration) var(--ease);
}
a.app-tile:hover { box-shadow: var(--shadow-md); transform: translateY(-3px); }
.app-tile__icon {
  display: inline-flex; align-items: center; justify-content: center; width: 64px; height: 64px;
  border-radius: 18px; background: var(--brand-gradient); color: var(--brand-white); box-shadow: var(--shadow-md);
}
.app-tile__icon .icon { width: 30px; height: 30px; }
.app-tile__name { font-size: var(--text-lg); font-weight: var(--weight-bold); margin: 0; }
.app-tile__desc { font-size: var(--text-sm); color: var(--color-text-secondary); margin: 0; }
.app-tile .badge { position: absolute; top: var(--space-4); right: var(--space-4); }
.app-tile.is-disabled { cursor: default; }
.app-tile.is-disabled .app-tile__icon { background: var(--color-navy-100); color: var(--color-text-secondary); box-shadow: none; }

/* ---------- Mouvement réduit ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ---------- Page d'erreur ---------- */
.error-page { min-height: 100vh; display: grid; place-items: center; padding: var(--space-5); }
.error-page__card { width: min(520px, 100%); text-align: center; padding: var(--space-7) var(--space-6); }
.error-page__code { font-size: var(--text-3xl); font-weight: var(--weight-bold); margin: var(--space-4) 0 0; color: var(--color-link); }
.error-page__title { font-size: var(--text-2xl); }
.error-page__actions { justify-content: center; margin-top: var(--space-5); }
.error-page__debug { text-align: left; font-size: var(--text-xs); background: var(--color-surface-muted); padding: var(--space-4); border-radius: var(--radius-md); overflow: auto; max-height: 320px; margin-top: var(--space-5); }

/* Logo du CRM (carré bleu nuit) */
.brand-logo { border-radius: var(--radius-md); display: block; }

/* ---------- Accueil provisoire (remplacé à l'étape 5) ---------- */
.home-header { padding: var(--space-5) 0; }
.home-header.bg-gradient { background: var(--hero-gradient); border-bottom: 1px solid var(--color-border); }
.home-header__eyebrow { margin: 0; font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.home-header__title { margin: 0; font-size: var(--text-xl); }
.home-avatar { width: 28px; height: 28px; font-size: var(--text-xs); }
.home-main { padding-top: var(--space-7); padding-bottom: var(--space-7); }
.menu__meta { margin: 0; padding: var(--space-2) var(--space-3); font-size: var(--text-sm); color: var(--color-text); overflow-wrap: anywhere; }
@media (max-width: 560px) { .home-name { display: none; } }
.home-section-title { font-size: var(--text-xl); margin: 0 0 var(--space-4); }
.home-logo { border: 2px solid rgba(255, 255, 255, 0.7); }
.home-app__head { margin-bottom: var(--space-3); flex-wrap: nowrap; }
.home-modules { list-style: none; margin: 0; padding: 0; }
.home-modules li { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); padding: var(--space-2) 0; border-top: 1px solid var(--color-border); font-size: var(--text-sm); }
.home-app__icon { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex-shrink: 0; border-radius: 12px; background: var(--brand-gradient); color: var(--brand-white); }

/* ---------- Lanceur d'applications ---------- */
.launcher-section + .launcher-section { margin-top: var(--space-7); }
.launcher { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-5); grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.launcher > li { display: flex; }
.launcher .app-tile { width: 100%; }
.app-tile__meta { margin-top: auto; padding-top: var(--space-2); display: inline-flex; align-items: center; gap: var(--space-1); font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--color-text); }
a.app-tile:hover .app-tile__meta .icon { transform: translateX(3px); }
.app-tile__meta .icon { transition: transform var(--duration) var(--ease); }
.app-tile__note { margin-top: auto; padding-top: var(--space-2); display: inline-flex; align-items: flex-start; gap: var(--space-2); font-size: var(--text-xs); color: var(--color-text-secondary); }
.app-tile.is-disabled .badge { position: static; align-self: flex-start; margin-top: auto; }
.app-tile.is-disabled .app-tile__name { color: var(--color-text-secondary); }
.app-tile--manage .app-tile__icon { background: var(--brand-navy); }
.app-tile { position: relative; }
.app-tile__count { position: absolute; top: var(--space-4); right: var(--space-4); }

/* ---------- Notifications (cloche de la barre du haut) ---------- */
.topbar__end { display: flex; align-items: center; gap: var(--space-2); }
.notif__button { position: relative; }
.notif__count { position: absolute; top: 2px; right: 2px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--color-danger-solid); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.notif__panel { width: min(380px, calc(100vw - 32px)); right: 0; left: auto; padding: 0; }
.notif__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border); }
.notif__empty { margin: 0; padding: var(--space-4); }
.notif__list { list-style: none; margin: 0; padding: var(--space-1) 0; max-height: 420px; overflow-y: auto; }
.notif__item { display: flex; align-items: flex-start; gap: var(--space-3); white-space: normal; height: auto; padding: var(--space-2) var(--space-4); }
.notif__item.is-unread { background: var(--color-navy-50); }
.notif__item.is-unread strong::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--color-focus); vertical-align: middle; }
.notif__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notif__text strong { font-size: var(--text-sm); overflow-wrap: anywhere; }
.notif__icon { flex-shrink: 0; margin-top: 2px; }
.notif__icon--success { color: var(--color-success); }
.notif__icon--warning { color: var(--color-warning); }
.notif__icon--danger { color: var(--color-danger); }

/* Un groupe de champs (fieldset) ne doit jamais élargir la page sur petit écran */
fieldset { min-width: 0; min-inline-size: 0; }

/* ---------- Filtres actifs : compteur du bouton « Filtres », puces supprimables (avis, messagerie) ---------- */
.filter-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--brand-blue); color: #ffffff; font-size: var(--text-xs); font-weight: 700; line-height: 1; }
.filter-chips { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-bottom: var(--space-4); }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 30px; padding: 2px 8px 2px 12px; border-radius: 999px; border: 1px solid var(--color-border-strong); background: var(--color-active); color: var(--color-text); font-size: var(--text-sm); text-decoration: none; }
.filter-chip:hover, .filter-chip:focus-visible { border-color: var(--color-focus); color: var(--color-text); }
.filter-chip .icon { width: 14px; height: 14px; color: var(--color-text-secondary); }
.filter-chips__clear { font-size: var(--text-sm); font-weight: 600; }

/* ---------- Réponses IA : badge (traçabilité), contexte, avertissements, indicateurs, test de connexion ---------- */
.ai-badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; background: #f4f5fa; color: #19254d; font-size: var(--text-xs); font-weight: 650; white-space: nowrap; vertical-align: middle; }
.ai-badge .icon { width: 14px; height: 14px; color: #19254d; }
.ai-context { margin: var(--space-2) 0 0; font-size: var(--text-xs); color: var(--color-text-secondary); }
.ai-warnings { list-style: none; margin: var(--space-2) 0 0; padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); background: var(--color-warning-bg); color: var(--color-warning); font-size: var(--text-xs); }
.ai-warnings[hidden] { display: none; }
.ai-warnings li + li { margin-top: 2px; }
.ai-stats { display: flex; flex-direction: column; gap: var(--space-2); margin: var(--space-3) 0 0; }
.ai-stats div { display: flex; justify-content: space-between; gap: var(--space-3); font-size: var(--text-sm); }
.ai-stats dt { color: var(--color-text-secondary); }
.ai-stats dd { margin: 0; font-weight: 700; text-align: right; overflow-wrap: anywhere; }
.ai-connection { margin-top: var(--space-3); font-size: var(--text-sm); }
.ai-connection[hidden] { display: none; }
.ai-connection p { margin: 0 0 var(--space-2); }
.ai-connection__ok { color: var(--color-success); font-weight: 600; }
.ai-connection__error { color: var(--color-danger); font-weight: 600; }
.ai-connection__warning { padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); background: var(--color-warning-bg); color: var(--color-warning); }
