/* =============================================================================
   MECSYF SaaS — Design System & Application Styles
   Palette: marque plateforme Mizan (tokens --brand-*, cf. #1562)
   ============================================================================= */

/* --- Variables --- */
:root {
    /* --- Marque plateforme (#1562) -------------------------------------------
       Tokens SÉMANTIQUES. Le back-office porte la marque de la PLATEFORME, le
       portail celle de l'INSTITUTION — marque à deux couches (#1457). Les noms
       --brand-primary / --brand-secondary sont ceux que le portail écrit déjà
       dans js/utils/theme.js : même vocabulaire, mécanisme différent. Ici les
       valeurs sont figées ; elles ne viennent PAS de /config/public/, sans quoi
       le back-office prendrait les couleurs du tenant et la séparation des deux
       couches tomberait.
       ------------------------------------------------------------------------ */
    /* Charte YOKARZA (arbitrage du 07/08, #1457) — marine et or de la marque
       Mizan. Contrastes mesurés, seuils AA : 4,5 pour du texte, 3,0 pour un
       élément d'interface.
         blanc sur --brand-primary ................ 12,14
         --brand-primary sur blanc ................ 12,14
         --brand-primary-darkest sur le fond teinté 15,54
         blanc sur --brand-primary-dark ........... 14,57 (barre latérale) */
    --brand-primary-darkest: #0A1D2B;
    --brand-primary-dark: #0D2537;
    --brand-primary: #123249;
    --brand-primary-light: #20547A;
    --brand-primary-lighter: #2E6D9B;
    --brand-primary-bg: #F0F4F8;

    /* ⚠️ L'or est une couleur d'ORNEMENT, jamais un texte ni une action sur
       fond clair : il mesure 2,60 sur blanc, pour 4,5 requis. Il tient sur le
       marine (4,68) et en filet. La déclinaison foncée est volontairement plus
       sombre que la charte : à la valeur de charte elle tombait à 4,03 sur
       blanc, or elle sert de couleur de TEXTE dans 63 usages. #8A6C1B est la
       valeur la plus claire qui passe encore les deux fonds (4,95 et 4,51). */
    --brand-secondary: #AE8329;
    --brand-secondary-dark: #856320;
    --brand-secondary-light: #C9A24B;
    /* Existait comme repli implicite dans js/pages/members.js — la variable y
       était appelée avec une valeur de secours, sans jamais être déclarée nulle
       part. Posée ici à sa valeur de fait : aucun rendu ne change, et le repli
       cesse d'être un accident. */
    --brand-secondary-bg: #FAF3E4;

    /* Couleur d'ACTION (#1562). L'or ne pouvant pas la porter sur fond clair,
       l'azur dérivé de la charte prend ce rôle : 5,42 sur blanc, donc utilisable
       en anneau de focus comme en texte de lien. */
    --brand-action: #20547A;


    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    --red: #ef4444;
    --red-light: #fef2f2;
    --orange: #f59e0b;
    --orange-light: #fffbeb;
    --blue: #3b82f6;
    --blue-light: #eff6ff;
    --teal: #14b8a6;
    --teal-light: #f0fdfa;

    --sidebar-w: 260px;
    --topbar-h: 64px;
    /* Échelle de rayons unique (#1006) — plus de 5/6/9/10px ad hoc. */
    --radius-xs: 4px;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
    --transition-fast: .15s ease;
    --transition: .2s ease;
    --transition-slow: .3s ease;

    /* Couleurs de statut (#1006) — source unique des badges/notifs, plus de hex
       en dur dispersés (.badge-status, .notif-item). */
    --status-success-bg: #dcfce7;
    --status-success-fg: #166534;
    --status-warning-bg: #fef3c7;
    --status-warning-fg: #92400e;
    --status-danger-bg: #fee2e2;
    --status-danger-fg: #991b1b;
    --status-info-bg: #dbeafe;
    --status-info-fg: #1e40af;
    --status-neutral-bg: var(--gray-100);
    --status-neutral-fg: var(--gray-600);
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* Base 16px (#1006) — à 14px, les tableaux (.85rem) tombaient à 12px réels et
   les en-têtes (.78rem) à 11px : sous le seuil de confort WCAG. À 16px, tout
   le système rem remonte d'un cran (~14 %) : tableaux ≥ 13px, plus d'air. */
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; }
input, select, textarea { font: inherit; }
table { border-collapse: collapse; width: 100%; }
img { max-width: 100%; display: block; }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* =============================================================================
   LOGIN PAGE
   ============================================================================= */
/* Refonte #1301 — marque à DEUX COUCHES et responsive DIFFÉRENCIÉ par produit.
   Le back-office porte la marque de la PLATEFORME ; le portail celle du tenant.
   Source de vérité : docs/design/maquette_connexion_deux_marques.html.

   Le responsive est piloté par une CONTAINER QUERY et non par la fenêtre : le seuil
   dépend de la place dont dispose le bloc, pas de l'appareil. Le conteneur de requête
   est le WRAPPER (.login-page.bo) — un élément portant `container-type` ne peut pas
   être ciblé par sa propre @container query, seulement ses descendants. */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--white);
    padding: 0;
}
.login-page.bo { container: bo / inline-size; }

/* PLEIN ÉCRAN, pas une carte flottante — c'est ce que montre la maquette : la
   connexion occupe la fenêtre, le bandeau tient toute la hauteur. Empilé par
   défaut (le bandeau au-dessus, le formulaire dessous) : sur un téléphone tout
   est dans le flux vertical, ce n'est pas une dégradation mais la base. */
.login {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100vh;
    background: var(--white);
    overflow: hidden;
}

/* --- Bandeau de marque (plateforme) ---
   Proposition Claude Design : le symbole passe en BADGE discret accompagné du mot
   et de sa signature, l'accroche prend le premier plan, et les repères de confiance
   deviennent des cartouches — un agrément est une donnée, pas une puce de liste. */
.login-band {
    background: linear-gradient(160deg, var(--brand-primary) 0%, var(--brand-primary-darkest) 100%);
    color: #EAF1F7;
    padding: 1.35rem 1.5rem 1.15rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}
.login-band .brandline { display: flex; align-items: center; gap: .8rem; }
.login-band .badge-marque {
    width: 3rem; height: 3rem; flex: none;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, .07);
    border: 1px solid rgba(255, 255, 255, .14);
}
.login-band .mizan-marque { width: 1.75rem; height: auto; }
.login-band .wordmark { display: flex; flex-direction: column; line-height: 1.15; }
.login-band .wordmark b { font-size: 1.1rem; font-weight: 700; letter-spacing: .18em; }
.login-band .wordmark small {
    font-size: .6rem; letter-spacing: .18em; text-transform: uppercase;
    color: rgba(234, 241, 247, .62);
}
.login-band .band-main { display: flex; flex-direction: column; }
.login-band .beyebrow {
    display: none;
    font-size: .68rem; font-weight: 700; letter-spacing: .2em; text-transform: uppercase;
    color: var(--brand-secondary-light);
    margin: 0 0 .7rem;
    align-items: center; gap: .625rem;
}
.login-band .beyebrow::before {
    content: ""; width: 22px; height: 2px; flex: none; background: var(--brand-secondary);
}
.login-band .pitch {
    font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
    font-size: 1.15rem; line-height: 1.25; margin: 0; text-wrap: balance;
}
.login-band .pitch-sub {
    margin: .85rem 0 0; font-size: .82rem; line-height: 1.55;
    color: rgba(234, 241, 247, .7); max-width: 42ch;
}
.login-band .band-foot { display: flex; flex-direction: column; gap: .75rem; }
.login-band .cartouches { display: flex; gap: .625rem; flex-wrap: wrap; }
.login-band .cartouche {
    flex: 1 1 12rem; min-width: 0;
    display: flex; flex-direction: column; gap: .2rem;
    padding: .6rem .8rem;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, .04);
}
.login-band .cartouche .k {
    font-size: .6rem; letter-spacing: .14em; text-transform: uppercase;
    color: rgba(234, 241, 247, .55);
}
.login-band .cartouche .v { font-size: .84rem; font-weight: 600; color: var(--white); }
.login-band .band-legal {
    margin: 0; font-size: .7rem; color: rgba(234, 241, 247, .6);
    display: flex; align-items: center; gap: .45rem; flex-wrap: wrap;
}
.login-band .band-legal i { color: var(--brand-secondary-light); }
.login-band .band-legal b { color: rgba(234, 241, 247, .85); font-weight: 600; }

/* --- Panneau de formulaire ---
   Il GARDE la classe .login-card : tout le flux de double authentification cible
   `.login-card`, son `h2` et son `form`. Renommer la classe casserait 400 lignes
   de logique 2FA sans qu'aucun test ne le voie. */
.login-card {
    /* Gris très clair plutôt que blanc : les champs, eux blancs, s'en détachent.
       Sur fond blanc ils n'existaient que par leur filet. */
    background: var(--gray-50);
    padding: 1.6rem 1.5rem 1.75rem;
    display: flex;
    flex-direction: column;
}
.login-card h2 {
    font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
    font-size: 1.65rem; font-weight: 600; margin-bottom: .25rem; color: var(--brand-primary);
}
.login-sub { margin: 0 0 1.75rem; font-size: .86rem; color: var(--gray-500); }
.login-foot {
    margin: 1.5rem 0 0; padding-top: 1.1rem; border-top: 1px solid var(--gray-200);
    display: flex; flex-direction: column; gap: .35rem;
    font-size: .72rem; color: var(--gray-400);
}
.login-foot .secure { color: var(--gray-500); }
.login-foot .secure i { margin-right: .35rem; }
/* La version est écrite par `Layout.loadVersion`, partagée avec le pied de
   l'application authentifiée : on ne touche pas à son contrat (`textContent`),
   on la replie dans la ligne de signature. Le séparateur est posé en CSS et
   disparaît de lui-même quand la version est vide — /health injoignable. */
/* `login-sig` et non `sig` : cette dernière existe déjà plus bas pour le bloc des
   soldes intermédiaires de gestion, où elle vaut `display: grid`. Le pied héritait
   d'une grille et la signature se cassait en deux avec un blanc au milieu. */
.login-foot .login-sig { font-variant-numeric: tabular-nums; }
.login-foot .login-sig #login-version:not(:empty)::before { content: " · "; }

/* Révéler le mot de passe — cible tactile de 44px, jamais un simple pictogramme. */
.input-reveal {
    position: absolute; right: .35rem;
    width: 2.5rem; height: 2.5rem;
    display: flex; align-items: center; justify-content: center;
    background: none; border: 0; cursor: pointer;
    color: var(--gray-400); font-size: .9rem;
    border-radius: var(--radius-xs);
}
.input-reveal:hover { color: var(--brand-action); }
.input-reveal:focus-visible { outline: 2px solid var(--brand-action); outline-offset: 1px; }

/* Champ à icône — la maquette pose un repère visuel dans le champ lui-même.
   L'icône est décorative : `aria-hidden`, et le label reste le seul intitulé. */
.input-icon { position: relative; display: flex; align-items: center; }
.input-icon i {
    position: absolute; left: 1rem;
    color: var(--gray-400); font-size: .85rem; pointer-events: none;
}
/* Sélecteur porté au même poids que `.form-group input` (0,2,0), qui pose le
   padding par défaut — sans cela l'icône chevauche le texte saisi. */
.form-group .input-icon input { padding-left: 2.75rem; background: var(--white); }
.form-group .input-icon:has(.input-reveal) input { padding-right: 3rem; }

/* Le sous-titre appartient à l'écran de CONNEXION. Les écrans de sécurité
   remplacent le `h2` et le `form`, jamais ce paragraphe : il faut donc le
   masquer par le même levier que le bandeau, sans toucher leur code. */
.login:has(.twofa-card) .login-sub,
.login:has(.twofa-card) .login-foot,
.login:has(.twofa-card) #login-version { display: none; }
/* Les écrans de sécurité restent en deux colonnes : le bandeau porte le repère
   « Connecté à … », et c'est au moment d'approuver un QR code ou un appareil que
   ce repère compte le plus. Le volet de droite suffit parce que la page occupe
   désormais tout l'écran. */

/* --- Split : dès que le bloc dispose de 640px ---
   Le back-office assume le split tôt : son public travaille sur grand écran ou
   tablette. Le portail, lui, garde la carte empilée plus longtemps. */
@container bo (min-width: 640px) {
    .login {
        display: grid;
        grid-template-columns: 1.04fr .96fr;
        align-items: stretch;
    }
    .login-band { padding: 2.4rem 2.1rem; }
    /* Colonne haute : la forme empilée occupe l'espace que l'horizontale laissait vide. */
    .login-band .beyebrow { display: flex; }
    .login-band .pitch { font-size: clamp(1.25rem, 2.3vw, 1.5rem); margin-top: .15rem; }
    .login-band { padding: 3.5rem 3.75rem; justify-content: space-between; gap: 2rem; }
    .login-band .band-main { margin: auto 0; }
    .login-band .badge-marque { width: 3.5rem; height: 3.5rem; }
    .login-band .mizan-marque { width: 2rem; }
    .login-band .wordmark b { font-size: 1.2rem; }
    .login-band .pitch { font-size: clamp(1.6rem, 2.6vw, 2.1rem); }
    .login-band .beyebrow { margin: 0 0 1rem; }
    /* La colonne fait la moitié de l'écran, mais un formulaire large de 700 px
       serait pénible à lire : on le borne et on le centre dans sa colonne. */
    .login-card { padding: 3rem; justify-content: center; align-items: center; }
    .login-card > * { width: 100%; max-width: 26rem; }
}

/* --- 2FA Setup & Verify --- */
/* Pendant la double authentification, le bandeau RESTE : la page occupe tout
   l'écran, donc le panneau de droite a la place d'accueillir le QR code et les
   six cases. Seuls le sous-titre et le pied de l'écran de connexion s'effacent,
   parce qu'ils ne parlent plus de ce qui est affiché.

   Le déclencheur est `:has()` plutôt qu'une classe posée par le JS : le flux 2FA
   ajoute `.twofa-card` en trois endroits, et le CSS s'y adapte sans qu'aucun de
   ces trois appels n'ait à le savoir. Sur un navigateur sans `:has()`, le
   sous-titre reste visible — dégradé cosmétique, jamais cassé. */
.twofa-card { max-width: none; }
.twofa-progress { margin: 0 0 1.1rem; font-size: .72rem; font-weight: 600; letter-spacing: .04em;
    text-transform: uppercase; color: var(--brand-action); }
.twofa-legal { text-align: center; font-size: .72rem; color: var(--gray-400); margin-top: 1rem; }
.twofa-steps { display: flex; flex-direction: column; gap: 1.25rem; margin-bottom: 1.5rem; }
.twofa-step { display: flex; gap: .875rem; align-items: flex-start; }
.twofa-step-num {
    flex-shrink: 0;
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--brand-primary-dark);
    color: var(--white);
    font-size: .75rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    margin-top: 1px;
}
/* `min-width: 0` est indispensable : un élément flex a par défaut `min-width: auto`
   et refuse de descendre sous la largeur minimale de son contenu. Sans lui, la rangée
   de saisie et les textes de cette colonne débordaient de la carte sur téléphone —
   la sixième case était coupée, et rien ne le signalait au niveau du document. */
.twofa-step-body { flex: 1; min-width: 0; }
.twofa-step-title { font-size: .85rem; font-weight: 600; color: var(--gray-800); margin-bottom: .25rem; }
.twofa-step-desc { font-size: .8rem; color: var(--gray-500); line-height: 1.5; }
.twofa-app-badges { display: flex; gap: .5rem; margin-top: .5rem; flex-wrap: wrap; }
.twofa-app-badge {
    display: inline-flex; align-items: center; gap: .35rem;
    background: var(--gray-100); border: 1px solid var(--gray-200);
    border-radius: var(--radius-xs); padding: .3rem .6rem;
    font-size: .75rem; font-weight: 500; color: var(--gray-700);
}
.twofa-qr-wrapper {
    display: flex; justify-content: center;
    background: var(--gray-50); border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm); padding: 1.25rem;
    margin: .75rem 0;
}
.twofa-qr-wrapper img, .twofa-qr-wrapper svg {
    width: 180px; height: 180px;
    display: block;
}
.twofa-secret-box {
    background: var(--gray-50); border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm); padding: .6rem .875rem;
    display: flex; align-items: center; justify-content: space-between; gap: .5rem;
    margin-top: .5rem;
}
.twofa-secret-box code {
    font-size: .8rem; letter-spacing: .12rem;
    color: var(--brand-primary-dark); word-break: break-all; flex: 1;
}
.twofa-copy-btn {
    flex-shrink: 0; background: none; border: 1px solid var(--gray-300);
    border-radius: var(--radius-xs); padding: .25rem .5rem; cursor: pointer;
    font-size: .75rem; color: var(--gray-600); transition: all .15s;
}
.twofa-copy-btn:hover { background: var(--gray-200); color: var(--gray-800); }
.twofa-divider {
    height: 1px; background: var(--gray-200); margin: 1.25rem 0;
}
.twofa-otp-row {
    display: flex; gap: .5rem; justify-content: center; margin-bottom: 1.25rem;
    min-width: 0;
}
.twofa-otp-digit {
    /* Largeur SOUPLE : à 52px fixes, six cases plus leurs gouttières débordaient
       d'un écran de 375px — la sixième était coupée. Elles se partagent désormais
       la place disponible sans jamais dépasser leur taille de confort. */
    flex: 1 1 0; min-width: 0; max-width: 52px;
    aspect-ratio: 52 / 60; height: auto;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 1.6rem; font-weight: 700; text-align: center;
    color: var(--brand-primary-dark);
    background: var(--white);
    transition: border-color .15s, box-shadow .15s;
    outline: none;
    -moz-appearance: textfield;
}
.twofa-otp-digit::-webkit-outer-spin-button,
.twofa-otp-digit::-webkit-inner-spin-button { -webkit-appearance: none; }
.twofa-otp-digit:focus { border-color: var(--brand-primary-dark); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 12%, transparent); }
.twofa-otp-digit.filled { border-color: var(--brand-primary-dark); background: var(--brand-primary-bg); }
.twofa-verify-icon {
    width: 72px; height: 72px; border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-primary-dark), var(--brand-primary-light));
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1.25rem;
    box-shadow: 0 4px 16px color-mix(in srgb, var(--brand-primary) 25%, transparent);
}
.twofa-verify-icon i { font-size: 1.75rem; color: var(--white); }
.twofa-hint {
    text-align: center; font-size: .8rem; color: var(--gray-400);
    margin-bottom: 1rem; line-height: 1.5;
}

/* --- Forms --- */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
    display: block; font-size: .85rem; font-weight: 500;
    color: var(--gray-700); margin-bottom: .375rem;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%; padding: .625rem .875rem;
    border: 1px solid var(--gray-300); border-radius: var(--radius-sm);
    background: var(--white); color: var(--gray-800);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none; border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 12%, transparent);
}
.form-group .error-text { color: var(--red); font-size: .78rem; margin-top: .25rem; }
.form-group.has-error input,
.form-group.has-error select,
.form-group.has-error textarea,
.form-group.has-error .dd-trigger { border-color: var(--red); }
/* FormField (#818) — marqueur requis, hint, case à cocher alignée. */
.ff-req { color: var(--red); }
.ff-hint { display: block; color: var(--gray-400); font-size: .78rem; margin-top: .25rem; }
.ff-checkbox { display: flex; align-items: center; gap: .5rem; font-weight: normal; cursor: pointer; margin: 0; }
.ff-checkbox input { width: auto; margin: 0; }
/* FormField — champ numérique avec unité (%, FCFA…) + section repliée (FormModal). */
.ff-suffix { position: relative; display: block; }
.ff-suffix input { padding-right: 3.4rem; }
.ff-suffix .ff-unit {
    position: absolute; right: .75rem; top: 50%; transform: translateY(-50%);
    font-size: .78rem; color: var(--gray-400); pointer-events: none;
}
.ff-section { border: 1px solid var(--gray-200); border-radius: var(--radius-sm); padding: .85rem 1rem 1rem; margin-top: 1rem; }
.ff-section > legend { padding: 0 .4rem; font-weight: 600; font-size: .82rem; color: var(--gray-800); }
.ff-section > legend i { margin-right: .4rem; color: var(--brand-primary); }
.ff-section .ff-section-note { font-size: .75rem; color: var(--gray-400); margin: .1rem 0 .75rem; }
/* Placeholder pour éditeur contenteditable vide (#846 messagerie rich text). */
[contenteditable][data-ph]:empty::before { content: attr(data-ph); color: #9ca3af; pointer-events: none; }
/* Zone d'upload glisser-déposer (#846 — miroir du portail). */
.file-drop {
    display: block; border: 2px dashed #d1d5db; border-radius: var(--radius-sm);
    padding: 1.5rem 1rem; text-align: center; cursor: pointer;
    transition: border-color .2s, background .2s;
}
.file-drop:hover, .file-drop.drag-over { border-color: var(--brand-primary); background: color-mix(in srgb, var(--brand-primary) 4%, transparent); }
.file-drop i { font-size: 1.6rem; color: #9ca3af; margin-bottom: .4rem; }
.file-drop p { font-size: .85rem; color: #6b7280; margin: 0; }
.file-drop input[type="file"] { display: none; }
/* Listes de l'éditeur riche + aperçu (#846) : puces alignées (sinon clipées/décalées). */
#msg-editor ul, #msg-editor ol, #msg-preview ul, #msg-preview ol { margin: .2rem 0 .5rem; padding-left: 1.4rem; }
#msg-editor li, #msg-preview li { margin: .15rem 0; }

/* --- Buttons --- */
.btn {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .625rem 1.25rem; border-radius: var(--radius-sm);
    font-weight: 500; font-size: .875rem;
    transition: all var(--transition);
}
.btn-primary {
    background: var(--brand-primary); color: var(--white);
}
.btn-primary:hover { background: var(--brand-primary-dark); }
.btn-secondary {
    background: var(--gray-100); color: var(--gray-700);
    border: 1px solid var(--gray-300);
}
.btn-secondary:hover { background: var(--gray-200); }
.btn-danger { background: var(--red); color: var(--white); }
.btn-danger:hover { background: #dc2626; }
.btn-gold { background: var(--brand-secondary); color: var(--gray-900); }
.btn-gold:hover { background: var(--brand-secondary-dark); }
.btn-sm { padding: .375rem .75rem; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* =============================================================================
   LAYOUT (Sidebar + Topbar + Content)
   ============================================================================= */
.app-layout { display: flex; min-height: 100vh; }

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-w); height: 100vh;
    /* #1008 — fond PLAT (fini le dégradé) : surfaces calmes, l'accent visuel
       est porté par la pilule active et les badges. */
    background: var(--brand-primary-darkest);
    color: var(--white); display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; z-index: 100;
    transition: transform var(--transition-slow); overflow: hidden;
}
/* Fermeture sidebar mobile (close + backdrop) — cachés en desktop, révélés < 1024px. */
.sidebar-close {
    display: none; margin-left: auto; padding: .25rem;
    background: none; border: none; color: var(--white);
    font-size: 1.15rem; cursor: pointer; opacity: .85;
}
.sidebar-close:hover { opacity: 1; }
.sidebar-backdrop {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.45); z-index: 90;
    opacity: 0; transition: opacity .3s ease;
}
.sidebar-header {
    padding: 1.25rem 1.5rem; display: flex; align-items: center; gap: .75rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
/* Logo MECSYF (vert) posé sur un badge blanc : sinon il se fond dans le
   dégradé vert de la sidebar (faible contraste). object-fit pour ne pas
   déformer un logo non carré. */
.sidebar-header img {
    height: 40px; width: 40px; padding: 5px;
    background: var(--white); border-radius: var(--radius-sm);
    object-fit: contain;
    box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.sidebar-header .brand h2 { font-size: 1.1rem; font-weight: 700; letter-spacing: .5px; }
.sidebar-header .brand span { font-size: .7rem; opacity: .7; display: block; }

.sidebar-nav { flex: 1; min-height: 0; overflow-y: auto; padding: .5rem 0 1rem; }
/* #1008 — sections repliables : l'en-tête est un bouton (chevron pivotant),
   la préférence est persistée (localStorage), le groupe de la page active
   reste toujours déplié. */
.nav-group + .nav-group { margin-top: .35rem; }
.sidebar-nav .nav-section {
    width: 100%; display: flex; align-items: center; justify-content: space-between;
    padding: .5rem 1.5rem .35rem; font-size: .7rem; text-transform: uppercase;
    letter-spacing: 1.2px; color: rgba(255,255,255,.5); font-weight: 600;
    background: none; border: none; cursor: pointer; text-align: left;
    transition: color var(--transition-fast);
}
.sidebar-nav .nav-section:hover { color: rgba(255,255,255,.85); }
.sidebar-nav .nav-section i { font-size: .6rem; transition: transform var(--transition); }
.nav-group.collapsed .nav-section i { transform: rotate(-90deg); }
.nav-group.collapsed .nav-group-items { display: none; }
/* #1008 — item = ligne arrondie, actif = PILULE dorée translucide (remplace
   bordure gauche 4px + dégradé). */
.sidebar-nav .nav-item {
    display: flex; align-items: center; gap: .75rem;
    margin: .1rem .75rem; padding: .55rem .875rem;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,.72); font-size: .875rem; cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.sidebar-nav .nav-item:hover { background: rgba(255,255,255,.08); color: var(--white); }
.sidebar-nav .nav-item:hover i { color: var(--brand-secondary-light); }
.sidebar-nav .nav-item.active {
    background: color-mix(in srgb, var(--brand-secondary) 16%, transparent);
    color: var(--white); font-weight: 600;
}
.sidebar-nav .nav-item.active i { color: var(--brand-secondary); }
.sidebar-nav .nav-item i {
    width: 20px; text-align: center; font-size: .9rem;
    transition: color var(--transition);
}
/* Badge compteur « à traiter » (#1008) — alimenté par Sidebar.refreshBadges. */
.sidebar-nav .nav-count {
    margin-left: auto; background: var(--red); color: var(--white);
    font-size: .7rem; font-weight: 600; border-radius: 999px;
    padding: .05rem .45rem; align-items: center; line-height: 1.3;
}

.sidebar-footer {
    padding: 1rem 1.5rem; border-top: 1px solid rgba(255,255,255,.1);
    display: flex; align-items: center; gap: .75rem;
}
.sidebar-footer .avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--brand-secondary); display: flex; align-items: center;
    justify-content: center; font-weight: 700; color: var(--gray-900); font-size: .85rem;
}
.sidebar-footer .user-info { flex: 1; }
.sidebar-footer .user-info .name { font-size: .85rem; font-weight: 600; }
.sidebar-footer .user-info .role { font-size: .7rem; opacity: .6; }
.sidebar-footer .logout-btn {
    color: rgba(255,255,255,.5); font-size: 1rem; padding: .375rem;
    border-radius: var(--radius-xs); transition: all var(--transition);
}
.sidebar-footer .logout-btn:hover { color: var(--red); background: rgba(255,255,255,.1); }

/* --- Activity collapsible --- */
.activity-list.collapsed .activity-item:nth-child(n+4) { display: none; }
.activity-toggle {
    display: flex; align-items: center; justify-content: center; gap: .375rem;
    padding: .5rem; margin-top: .5rem; font-size: .8rem; color: var(--brand-primary);
    cursor: pointer; border-radius: var(--radius-sm); transition: background var(--transition);
}
.activity-toggle:hover { background: var(--brand-primary-bg); }
.activity-toggle i { font-size: .7rem; transition: transform .2s; }
.activity-toggle.open i { transform: rotate(180deg); }

/* --- Main area --- */
.main-area {
    flex: 1; margin-left: var(--sidebar-w);
    display: flex; flex-direction: column; min-height: 100vh;
}

/* --- Topbar --- */
.topbar {
    height: var(--topbar-h); background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    display: flex; align-items: center; padding: 0 1.5rem;
    position: sticky; top: 0; z-index: 50;
    box-shadow: var(--shadow-sm);
}
.topbar .page-title { font-size: 1.125rem; font-weight: 600; color: var(--gray-800); }
/* #1008 — fil d'ariane : section de nav grisée devant le titre. */
.topbar .crumb-section { color: var(--gray-400); font-weight: 500; font-size: .9rem; }
.topbar .crumb-sep { margin: 0 .45rem; color: var(--gray-300); font-weight: 400; }
/* #1011 — chip de périmètre permanent (verrouillé = imposé par le rôle). */
.scope-chip {
    display: inline-flex; align-items: center; gap: .4rem;
    font-size: .75rem; font-weight: 500; border-radius: 999px;
    padding: .25rem .7rem; margin-left: .9rem; white-space: nowrap;
}
.scope-chip i { font-size: .68rem; }
.scope-chip.scope-global { background: var(--brand-primary-bg); color: var(--brand-primary); }
.scope-chip.scope-locked { background: var(--status-warning-bg); color: var(--status-warning-fg); }
.scope-chip.scope-warning { background: var(--status-danger-bg); color: var(--status-danger-fg); }
/* #1011 — suffixe de périmètre sur le titre d'une liste scopée (chef d'agence…). */
.scope-suffix { font-size: .9rem; font-weight: 500; color: var(--brand-primary); }
/* #1008 — hint du raccourci clavier `/` dans la recherche. */
.topbar .search-kbd {
    position: absolute; right: .6rem; top: 50%; transform: translateY(-50%);
    border: 1px solid var(--gray-300); border-radius: var(--radius-xs);
    padding: 0 .35rem; font-size: .7rem; color: var(--gray-400); background: var(--white);
    pointer-events: none;
}
.topbar .topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.topbar .search-box {
    position: relative;
}
.topbar .search-box input {
    padding: .5rem .75rem .5rem 2.25rem;
    border: 1px solid var(--gray-200); border-radius: var(--radius-sm);
    background: var(--gray-50); width: 280px; font-size: .85rem;
    transition: all var(--transition);
}
.topbar .search-box input:focus {
    background: var(--white); border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 8%, transparent); width: 320px;
}
.topbar .search-box i {
    position: absolute; left: .75rem; top: 50%; transform: translateY(-50%);
    color: var(--gray-400); font-size: .85rem;
}
.topbar .notif-btn {
    position: relative; width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--gray-500); transition: all var(--transition);
}
.topbar .notif-btn:hover { background: var(--gray-100); color: var(--gray-700); }
.topbar .notif-btn .dot {
    position: absolute; top: 6px; right: 6px; width: 8px; height: 8px;
    background: var(--red); border-radius: 50%; border: 2px solid var(--white);
}
.notif-badge {
    position: absolute; top: 2px; right: 2px; min-width: 18px; height: 18px;
    background: var(--red); color: white; font-size: .7rem; font-weight: 700;
    border-radius: 999px; display: flex; align-items: center; justify-content: center;
    padding: 0 4px; border: 2px solid white;
}
.notif-panel {
    position: absolute; top: 100%; right: 0; width: min(340px, 90vw); max-height: 420px;
    background: white; border-radius: var(--radius); box-shadow: 0 8px 32px rgba(0,0,0,.15);
    z-index: 1000; overflow: hidden; margin-top: .5rem;
}
.notif-panel-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: .75rem 1rem; border-bottom: 1px solid var(--gray-100);
    font-size: .85rem;
}
.notif-panel-list { max-height: 360px; overflow-y: auto; }
.notif-panel-footer {
    padding: .5rem 1rem; border-top: 1px solid var(--gray-100);
    font-size: .72rem; color: var(--gray-400); text-align: center;
}
.notif-item {
    display: flex; gap: .75rem; align-items: flex-start;
    padding: .75rem 1rem; border-bottom: 1px solid var(--gray-50);
    cursor: pointer; transition: background .15s; position: relative;
}
.notif-item:hover { background: var(--gray-50); }
.notif-item.unread { background: var(--brand-primary-bg); }
.notif-item-icon {
    flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: .8rem; margin-top: .1rem;
    background: var(--gray-100); color: var(--gray-500);
}
.notif-item.notif-success .notif-item-icon { background: var(--status-success-bg); color: var(--status-success-fg); }
.notif-item.notif-warning .notif-item-icon { background: var(--status-warning-bg); color: var(--status-warning-fg); }
.notif-item.notif-danger  .notif-item-icon { background: var(--status-danger-bg); color: var(--status-danger-fg); }
.notif-item.notif-info    .notif-item-icon { background: var(--status-info-bg); color: var(--status-info-fg); }
.notif-item-body { flex: 1; min-width: 0; }
.notif-item-title { font-size: .82rem; font-weight: 500; color: var(--gray-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-item.unread .notif-item-title { font-weight: 700; }
.notif-item-text  { font-size: .75rem; color: var(--gray-500); margin-top: .1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-item-date  { font-size: .7rem; color: var(--gray-400); margin-top: .2rem; }
.notif-item-dot {
    position: absolute; top: .85rem; right: .75rem;
    width: 8px; height: 8px; background: var(--brand-primary); border-radius: 50%;
}
.notif-danger-text { color: var(--red); }
.notif-empty { padding: 1.25rem 1rem; text-align: center; color: var(--gray-400); font-size: .85rem; }
.mobile-menu-btn { display: none; }

/* =============================================================================
   CONTENT AREA
   ============================================================================= */
.content { flex: 1; padding: 1.5rem; }

/* --- Page header --- */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); }
.page-header .actions { display: flex; gap: .5rem; }

/* --- Cards --- */
.card {
    background: var(--white); border-radius: var(--radius);
    box-shadow: var(--shadow); border: 1px solid var(--gray-100);
}
.card-header {
    padding: 1rem 1.25rem; border-bottom: 1px solid var(--gray-100);
    display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: .95rem; font-weight: 600; }
.card-body { padding: 1.25rem; }

/* --- KPI Grid --- */
.kpi-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem; margin-bottom: 1.5rem;
}
.kpi-card {
    background: var(--white); border-radius: var(--radius);
    padding: 1.25rem; box-shadow: var(--shadow);
    border-left: 4px solid var(--brand-primary); border-top: none;
    display: flex; align-items: flex-start; gap: 1rem;
    transition: transform var(--transition);
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi-card.gold { border-left-color: var(--brand-secondary); }
.kpi-card.blue { border-left-color: var(--blue); }
.kpi-card.teal { border-left-color: var(--teal); }
.kpi-card.red { border-left-color: var(--red); }
.kpi-card .kpi-icon {
    width: 44px; height: 44px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; flex-shrink: 0;
}
.kpi-card .kpi-icon.green { background: var(--brand-primary-bg); color: var(--brand-primary); }
.kpi-card .kpi-icon.gold { background: var(--orange-light); color: var(--orange); }
.kpi-card .kpi-icon.blue { background: var(--blue-light); color: var(--blue); }
.kpi-card .kpi-icon.teal { background: var(--teal-light); color: var(--teal); }
.kpi-card .kpi-icon.red { background: var(--red-light); color: var(--red); }
.kpi-card .kpi-info { flex: 1; }
.kpi-card .kpi-label { font-size: .78rem; color: var(--gray-500); margin-bottom: .25rem; }
.kpi-card .kpi-value { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); line-height: 1.2; }
.kpi-card .kpi-trend { font-size: .75rem; margin-top: .25rem; }
.kpi-card .kpi-trend.up { color: var(--brand-primary); }
.kpi-card .kpi-trend.down { color: var(--red); }

/* --- Grid layouts --- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.5rem; margin-bottom: 1.5rem; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; margin-bottom: 1.5rem; }

/* --- Tables --- */
.data-table { width: 100%; }
.data-table thead th {
    text-align: left; padding: .75rem 1rem; font-size: .78rem;
    font-weight: 600; color: var(--gray-500); text-transform: uppercase;
    letter-spacing: .5px; background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}
.data-table tbody td {
    padding: .75rem 1rem; font-size: .85rem; color: var(--gray-700);
    border-bottom: 1px solid var(--gray-100);
}
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: var(--gray-50); }

/* --- Status badges --- */
.badge-status {
    display: inline-flex; align-items: center; padding: .2rem .6rem;
    border-radius: var(--radius-xs); font-size: .75rem; font-weight: 500;
}
.badge-status.success { background: var(--status-success-bg); color: var(--status-success-fg); }
.badge-status.warning { background: var(--status-warning-bg); color: var(--status-warning-fg); }
.badge-status.danger { background: var(--status-danger-bg); color: var(--status-danger-fg); }
.badge-status.info { background: var(--status-info-bg); color: var(--status-info-fg); }
.badge-status.neutral { background: var(--status-neutral-bg); color: var(--status-neutral-fg); }

/* --- Pagination --- */
.pagination {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.25rem; border-top: 1px solid var(--gray-100);
}
.pagination .info { font-size: .8rem; color: var(--gray-500); }
.pagination .pages { display: flex; gap: .25rem; }
.pagination .pages button {
    width: 32px; height: 32px; border-radius: var(--radius-xs);
    display: flex; align-items: center; justify-content: center;
    font-size: .8rem; color: var(--gray-600);
    transition: all var(--transition);
}
.pagination .pages button:hover { background: var(--gray-100); }
.pagination .pages button.active {
    background: var(--brand-primary); color: var(--white);
}

/* --- Activity feed --- */
.activity-item {
    display: flex; gap: .75rem; padding: .75rem 0;
    border-bottom: 1px solid var(--gray-100);
}
.activity-item:last-child { border-bottom: none; }
.activity-item .activity-icon {
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: .75rem; flex-shrink: 0;
}
.activity-item .activity-text { font-size: .85rem; color: var(--gray-700); flex: 1; }
.activity-item .activity-text strong { font-weight: 600; color: var(--gray-800); }
.activity-item .activity-time { font-size: .75rem; color: var(--gray-400); white-space: nowrap; }

/* --- Toolbar (filters + search) --- */
.toolbar {
    display: flex; align-items: center; gap: .75rem;
    padding: 1rem 1.25rem; border-bottom: 1px solid var(--gray-100);
    flex-wrap: wrap;
}
.toolbar .search-input {
    padding: .5rem .75rem .5rem 2.25rem; border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm); background: var(--gray-50); width: 240px;
    font-size: .85rem;
}
.toolbar .filter-select {
    padding: .5rem .75rem; border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm); background: var(--white); font-size: .85rem;
    color: var(--gray-600);
}

/* --- Dropdown maison (#1294) — remplace les <select> natifs dont le popup OS
   déborde l'UI. Ouverture vers le bas, hauteur bornée + scroll, positionné en CSS. */
.dd { position: relative; display: inline-block; }
.dd-trigger {
    display: inline-flex; align-items: center; justify-content: space-between; gap: .5rem;
    min-width: 160px; padding: .5rem .75rem; border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm); background: var(--white); color: var(--gray-700);
    font-family: inherit; font-size: .85rem; cursor: pointer; text-align: left;
}
.dd-trigger:focus-visible {
    outline: none; border-color: var(--brand-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 12%, transparent);
}
.dd-caret { font-size: .65rem; color: var(--gray-400); transition: transform var(--transition); }
.dd-trigger[aria-expanded="true"] .dd-caret { transform: rotate(180deg); }
/* #1325 — un Dropdown au niveau champ (enfant direct d'un .form-group) doit remplir
   la largeur du champ, comme un <input>/<select>, pour ne pas apparaître comme une
   pilule étroite au milieu de champs pleine largeur. Le sélecteur d'indicatif du
   téléphone (.phone-cc .dd, imbriqué) et les dropdowns de toolbar/filtre (hors
   .form-group) gardent leur largeur au contenu. */
.form-group > .dd { display: block; }
.form-group > .dd > .dd-trigger { width: 100%; }
.dd-menu {
    position: absolute; left: 0; top: calc(100% + .25rem); z-index: 70;
    margin: 0; padding: .25rem; list-style: none; min-width: 100%;
    background: var(--white); border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm); box-shadow: 0 8px 24px -8px rgba(17, 24, 39, .25);
    max-height: 16rem; overflow-y: auto;
}
.dd-option {
    padding: .5rem .6rem; border-radius: var(--radius-xs); cursor: pointer;
    color: var(--gray-800); font-size: .85rem; white-space: nowrap;
}
.dd-option:hover, .dd-option.dd-active { background: var(--gray-100); }
.dd-option.dd-selected { color: var(--brand-primary); font-weight: 500; }
/* En-tête d'optgroup — non sélectionnable (#1294 lot 3c). */
.dd-group {
    padding: .4rem .6rem .2rem; font-size: .72rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .03em; color: var(--gray-400);
    cursor: default; pointer-events: none;
}

/* Variante combo éditable (#1294 p2) — input à saisie libre + suggestions. */
.dd-combo { display: block; }
.dd-combo-field { width: 100%; min-width: 0; padding: 0; cursor: text; }
.dd-combo-input {
    flex: 1; min-width: 0; border: none; background: transparent; outline: none;
    padding: .5rem .75rem; border-radius: var(--radius-sm);
    font-family: inherit; font-size: .85rem; color: var(--gray-800);
}
.dd-combo-field .dd-caret { margin-right: .6rem; }
.dd-combo-field:focus-within {
    border-color: var(--brand-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 12%, transparent);
}
.dd-combo-input[aria-expanded="true"] ~ .dd-caret { transform: rotate(180deg); }

/* FileInput (#1294 p6) — zone d'upload stylée (réplique le .file-drop du portail).
   Label cliquable ; l'<input type="file"> natif est masqué. */
.file-drop {
    display: block; border: 2px dashed var(--gray-300); border-radius: var(--radius-sm);
    padding: 1.5rem 1rem; text-align: center; cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}
.file-drop:hover, .file-drop.drag-over { border-color: var(--brand-primary); background: var(--brand-primary-bg); }
.file-drop i { font-size: 1.75rem; color: var(--gray-300); }
.file-drop:hover i, .file-drop.drag-over i { color: var(--brand-primary); }
.file-drop p { font-size: .82rem; color: var(--gray-500); margin: .5rem 0 0; }
.file-drop .file-drop-hint { font-size: .72rem; color: var(--gray-400); margin-top: .2rem; }
/* Masqué VISUELLEMENT mais focalisable au clavier (pas `display:none`, qui le
   sortirait de l'ordre de tabulation) — la zone montre alors un focus (#1296). */
.file-drop input[type="file"] {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.file-drop:focus-within { border-color: var(--brand-primary); background: var(--brand-primary-bg); }
.file-name { margin-top: .5rem; font-size: .8rem; color: var(--brand-primary); font-weight: 500; word-break: break-all; }

/* DatePicker (#1294 p3) — champ masqué JJ/MM/AAAA + calendrier maison.
   Remplace <input type="date"> (calendrier natif OS qui déborde, affichage
   dépendant de la locale). La valeur soumise reste ISO (hidden). */
.dp { position: relative; display: inline-block; }
.dp-field {
    display: inline-flex; align-items: center; gap: .25rem;
    border: 1px solid var(--gray-300); border-radius: var(--radius-sm);
    background: var(--white); padding: 0 .35rem 0 0;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.dp-field:focus-within { border-color: var(--brand-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 12%, transparent); }
.dp-invalid .dp-field { border-color: var(--red); }
.dp-readonly .dp-field { background: var(--gray-50); }

/* Indicatif téléphone (#1294) — Dropdown maison compact aligné sur la hauteur du
   champ numéro (44px, anti-zoom iOS). */
.phone-cc { flex: 0 0 auto; }
.phone-cc .dd, .phone-cc .dd-trigger { width: 100%; }
.phone-cc .dd-trigger { min-width: 6rem; min-height: 44px; font-size: 16px; }
.dp-readonly .dp-input { color: var(--gray-500); cursor: default; }
.dp-input, .dp-time {
    border: none; background: transparent; outline: none;
    font-family: inherit; font-size: .85rem; color: var(--gray-800);
    padding: .5rem .5rem; min-width: 0;
}
.dp-input { width: 6.5rem; }
.dp-time { width: 3.5rem; border-left: 1px solid var(--gray-200); padding-left: .5rem; }
.dp-cal-btn {
    display: inline-flex; align-items: center; justify-content: center;
    border: none; background: transparent; color: var(--gray-400);
    cursor: pointer; padding: .35rem; border-radius: var(--radius-xs); font-size: .85rem;
}
.dp-cal-btn:hover { color: var(--brand-primary); background: var(--gray-100); }
.dp-cal {
    position: absolute; left: 0; top: calc(100% + .25rem); z-index: 70;
    width: 15.5rem; padding: .6rem; background: var(--white);
    border: 1px solid var(--gray-200); border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px -8px rgba(17, 24, 39, .25);
}
.dp-cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .4rem; }
.dp-title {
    font-size: .82rem; font-weight: 700; color: var(--gray-800);
    text-transform: capitalize; border: none; background: transparent;
    cursor: pointer; padding: .2rem .5rem; border-radius: var(--radius-xs);
}
.dp-title:hover:not([disabled]) { background: var(--gray-100); color: var(--brand-primary); }
.dp-title[disabled] { cursor: default; }
/* Grille mois/années (3 colonnes) — même métaphore que la grille des jours.
   Spécificité .dp-grid.dp-mg pour l'emporter sur les 7 colonnes de .dp-grid. */
.dp-grid.dp-mg { grid-template-columns: repeat(3, 1fr); gap: .3rem; margin-top: .2rem; }
.dp-cell {
    border: none; background: transparent; cursor: pointer;
    padding: .5rem .25rem; border-radius: var(--radius-xs);
    font-family: inherit; font-size: .8rem; color: var(--gray-700); text-align: center;
}
.dp-cell:hover { background: var(--brand-primary-bg); color: var(--brand-primary); }
.dp-cell.dp-cell-cur { box-shadow: inset 0 0 0 1px var(--gray-300); font-weight: 700; }
.dp-cell.dp-selected { background: var(--brand-primary); color: var(--white); font-weight: 700; }
.dp-cell.dp-disabled { color: var(--gray-300); cursor: default; }
.dp-cell.dp-disabled:hover { background: transparent; }
.dp-nav {
    border: none; background: transparent; color: var(--gray-500); cursor: pointer;
    padding: .25rem .45rem; border-radius: var(--radius-xs); font-size: .75rem;
}
.dp-nav:hover { background: var(--gray-100); color: var(--brand-primary); }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-weekdays { margin-bottom: .2rem; }
.dp-wd { text-align: center; font-size: .68rem; font-weight: 700; color: var(--gray-400); padding: .2rem 0; }
.dp-blank { visibility: hidden; }
.dp-day {
    border: none; background: transparent; cursor: pointer;
    aspect-ratio: 1; border-radius: var(--radius-xs);
    font-family: inherit; font-size: .78rem; color: var(--gray-700);
    display: flex; align-items: center; justify-content: center;
}
.dp-day:hover { background: var(--brand-primary-bg); color: var(--brand-primary); }
.dp-day.dp-today { font-weight: 700; box-shadow: inset 0 0 0 1px var(--gray-300); }
.dp-day.dp-selected { background: var(--brand-primary); color: var(--white); font-weight: 700; }
.dp-day.dp-disabled { color: var(--gray-300); cursor: default; }

/* Tooltip maison (#1294 p8) — remplace l'info-bulle native de `title` (temporisée,
   non stylée, OS). position:fixed → jamais rognée par un conteneur overflow. */
.tooltip {
    position: fixed; z-index: 200; pointer-events: none;
    background: var(--gray-900); color: var(--white);
    font-size: .72rem; line-height: 1.35; font-weight: 500;
    padding: .35rem .55rem; border-radius: var(--radius-xs);
    max-width: 16rem; box-shadow: var(--shadow-md);
}
.tooltip::after {
    content: ''; position: absolute; left: 50%; transform: translateX(-50%);
    border: 5px solid transparent; border-top-color: var(--gray-900); top: 100%;
}
.tooltip.tooltip-below::after {
    top: auto; bottom: 100%; border-top-color: transparent; border-bottom-color: var(--gray-900);
}

/* --- Composants gabarits (#1009) --------------------------------------------- */
/* PageHeader — sous-titre chiffré (+ périmètre #1011). */
.page-subtitle { font-size: .85rem; color: var(--gray-500); margin-top: .25rem; }

/* KpiTiles — tuiles d'indicateurs compactes (fiche, dashboard). */
.kpi-tiles {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: .75rem; margin-bottom: 1.5rem;
}
.kpi-tile {
    background: var(--white); border: 1px solid var(--gray-100);
    border-radius: var(--radius-sm); padding: .7rem .875rem;
}
.kpi-tile-label { font-size: .75rem; color: var(--gray-500); }
.kpi-tile-value { font-size: 1.15rem; font-weight: 700; margin-top: .15rem; line-height: 1.25; }
.kpi-tile-hint { font-size: .72rem; color: var(--gray-400); margin-top: .1rem; }

/* Toolbar — chips de filtres (verrouillé #1011 / actif supprimable / select). */
.chip {
    display: inline-flex; align-items: center; gap: .4rem;
    font-size: .8rem; border-radius: 999px; padding: .3rem .75rem; white-space: nowrap;
}
.chip-locked { background: var(--status-warning-bg); color: var(--status-warning-fg); }
.chip-active { background: var(--brand-primary-bg); color: var(--brand-primary); }
.chip-remove { display: inline-flex; color: inherit; opacity: .7; padding: 0 .1rem; }
.chip-remove:hover { opacity: 1; }
.chip-select { background: var(--white); border: 1px dashed var(--gray-300); color: var(--gray-600); cursor: pointer; }
.chip-select select {
    border: none; background: transparent; font-size: .8rem;
    color: var(--gray-700); outline: none; cursor: pointer;
}
/* Dropdown maison à l'intérieur d'un chip de filtre : trigger fondu (#1294). */
.chip-select .dd-trigger {
    border: none; background: transparent; min-width: auto;
    padding: 0 .1rem; font-size: .8rem; color: var(--gray-700); gap: .3rem;
}
.toolbar .toolbar-actions { margin-left: auto; display: flex; gap: .5rem; }

/* Tri DataTable — en-têtes cliquables. */
.data-table thead th.th-sort { cursor: pointer; user-select: none; }
.data-table thead th.th-sort:hover { color: var(--gray-700); }
.data-table thead th.th-sort.active { color: var(--brand-primary); }
.data-table thead th.th-sort i { margin-left: .25rem; font-size: .7rem; }

/* EmptyState — état vide invitant. */
.empty-state-title { font-size: .95rem; font-weight: 600; color: var(--gray-600); }
.empty-state-body { font-size: .85rem; margin-top: .25rem; }
.empty-state-action { margin-top: 1rem; }

/* --- Gabarit FICHE (#963 — membre, puis crédit #964 / épargne #965) ---------- */
/* En-tête d'entité : avatar initiales + nom/n° + chips + domiciliation. */
.entity-header { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
/* Les actions de l'en-tête (primaire + menu ⋯) restent CÔTE À CÔTE et alignées —
   la règle historique est scopée .page-header .actions et ne s'applique pas ici. */
.entity-header .actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.entity-avatar {
    width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0;
    background: var(--brand-primary); color: var(--white);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.05rem;
}
.entity-chips { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .35rem; }
.entity-domicile { font-size: .8rem; color: var(--gray-500); margin-top: .35rem; }

/* Cellule identité de liste (#1010) — avatar + nom + n°/méta empilés.
   Source unique via le composant IdentityCell (anti-recopie sur ~8 listes). */
.id-cell { display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; color: inherit; max-width: 100%; }
.id-cell__av {
    width: 30px; height: 30px; flex-shrink: 0; border-radius: 50%;
    background: var(--brand-primary); color: var(--white);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .72rem;
}
.id-cell__text { display: flex; flex-direction: column; min-width: 0; }
.id-cell__name { font-weight: 600; color: var(--gray-900); }
a.id-cell:hover .id-cell__name { color: var(--brand-primary); }
.id-cell__sub { font-size: .72rem; color: var(--gray-400); }
.id-cell__sub .text-mono { font-size: .72rem; color: var(--gray-500); }

/* Mini-jauge de progression en cellule (#1010) — ex. % remboursé d'un prêt. */
.mini-bar { height: 4px; border-radius: 999px; background: var(--gray-100); margin-top: .25rem; max-width: 140px; overflow: hidden; }
.mini-bar > i { display: block; height: 100%; background: var(--brand-primary); }

/* StatFilters (#1010) — compteurs de statut cliquables en tête de liste.
   Composant partagé : tokens --status-*, état actif, barre de répartition. */
.stat-filters-wrap { margin-bottom: 1.25rem; }
.stat-filters { display: flex; gap: .75rem; align-items: flex-start; flex-wrap: wrap; }
.stat-filters__sep { align-self: stretch; width: 1px; background: var(--gray-200); margin: .25rem .25rem; }
.stat-filters__group { display: flex; flex-direction: column; }
.stat-filters__group-label { font-size: .72rem; color: var(--gray-400); margin: 0 0 .35rem .1rem; }
.stat-filters__tiles { display: flex; gap: .5rem; flex-wrap: wrap; }
.stat-tile {
    position: relative; min-width: 92px; text-align: left; cursor: pointer;
    background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius-sm);
    padding: .55rem .8rem; font-family: inherit; transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.stat-tile:hover { border-color: var(--gray-300); }
.stat-tile--anchor { background: var(--gray-50); }
.stat-tile.is-active { border-color: var(--brand-primary); box-shadow: inset 0 0 0 1px var(--brand-primary); }
.stat-tile__value { display: block; font-size: 1.25rem; font-weight: 700; line-height: 1.1; }
.stat-tile__label { display: block; font-size: .75rem; color: var(--gray-500); margin-top: .1rem; white-space: nowrap; }
.stat-tile__hint { display: block; font-size: .7rem; color: var(--gray-400); margin-top: .1rem; white-space: nowrap; }
.stat-tile__x { position: absolute; top: .3rem; right: .4rem; font-size: .68rem; color: var(--gray-400); }
.stat-bar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; margin: .85rem 0 0; background: var(--gray-100); }
.stat-bar > span { display: block; }
.stat-bar__legend { display: flex; gap: .9rem; flex-wrap: wrap; font-size: .72rem; color: var(--gray-500); margin-top: .45rem; }
.stat-bar__leg-item i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: .3rem; }

/* Bandeau d'état de dossier (incomplet, à traiter…). */
.banner {
    display: flex; align-items: center; gap: .6rem;
    border-radius: var(--radius-sm); padding: .6rem .9rem;
    font-size: .85rem; margin-bottom: 1rem;
}
.banner-warning { background: var(--status-warning-bg); color: var(--status-warning-fg); }
/* CTA du bandeau (mockup) — bouton plein assorti au fond du bandeau. */
.banner .banner-cta {
    background: var(--status-warning-fg); color: var(--white);
    flex-shrink: 0; white-space: nowrap;
}
.banner .banner-cta:hover { opacity: .9; }

/* Valeur manquante actionnable (remplace le tiret muet). */
.to-complete { color: var(--status-warning-fg); font-style: italic; }

/* Menu d'actions secondaires — details/summary natif (clavier + zéro JS). */
.actions-menu { position: relative; }
.actions-menu summary { list-style: none; }
.actions-menu summary::-webkit-details-marker { display: none; }
.actions-menu-panel {
    position: absolute; right: 0; top: calc(100% + .4rem); z-index: 60;
    background: var(--white); border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
    padding: .35rem; min-width: 230px;
    display: flex; flex-direction: column; gap: .1rem;
}
.actions-menu-panel .btn {
    justify-content: flex-start; width: 100%;
    background: none; border: none; color: var(--gray-700);
    padding: .5rem .75rem; font-size: .85rem; border-radius: var(--radius-xs);
}
.actions-menu-panel .btn:hover { background: var(--gray-100); }

/* Lignes d'alertes LBC/FT colorées par sévérité (#963, données #962). */
.alert-row {
    display: flex; gap: .6rem; align-items: flex-start;
    padding: .55rem .75rem; border-radius: var(--radius-sm); margin-bottom: .4rem;
}
.alert-row.severity-critical, .alert-row.severity-high { background: var(--status-danger-bg); color: var(--status-danger-fg); }
.alert-row.severity-medium { background: var(--status-warning-bg); color: var(--status-warning-fg); }
.alert-row.severity-low { background: var(--status-info-bg); color: var(--status-info-fg); }

/* --- Modal --- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; opacity: 0; visibility: hidden;
    transition: all .2s ease;
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal {
    background: var(--white); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); width: 90%; max-width: 560px;
    max-height: 85vh; overflow-y: auto;
    transform: translateY(20px); transition: transform .2s ease;
}
.modal-wide { max-width: 960px; }
.modal-overlay.active .modal { transform: translateY(0); }
.modal-header {
    padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--gray-100);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 1.1rem; font-weight: 600; }
.modal-header .close-btn {
    width: 32px; height: 32px; border-radius: var(--radius-xs);
    display: flex; align-items: center; justify-content: center;
    color: var(--gray-400); transition: all var(--transition);
}
.modal-header .close-btn:hover { background: var(--gray-100); color: var(--gray-700); }
.modal-body { padding: 1.5rem; }
.modal-footer {
    padding: 1rem 1.5rem; border-top: 1px solid var(--gray-100);
    display: flex; justify-content: flex-end; gap: .5rem;
}

/* --- Loading --- */
.spinner {
    width: 32px; height: 32px; border: 3px solid var(--gray-200);
    border-top-color: var(--brand-primary); border-radius: 50%;
    animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center {
    display: flex; align-items: center; justify-content: center;
    padding: 3rem; flex-direction: column; gap: 1rem;
    color: var(--gray-400);
}

/* --- Empty state --- */
.empty-state {
    text-align: center; padding: 3rem 1.5rem; color: var(--gray-400);
}
.empty-state i { font-size: 2.5rem; margin-bottom: 1rem; }
.empty-state p { font-size: .9rem; }

/* --- Toasts --- */
.toast-container {
    position: fixed; top: 1rem; right: 1rem; z-index: 2000;
    display: flex; flex-direction: column; gap: .5rem;
}
.toast {
    background: var(--white); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg); padding: .875rem 1.25rem;
    display: flex; align-items: flex-start; gap: .75rem;
    font-size: .85rem; min-width: 300px; max-width: 480px;
    animation: slideIn .3s ease;
    border-left: 4px solid var(--brand-primary);
}
.toast > i { padding-top: 2px; }
/* Préserve les sauts de ligne `\n` dans le message Toast (cf. fix XSS #165) */
.toast > span { white-space: pre-line; }
.toast.error { border-left-color: var(--red); }
.toast.warning { border-left-color: var(--orange); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* --- Chart containers --- */
.chart-container { position: relative; }
.chart-bar-group { display: flex; align-items: flex-end; gap: 2px; height: 120px; }
.chart-bar {
    flex: 1; background: var(--brand-primary); border-radius: 3px 3px 0 0;
    min-width: 8px; transition: height .3s ease;
    position: relative;
}
.chart-bar.secondary { background: var(--brand-primary-lighter); opacity: .5; }
.chart-bar:hover { opacity: .8; }

/* --- Chart tooltips --- */
[data-tooltip] { position: relative; cursor: pointer; }
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
    background: var(--gray-900, #1a1a2e); color: #fff;
    font-size: .7rem; font-weight: 500; line-height: 1.3;
    padding: .35rem .6rem; border-radius: var(--radius-xs);
    white-space: nowrap; pointer-events: none;
    opacity: 0; transition: opacity .15s ease;
    z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
[data-tooltip]::before {
    content: ''; position: absolute; bottom: calc(100% + 2px); left: 50%; transform: translateX(-50%);
    border: 4px solid transparent; border-top-color: var(--gray-900, #1a1a2e);
    opacity: 0; transition: opacity .15s ease;
    z-index: 100; pointer-events: none;
}
[data-tooltip]:hover::after,
[data-tooltip]:hover::before { opacity: 1; }
.chart-bar[data-tooltip] { overflow: visible; }
.chart-bar-col { position: relative; }
.donut-segment { cursor: pointer; }
.donut-segment:hover { opacity: .75; }
svg [data-tooltip] { position: static; }
.hbar-row { position: relative; }
.chart-svg-tooltip {
    position: fixed; transform: translateX(-50%) translateY(-100%);
    background: var(--gray-900, #1a1a2e); color: #fff;
    font-size: .7rem; font-weight: 500; line-height: 1.3;
    padding: .35rem .6rem; border-radius: var(--radius-xs);
    white-space: nowrap; pointer-events: none;
    opacity: 0; transition: opacity .15s ease;
    z-index: 1000; box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.chart-legend { display: flex; gap: 1.5rem; margin-top: .75rem; }
.chart-legend span {
    display: flex; align-items: center; gap: .375rem;
    font-size: .75rem; color: var(--gray-500);
}
.chart-legend span::before {
    content: ''; width: 10px; height: 10px; border-radius: 2px;
    background: var(--brand-primary);
}
.chart-legend span.secondary::before { background: var(--brand-primary-lighter); opacity: .5; }

/* --- Donut --- */
.donut-container { display: flex; align-items: center; gap: 1.5rem; }
.donut-legend { display: flex; flex-direction: column; gap: .5rem; }
.donut-legend-item {
    display: flex; align-items: center; gap: .5rem; font-size: .8rem;
}
.donut-legend-item .dot {
    width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}

/* --- Tabs --- */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--gray-100); margin-bottom: 1.5rem; }
.tab, .tab-btn {
    padding: .75rem 1.25rem; font-size: .875rem; font-weight: 500;
    color: var(--gray-500); border-bottom: 2px solid transparent;
    margin-bottom: -2px; transition: all var(--transition);
    display: inline-flex; align-items: center; gap: .5rem;
}
.tab:hover, .tab-btn:hover { color: var(--gray-700); }
.tab.active, .tab-btn.active { color: var(--brand-primary); border-bottom-color: var(--brand-primary); }

/* Extra button sizes */
.btn-xs { padding: .25rem .5rem; font-size: .75rem; border-radius: var(--radius-xs); }
.btn-success { background: var(--brand-primary-lighter); color: var(--white); }
.btn-success:hover { background: var(--brand-primary); }
.btn-warning { background: var(--orange); color: var(--white); }
.btn-warning:hover { background: var(--brand-secondary-dark); }

/* =============================================================================
   UTILITAIRES (#1006) — résorption progressive des styles inline des pages.
   Un pattern répété en style="" dans 2+ pages doit devenir une classe ici.
   ============================================================================= */
/* Flex */
.u-flex { display: flex; align-items: center; }
.u-flex-col { display: flex; flex-direction: column; }
.u-flex-start { display: flex; align-items: flex-start; }
.u-between { justify-content: space-between; }
.u-end { justify-content: flex-end; }
.u-wrap { flex-wrap: wrap; }
.u-grow { flex: 1; min-width: 0; }
/* Espacements (gap flex/grid) */
.gap-1 { gap: .25rem; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.gap-4 { gap: 1rem; }
/* Rythme vertical entre enfants */
.stack-1 > * + * { margin-top: .25rem; }
.stack-2 > * + * { margin-top: .5rem; }
.stack-3 > * + * { margin-top: 1rem; }
/* Grilles denses (tuiles, formulaires) */
.grid-dense { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; }
.form-2col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
/* Texte */
.text-muted { color: var(--gray-500); }
.text-faint { color: var(--gray-400); }
.text-sm { font-size: .85rem; }
.text-xs { font-size: .78rem; }
.text-right { text-align: right; }
.text-mono { font-family: 'Courier New', monospace; }
.u-truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Bannière « nouvelle version disponible » (#1330) — au-dessus d'une éventuelle
   bottom-nav (portail via --nav-h ; fallback 0 en back-office). */
.version-banner {
    position: fixed; left: 50%; bottom: calc(var(--nav-h, 0px) + 1rem); transform: translateX(-50%);
    z-index: 2000; display: flex; align-items: center; gap: .6rem;
    max-width: calc(100vw - 2rem);
    background: var(--gray-900); color: var(--white);
    padding: .5rem .5rem .5rem 1rem; border-radius: var(--radius);
    box-shadow: var(--shadow-lg); font-size: .85rem;
}
.version-banner i { color: var(--brand-secondary); margin-right: .35rem; }
.version-banner-close {
    color: var(--gray-400); font-size: 1.15rem; line-height: 1; padding: 0 .35rem;
    background: none; border: none; cursor: pointer;
}
.version-banner-close:hover { color: var(--white); }

/* =============================================================================
   RESPONSIVE
   ============================================================================= */
@media (max-width: 1024px) {
    .grid-2, .grid-2-1, .grid-3 { grid-template-columns: 1fr; }
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: inline-flex; }
    .sidebar-backdrop.active { display: block; opacity: 1; }
    .main-area { margin-left: 0; }
    .mobile-menu-btn { display: flex; }
    .topbar .search-box input { width: 200px; }
    .topbar .search-box input:focus { width: 200px; }
    /* Documentation — stack TOC above content */
    .help-layout { flex-direction: column; }
    .help-toc { width: 100%; position: static; max-height: 220px; }
}
@media (max-width: 640px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .form-2col { grid-template-columns: 1fr; }
    .content { padding: 1rem; }
    .topbar .search-box { display: none; }
    /* Chip de périmètre : masqué en très petit écran (titre prioritaire) —
       l'info reste dans le footer sidebar pour les rôles de caisse. */
    .scope-chip { display: none; }
    .page-header { flex-direction: column; align-items: flex-start; }
    /* Documentation — hide TOC, tighten cards */
    .help-toc { display: none; }
    .help-header { flex-direction: column; gap: 16px; }
    .help-section { padding: 20px 16px; }
    .help-title { font-size: 22px; }
}

/* =============================================================================
   DOCUMENTATION PAGES — help.js & docs.js (shared)
   ============================================================================= */
.help-wrapper { max-width: 1200px; margin: 0 auto; padding: 0 0 60px; }
.help-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    padding: 32px 0 24px; border-bottom: 2px solid var(--brand-primary); margin-bottom: 32px;
}
.help-title { font-size: 28px; font-weight: 700; color: var(--brand-primary-dark); margin: 0 0 6px; }
.help-subtitle { color: var(--gray-500); font-size: 14px; margin: 0; }

.help-layout { display: flex; gap: 32px; align-items: flex-start; }

.help-toc {
    width: 220px; flex-shrink: 0; position: sticky; top: 80px;
    background: var(--white); border: 1px solid var(--gray-200);
    border-radius: var(--radius); padding: 16px; max-height: calc(100vh - 100px); overflow-y: auto;
}
.help-toc-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--gray-400); margin: 0 0 12px; }
.help-toc-link {
    display: flex; align-items: center; gap: 8px; padding: 6px 8px;
    color: var(--gray-600); font-size: 13px; border-radius: var(--radius-xs);
    cursor: pointer; text-decoration: none; transition: var(--transition);
}
.help-toc-link:hover { background: var(--brand-primary-bg); color: var(--brand-primary); }
.help-toc-link i { width: 14px; text-align: center; font-size: 12px; color: var(--gray-400); }

.help-content { flex: 1; min-width: 0; }
.help-section {
    background: var(--white); border: 1px solid var(--gray-200);
    border-radius: var(--radius); padding: 32px; margin-bottom: 24px;
}
.help-section h2 {
    font-size: 20px; font-weight: 700; color: var(--brand-primary-dark);
    border-bottom: 1px solid var(--gray-100); padding-bottom: 12px; margin: 0 0 20px;
    display: flex; align-items: center; gap: 10px;
}
.help-section h2 i { color: var(--brand-primary); }
.help-section h3 { font-size: 15px; font-weight: 600; color: var(--gray-700); margin: 20px 0 10px; }
.help-section p { color: var(--gray-600); line-height: 1.7; margin: 0 0 12px; }
.help-section ul { margin: 0 0 12px; padding-left: 20px; }
.help-section li { color: var(--gray-600); line-height: 1.8; font-size: 14px; }
.help-section li strong { color: var(--gray-800); }

.help-note {
    background: var(--brand-primary-bg); border-left: 3px solid var(--brand-primary);
    border-radius: var(--radius-xs); padding: 12px 16px; margin: 16px 0;
    font-size: 13px; color: var(--brand-primary-dark);
    display: flex; align-items: flex-start; gap: 10px;
}
.help-note i { margin-top: 2px; flex-shrink: 0; }
.help-note-warning { background: #fffbeb; border-color: var(--orange); color: #92400e; }
.help-note-warning i { color: var(--orange); }

.help-table-wrap { overflow-x: auto; margin: 12px 0; }
.help-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.help-table th { background: var(--gray-50); color: var(--gray-600); font-weight: 600; text-align: left; padding: 10px 14px; border-bottom: 2px solid var(--gray-200); white-space: nowrap; }
.help-table td { padding: 10px 14px; border-bottom: 1px solid var(--gray-100); color: var(--gray-700); vertical-align: top; }
.help-table tr:last-child td { border-bottom: none; }

.help-workflow {
    display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
    background: var(--gray-50); border-radius: var(--radius-sm); padding: 16px; margin: 12px 0;
}
.help-step {
    display: flex; align-items: center; gap: 8px;
    background: var(--white); border: 1px solid var(--gray-200);
    border-radius: var(--radius-xs); padding: 8px 14px; font-size: 13px; color: var(--gray-700);
}
.help-step.step-success { background: var(--brand-primary-bg); border-color: var(--brand-primary); color: var(--brand-primary-dark); }
.step-num {
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--brand-primary); color: white; font-size: 11px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.step-success .step-num { background: var(--brand-primary-dark); }
.step-arrow { color: var(--gray-400); font-size: 16px; }

.help-roles { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--gray-100); }
.help-roles-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--gray-400); margin-bottom: 8px; }
.help-roles-list { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 100px; font-size: 11px; font-weight: 600; }
.badge-purple { background: #f5f3ff; color: #7c3aed; }
.badge-blue   { background: #eff6ff; color: #2563eb; }
.badge-green  { background: var(--brand-primary-bg); color: var(--brand-primary-dark); }
.badge-orange { background: #fffbeb; color: #92400e; }
.badge-teal   { background: var(--teal-light); color: #0f766e; }
.badge-gray   { background: var(--gray-100); color: var(--gray-600); }
.badge-red    { background: #fef2f2; color: #dc2626; }

.help-footer {
    text-align: center; padding: 32px 0 0;
    border-top: 1px solid var(--gray-200); color: var(--gray-400); font-size: 12px; line-height: 2;
}

.docs-code {
    background: var(--gray-800); color: #e2e8f0; border-radius: var(--radius-sm);
    padding: 16px 20px; font-family: 'Courier New', monospace; font-size: 12px;
    line-height: 1.6; overflow-x: auto; margin: 12px 0; white-space: pre;
}
.help-wrapper code {
    background: var(--gray-100); color: var(--brand-primary-dark);
    padding: 2px 6px; border-radius: var(--radius-xs); font-family: 'Courier New', monospace; font-size: 12px;
}

@media print {
    .no-print { display: none !important; }
    .help-layout { display: block !important; }
    .help-toc { display: none !important; }
    .help-section { break-inside: avoid; border: none; box-shadow: none; padding: 20px 0; }
    .help-section h2 { color: var(--brand-primary-dark); border-bottom: 1px solid #ccc; }
    .help-header { border-bottom: 2px solid var(--brand-primary-dark); }
    .help-title { color: var(--brand-primary-dark); }
    .docs-code { background: #f3f4f6; color: #1f2937; border: 1px solid #e5e7eb; }
    body { font-size: 12px; }
    @page { margin: 20mm; }
}

/* =============================================================================
   ÉTATS FINANCIERS — bilan / compte de résultat en deux colonnes (maquette
   validée #1064/#1095, reprise PR #1378+). Pattern partagé : États Financiers
   aujourd'hui, page Comptabilité (balance, plan) au fil des lots suivants.
   Alignement actif/passif : chaque colonne est une pile flex et le TOTAL est
   ÉPINGLÉ en bas (margin-top:auto) — TOTAL ACTIF et TOTAL PASSIF tombent
   toujours sur la même ligne, quel que soit le nombre de lignes dépliées.
   ============================================================================= */
.bilan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0; align-items: stretch; }
.bilan-grid > .bcol:first-child { border-right: 1px solid var(--gray-100); }
.bcol { display: flex; flex-direction: column; }
.bcol h4 { margin: 0; padding: .7rem 1.1rem; font-size: .8rem; text-transform: uppercase;
    letter-spacing: .05em; color: var(--gray-600); background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200); }
.masse { display: flex; gap: .5rem; align-items: center; padding: .5rem 1.1rem;
    font-weight: 600; font-size: .82rem; cursor: pointer; background: var(--white);
    border-bottom: 1px solid var(--gray-100); }
.masse:hover { background: var(--gray-50); }
.masse:focus-visible { outline: 2px solid var(--brand-action); outline-offset: -2px; }
.subrow { display: flex; gap: .5rem; align-items: center;
    padding: .32rem 1.1rem .32rem 2rem; font-size: .8rem; color: var(--gray-600);
    border-bottom: 1px solid var(--gray-50); }
.masse .code, .subrow .code { color: var(--gray-400); font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .74rem; min-width: 44px; flex: none; }
.masse .lb, .subrow .lb, .totrow .lb { flex: 1; min-width: 0; }
.masse .mt, .subrow .mt { font-variant-numeric: tabular-nums; min-width: 96px;
    text-align: right; flex: none; }
.masse .mt { color: var(--gray-900); } .subrow .mt { color: var(--gray-700); }
.masse .n1, .subrow .n1, .colhead .n1, .totrow .n1 { font-variant-numeric: tabular-nums;
    color: var(--gray-400); min-width: 88px; text-align: right; flex: none; }
/* Colonnes Brut / Amort-Prov de l'actif — version DÉVELOPPÉE uniquement */
.masse .bt, .subrow .bt, .colhead .bt { font-variant-numeric: tabular-nums;
    color: var(--gray-500); min-width: 88px; text-align: right; flex: none; font-size: .76rem; }
.totrow { display: flex; gap: .5rem; align-items: center; padding: .65rem 1.1rem;
    font-weight: 700; background: var(--brand-primary-bg); color: var(--brand-primary-dark);
    border-top: 1px solid #cfe6da; margin-top: auto; }
.totrow .mt { font-variant-numeric: tabular-nums; min-width: 96px; text-align: right; flex: none; }
.totrow .n1 { color: var(--brand-primary); font-weight: 600; }
.colhead { display: flex; gap: .5rem; padding: .4rem 1.1rem; font-size: .68rem;
    text-transform: uppercase; letter-spacing: .04em; color: var(--gray-400);
    border-bottom: 1px solid var(--gray-100); }
.colhead .lb { flex: 1; min-width: 0; }
.colhead .mt { min-width: 96px; text-align: right; flex: none; }
@media (max-width: 820px) {
    .bilan-grid { grid-template-columns: 1fr; }
    .bilan-grid > .bcol:first-child { border-right: 0; border-bottom: 1px solid var(--gray-100); }
}

/* Ratios prudentiels — carte verdict (maquette #1095, refondue #1415)
 *
 * UN seul gabarit, partagé par Reporting → Ratios et États Financiers → Ratios : les deux
 * pages affichaient la même donnée dans deux cartes différentes. `--accent` porte la
 * couleur du verdict, posée par l'appelant.
 *
 * La régularité de la grille tient à trois réservations, pas à une hauteur figée :
 * en-tête de hauteur fixe (le nom tient sur deux lignes sans décaler la valeur), ligne
 * d'écart présente même vide, et courbe poussée en bas par `margin-top: auto`. Les cartes
 * d'une même rangée s'égalisent alors d'elles-mêmes, note de péremption comprise.
 */
.ratios { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: .75rem; padding: 1.1rem 1.25rem; }

/* Vignette générique valeur/verdict — sert AUSSI les tranches de crédits en souffrance
   (ANNEXE 4.6), pas seulement les ratios : elle survit donc à la refonte #1415. */
.ratio { border: 1px solid var(--gray-200); border-radius: var(--radius-sm);
    padding: .75rem .875rem; position: relative; background: var(--white); }
.ratio.ok { border-left: 4px solid var(--brand-primary); }
.ratio.ko { border-left: 4px solid var(--status-danger-fg); }
.ratio.warn { border-left: 4px solid var(--brand-secondary-dark); }
.ratio .rn { font-size: .78rem; color: var(--gray-600); font-weight: 600; }
.ratio .rv { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums;
    margin-top: .15rem; line-height: 1.1; }
.ratio .rmeta { display: flex; justify-content: space-between; align-items: center;
    margin-top: .35rem; font-size: .72rem; color: var(--gray-500); }

.ratio-card { background: var(--white); border: 1px solid var(--gray-200);
    border-left: 4px solid var(--accent, var(--gray-300)); border-radius: var(--radius);
    padding: .75rem .875rem 0; display: flex; flex-direction: column;
    min-height: 15.5rem; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
/* Sans courbe (États Financiers) la carte n'a pas à réserver la place d'une vignette. */
.ratio-card.rc-plat { min-height: 0; padding-bottom: .75rem; }
.ratio-card.rc-absent { background: var(--gray-50); }
.rc-head { display: flex; justify-content: space-between; align-items: flex-start;
    gap: .5rem; min-height: 2.4rem; }
.rc-id { display: flex; align-items: flex-start; gap: .375rem; min-width: 0; flex: 1; }
.rc-code { font-size: .68rem; font-weight: 700; color: var(--accent); line-height: 1.5;
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    border-radius: var(--radius-xs); padding: 0 .3rem; flex-shrink: 0; letter-spacing: .02em; }
.rc-code.rc-code-off { color: var(--gray-400); background: var(--gray-100); }
/* Deux lignes autorisées, jamais trois — et jamais de troncature en « … » : le nom
   complet d'un ratio est ce qui l'identifie pour un inspecteur. */
.rc-nom { font-size: .8rem; font-weight: 600; color: var(--gray-800); line-height: 1.25;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* Le badge ne se coupe jamais : « Non conforme » sur deux lignes déformait l'en-tête. */
.rc-badge { flex-shrink: 0; white-space: nowrap; font-size: .68rem; padding: .15rem .45rem; }
.rc-val { display: flex; align-items: baseline; gap: .4rem; flex-wrap: wrap; margin-top: .125rem; }
.rc-chiffre { font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.rc-norme { font-size: .73rem; color: var(--gray-400); white-space: nowrap; }
.rc-ecart { font-size: .71rem; font-weight: 600; margin-top: .125rem;
    font-variant-numeric: tabular-nums; min-height: 1rem;
    display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.rc-stale { font-size: .7rem; color: var(--brand-secondary-dark); margin-top: .5rem; line-height: 1.35;
    background: color-mix(in srgb, var(--brand-secondary) 12%, transparent);
    border-radius: var(--radius-xs); padding: .3rem .4rem; }
.rc-spark { margin: auto -.875rem 0; padding-top: .5rem;
    border-top: 1px solid var(--gray-100); min-height: 96px; }
.rc-spark-vide { font-size: .71rem; color: var(--gray-400); text-align: center;
    padding: 2rem .5rem; line-height: 1.5; }
.rc-spark-vide span { font-size: .67rem; color: var(--gray-300); }
/* Jauge valeur/norme (#987) — le trait or EST la norme. Une barre sans repère ne dit
   rien : remplie à fond, on ignore si le seuil est atteint ou dépassé de moitié. */
.rc-jauge { position: relative; height: 8px; margin-top: .55rem;
    background: var(--gray-100); border-radius: 999px; }
.rc-jauge > i { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 999px; }
.rc-jauge > b { position: absolute; top: -3px; bottom: -3px; width: 2.5px;
    border-radius: 2px; background: var(--brand-secondary-dark); }
/* Hors échelle (#1470) : la barre sature au triple de la norme. Sans ce chevron, une barre
   pleine se lit comme un maximum atteint alors que la valeur le dépasse largement. */
.rc-jauge > u { position: absolute; right: -.5rem; top: 50%; transform: translateY(-50%);
    font-size: .8rem; text-decoration: none; line-height: 1; font-style: normal; }
/* La barre saturée se termine en biseau : sans lui, un remplissage à 100 % se lit comme un
   maximum atteint, alors que la valeur le dépasse — c'est ce que montrait R7 à 2 396 %. */
.rc-jauge.rc-sature > i { border-top-right-radius: 0; border-bottom-right-radius: 0;
    clip-path: polygon(0 0, calc(100% - 5px) 0, 100% 50%, calc(100% - 5px) 100%, 0 100%); }
/* L'assiette (#1470) — ce que le ratio rapporte à quoi. Présente sur TOUTES les cartes :
   n'apparaître que sur les cas douteux la ferait lire comme une alerte.
   Deux lignes courtes, sous un filet : c'est une note de bas de carte, jamais un titre —
   le chiffre du ratio doit rester ce qu'on voit en premier. */
.rc-assiette { display: flex; flex-direction: column; gap: .05rem; margin-top: .5rem;
    padding-top: .4rem; border-top: 1px solid var(--gray-100); }
.rc-assiette-nom { font-size: .68rem; color: var(--gray-500); line-height: 1.3;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rc-assiette-chiffres { font-size: .68rem; color: var(--gray-400);
    font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: .35rem;
    flex-wrap: wrap; }
/* Poussé à DROITE de la ligne d'écart : collé au texte, il se lisait comme sa suite
   (« 158 fois la norme assiette marginale »). Séparé, on distingue l'écart de ce qui
   en qualifie la lecture. */
.rc-assiette-flag { margin-left: auto; background: var(--status-warning-bg);
    color: var(--status-warning-fg); border-radius: var(--radius-xs); padding: 0 .3rem;
    font-weight: 700; font-size: .63rem; white-space: nowrap; }
.rc-pied { display: flex; justify-content: space-between; gap: .5rem; margin-top: .4rem;
    font-size: .7rem; color: var(--gray-500); font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 999px; background: var(--gray-100); margin-top: .5rem; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; }

/* SIG — cartes de soldes (maquette, intégrées au compte de résultat) */
.sig { padding: 1rem 1.25rem; display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; }
.sig .s { background: var(--gray-50); border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm); padding: .6rem .75rem; }
.sig .s .l { font-size: .72rem; color: var(--gray-500); }
.sig .s .v { font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: .1rem; }

/* =============================================================================
   COMPTABILITÉ — rendu maquette (#1064) : grand livre (en-tête compte + totaux),
   livre-journal, plan comptable en arborescence repliable, exercices & périodes.
   Classes partagées avec États Financiers (.tbl-wrap, .piece).
   ============================================================================= */
.tbl-wrap { overflow-x: auto; }
.piece { color: var(--brand-primary); text-decoration: none; font-weight: 600; }
.piece:hover { text-decoration: underline; }
.glhead { display: flex; gap: .75rem; align-items: center; padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-100); flex-wrap: wrap; }
.glhead .spacer, .editions .spacer { flex: 1; }
/* Titre + contexte de l'état EMPILÉS : la ligne de filtres reste alors entière à
   droite au lieu d'être repoussée par un sous-titre qui la coupe en deux. */
.glhead-title { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.glhead-filters { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
@media (max-width: 900px) {
    /* Sous 900px les filtres passent sous le titre et occupent toute la largeur —
       une barre d'outils qui déborde horizontalement est inutilisable au doigt. */
    .glhead-filters { width: 100%; }
    .glhead .spacer { display: none; }
}
.acctchip { display: flex; align-items: center; gap: .6rem; background: var(--brand-primary-bg);
    border: 1px solid #cfe6da; border-radius: var(--radius-sm); padding: .45rem .75rem; }
.acctchip code { background: var(--white); }
.datein { border: 1px solid var(--gray-300); border-radius: var(--radius-sm);
    padding: .4rem .6rem; font-size: .8rem; color: var(--gray-500); background: var(--white); }
.totline { display: flex; gap: .5rem; padding: .75rem 1.25rem;
    border-bottom: 1px solid var(--gray-100); flex-wrap: wrap; }
.tot { background: var(--gray-50); border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm); padding: .35rem .7rem; font-size: .8rem; color: var(--gray-600); }
.tot b { font-variant-numeric: tabular-nums; color: var(--gray-900); }
.tot.hi { background: var(--brand-primary-bg); border-color: #cfe6da; }
.tot.hi b { color: var(--brand-primary); }
.editions { display: flex; gap: .6rem; align-items: center; padding: .7rem 1.25rem;
    background: var(--brand-primary-bg); border-bottom: 1px solid #cfe6da; flex-wrap: wrap;
    font-size: .8rem; color: var(--brand-primary-dark); }
.editions .lbl { font-weight: 600; }
/* Plan comptable — arborescence repliable classe → agrégats → feuilles */
.cls-row { display: flex; gap: .5rem; align-items: center; padding: .55rem .75rem;
    background: var(--gray-50); border-bottom: 1px solid var(--gray-200);
    font-weight: 600; cursor: pointer; font-size: .875rem; }
.cls-row:focus-visible, .acct-row:focus-visible { outline: 2px solid var(--brand-action); outline-offset: -2px; }
.cls-row .cnt { margin-left: auto; color: var(--gray-400); font-size: .82rem;
    font-weight: 400; font-variant-numeric: tabular-nums; }
.acct-row { display: flex; gap: .6rem; align-items: center; padding: .34rem .75rem;
    border-bottom: 1px solid var(--gray-50); font-size: .85rem; }
.acct-row:hover { background: var(--gray-50); }
.acct-row code { min-width: 82px; }
.acct-row .end { margin-left: auto; display: flex; gap: .5rem; align-items: center; }
.acct-row .sold { font-variant-numeric: tabular-nums; min-width: 110px; text-align: right;
    font-size: .8rem; color: var(--gray-700); }
.chev { color: var(--gray-400); width: 12px; display: inline-block; flex: none; font-style: normal; }
/* Exercices & périodes — grille des 12 mois */
.fy { padding: 1.25rem; }
.months { display: grid; grid-template-columns: repeat(12, 1fr); gap: .4rem; }
.m { border-radius: var(--radius-xs); padding: .5rem .2rem .4rem; text-align: center;
    font-size: .7rem; border: 1px solid var(--gray-200); background: var(--white); color: var(--gray-700); }
.m .s { display: block; font-size: .62rem; margin-top: .25rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .4px; }
.m.closed { background: var(--status-neutral-bg); color: var(--gray-500); }
.m.prov { background: var(--status-warning-bg); border-color: #f2dfa0; }
.m.cur { background: var(--brand-primary-bg); border-color: var(--brand-primary-lighter); }
.m.next { color: var(--gray-400); }
.fy .legend { display: flex; gap: 1rem; margin-top: .75rem; font-size: .75rem;
    color: var(--gray-500); flex-wrap: wrap; }
.fy .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px;
    margin-right: .3rem; vertical-align: -1px; font-style: normal; }
@media (max-width: 900px) { .months { grid-template-columns: repeat(6, 1fr); } }
@media (max-width: 560px) { .months { grid-template-columns: repeat(4, 1fr); } }
.acct-row .sold.neg { color: var(--red); font-weight: 600; }
/* Mobile : la colonne développée (Brut/Amort/Net/N-1) dépasse 500px de large —
   elle défile DANS sa colonne, jamais au niveau du document (review #1396, #1095). */
@media (max-width: 600px) {
    .bcol { overflow-x: auto; }
    .bcol > .masse, .bcol > .subrow, .bcol > .colhead, .bcol > .totrow { min-width: 540px; }
}
.colhead .code { min-width: 44px; flex: none; }
