/* CadFinance — feuille de style.
   Système de design issu de l'identité visuelle validée le 22.09.2026
   (voir "CadFinance Identité design/" à la racine du projet, produit avec
   un outil de maquettage à partir du prompt DESIGN-PROMPT.md). Mode clair par défaut,
   mode sombre automatique selon la préférence système (prefers-color-scheme) —
   aucun bouton de bascule n'a été prévu dans la maquette. */

/* Police Inter chargée depuis partials/head.ejs (preconnect + <link>, plus
   rapide qu'un @import CSS qui retarde le premier rendu). */

:root {
  color-scheme: light;

  /* Fonds et surfaces */
  --bg-auth: #005289;
  --bg-app: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --hover: #f9fafb;

  /* Texte */
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --ph: #9ca3af;

  /* Bordures */
  --border: #d1d5db;
  --subtle: #e5e7eb;
  --card-bd: transparent;

  /* Accent / actions */
  --action: #005289;
  --action-hover: #004879;
  --action-press: #003b63;
  --on-action: #ffffff;
  --on-action-hover: #ffffff;
  --tert-hover: #f2f6f9;
  --ring: rgba(138, 175, 201, .4);

  /* Barre supérieure */
  --topbar: #005289;
  --topbar-bd: transparent;

  /* Ombres */
  --shadow-card: 0 25px 50px -12px rgba(0, 0, 0, .25);
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, .1);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .05);

  /* États désactivés */
  --dis-bg: #d1d5db;
  --dis-tx: #6b7280;

  /* Danger */
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --err-msg: #dc2626;

  /* Interrupteur */
  --switch-off: #d1d5db;

  /* Couleurs sémantiques (fond / bordure / texte) */
  --ok: #16a34a;    --ok-bg: #f0fdf4;   --ok-bd: #bbf7d0;   --ok-tx: #166534;
  --err: #dc2626;   --err-bg: #fef2f2;  --err-bd: #fecaca;  --err-tx: #991b1b;
  --warn-bg: #fffbeb; --warn-bd: #fde68a; --warn-tx: #92400e;
  --info-bg: #f2f6f9; --info-bd: #b8cfde; --info-tx: #002d4b;
  --neu-bg: #f3f4f6;  --neu-bd: #f3f4f6;  --neu-tx: #4b5563;

  /* Statut de synchronisation */
  --run: #4d86ac;
  --idle: #9ca3af;

  /* Logos sur fond coloré */
  --logo-pill: transparent;

  /* Badges par école (oklch, teinte constante entre claire/sombre) */
  --sch-cad-bg: oklch(0.95 0.03 285); --sch-cad-tx: oklch(0.42 0.1 285);
  --sch-sawi-bg: oklch(0.95 0.03 340); --sch-sawi-tx: oklch(0.42 0.1 340);
  --sch-fmp-bg: oklch(0.95 0.03 200); --sch-fmp-tx: oklch(0.42 0.08 200);

  /* Rayons */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 999px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --bg-auth: #001f34;
    --bg-app: #030712;
    --surface: #111827;
    --surface-2: #1f2937;
    --hover: #1f2937;

    --text: #f9fafb;
    --text-2: #d1d5db;
    --muted: #9ca3af;
    --ph: #6b7280;

    --border: #374151;
    --subtle: #1f2937;
    --card-bd: #1f2937;

    --action: #4d86ac;
    --action-hover: #8aafc9;
    --action-press: #005289;
    --on-action: #ffffff;
    --on-action-hover: #001f34;
    --tert-hover: #1f2937;
    --ring: rgba(77, 134, 172, .4);

    --topbar: #001f34;
    --topbar-bd: #1f2937;

    --shadow-card: 0 25px 50px -12px rgba(0, 0, 0, .6);
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, .4);
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .4);

    --dis-bg: #374151;
    --dis-tx: #6b7280;

    --danger: #dc2626;
    --danger-hover: #ef4444;
    --err-msg: #f87171;

    --switch-off: #374151;

    --ok: #16a34a;    --ok-bg: rgba(22, 163, 74, .15);  --ok-bd: rgba(22, 163, 74, .4);  --ok-tx: #4ade80;
    --err: #dc2626;   --err-bg: rgba(220, 38, 38, .15); --err-bd: rgba(220, 38, 38, .4); --err-tx: #f87171;
    --warn-bg: rgba(217, 119, 6, .15); --warn-bd: rgba(217, 119, 6, .4); --warn-tx: #fbbf24;
    --info-bg: rgba(77, 134, 172, .15); --info-bd: #003b63; --info-tx: #8aafc9;
    --neu-bg: #1f2937; --neu-bd: #1f2937; --neu-tx: #9ca3af;

    --run: #4d86ac;
    --idle: #6b7280;

    --logo-pill: #ffffff;

    --sch-cad-bg: oklch(0.3 0.06 285); --sch-cad-tx: oklch(0.84 0.07 285);
    --sch-sawi-bg: oklch(0.3 0.06 340); --sch-sawi-tx: oklch(0.84 0.07 340);
    --sch-fmp-bg: oklch(0.3 0.05 200); --sch-fmp-tx: oklch(0.84 0.06 200);
  }
}

/* ── Base ─────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg-app);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--action); text-decoration: none; }
a:hover { color: var(--action-hover); }
h1 { font-size: 30px; line-height: 36px; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 6px; }
h2 { font-size: 20px; line-height: 28px; font-weight: 600; margin: 24px 0 8px; }
h3 { font-size: 16px; line-height: 24px; font-weight: 600; margin: 0 0 4px; }
p.lead { color: var(--muted); margin: 0 0 20px; font-size: 14px; line-height: 20px; }
.muted { color: var(--muted); font-size: 13px; }
label { display: block; font-size: 14px; line-height: 20px; font-weight: 500; color: var(--text-2); margin: 14px 0 6px; }
input::placeholder { color: var(--ph); }

/* ── Coquille d'authentification ──────────────────────────────────────── */
/* Carte centrée sur le fond de marque, pour connexion / 2FA / invitation /
   codes de secours — le contexte le plus formel de l'application. */
.auth-shell {
  min-height: 100vh;
  background: var(--bg-auth);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 16px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--card-bd);
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.auth-card.wide { max-width: 480px; }
.auth-card h1 { font-size: 24px; line-height: 28px; letter-spacing: -0.01em; }
.auth-card .lead { margin: 0; }
.auth-card form { display: flex; flex-direction: column; gap: 20px; }
.auth-card label { margin: 0 0 6px; }
.auth-footer-links {
  display: flex; justify-content: center; align-items: center; gap: 12px;
  font-size: 14px; line-height: 20px; font-weight: 500;
}
.auth-footer-links a, .auth-footer-links span.link { color: var(--action); cursor: pointer; }
.auth-footer-links span.muted-link { color: var(--muted); cursor: pointer; }

/* Bande des trois logos, sous la carte de connexion */
.school-strip {
  border-top: 1px solid var(--subtle);
  padding-top: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  opacity: .7;
  flex-wrap: wrap;
}
.school-strip img { height: 30px; width: auto; display: block; }
.school-strip .pill { padding: 5px; border-radius: var(--radius-sm); background: var(--logo-pill); display: flex; }

/* ── Coquille applicative (tableau de bord, administration) ──────────── */
.app-shell { min-height: 100vh; background: var(--bg-app); color: var(--text); display: flex; flex-direction: column; }
.topbar {
  height: 56px; flex: none; background: var(--topbar); border-bottom: 1px solid var(--topbar-bd);
  display: flex; align-items: center; padding: 0 32px; gap: 40px; color: #fff; position: relative; z-index: 20;
}
.topbar .brand { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; color: #fff; }
.topbar .brand:hover { color: #fff; }
.topbar-nav { display: flex; gap: 28px; align-self: stretch; }
.topbar-nav a {
  display: flex; align-items: center; font-size: 14px; font-weight: 500;
  color: rgba(255, 255, 255, .78); box-shadow: inset 0 -2px 0 transparent;
}
.topbar-nav a:hover { color: #fff; }
.topbar-nav a.active { font-weight: 600; color: #fff; box-shadow: inset 0 -2px 0 #fff; }
.topbar-end { margin-left: auto; display: flex; align-items: center; gap: 20px; position: relative; }
.topbar-sep { width: 1px; height: 28px; background: rgba(229, 231, 235, .2); }
.user-menu-trigger {
  display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 4px 8px; border-radius: var(--radius-md);
  background: transparent; border: none; color: inherit; font: inherit;
}
.user-menu-trigger:hover { background: rgba(255, 255, 255, .08); }
.user-menu-trigger .who { display: flex; flex-direction: column; align-items: flex-end; }
.user-menu-trigger .who .name { font-size: 14px; line-height: 18px; font-weight: 500; }
.user-menu-trigger .who .role { font-size: 12px; line-height: 16px; color: rgba(255, 255, 255, .78); }
.user-menu-trigger .caret { font-size: 12px; color: rgba(255, 255, 255, .78); }
.user-menu {
  position: absolute; right: 0; top: 52px; width: 260px; background: var(--surface); color: var(--text);
  border: 1px solid var(--subtle); border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
  padding: 6px; display: none; flex-direction: column; z-index: 30;
}
.user-menu.open { display: flex; }
.user-menu .who { padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.user-menu .who .name { font-size: 14px; font-weight: 600; }
.user-menu .who .email { font-size: 13px; color: var(--muted); }
.user-menu hr { border: none; height: 1px; background: var(--subtle); margin: 4px 0; width: 100%; }
.user-menu button.item {
  padding: 8px 10px; border-radius: var(--radius-sm); font-size: 14px; color: var(--text); text-align: left;
  background: none; border: none; font: inherit; cursor: pointer; width: 100%;
}
.user-menu button.item:hover { background: var(--hover); }

.admin-subnav { flex: none; background: var(--surface); border-bottom: 1px solid var(--subtle); }
.admin-subnav-inner { max-width: 1200px; margin: 0 auto; padding: 0 32px; display: flex; gap: 28px; }
.admin-subnav a {
  padding: 14px 0 12px; font-size: 14px; line-height: 20px; font-weight: 500; color: var(--text-2);
  border-bottom: 2px solid transparent;
}
.admin-subnav a:hover { color: var(--text); }
.admin-subnav a.active { color: var(--text); border-bottom-color: var(--action); }

.app-main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 32px; box-sizing: border-box; display: flex; flex-direction: column; gap: 24px; }
.app-footer { width: 100%; max-width: 1200px; margin: 0 auto; padding: 16px 32px; box-sizing: border-box; border-top: 1px solid var(--subtle); font-size: 12px; line-height: 16px; color: var(--muted); }

/* ── Cartes ──────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs);
  border: 1px solid var(--card-bd); padding: 24px;
}
.card-flat { box-shadow: none; border: 1px solid var(--subtle); }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-top: 4px; }
.section-title h2 { margin: 0; }
.badge-count { background: var(--neu-bg); color: var(--muted); border-radius: var(--radius-full); padding: 1px 8px; font-size: 12px; }

/* ── Boutons ─────────────────────────────────────────────────────────── */
button, .btn { font-family: inherit; }
button.primary, a.primary {
  display: inline-block; padding: 10px 20px; border: none; border-radius: var(--radius-md);
  background: var(--action); color: var(--on-action); font-size: 16px; font-weight: 700;
  cursor: pointer; text-decoration: none; text-align: center;
}
button.primary:hover, a.primary:hover { background: var(--action-hover); color: var(--on-action-hover); }
button.primary:active { background: var(--action-press); }
button.primary:focus-visible, a.primary:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
button.primary:disabled { background: var(--dis-bg); color: var(--dis-tx); cursor: not-allowed; }
button.primary.block, a.primary.block { display: block; width: 100%; }

button.secondary, a.secondary {
  display: inline-block; padding: 10px 20px; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: transparent; color: var(--text-2); font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none;
}
button.secondary:hover, a.secondary:hover { background: var(--hover); }
button.secondary:disabled { background: var(--surface-2); color: var(--muted); border-color: var(--subtle); cursor: not-allowed; }

button.tertiary {
  padding: 8px 12px; border: none; border-radius: var(--radius-md); background: transparent; color: var(--action);
  font-size: 14px; font-weight: 600; cursor: pointer;
}
button.tertiary:hover { background: var(--tert-hover); }

button.danger {
  padding: 8px 16px; border: none; border-radius: var(--radius-md); background: var(--danger); color: #fff;
  font-size: 14px; font-weight: 700; cursor: pointer;
}
button.danger:hover { background: var(--danger-hover); }

/* ── Champs de formulaire ────────────────────────────────────────────── */
input[type=text], input[type=email], input[type=password], input[type=search], select, textarea {
  width: 100%; height: 42px; box-sizing: border-box; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-md); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; outline: none;
}
select { height: 42px; }
input:focus, select:focus, textarea:focus {
  border-color: var(--action); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ring);
}
input:disabled, select:disabled {
  background: var(--surface-2); color: var(--muted); border-color: var(--subtle); cursor: not-allowed;
}
input.invalid { border-color: var(--danger); }
.field-error { display: block; font-size: 12px; line-height: 16px; color: var(--err-msg); margin-top: 6px; }
.field-help { font-size: 12px; line-height: 16px; color: var(--muted); margin-top: 6px; }
input[readonly] { background: var(--surface-2); color: var(--text-2); cursor: default; }
.field-row { display: flex; gap: 8px; }
.field-row input[readonly] { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* Code de vérification (2FA) — un seul champ réel côté serveur (accepte à la
   fois un code TOTP à 6 chiffres et un code de secours alphanumérique), mis
   en valeur visuellement plutôt que scindé en cases séparées. */
.code-input {
  height: 56px; text-align: center; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 24px; font-weight: 600; letter-spacing: .18em;
}

/* Case à cocher — case native stylée par accent-color plutôt qu'une case
   reconstruite en CSS, pour ne jamais toucher à la structure réelle des
   <input name="permissions"> (écran Rôles, sensible côté sécurité). */
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px 20px; margin: 10px 0 20px; }
.checkbox-grid label,
.check-row {
  display: flex; align-items: flex-start; gap: 10px; font-weight: 400; margin: 0; font-size: 14px; line-height: 20px;
  cursor: pointer; user-select: none; color: var(--text);
}
.checkbox-grid input[type=checkbox],
.check-row input[type=checkbox] {
  width: 18px; height: 18px; margin: 1px 0 0; flex: none; cursor: pointer; accent-color: var(--action);
}
.checkbox-grid label:has(input:disabled),
.check-row.locked { color: var(--muted); cursor: not-allowed; }
.checkbox-grid input[type=checkbox]:disabled { cursor: not-allowed; }
.checkbox-grid .perm-desc { display: block; color: var(--muted); font-size: 12px; }

/* Robustesse du mot de passe */
.strength-bars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 8px; }
.strength-bars span { height: 4px; border-radius: var(--radius-full); background: var(--subtle); }
.strength-bars span.filled.weak { background: var(--err); }
.strength-bars span.filled.strong { background: var(--ok); }
.strength-label { font-size: 12px; line-height: 16px; margin-top: 4px; display: block; }
.strength-label.weak { color: var(--err-msg); }
.strength-label.strong { color: var(--ok-tx); }

/* ── Interrupteur (actif / inactif) ──────────────────────────────────── */
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; background: none; border: none; font: inherit; padding: 0; }
.switch .track { width: 36px; height: 20px; border-radius: var(--radius-full); background: var(--switch-off); position: relative; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: var(--radius-full); background: #fff; transition: left .15s ease; }
.switch.on .track { background: var(--action); }
.switch.on .track::after { left: 18px; }

/* ── Puce de statut ──────────────────────────────────────────────────── */
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: var(--radius-full); flex: none; }
.status-dot.active, .status-dot.ok { background: var(--ok); }
.status-dot.inactive, .status-dot.err { background: var(--err); }
.status-dot.idle { background: var(--idle); }
.status-dot.run { background: var(--run); animation: cfPulse 1.6s ease-in-out infinite; }
@keyframes cfPulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }

/* ── Badges ──────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; padding: 2px 10px; border-radius: var(--radius-full);
  font-size: 12px; line-height: 16px; font-weight: 600; white-space: nowrap; border: 1px solid transparent;
}
.badge.ok { background: var(--ok-bg); color: var(--ok-tx); border-color: var(--ok-bd); }
.badge.err { background: var(--err-bg); color: var(--err-tx); border-color: var(--err-bd); }
.badge.warn { background: var(--warn-bg); color: var(--warn-tx); border-color: var(--warn-bd); }
.badge.info { background: var(--info-bg); color: var(--info-tx); border-color: var(--info-bd); }
.badge.neu { background: var(--neu-bg); color: var(--neu-tx); border-color: var(--neu-bd); }
.badge.system { background: var(--info-bg); color: var(--info-tx); border-color: var(--info-bd); }
.badge.school-cad { background: var(--sch-cad-bg); color: var(--sch-cad-tx); }
.badge.school-sawi { background: var(--sch-sawi-bg); color: var(--sch-sawi-tx); }
.badge.school-fmp { background: var(--sch-fmp-bg); color: var(--sch-fmp-tx); }

/* ── Alertes ─────────────────────────────────────────────────────────── */
.alert { padding: 16px; border-radius: var(--radius-md); font-size: 14px; line-height: 20px; border: 1px solid transparent; }
.alert strong, .alert .alert-title { display: block; font-weight: 600; margin-bottom: 2px; }
.alert.ok, .alert.success { background: var(--ok-bg); border-color: var(--ok-bd); color: var(--ok-tx); }
.alert.error { background: var(--err-bg); border-color: var(--err-bd); color: var(--err-tx); }
.alert.warn { background: var(--warn-bg); border-color: var(--warn-bd); color: var(--warn-tx); }
.alert.info { background: var(--info-bg); border-color: var(--info-bd); color: var(--info-tx); }

/* ── Tableaux ────────────────────────────────────────────────────────── */
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--subtle); vertical-align: middle; }
table.data th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; background: var(--surface-2); }
table.data tbody tr:hover { background: var(--hover); }
table.data tr:last-child td { border-bottom: none; }
.table-card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); border: 1px solid var(--card-bd); overflow: hidden; }
.table-card-head { padding: 16px 20px; font-size: 16px; font-weight: 600; border-bottom: 1px solid var(--subtle); }
.table-empty { padding: 40px 24px; text-align: center; font-size: 14px; line-height: 20px; color: var(--muted); }

/* ── Divers ──────────────────────────────────────────────────────────── */
.inline-form { display: inline; margin: 0; }
.qr { text-align: center; margin: 4px 0; }
.qr img { border: 1px solid var(--subtle); border-radius: var(--radius-md); padding: 16px; background: #ffffff; }
.secret-key { font-family: ui-monospace, Menlo, monospace; font-size: 14px; letter-spacing: .08em; word-break: break-all; background: var(--surface-2); color: var(--text); padding: 10px 12px; border: 1px solid var(--subtle); border-radius: var(--radius-md); }
.codes-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px; padding: 16px 20px; background: var(--surface-2); border-radius: var(--radius-md); }
code.backup-code { display: block; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; line-height: 24px; letter-spacing: .1em; color: var(--text); }
.role-badge { display: inline-block; background: var(--neu-bg); color: var(--neu-tx); padding: 2px 10px; border-radius: var(--radius-full); font-size: 12px; font-weight: 600; }
.role-badge.system { background: var(--info-bg); color: var(--info-tx); }

/* ── Page pleine (erreur) ────────────────────────────────────────────── */
.error-page { flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px; }
.error-page .box { max-width: 420px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.error-page .code { font-size: 56px; line-height: 60px; font-weight: 700; letter-spacing: -0.02em; color: var(--muted); font-variant-numeric: tabular-nums; }
.error-page h1 { font-size: 20px; line-height: 28px; margin: 0; }
.error-page p { font-size: 15px; line-height: 22px; color: var(--text-2); margin: 0; }

/* ── Écrans métier : dossiers, revue, statistiques ───────────────────── */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head .meta { font-size: 13px; color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--card-bd); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); padding: 16px 20px; display: flex; flex-direction: column; gap: 4px; color: var(--text); }
a.kpi:hover { color: var(--text); background: var(--hover); }
.kpis.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) { .kpis.three { grid-template-columns: 1fr; } }
.kpi .label { font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.kpi .value { font-size: 22px; line-height: 30px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; white-space: nowrap; }
.kpi .sub { font-size: 13px; color: var(--muted); }
.kpi.warn .value { color: var(--warn-tx); }
.kpi.err .value { color: var(--err-tx); }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 16px 20px; background: var(--surface); border: 1px solid var(--card-bd); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); }
.filters .f { display: flex; flex-direction: column; gap: 4px; min-width: 140px; flex: 1 1 140px; }
.filters .f.wide { flex: 2 1 240px; }
.filters label { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); }
.filters input, .filters select { height: 36px; padding: 6px 10px; font-size: 13px; }
.filters .actions { display: flex; gap: 8px; flex: 0 0 auto; }
.filters .actions button, .filters .actions a { height: 36px; padding: 0 14px; display: inline-flex; align-items: center; font-size: 14px; }

.table-scroll { overflow-x: auto; }
table.data.compact th, table.data.compact td { padding: 8px 10px; font-size: 13px; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tr.clickable { cursor: pointer; }
table.data td .sub { display: block; font-size: 12px; color: var(--muted); }
.codes { display: flex; flex-wrap: wrap; gap: 4px; }
.nowrap { white-space: nowrap; }
.small { font-size: 12px; }
.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }

.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 180px 1fr 140px; gap: 12px; align-items: center; font-size: 13px; }
.bar-track { display: block; height: 10px; background: var(--surface-2); border-radius: var(--radius-full); overflow: hidden; border: 1px solid var(--subtle); }
.bar-fill { display: block; height: 100%; background: var(--action); border-radius: var(--radius-full); }
.bar-fill.warn { background: #d97706; }
.bar-fill.err { background: var(--err); }
.bar-fill.ok { background: var(--ok); }
.bar-fill.neu { background: var(--idle); }
.bar-row .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; align-items: start; }
@media (max-width: 1000px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } .bar-row { grid-template-columns: 120px 1fr 110px; } }
dl.facts { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; margin: 0; font-size: 14px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.card h2 { margin-top: 0; }

.anomaly { border: 1px solid var(--subtle); border-radius: var(--radius-md); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.anomaly + .anomaly { margin-top: 12px; }
.anomaly.closed { opacity: .7; }
.anomaly .head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.anomaly .forbidden { font-size: 13px; color: var(--err-tx); }
.decision-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.decision-form select { width: auto; height: 34px; padding: 0 8px; font-size: 13px; }
.decision-form input[type=text] { flex: 1 1 220px; height: 34px; padding: 6px 10px; font-size: 13px; }
.decision-form button { height: 34px; padding: 0 14px; font-size: 13px; }
/* Variante compacte (tableau de la revue) : choix sur une ligne, commentaire
   et bouton sur la suivante, pour une colonne étroite. */
.decision-form.compact { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
.decision-form.compact select { grid-column: 1 / -1; width: 100%; }
.decision-form.compact input[type=text] { min-width: 0; }
/* Boutons de décision (texte, sans icône). */
.decision-boutons { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.decision-boutons input[type=text] { flex: 1 1 220px; }
.decision-boutons.compact { display: flex; }
.decision-boutons.compact input[type=text] { flex: 1 1 100%; }
.dec-choix { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.decision-form .dec-btn {
  height: 32px; padding: 0 12px; border-radius: var(--radius-md); border: 1.5px solid currentColor; background: var(--surface);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.dec-btn.prise { color: var(--info-tx); border-color: var(--info-bd); }
.dec-btn.resolu { color: var(--ok-tx); border-color: var(--ok-bd); }
.dec-btn.faux { color: var(--neu-tx); border-color: var(--border); }
.dec-btn.rouvrir { color: var(--warn-tx); border-color: var(--warn-bd); }
.dec-btn.prise:hover { background: var(--info-bg); }
.dec-btn.resolu:hover { background: var(--ok-bg); }
.dec-btn.faux:hover { background: var(--neu-bg); }
.dec-btn.rouvrir:hover { background: var(--warn-bg); }
.dec-btn:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }
/* Page en pleine largeur (gouttières conservées). */
.app-main.app-main-large { max-width: none; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.timeline li { border-left: 2px solid var(--subtle); padding-left: 12px; }
.timeline .when { color: var(--muted); font-size: 12px; }
.notice { font-size: 13px; color: var(--muted); border-left: 3px solid var(--info-bd); padding: 8px 12px; background: var(--info-bg); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ── Diagnostic assisté ──────────────────────────────────────────────── */
.diag { border: 1px solid var(--info-bd); background: var(--info-bg); border-radius: var(--radius-md); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.diag-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--info-tx); }
.diag-hyp { margin: 0; font-size: 15px; line-height: 22px; font-weight: 600; color: var(--text); }
.diag h4 { margin: 0 0 4px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.diag ul, .diag ol { margin: 0; padding-left: 18px; font-size: 13px; line-height: 20px; color: var(--text-2); }
.diag ol li + li, .diag ul li + li { margin-top: 2px; }
.diag .where { display: inline-block; font-size: 11px; font-weight: 600; padding: 0 6px; border-radius: var(--radius-full); background: var(--surface); border: 1px solid var(--subtle); color: var(--muted); margin-right: 6px; }
.diag .copy-row { display: flex; gap: 8px; }
.diag .copy-row input { flex: 1; min-width: 0; height: 36px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--surface); }
.diag .copy-row button { height: 36px; padding: 0 14px; font-size: 13px; }
.badge.conf-forte { background: var(--ok-bg); color: var(--ok-tx); border-color: var(--ok-bd); }
.badge.conf-moyenne { background: var(--warn-bg); color: var(--warn-tx); border-color: var(--warn-bd); }
.badge.conf-faible { background: var(--neu-bg); color: var(--neu-tx); border-color: var(--neu-bd); }
.cands { display: flex; flex-direction: column; gap: 8px; }
.cand { background: var(--surface); border: 1px solid var(--subtle); border-radius: var(--radius-md); padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: start; }
.cand.top { border-color: var(--action); }
.cand .t { font-size: 14px; font-weight: 600; }
.cand .m { font-size: 12px; color: var(--muted); }
.cand .score { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.cand .score .bar-track { width: 90px; }
.cand .reasons { grid-column: 1 / -1; font-size: 12px; line-height: 18px; color: var(--text-2); }
.cand .reasons .neg { color: var(--err-tx); }
.cand form { display: flex; gap: 6px; }
.diag-mini { margin-top: 6px; font-size: 12px; line-height: 18px; color: var(--text-2); }
.diag-mini details summary { cursor: pointer; color: var(--action); font-weight: 600; list-style: none; margin-top: 4px; }
.diag-mini details summary::-webkit-details-marker { display: none; }
.diag-mini details[open] summary { margin-bottom: 6px; }

/* ── Filtres dynamiques et saisie semi-automatique ───────────────────── */
.cf-results { transition: opacity .15s ease; }
.cf-results.is-loading { opacity: .55; }
.filters-status { align-self: center; font-size: 12px; color: var(--muted); min-width: 90px; }
.filters-status.error { color: var(--err-msg); }
.more-row { display: flex; justify-content: center; padding: 14px; border-top: 1px solid var(--subtle); }
.suggest-wrap { position: relative; }
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40; list-style: none; margin: 0; padding: 6px;
  background: var(--surface); color: var(--text); border: 1px solid var(--subtle); border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm); max-height: 360px; overflow-y: auto; min-width: 320px;
}
.suggest li[role=option] { padding: 7px 10px; border-radius: var(--radius-sm); cursor: pointer; display: flex; flex-direction: column; gap: 1px; }
.suggest li[role=option]:hover, .suggest li[role=option].active { background: var(--hover); }
.suggest li[role=option].active { box-shadow: inset 2px 0 0 var(--action); }
.suggest .s-main { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest .s-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest .suggest-group { padding: 8px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.suggest .suggest-empty { padding: 8px 10px; font-size: 13px; color: var(--muted); }

/* L’attribut hidden l’emporte toujours (sinon display: inline-flex des boutons le neutralise). */
[hidden] { display: none !important; }

/* ── Choix des colonnes (Dossiers, Revue humaine) ────────────────────── */
.page-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
/* Toujours à droite, même quand le bloc passe à la ligne sous le titre :
   le panneau « Colonnes », aligné sur le bord droit du bouton, reste ainsi
   dans l'écran. */
.page-head .page-actions { margin-left: auto; }
.table-note { padding: 8px 12px; font-size: 12px; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--subtle); }
.colpicker { position: relative; }
.colpicker > summary {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); color: var(--text-2); font-size: 14px; font-weight: 600; cursor: pointer; list-style: none; user-select: none;
}
.colpicker > summary::-webkit-details-marker { display: none; }
.colpicker > summary:hover { background: var(--hover); }
.colpicker > summary:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.colpicker[open] > summary { border-color: var(--action); }
.colpicker-count { background: var(--neu-bg); color: var(--muted); border-radius: var(--radius-full); padding: 0 8px; font-size: 12px; line-height: 18px; font-variant-numeric: tabular-nums; }
.colpicker-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 45; width: 360px; max-width: calc(100vw - 48px); max-height: min(70vh, 620px); max-height: min(70dvh, 620px); overflow-y: auto;
  background: var(--surface); color: var(--text); border: 1px solid var(--subtle); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); padding: 12px;
}
.colpicker-head { display: flex; flex-direction: column; gap: 2px; padding: 2px 4px 10px; border-bottom: 1px solid var(--subtle); }
.colpicker-head strong { font-size: 14px; }
.colpicker-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.colpicker-title button.tertiary { padding: 4px 8px; font-size: 13px; }
.colpicker-head span { font-size: 12px; line-height: 16px; color: var(--muted); }
.colpicker-list { list-style: none; margin: 6px 0; padding: 0; display: flex; flex-direction: column; }
.colpicker-list li { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-radius: var(--radius-sm); }
.colpicker-list li:hover { background: var(--hover); }
.colpicker-list li.off + li:not(.off), .colpicker-list li:not(.off) + li.off { border-top: 1px solid var(--subtle); }
.colpicker-list .check-row { flex: 1; min-width: 0; margin: 0; }
.colpicker-list .check-row.locked { color: var(--text); cursor: default; }
.colpicker-label { display: flex; flex-direction: column; min-width: 0; font-size: 13px; line-height: 18px; }
.colpicker-help { font-size: 12px; line-height: 16px; color: var(--muted); }
.colpicker-move { display: flex; gap: 2px; flex: none; }
.colpicker-list li.off .colpicker-move { visibility: hidden; }
.colpicker-move button {
  width: 28px; height: 28px; border: 1px solid var(--subtle); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-2);
  font-size: 14px; line-height: 1; cursor: pointer; padding: 0;
}
.colpicker-move button:hover:not(:disabled) { background: var(--hover); color: var(--action); }
.colpicker-move button:disabled, .colpicker-move button[aria-disabled=true] { opacity: .35; cursor: default; }
.colpicker-move button[aria-disabled=true]:hover { background: var(--surface); color: var(--text-2); }
.colpicker form[aria-busy=true] .colpicker-list { opacity: .55; }
.colpicker-move button:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.colpicker-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--subtle); }
.colpicker-actions button.secondary { padding: 6px 14px; }
.colpicker-actions button.tertiary:disabled { color: var(--muted); cursor: default; background: none; }
.colpicker-status { font-size: 12px; color: var(--muted); }
.colpicker-status.error { color: var(--err-msg); }

/* Barre du haut : les onglets défilent horizontalement quand ils ne tiennent
   pas, au lieu d'élargir la page ou de passer sur deux lignes. */
.topbar-nav { overflow-x: auto; min-width: 0; scrollbar-width: none; }
.topbar-nav::-webkit-scrollbar { display: none; }
.topbar-nav a { white-space: nowrap; }
.topbar-end { flex: none; }
@media (max-width: 1100px) {
  .topbar { gap: 20px; padding: 0 20px; }
  .topbar-nav { gap: 20px; }
}
@media (max-width: 900px) {
  .topbar { gap: 14px; padding: 0 16px; }
  .topbar-nav { gap: 16px; }
  .user-menu-trigger .who { display: none; }
  .app-main { padding: 24px 16px; }
}
@media (max-width: 360px) {
  .topbar .brand { font-size: 16px; }
}
/* Contenu qui ne doit pas élargir la page sur mobile. */
.codes .badge { white-space: normal; }
.kpi { min-width: 0; }
@media (max-width: 480px) {
  .kpis { grid-template-columns: 1fr; }
}


/* ── Journal et mémoire des décisions ────────────────────────────────── */
table.data.journal td { vertical-align: top; }
tr.is-off td { background: var(--surface-2); }
.cf-more summary { cursor: pointer; color: var(--action); font-size: 12px; font-weight: 600; margin-top: 4px; }
.cf-comment { font-size: 13px; line-height: 19px; color: var(--text-2); white-space: pre-line; overflow-wrap: anywhere; }
.cas-sim { margin-top: 6px; font-size: 12px; line-height: 18px; color: var(--text-2); }
.cas-sim summary { cursor: pointer; color: var(--action); font-weight: 600; }
.cas-sim ul { margin: 4px 0 0; padding-left: 18px; }
.cas-sim li + li { margin-top: 4px; }
