/* Copyright (c) 2026 MYTH TECHNOLOGIES. All rights reserved. */
/* ============================================================
   Team Management — Operations console SPA (OPS-TEAM-MGMT-UI-001)
   Design ported from the DriverPro back-office "Team Management",
   extended with the product-scoped-role dimension.
   MYTH Technologies © 2024-2026
   ============================================================ */

:root {
  color-scheme: dark light;

  /* ── Palette (dark, default) ── */
  --bg:           #060b18;
  --bg-2:         #0a1020;
  --surface:      rgba(10, 16, 32, 0.90);
  --surface-2:    rgba(14, 22, 44, 0.95);
  --surface-3:    rgba(18, 28, 56, 0.80);
  --line:         rgba(110, 140, 220, 0.12);
  --line-2:       rgba(110, 140, 220, 0.22);
  --text:         #eaefff;
  --muted:        #8695b8;
  --muted-2:      #b4bede;

  /* ── Accents ── */
  --indigo:       #6c7fff;
  --indigo-dim:   rgba(108, 127, 255, 0.14);
  --indigo-glow:  rgba(108, 127, 255, 0.30);
  --ok:           #4ecf8e;
  --ok-dim:       rgba(78, 207, 142, 0.12);
  --warn:         #f5b349;
  --warn-dim:     rgba(245, 179, 73, 0.12);
  --danger:       #f06878;
  --danger-dim:   rgba(240, 104, 120, 0.12);
  --purple:       #a87fff;
  --purple-dim:   rgba(168, 127, 255, 0.14);
  --teal:         #4ce8d8;
  --teal-dim:     rgba(76, 232, 216, 0.12);

  /* ── Role colors ── */
  --role-admin:     #a87fff;
  --role-admin-bg:  rgba(168, 127, 255, 0.12);
  --role-support:   #60a5f5;
  --role-support-bg: rgba(96, 165, 245, 0.12);
  --role-dev:       #4ecf8e;
  --role-dev-bg:    rgba(78, 207, 142, 0.12);
  --role-qa:        #f5b349;
  --role-qa-bg:     rgba(245, 179, 73, 0.12);
  --role-ops:       #4ce8d8;
  --role-ops-bg:    rgba(76, 232, 216, 0.12);
  --role-auditor:   #94a3b8;
  --role-auditor-bg: rgba(148, 163, 184, 0.10);
  --role-moderator: #f472b6;
  --role-moderator-bg: rgba(244, 114, 182, 0.12);
  --role-default:   #8695b8;
  --role-default-bg: rgba(134, 149, 184, 0.10);

  /* ── Layout ── */
  --sidebar-w:    248px;
  --detail-w:     440px;
  --radius-sm:    8px;
  --radius:       12px;
  --radius-lg:    18px;
  --radius-xl:    24px;
  --shadow-sm:    0 2px 12px rgba(0,0,0,0.28);
  --shadow:       0 8px 36px rgba(0,0,0,0.40);
  --shadow-xl:    0 24px 80px rgba(0,0,0,0.56);

  /* ── Typography ── */
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;   /* Inter retirée : jamais livrée (OPS-CONSOLE-FONT-DETERMINISM-001) */
  --mono: 'IBM Plex Mono', 'SFMono-Regular', ui-monospace, Menlo, monospace;
}

/* ── Light theme ── */
@media (prefers-color-scheme: light) {
  :root {
    --bg:        #f4f6fb;
    --bg-2:      #eef1f8;
    --surface:   #ffffff;
    --surface-2: #ffffff;
    --surface-3: #f2f5fb;
    --line:      rgba(60, 80, 140, 0.14);
    --line-2:    rgba(60, 80, 140, 0.24);
    --text:      #17203a;
    --muted:     #5b6785;
    --muted-2:   #3a4664;
  }
}
html[data-theme="light"] { --bg:#f4f6fb; --bg-2:#eef1f8; --surface:#fff; --surface-2:#fff; --surface-3:#f2f5fb; --line:rgba(60,80,140,.14); --line-2:rgba(60,80,140,.24); --text:#17203a; --muted:#5b6785; --muted-2:#3a4664;  --purple:#6d5bc6;}
html[data-theme="dark"] { --bg:#060b18; --bg-2:#0a1020; --surface:rgba(10,16,32,.90); --surface-2:rgba(14,22,44,.95); --surface-3:rgba(18,28,56,.80); --text:#eaefff; --muted:#8695b8; --muted-2:#b4bede; }

/* ── Reset ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body, #root { min-height: 100%; margin: 0; }
body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

/* Le lissage en niveaux de gris n'est un gain que sur fond SOMBRE, où le rendu
   sous-pixels déborde en franges colorées. Sur fond CLAIR il fait l'inverse :
   il supprime le sous-pixel, amincit les glyphes et délave le texte. La règle
   était posée sans condition alors que cette console a DEUX thèmes.
   (macOS uniquement : Chrome ignore la propriété sous Windows.) */
html[data-theme="dark"] body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: transparent;
  z-index: 0;
}
@media (prefers-color-scheme: light) {
  body::before { opacity: 0.5; }
}
#root { position: relative; z-index: 1; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: inherit; text-decoration: none; }
p, h1, h2, h3, h4, h5 { margin: 0; }
svg {
  width: 16px; height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--indigo);
  outline-offset: 2px;
}
.icon { display: inline-flex; align-items: center; }
.icon svg { width: 1em; height: 1em; }

/* ── Shell ───────────────────────────────────────────── */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}
.shell.detail-open {
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--detail-w);
}
.mobile-menu-toggle, .mobile-navigation { display: none; }

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  background: rgba(6, 10, 22, 0.98);
  border-right: 1px solid var(--line);
}
@media (prefers-color-scheme: light) {
  .sidebar { background: #ffffff; }
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--line);
}
.brand-icon {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--indigo);
  flex-shrink: 0;
}
.myth-mark { width:34px; height:34px; object-fit:contain; flex:0 0 auto; }
.brand-icon svg { stroke: #fff; width: 17px; height: 17px; }
.brand-copy { min-width: 0; }
.brand-copy strong {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-copy small {
  display: block;
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ── Nav ── */
.nav { flex: 1; padding: 10px 10px; overflow-y: auto; }
.nav-group-label {
  padding: 12px 8px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--muted);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--muted-2);
  font-size: 13.5px;
  font-weight: 500;
  background: transparent;
  transition: background 120ms, color 120ms;
  text-align: left;
}
.nav-item:hover { background: var(--indigo-dim); color: var(--text); }
.nav-item.active {
  background: var(--indigo-dim);
  color: var(--indigo);
  font-weight: 600;
}
.nav-item svg { width: 16px; height: 16px; opacity: 0.8; }
.nav-item.active svg { opacity: 1; }
.nav-badge {
  margin-left: auto;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: 9px;
  background: rgba(108,127,255,0.2);
  color: var(--indigo);
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--muted-2);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 120ms, color 120ms;
}
.nav-link:hover { background: var(--indigo-dim); color: var(--text); }

/* ── Sidebar footer ── */
.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 6px;
}
.me-card {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  border: 1px solid var(--line);
  width:100%; color:var(--text); text-align:left; cursor:pointer;
}
.me-card:hover { border-color:var(--indigo); background:var(--indigo-dim); }
.me-open { color:var(--indigo); font-size:10px; font-weight:700; white-space:nowrap; }
.me-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--indigo);
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.me-info { min-width: 0; flex: 1; }
.me-name {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.me-email {
  margin-top: 1px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.me-role {
  margin-top: 1px;
  font-size: 10.5px;
  color: var(--muted);
}
.btn-logout, .btn-change-pw {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--muted-2);
  font-size: 12.5px;
  background: transparent;
  transition: background 120ms, color 120ms;
  text-align: left;
}
.btn-theme { width:100%; min-height:32px; border:1px solid var(--line); border-radius:var(--radius-sm); color:var(--muted-2); background:transparent; font-size:15px; }
.btn-theme:hover { border-color:var(--indigo); color:var(--indigo); }
.btn-change-pw:hover { background: var(--indigo-dim); color: var(--indigo); }
.btn-logout:hover { background: var(--danger-dim); color: var(--danger); }

/* ── Main area ───────────────────────────────────────── */
.main { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }

/* ── Topbar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 66px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  /* Fond OPAQUE, sans `backdrop-filter`. Un flou d'arrière-plan force le
     navigateur à composer la barre dans sa propre couche, et le texte d'une
     couche non opaque perd le lissage sous-pixels (ClearType sur Windows,
     LCD text ailleurs) : il repasse en niveaux de gris et paraît cotonneux.
     Le verre dépoli coûtait donc la netteté de l'en-tête pour flouter un fond
     uni, qui n'a rien à flouter (OPS-CONSOLE-FONT-SMOOTHING-001). */
  background: var(--bg);
}
.topbar-left { min-width: 0; }
.topbar-eyebrow {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--indigo);
  margin-bottom: 2px;
}
.topbar-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.topbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
}
.topbar-right > .account-summary,
.topbar-right > .btn,
.topbar-right > .btn-icon {
  height: 40px;
}
.account-summary {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  max-width: 360px;
  padding: 4px 9px 4px 6px;
  color: var(--text);
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
  transition: border-color 120ms, background 120ms;
}
.account-summary:hover { border-color: var(--indigo); background: var(--indigo-dim); }
.account-avatar {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 7px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}
.account-copy {
  display: grid;
  min-width: 0;
  line-height: 1.22;
}
.account-copy strong,
.account-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-copy strong { font-size: 12px; font-weight: 700; }
.account-copy span { color: var(--muted); font-size: 10.5px; }
.account-role {
  flex: 0 0 auto;
  padding: 3px 6px;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  color: var(--indigo);
  font-size: 10px;
  font-weight: 700;
}
.btn-theme-top { flex: 0 0 auto; }
.topbar-right > .btn-icon { width: 40px; }

/* ── Filter bar ── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 16, 32, 0.60);
  flex-wrap: wrap;
}
@media (prefers-color-scheme: light) {
  .filter-bar { background: var(--surface-3); }
}
.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 340px;
}
.search-wrap svg {
  position: absolute;
  left: 10px;
  top: 50%; transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.search-input {
  width: 100%;
  height: 36px;
  padding: 0 10px 0 34px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13.5px;
  outline: none;
  transition: border-color 150ms;
}
.search-input:focus { border-color: var(--indigo); box-shadow: 0 0 0 3px var(--indigo-dim); }

.filter-select {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  outline: none;
  cursor: pointer;
  min-width: 120px;
  transition: border-color 150ms;
}
.filter-select:focus { border-color: var(--indigo); }

.filter-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
}
.role-shortcuts {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  padding-top: 2px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.role-shortcut {
  flex: 0 0 auto;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line-2);
  border-radius: 5px;
  background: var(--surface-3);
  color: var(--muted-2);
  font-size: 11.5px;
  font-weight: 650;
  white-space: nowrap;
}
.role-shortcut:hover { border-color: var(--indigo); color: var(--indigo); }
.role-shortcut.active { border-color: var(--indigo); background: var(--indigo-dim); color: var(--indigo); }

/* ── Page content ── */
.page { padding: 20px 24px; flex: 1; }

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: filter 130ms, box-shadow 130ms;
  border: 1px solid transparent;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { filter: brightness(0.96); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; filter: none; }

.btn-primary {
  background: var(--indigo);
  color: #fff;
  box-shadow: 0 4px 16px rgba(108,127,255,0.28);
}
.btn-primary:hover { box-shadow: 0 6px 24px rgba(108,127,255,0.42); }

.btn-secondary {
  background: var(--surface-3);
  border-color: var(--line-2);
  color: var(--muted-2);
}
.btn-secondary:hover { color: var(--text); border-color: var(--indigo); }

.btn-ghost {
  background: transparent;
  border-color: var(--line-2);
  color: var(--muted-2);
}
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }

.btn-danger {
  background: var(--danger-dim);
  border-color: rgba(240,104,120,0.32);
  color: var(--danger);
}
.btn-danger:hover { background: rgba(240,104,120,0.22); }

.btn-warn {
  background: var(--warn-dim);
  border-color: rgba(245,179,73,0.30);
  color: var(--warn);
}

.btn-ok {
  background: var(--ok-dim);
  border-color: rgba(78,207,142,0.30);
  color: var(--ok);
}

.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 11.5px; }
.btn-icon {
  width: 34px; height: 34px; padding: 0;
  display: inline-grid; place-items: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--surface-3);
  color: var(--muted-2);
  transition: border-color 120ms, color 120ms, background 120ms;
}
.btn-icon:hover { border-color: var(--indigo); color: var(--indigo); background: var(--indigo-dim); }
.btn-icon svg { width: 15px; height: 15px; }

/* ── User table ───────────────────────────────────────── */
.users-table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table-scroll { overflow-x: auto; }
.users-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}
.users-table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  background: rgba(10, 16, 32, 0.92);
  white-space: nowrap;
}
@media (prefers-color-scheme: light) {
  .users-table th { background: var(--surface-3); }
}
.users-table tbody tr {
  cursor: pointer;
  transition: background 100ms;
  border-bottom: 1px solid var(--line);
}
.users-table tbody tr:last-child { border-bottom: none; }
.users-table tbody tr:hover {
  background: var(--indigo-dim);
  box-shadow: inset 3px 0 0 var(--indigo);
}
.users-table tbody tr.selected {
  background: rgba(108, 127, 255, 0.09);
  box-shadow: inset 3px 0 0 var(--indigo);
}
.users-table td {
  padding: 12px 16px;
  vertical-align: middle;
}
.users-table td.access-cell,
.users-table td.products-cell {
  vertical-align: middle;
  text-align: left;
}

/* ── User row cells ── */
.user-cell {
  display: flex;
  align-items: center;
  gap: 11px;
}
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  position: relative;
}
.user-avatar::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.18);
}
.user-email {
  font-size: 13.5px;
  font-weight: 500;
}
.user-name {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 1px;
}
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.muted-2 { color: var(--muted-2); }

/* ── Status pills ── */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.status-pill::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.status-active    { color: var(--ok);      background: var(--ok-dim);     }
.status-suspended { color: var(--warn);    background: var(--warn-dim);   }
.status-banned    { color: var(--danger);  background: var(--danger-dim); }
.status-pending   { color: var(--muted-2); background: rgba(134,149,184,0.10); }

/* ── Role badges ── */
.role-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}
.table-chip-stack { display: grid; justify-content: start; gap: 5px; }
.table-chip-row { display: flex; align-items: center; justify-content: flex-start; gap: 5px; min-height: 20px; }
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.role-badge svg { width: 12px; height: 12px; }
.role-admin    { color: var(--role-admin);     background: var(--role-admin-bg);     border-color: rgba(168,127,255,0.22); }
.role-support  { color: var(--role-support);   background: var(--role-support-bg);   border-color: rgba(96,165,245,0.22); }
.role-dev      { color: var(--role-dev);       background: var(--role-dev-bg);       border-color: rgba(78,207,142,0.22); }
.role-qa       { color: var(--role-qa);        background: var(--role-qa-bg);        border-color: rgba(245,179,73,0.22); }
.role-ops      { color: var(--role-ops);       background: var(--role-ops-bg);       border-color: rgba(76,232,216,0.22); }
.role-auditor  { color: var(--role-auditor);   background: var(--role-auditor-bg);   border-color: rgba(148,163,184,0.18); }
.role-moderator{ color: var(--role-moderator); background: var(--role-moderator-bg); border-color: rgba(244,114,182,0.22); }
.role-default  { color: var(--role-default);   background: var(--role-default-bg);   border-color: rgba(134,149,184,0.18); }

/* Product-scoped role chip: role @ product (OPS-TEAM-MGMT-UI-001). */
.product-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px 2px 6px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--line-2);
  background: var(--surface-3);
  white-space: nowrap;
}
.product-chip .at { color: var(--muted); font-weight: 400; }
.product-chip .product-name { color: var(--text); }
.product-chip .role-name { color: var(--indigo); }
.product-count-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--teal);
  background: var(--teal-dim);
  border: 1px solid rgba(76,232,216,0.22);
}
/* Scope tag: distinguishes platform-wide (global) from product-scoped roles. */
.scope-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.scope-global  { color: var(--indigo); background: var(--indigo-dim); border: 1px solid rgba(108,127,255,0.22); }
.scope-product { color: var(--teal);   background: var(--teal-dim);   border: 1px solid rgba(76,232,216,0.22); }

/* ── Must-change badge ── */
.must-change-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--warn);
  background: var(--warn-dim);
  border: 1px solid rgba(245,179,73,0.22);
  white-space: nowrap;
}
.must-change-badge svg { width: 12px; height: 12px; }
.lock-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--danger);
  background: var(--danger-dim);
  border: 1px solid rgba(240,104,120,0.22);
  white-space: nowrap;
}

/* ── KPI strip ── */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.kpi-card {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  display: grid;
  gap: 4px;
}
.kpi-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.kpi-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}
.kpi-card.kpi-total  .kpi-value { color: var(--text); }
.kpi-card.kpi-active .kpi-value { color: var(--ok); }
.kpi-card.kpi-admin  .kpi-value { color: var(--purple); }
.kpi-card.kpi-warn   .kpi-value { color: var(--warn); }
.kpi-card.kpi-info   .kpi-value { color: var(--indigo); }
.kpi-sub {
  font-size: 11.5px;
  color: var(--muted);
}

/* ── Empty state ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 64px 24px;
  text-align: center;
}
.empty-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius);
  background: var(--surface-3);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  color: var(--muted);
}
.empty-icon svg { width: 24px; height: 24px; }
.empty-title { font-size: 15px; font-weight: 600; }
.empty-desc { font-size: 13px; color: var(--muted); max-width: 320px; }

/* ── Detail panel ─────────────────────────────────────── */
.detail {
  border-left: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}
.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}
.detail-user {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.detail-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  position: relative;
}
.detail-avatar::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.18);
}
.detail-name-block { min-width: 0; }
.detail-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.detail-email {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.detail-close {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--surface-3);
  color: var(--muted-2);
  flex-shrink: 0;
  transition: color 120ms, border-color 120ms;
}
.detail-close:hover { color: var(--text); border-color: var(--muted-2); }
.detail-close svg { width: 15px; height: 15px; }

.detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(110,140,220,0.24) transparent;
}

.detail-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.detail-section-title {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 0;
  font-size: 13px;
}
.detail-row-label { color: var(--muted); font-size: 12.5px; }
.detail-row-value { font-weight: 500; text-align: right; }

.detail-roles-list { display: flex; flex-direction: column; gap: 8px; }
.detail-role-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  border: 1px solid var(--line);
}
.detail-role-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.detail-role-name { font-size: 13px; font-weight: 600; }
.detail-role-meta { font-size: 11px; color: var(--muted); }

.detail-actions {
  padding: 16px 20px;
  display: grid;
  gap: 8px;
}
.detail-action-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.readonly-note {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  padding: 8px 0;
}

/* ── Roles view ───────────────────────────────────────── */
.roles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.role-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  display: grid;
  gap: 12px;
  transition: border-color 150ms;
}
.role-card:hover { border-color: var(--line-2); }
.role-card-header { display: flex; align-items: center; gap: 10px; }
.role-card-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.role-card-icon svg { width: 18px; height: 18px; }
.role-card-name { font-size: 14.5px; font-weight: 700; }
.role-card-key { font-size: 11.5px; color: var(--muted); font-family: var(--mono); margin-top: 1px; }
.role-card-desc { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.role-card-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  gap: 12px;
}
.pagination-info { font-size: 12.5px; color: var(--muted); }
.pagination-btns { display: flex; gap: 6px; }

/* ── Modals ───────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 18, 0.72);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  animation: fadein 150ms ease;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 500px;
  animation: slidein 200ms cubic-bezier(0.22, 0.68, 0, 1.2);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
}
@keyframes slidein { from { transform: translateY(16px) scale(0.97); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}
.modal-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 9px;
}
.modal-title svg { width: 18px; height: 18px; color: var(--indigo); }
.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  border: 1px solid var(--line-2);
  background: var(--surface-3);
  color: var(--muted-2);
  transition: color 120ms, border-color 120ms;
}
.modal-close:hover { color: var(--text); border-color: var(--muted-2); }
.modal-close svg { width: 15px; height: 15px; }

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
}

/* ── Form fields ── */
.form-group {
  display: grid;
  gap: 5px;
  margin-bottom: 14px;
}
.form-group:last-child { margin-bottom: 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.create-product-assignments { display: grid; gap: 7px; max-height: 196px; overflow-y: auto; padding-right: 4px; }
.create-product-assignment { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(142px, .9fr); align-items: center; gap: 8px; padding: 8px 9px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 13px; }
.create-product-assignment .form-select { min-height: 32px; padding: 5px 8px; }
.create-product-assignment input { width: 15px; height: 15px; }
.create-product-assignment.is-disabled { opacity: .72; background: color-mix(in srgb, var(--warn-dim) 38%, transparent); }
.product-availability { justify-self: end; display: inline-flex; align-items: center; gap: 5px; padding: 3px 7px; border-radius: 99px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.product-availability::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.product-availability-active { color: var(--ok); background: var(--ok-dim); }
.product-availability-planned { color: var(--warn); background: var(--warn-dim); }
.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted-2);
  letter-spacing: 0.03em;
}
.form-label .req { color: var(--danger); margin-left: 2px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0 12px;
  height: 40px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: rgba(6, 10, 22, 0.70);
  color: var(--text);
  font-size: 13.5px;
  outline: none;
  transition: border-color 150ms, box-shadow 150ms;
}
@media (prefers-color-scheme: light) {
  .form-input, .form-select, .form-textarea { background: var(--surface-3); }
}
.form-textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 80px; }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--indigo-dim);
}
.form-select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238695b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 36px; }
.form-hint { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 3px; }

/* ── Scope switch (global vs product) ── */
.scope-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.scope-option {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: rgba(6,10,22,0.5);
  cursor: pointer;
  transition: border-color 120ms, background 120ms;
}
@media (prefers-color-scheme: light) { .scope-option { background: var(--surface-3); } }
.scope-option.active { border-color: var(--indigo); background: var(--indigo-dim); }
.scope-option-title { font-size: 13px; font-weight: 600; }
.scope-option-desc { font-size: 11px; color: var(--muted); }

/* ── Password strength ── */
.password-strength {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}
.strength-bar {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: var(--line-2);
  transition: background 250ms;
}
.strength-bar.fill-1 { background: var(--danger); }
.strength-bar.fill-2 { background: var(--warn); }
.strength-bar.fill-3 { background: var(--ok); }

/* ── Secret (temp password shown once) ── */
.secret-panel {
  border: 1px solid rgba(245,179,73,0.32);
  background: var(--warn-dim);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  gap: 10px;
}
.secret-box { display: flex; gap: 8px; align-items: center; }
.secret-value {
  flex: 1;
  font-family: var(--mono);
  font-size: 15px;
  letter-spacing: 0.02em;
  background: rgba(6,10,22,0.55);
  border: 1px dashed var(--warn);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  word-break: break-all;
  user-select: all;
}
@media (prefers-color-scheme: light) { .secret-value { background: #fff; } }
.secret-note { font-size: 12px; color: var(--warn); line-height: 1.5; }

/* ── Confirm dialog ── */
.confirm-modal { max-width: 420px; }
.confirm-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 28px 24px;
  text-align: center;
}
.confirm-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  display: grid; place-items: center;
}
.confirm-icon.danger { background: var(--danger-dim); color: var(--danger); }
.confirm-icon.warn { background: var(--warn-dim); color: var(--warn); }
.confirm-icon.ok { background: var(--ok-dim); color: var(--ok); }
.confirm-icon svg { width: 26px; height: 26px; }
.confirm-title { font-size: 17px; font-weight: 700; }
.confirm-desc { font-size: 13.5px; color: var(--muted); line-height: 1.55; max-width: 320px; }

/* ── Toast ─────────────────────────────────────────────── */
.toast-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow);
  min-width: 280px;
  max-width: 400px;
  pointer-events: all;
  animation: toast-in 250ms cubic-bezier(0.22,0.68,0,1.2);
}
@keyframes toast-in { from { transform: translateY(12px) scale(0.96); opacity:0; } to { transform:none; opacity:1; } }
.toast-icon { width: 28px; height: 28px; border-radius: 50%; display:grid; place-items:center; flex-shrink:0; }
.toast-icon svg { width: 14px; height: 14px; }
.toast.ok .toast-icon { background: var(--ok-dim); color: var(--ok); }
.toast.error .toast-icon { background: var(--danger-dim); color: var(--danger); }
.toast.info .toast-icon { background: var(--indigo-dim); color: var(--indigo); }
.toast.warn .toast-icon { background: var(--warn-dim); color: var(--warn); }
.toast-msg { font-size: 13.5px; font-weight: 500; flex: 1; }
.toast-dismiss { color: var(--muted); background: none; border: none; padding: 2px; }
.toast-dismiss:hover { color: var(--text); }
.toast-dismiss svg { width: 14px; height: 14px; }

/* ── Loading skeleton ── */
.skeleton {
  background: var(--surface-3);
  animation: none;
  border-radius: 6px;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ── Loading spinner ── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--line-2);
  border-top-color: var(--indigo);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Banner ── */
.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  font-size: 13px;
  border-bottom: 1px solid;
}
.banner.info { background: var(--indigo-dim); border-color: rgba(108,127,255,0.22); color: var(--indigo); }
.banner.danger { background: var(--danger-dim); border-color: rgba(240,104,120,0.22); color: var(--danger); }
.banner.warn { background: var(--warn-dim); border-color: rgba(245,179,73,0.22); color: var(--warn); }
.banner svg { flex-shrink: 0; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(110,140,220,0.24); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(110,140,220,0.42); }

/* ── Responsive ── */
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .shell.detail-open { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .detail {
    position: fixed;
    inset: 0 0 0 auto;
    width: min(var(--detail-w), 100vw);
    z-index: 50;
    box-shadow: var(--shadow-xl);
  }
}

/* ── Operations refresh: restrained admin surface, explicit saved themes ─── */
html[data-theme="dark"] {
  --bg: #09111c;
  --bg-2: #0d1724;
  --surface: #101b29;
  --surface-2: #142131;
  --surface-3: #19283a;
  --line: rgba(160, 185, 215, .15);
  --line-2: rgba(160, 185, 215, .28);
  --text: #edf3fa;
  --muted: #95a5b9;
  --muted-2: #c8d3e1;
  --indigo: #6098e0;
  --indigo-dim: rgba(87, 147, 222, .13);
  --ok: #43b982;
  --ok-dim: rgba(67, 185, 130, .12);
  --warn: #d89d39;
  --warn-dim: rgba(216, 157, 57, .12);
  --danger: #df6d78;
  --danger-dim: rgba(223, 109, 120, .12);
}
html[data-theme="light"] {
  --bg: #f4f7fb;
  --bg-2: #eaf0f7;
  --surface: #ffffff;
  --surface-2: #ffffff;
  --surface-3: #f3f6fa;
  --line: rgba(47, 70, 101, .14);
  --line-2: rgba(47, 70, 101, .26);
  --text: #14243a;
  --muted: #5f7187;
  --muted-2: #3e5169;
  --indigo: #205e9f;
  --indigo-dim: rgba(37, 109, 184, .10);
  --ok: #197a55;
  --ok-dim: rgba(25, 122, 85, .10);
  --warn: #8a5810;
  --warn-dim: rgba(154, 98, 18, .10);
  --danger: #b94855;
  --danger-dim: rgba(185, 72, 85, .09);
  /* Badges de rôle en CLAIR : mêmes teintes, luminance baissée pour AA ≥ 4,5:1 sur fond blanc
     teinté (2,3–2,6:1 au tour web du 12/11) — OPS-WEB-KO-CAMPAGNE-1211-001. */
  --role-admin: #6d43c9; --role-support: #1f63b3; --role-dev: #17744a; --role-qa: #855700;
  --role-ops: #0d6d65; --role-auditor: #526073; --role-moderator: #ad2c6b; --role-default: #55617e;
}
html[data-theme="light"] .sidebar { background: #fff; }
/* OPS-CONSOLE-RESTES-TOUR-NUIT-1311-001 — les initiales blanches des avatars (liste, fiche, carte
   du compte) passent par les teintes de `avatarColor()` (staff/app.js), assombries au plus près :
   ≥ 4,6:1 sous le blanc. Le voile intérieur à 50 % du 12/11 est retiré : il assombrissait trop
   (noircissait les teintes) et la carte du compte (.account-avatar) n'en profitait pas (2,65:1). */
/* Thème sombre : le bouton principal (« Ajouter un membre ») gardait son aplat clair #6098e0 sous
   un texte blanc (2,97:1), et le badge du menu son encre #6098e0 sur l'entrée active (3,91:1). */
html[data-theme="dark"] .btn-primary { background: #2974d4; }
html[data-theme="dark"] .nav-badge { color: #75a6e4; }
html[data-theme="light"] .topbar { background: rgba(255,255,255,.94); }
html[data-theme="dark"] .sidebar { background: #0c1520; }
html[data-theme="dark"] .topbar { background: rgba(9,17,28,.94); }
body { background: var(--bg); }
body::before { display: none; }
.shell { grid-template-columns: 238px minmax(0, 1fr); }
.shell.detail-open { grid-template-columns: 238px minmax(0, 1fr) 410px; }
.sidebar { background: var(--surface); }
.brand { min-height: 72px; padding: 18px 16px; }
.myth-mark { width: 36px; height: 36px; }
.nav { padding: 12px 10px; }
.nav-group-label { padding: 16px 8px 7px; }
.nav-item, .nav-link { min-height: 38px; border-radius: 6px; }
.sidebar-footer { gap: 8px; padding: 12px; }
.me-card { border-radius: 6px; background: var(--surface-3); }
.btn-theme { min-height: 34px; border-radius: 6px; }
.topbar { min-height: 72px; padding: 14px 26px; background: var(--surface); }
.topbar-title { font-size: 19px; letter-spacing: 0; }
.topbar-eyebrow { color: var(--indigo); }
.page { max-width: 1480px; padding: 24px 26px 30px; }
.kpi-strip { gap: 0; margin-bottom: 18px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--line); }
.kpi-card { min-height: 108px; padding: 17px 18px; border: 0; border-right: 1px solid var(--line); border-radius: 0; background: var(--surface); }
.kpi-card:last-child { border-right: 0; }
.kpi-label { letter-spacing: .09em; }
.kpi-value { font-size: 27px; letter-spacing: 0; }
.filter-bar { gap: 9px; padding: 12px 14px; border: 1px solid var(--line); border-bottom: 0; background: var(--surface); }
.search-wrap { max-width: 390px; }
.search-input, .filter-select { border-radius: 6px; background: var(--surface-3); }
.filter-count { margin-left: auto; }
.users-table-wrap { border: 1px solid var(--line); border-radius: 0 0 8px 8px; background: var(--surface); box-shadow: none; }
.users-table th { height: 42px; background: var(--surface-3); }
.users-table td { padding: 13px 14px; }
.users-table tbody tr:hover { background: var(--indigo-dim); }
.users-table tbody tr.selected { background: var(--indigo-dim); box-shadow: inset 3px 0 0 var(--indigo); }
.user-avatar, .detail-avatar { border-radius: 8px; }
.user-avatar::after, .detail-avatar::after { display: none; }
.status-pill, .role-badge, .product-chip, .product-count-badge, .must-change-badge, .lock-badge { border-radius: 5px; }
.detail { background: var(--surface); border-left-color: var(--line); }
.detail-header { padding: 18px; background: var(--surface); }
.detail-section { padding: 16px 18px; }
.detail-actions { padding: 16px 18px; }
.detail-role-row { border-radius: 6px; background: var(--surface-3); }
.role-card, .empty-icon { border-radius: 8px; }
.role-card { padding: 16px; background: var(--surface); }
.modal { border-radius: 8px; background: var(--surface-2); }
.modal-backdrop { background: rgba(5, 12, 20, .58); backdrop-filter: blur(3px); }
.form-input, .form-select, .form-textarea { border-radius: 6px; background: var(--surface-3); }
.scope-option, .secret-panel, .secret-value { border-radius: 6px; }
.toast { border-radius: 6px; background: var(--surface-2); }
.skeleton { background: var(--surface-3); animation: none; }
@media (max-width: 980px) {
  .page { padding: 18px; }
  .topbar { padding: 13px 18px; }
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .kpi-card:nth-child(2) { border-right: 0; }
  .kpi-card:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 620px) {
  .page { padding: 14px; }
  .topbar { align-items: flex-start; padding: 12px 14px; }
  .topbar-right { gap: 7px; }
  .topbar .btn-primary { min-width: 0; padding: 0 10px; }
  .account-summary { max-width: 155px; }
  .account-role { display: none; }
  .kpi-strip { grid-template-columns: 1fr 1fr; }
  .filter-count { width: 100%; margin-left: 0; }
  .filter-bar { border-radius: 8px 8px 0 0; }
}

/* Affectation par produit : le role est accorde sur CHAQUE produit coche. */
.product-checks { display: flex; flex-direction: column; gap: .35rem; max-height: 12rem; overflow-y: auto; }
.product-check { display: flex; align-items: center; gap: .5rem; font-size: .9em; cursor: pointer; }
.product-check input { margin: 0; }

/* Ces règles doivent rester après le rafraîchissement desktop ci-dessus : la
   cascade ne doit jamais réintroduire la colonne latérale sous 980 px. */
@media (max-width: 980px) {
  .shell, .shell.detail-open { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .main { min-width: 0; width: 100%; }
  .mobile-menu-toggle { display: grid; }
  .mobile-navigation.open {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
  }
  .mobile-navigation .nav-item, .mobile-navigation .nav-link {
    min-height: 44px;
    padding: 9px 10px;
  }
  .page, .users-table-wrap, .table-scroll { min-width: 0; max-width: 100%; }
  .table-scroll { overflow-x: auto; overscroll-behavior-inline: contain; }
  .modal { max-width: calc(100vw - 24px); max-height: calc(100vh - 24px); }
  .modal-body { overflow-y: auto; }
}

@media (max-width: 620px) {
  .topbar { align-items: center; }
  .topbar-left { min-width: 0; }
  .topbar-eyebrow { display: none; }
  .topbar-title { font-size: 16px; line-height: 1.2; }
  .account-summary { display: none; }
  .topbar .btn-icon, .topbar .btn-primary { min-width: 42px; min-height: 42px; }
  .topbar .btn-primary { width: 42px; overflow: hidden; white-space: nowrap; font-size: 0; }
  .topbar .btn-primary svg { width: 18px; height: 18px; }
  .mobile-navigation.open { grid-template-columns: 1fr; }
  .filter-bar > .search-wrap, .filter-select { width: 100%; max-width: none; }
  .role-shortcut { min-height: 40px; }
}
