/* =================================================================
   SFE — Feuille de style de l'interface
   Direction : outil de travail, pas vitrine. Papier chaud, encre
   noire, un seul accent « latérite ». Les montants et références sont
   en Plex Mono à chiffres tabulaires, comme sur un ticket MCF.
   La facture imprimable (section plus bas) reste strictement N/B.
   ================================================================= */

:root {
    --sidebar-largeur: 256px;

    /* Encre & papier */
    --encre: #17181B;
    --encre-2: #2B2D33;
    --papier: #F4F2ED;
    --papier-2: #ECE9E2;
    --feuille: #FFFFFF;
    --trait: #E3DFD6;
    --trait-fort: #CFCAC0;
    --gris: #6C6E75;
    --gris-clair: #9A9BA0;

    /* Accent unique (changer ces 4 lignes pour changer la couleur de l'appli) */
    --accent: #C2461C;
    --accent-fonce: #9E3814;
    --accent-pale: #FBEAE2;
    --accent-vif: #F08A5D;   /* version claire pour fond sombre (page de connexion) */

    --vert: #24704F;
    --vert-pale: #E3F1EA;
    --rouge: #B3261E;
    --rouge-pale: #FBE8E6;
    --ocre: #8A5F1E;
    --ocre-pale: #F7EEDC;

    /* Anciennes variables conservées (utilisées dans des styles en ligne
       des pages et dans la facture imprimable) */
    --couleur-primaire: var(--encre);
    --couleur-primaire-fonce: var(--encre);
    --couleur-primaire-clair: var(--papier-2);
    --couleur-accent: var(--accent);
    --couleur-accent-clair: var(--accent-pale);
    --couleur-fond: var(--papier);
    --couleur-carte: var(--feuille);
    --couleur-texte: var(--encre);
    --couleur-texte-clair: var(--gris);
    --couleur-bordure: var(--trait);
    --couleur-danger: var(--rouge);
    --couleur-succes: var(--vert);

    --police-corps: "IBM Plex Sans", "Segoe UI", -apple-system, Roboto, Arial, sans-serif;
    --police-titres: var(--police-corps);
    --police-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

    --police-chiffres: var(--police-mono);

    /* Boutons principaux */
    --btn-fond: var(--encre);
    --btn-survol: #000;
    --btn-texte: #fff;

    /* Fond du panneau de connexion */
    --login-fond: #17181B;

    --rayon: 10px;
    --rayon-sm: 7px;
    --ombre-1: 0 1px 0 rgba(23,24,27,0.04), 0 1px 2px rgba(23,24,27,0.05);
    --ombre-2: 0 1px 0 rgba(23,24,27,0.04), 0 6px 18px -6px rgba(23,24,27,0.14);
    --ombre-3: 0 24px 60px -18px rgba(23,24,27,0.35), 0 2px 6px rgba(23,24,27,0.08);

    --ease: cubic-bezier(.2, .7, .2, 1);
    --ease-ressort: cubic-bezier(.34, 1.4, .64, 1);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    font-family: var(--police-corps);
    background: var(--papier);
    color: var(--encre);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

::selection { background: var(--accent); color: #fff; }

a { color: var(--encre); text-decoration: none; }

/* Liens de contenu : soulignement qui se dessine au survol */
.container a:not(.btn):not(.article-card) {
    color: var(--accent-fonce);
    font-weight: 500;
    background-image: linear-gradient(currentColor, currentColor);
    background-size: 0% 1px;
    background-position: 0 100%;
    background-repeat: no-repeat;
    transition: background-size .25s var(--ease), color .15s;
}
.container a:not(.btn):not(.article-card):hover { background-size: 100% 1px; }

.ico { flex-shrink: 0; display: block; }

/* ---------------------------------------------------------------
   Transitions entre pages (navigateurs récents : Chrome/Edge 126+).
   Le menu reste fixe, seul le contenu change ; l'indicateur actif
   glisse d'un lien à l'autre.
   --------------------------------------------------------------- */
@view-transition { navigation: auto; }
::view-transition-old(root),
::view-transition-new(root) { animation-duration: .18s; }
.sidebar { view-transition-name: sidebar; }
.nav-indicateur { view-transition-name: nav-indicateur; }
::view-transition-group(nav-indicateur) { animation-duration: .38s; animation-timing-function: var(--ease); }

/* ---------------------------------------------------------------
   Structure générale : menu latéral + zone de contenu
   --------------------------------------------------------------- */
.app-shell {
    display: flex;
    min-height: 100vh;
    align-items: stretch;
}

.sidebar {
    width: var(--sidebar-largeur);
    flex-shrink: 0;
    background: var(--sb-fond, var(--papier-2));
    border-right: 1px solid var(--sb-bord, var(--trait));
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 50;
}

.sidebar-brand {
    padding: 18px 16px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sidebar-brand > a {
    display: flex;
    align-items: center;
    gap: 11px;
    color: var(--sb-texte-fort, var(--encre));
}
.marque-monogramme {
    width: 38px;
    height: 38px;
    border-radius: 9px;
    background: var(--marque-fond, var(--encre));
    color: var(--marque-texte, #fff);
    display: grid;
    place-items: center;
    font-family: var(--police-mono);
    font-weight: 600;
    font-size: 0.92rem;
    letter-spacing: 0.02em;
    position: relative;
    overflow: hidden;
    transition: transform .3s var(--ease-ressort);
}
/* petite bande latérite façon ticket */
.marque-monogramme::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 4px;
    background: var(--accent);
}
.sidebar-brand > a:hover .marque-monogramme { transform: rotate(-6deg) scale(1.05); }
.marque-texte { display: flex; flex-direction: column; line-height: 1.2; }
.marque-texte strong { font-size: 0.98rem; font-weight: 700; letter-spacing: -0.01em; }
.marque-texte small { font-size: 0.7rem; color: var(--sb-texte-doux, var(--gris)); font-family: var(--police-mono); letter-spacing: 0.01em; }

.sidebar-fermer { display: none; }

.sidebar-nav {
    flex: 1;
    padding: 6px 10px 12px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--trait-fort) transparent;
}
.sidebar-nav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    margin: 1px 0;
    color: var(--sb-texte, var(--encre-2));
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--rayon-sm);
    transition: background-color .15s, color .15s;
}
.sidebar-nav a .ico { color: var(--sb-ico, var(--gris)); transition: color .15s, transform .25s var(--ease-ressort); }
.sidebar-nav a:hover { background: var(--sb-survol, rgba(23,24,27,0.05)); color: var(--sb-texte-fort, var(--encre)); }
.sidebar-nav a:hover .ico { color: var(--sb-texte-fort, var(--encre)); transform: translateX(2px); }
.sidebar-nav a.active {
    background: var(--sb-actif-fond, var(--feuille));
    color: var(--sb-actif-texte, var(--encre));
    font-weight: 600;
    box-shadow: var(--sb-actif-ombre, var(--ombre-1), inset 0 0 0 1px var(--trait));
}
.sidebar-nav a.active .ico { color: var(--accent); }
.nav-indicateur {
    position: absolute;
    left: -10px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--accent);
}
.nav-badge {
    margin-left: auto;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--rouge);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    font-style: normal;
    display: inline-grid;
    place-items: center;
    animation: pastille .5s var(--ease-ressort) both;
}
.sidebar-separator {
    margin-top: 14px;
    padding: 6px 10px 4px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sb-sep, var(--gris-clair));
}

.sidebar-user {
    margin: 0 10px 12px;
    padding: 10px;
    border-radius: var(--rayon);
    background: var(--sb-user-fond, var(--feuille));
    border: 1px solid var(--sb-user-bord, var(--trait));
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
}
.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--accent-pale);
    color: var(--accent-fonce);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.78rem;
    flex-shrink: 0;
}
.sidebar-user-infos { min-width: 0; }
.sidebar-user-name { color: var(--sb-texte-fort, var(--encre)); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-logout {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--sb-texte-doux, var(--gris));
    font-size: 0.78rem;
    transition: color .15s;
}
.sidebar-logout .ico { width: 14px; height: 14px; }
.sidebar-logout:hover { color: var(--rouge); }

.sidebar-voile { display: none; }

.main-wrapper {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* Barre du haut */
.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 14px;
    height: 54px;
    padding: 0 26px;
    background: color-mix(in srgb, var(--papier) 86%, transparent);
    backdrop-filter: saturate(1.4) blur(8px);
    -webkit-backdrop-filter: saturate(1.4) blur(8px);
    border-bottom: 1px solid transparent;
    transition: border-color .2s, box-shadow .2s;
}
body.defile .topbar { border-bottom-color: var(--trait); box-shadow: 0 6px 16px -14px rgba(23,24,27,0.5); }
.topbar-menu {
    display: none;
    background: none;
    border: 1px solid var(--trait);
    border-radius: var(--rayon-sm);
    padding: 7px;
    cursor: pointer;
    color: var(--encre);
}
.topbar-titre {
    font-size: 0.85rem;
    color: var(--gris);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity .2s, transform .2s var(--ease);
}
body.defile .topbar-titre { opacity: 1; transform: none; }
.topbar-horloge {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--police-mono);
    font-size: 0.8rem;
    color: var(--gris);
    background: var(--feuille);
    border: 1px solid var(--trait);
    border-radius: 999px;
    padding: 5px 12px 5px 10px;
    white-space: nowrap;
}
.horloge-heure { color: var(--encre); font-weight: 500; font-variant-numeric: tabular-nums; }
.horloge-point {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--vert);
    box-shadow: 0 0 0 0 rgba(36,112,79,0.5);
    animation: pulsation 2s infinite;
}
@keyframes pulsation {
    0%   { box-shadow: 0 0 0 0 rgba(36,112,79,0.45); }
    70%  { box-shadow: 0 0 0 7px rgba(36,112,79,0); }
    100% { box-shadow: 0 0 0 0 rgba(36,112,79,0); }
}

.container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 18px 26px 40px;
    flex: 1;
}
body.sans-menu .container { padding-top: 34px; }

/* Apparition en cascade des blocs de la page (l'indice --i est posé par ui.js).
   fill-mode « backwards » : aucune transformation ne reste après l'animation,
   donc les popups en position:fixed à l'intérieur ne sont pas affectés. */
@keyframes monter {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}
.container > * {
    animation: monter .55s var(--ease) backwards;
    animation-delay: calc(var(--i, 0) * 55ms);
}
.container > .modal-overlay,
.container > .popup-alerte-overlay,
.container > script,
.container > style { animation: none; }

/* Lignes de tableau : léger glissement à l'arrivée */
@keyframes ligne-entree {
    from { opacity: 0; transform: translateX(-6px); }
    to   { opacity: 1; transform: none; }
}
tr.ligne-anim { animation: ligne-entree .4s var(--ease) backwards; animation-delay: calc(120ms + var(--r, 0) * 28ms); }

@media (max-width: 960px) {
    .sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        height: 100%;
        transform: translateX(-104%);
        transition: transform .32s var(--ease);
        box-shadow: var(--ombre-3);
        view-transition-name: none;
    }
    body.menu-ouvert .sidebar { transform: none; }
    .sidebar-fermer {
        display: grid;
        place-items: center;
        background: none;
        border: 1px solid var(--trait);
        border-radius: var(--rayon-sm);
        padding: 6px;
        cursor: pointer;
        color: var(--encre);
    }
    .sidebar-voile {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 45;
        background: rgba(23,24,27,0.4);
        opacity: 0;
        pointer-events: none;
        transition: opacity .3s;
    }
    body.menu-ouvert .sidebar-voile { opacity: 1; pointer-events: auto; }
    .topbar { padding: 0 14px; }
    .topbar-menu { display: grid; place-items: center; }
    .topbar-titre { opacity: 1; transform: none; color: var(--encre); font-weight: 600; }
    .container { padding: 14px 14px 30px; }
}
@media (max-width: 560px) {
    [data-horloge-date] { display: none; }
}

/* ---------------------------------------------------------------
   État du MCF (barre du haut, à côté de l'horloge)
   --------------------------------------------------------------- */
.mcf-etat { position: relative; }
.mcf-etat { --mcf: var(--gris-clair); --mcf-pale: var(--papier-2); }
.mcf-etat.niveau-ok      { --mcf: var(--vert);  --mcf-pale: var(--vert-pale); }
.mcf-etat.niveau-simule  { --mcf: var(--ocre);  --mcf-pale: var(--ocre-pale); }
.mcf-etat.niveau-alerte  { --mcf: var(--rouge); --mcf-pale: var(--rouge-pale); }
.mcf-etat.niveau-erreur  { --mcf: var(--rouge); --mcf-pale: var(--rouge-pale); }
.mcf-bouton {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 32px;
    padding: 0 12px 0 10px;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--mcf) 35%, var(--trait));
    background: var(--mcf-pale);
    color: var(--mcf);
    font: 600 0.78rem var(--police-corps);
    white-space: nowrap;
    cursor: pointer;
    transition: box-shadow .2s, transform .15s var(--ease);
}
.mcf-bouton:hover { box-shadow: var(--ombre-1); transform: translateY(-1px); }
.mcf-voyant {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--mcf);
    flex-shrink: 0;
}
.niveau-ok .mcf-voyant { animation: mcf-pouls 2s infinite; }
.niveau-erreur .mcf-voyant, .niveau-alerte .mcf-voyant { animation: mcf-clignote 1.1s steps(2, jump-none) infinite; }
@keyframes mcf-pouls {
    0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--mcf) 55%, transparent); }
    70%  { box-shadow: 0 0 0 7px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}
@keyframes mcf-clignote { 50% { opacity: .25; } }
.mcf-panneau {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 310px;
    padding: 14px 16px 16px;
    background: var(--feuille);
    border: 1px solid var(--trait);
    border-top: 3px solid var(--mcf);
    border-radius: 12px;
    box-shadow: var(--ombre-3);
    z-index: 60;
    opacity: 0;
    transform: translateY(-6px) scale(.98);
    transform-origin: top right;
    pointer-events: none;
    transition: opacity .18s, transform .22s var(--ease);
}
.mcf-etat.ouvert .mcf-panneau { opacity: 1; transform: none; pointer-events: auto; }
.mcf-panneau-entete { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; color: var(--mcf); }
.mcf-panneau-entete strong { font-size: 0.92rem; }
.mcf-panneau dl { margin: 0 0 10px; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 0.8rem; }
.mcf-panneau dt { color: var(--gris); }
.mcf-panneau dd { margin: 0; color: var(--encre); font-weight: 500; text-align: right; overflow-wrap: anywhere; }
.mcf-sep { width: 1px; height: 14px; background: currentColor; opacity: .3; }
.mcf-dgi { display: inline-flex; align-items: center; gap: 4px; font-weight: 500; opacity: .9; }
.mcf-dgi.en-retard { color: var(--rouge); opacity: 1; font-weight: 600; }
.mcf-section {
    margin: 4px 0 8px;
    padding-top: 10px;
    border-top: 1px dashed var(--trait-fort);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--gris);
}
.mcf-section.en-retard { color: var(--rouge); }
.mcf-note-alerte { color: var(--rouge); font-weight: 500; }
.mcf-note { font-size: 0.75rem; color: var(--gris); margin: 0 0 12px; line-height: 1.45; }
.mcf-panneau .btn { width: 100%; justify-content: center; }
.mcf-synchro.en-cours { pointer-events: none; opacity: .85; }
.mcf-synchro.en-cours .ico { animation: mcf-tourne 0.9s linear infinite; }
@keyframes mcf-tourne { to { transform: rotate(360deg); } }
[data-dgi-champ].maj { animation: mcf-maj 1.2s ease; }
@keyframes mcf-maj { 0% { background: var(--accent-pale); } 100% { background: transparent; } }
@media (max-width: 1100px) {
    .mcf-dgi, .mcf-sep { display: none; }
}
@media (max-width: 760px) {
    .mcf-libelle, .mcf-sep { display: none; }
    .mcf-bouton { padding: 0 11px; }
    .mcf-panneau { right: -80px; width: min(310px, calc(100vw - 28px)); }
}

/* ---------------------------------------------------------------
   Fenêtres modales (sélection d'article, client…)
   --------------------------------------------------------------- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(23, 24, 27, 0.42);
    backdrop-filter: blur(2px);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}
.modal-overlay.ouvert { display: flex; animation: fondu .2s ease both; }
@keyframes fondu { from { opacity: 0; } to { opacity: 1; } }
@keyframes surgir {
    from { opacity: 0; transform: translateY(14px) scale(.97); }
    to   { opacity: 1; transform: none; }
}
.modal-box {
    background: var(--feuille);
    border-radius: 14px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    box-shadow: var(--ombre-3);
}
.modal-overlay.ouvert .modal-box { animation: surgir .32s var(--ease-ressort) both; }
.modal-box h3 { margin-top: 0; }
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
    border-top: 1px solid var(--trait);
    padding-top: 16px;
}
.modal-article-info {
    background: var(--papier);
    border: 1px dashed var(--trait-fort);
    border-radius: var(--rayon-sm);
    padding: 8px 12px;
    font-size: 0.85rem;
    margin-bottom: 14px;
    min-height: 20px;
}
.lignes-table td.article-cell { max-width: 220px; }
.lignes-table .ligne-vide { text-align: center; color: var(--gris); padding: 22px; font-style: italic; }

.modal-box-large { max-width: 640px; }

.article-cards-recherche { margin-bottom: 12px; }

.article-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    max-height: 360px;
    overflow-y: auto;
    padding: 4px 2px;
    margin-bottom: 6px;
}
.article-card {
    border: 1px solid var(--trait);
    border-radius: var(--rayon-sm);
    padding: 11px;
    cursor: pointer;
    background: var(--feuille);
    text-align: left;
    transition: border-color .15s, box-shadow .2s, transform .2s var(--ease);
    animation: monter .35s var(--ease) backwards;
}
.article-card:hover { border-color: var(--accent); box-shadow: var(--ombre-2); transform: translateY(-2px); }
.article-card:active { transform: translateY(0) scale(.98); }
.article-card.selectionnee { border-color: var(--accent); background: var(--accent-pale); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); }
.article-card .nom { font-weight: 600; font-size: 0.88rem; margin-bottom: 4px; display: block; }
.article-card .code { font-size: 0.72rem; color: var(--gris); display: block; margin-bottom: 6px; font-family: var(--police-mono); }
.article-card .prix { font-size: 0.82rem; font-weight: 600; color: var(--encre); font-family: var(--police-mono); }
.article-card .stock-info { font-size: 0.7rem; color: var(--gris); margin-top: 2px; }
.article-cards-vide { grid-column: 1 / -1; text-align: center; color: var(--gris); padding: 20px; }

.modal-retour-selection { margin-bottom: 14px; }

/* ---------------------------------------------------------------
   Popup d'alerte global (messages flash, validation, confirmation)
   --------------------------------------------------------------- */
.popup-alerte-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(23, 24, 27, 0.42);
    backdrop-filter: blur(2px);
    z-index: 2000;
}
.popup-alerte-overlay.ouvert { display: block; animation: fondu .18s ease both; }
.popup-alerte-overlay.fermeture { animation: fondu .16s ease reverse both; }
@keyframes popup-entree {
    from { opacity: 0; transform: translate(-50%, -46%) scale(.94); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.popup-alerte-box {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    background: var(--feuille);
    border-radius: 14px;
    width: calc(100% - 32px);
    max-width: 400px;
    box-sizing: border-box;
    padding: 26px 24px 20px;
    box-shadow: var(--ombre-3);
    text-align: center;
}
.popup-alerte-overlay.ouvert .popup-alerte-box { animation: popup-entree .34s var(--ease-ressort) both; }
.popup-alerte-overlay.fermeture .popup-alerte-box { animation: popup-entree .16s ease reverse both; }

/* Pastille d'icône au-dessus du titre (dessinée en CSS) */
.popup-alerte-box::before {
    content: "i";
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    margin: 0 auto 14px;
    border-radius: 50%;
    font-family: var(--police-mono);
    font-weight: 600;
    font-size: 1.2rem;
    background: var(--ocre-pale);
    color: var(--ocre);
    animation: pastille .5s .08s var(--ease-ressort) both;
}
@keyframes pastille { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
.popup-alerte-box.type-error::before   { content: "!"; background: var(--rouge-pale); color: var(--rouge); }
.popup-alerte-box.type-success::before { content: "✓"; background: var(--vert-pale); color: var(--vert); }
.popup-alerte-box.type-info::before    { content: "?"; }

.popup-alerte-titre {
    text-align: center;
    font-weight: 700;
    font-size: 1.05rem;
    margin: 0 0 6px;
    color: var(--encre);
    letter-spacing: -0.01em;
}
.popup-alerte-message {
    white-space: pre-line;
    text-align: center;
    font-size: 0.92rem;
    color: var(--encre-2);
    margin: 0 0 20px;
    line-height: 1.55;
}
.popup-alerte-actions { display: flex; justify-content: center; align-items: center; gap: 10px; }
.popup-alerte-actions .btn { min-width: 110px; text-align: center; justify-content: center; }

/* ---------------------------------------------------------------
   Composants communs
   --------------------------------------------------------------- */
.card {
    background: var(--feuille);
    border: 1px solid var(--trait);
    border-radius: var(--rayon);
    padding: 22px;
    margin-bottom: 18px;
    box-shadow: var(--ombre-1);
    overflow-x: auto;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }

/* Ligne « titre + bouton » en haut des pages de liste */
.container > div:has(> h1.mb-0) { margin: 6px 0 18px; }
.container > div:has(> h1.mb-0) > h1 { margin: 0; }

h1, h2, h3, h4 { font-family: var(--police-titres); color: var(--encre); font-weight: 600; letter-spacing: -0.015em; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.025em; margin: 6px 0 18px; line-height: 1.2; }
h2 { font-size: 1.12rem; }
h3 { font-size: 0.98rem; }

table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--feuille); }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--trait); text-align: left; font-size: 0.88rem; }
th {
    background: transparent;
    color: var(--gris);
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    white-space: nowrap;
    border-bottom: 1px solid var(--trait-fort);
}
tbody tr { transition: background-color .12s; }
tbody tr:hover { background: var(--papier); }
tbody tr:last-child td { border-bottom: none; }
td.text-right, .montant { font-family: var(--police-chiffres); font-variant-numeric: tabular-nums; font-size: 0.85rem; }
td.text-right, td.ref { white-space: nowrap; }

.form-group { margin-bottom: 14px; }
label, .form-label { display: block; font-weight: 500; margin-bottom: 5px; font-size: 0.83rem; color: var(--encre-2); }
input, select, textarea, .form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--trait-fort);
    border-radius: var(--rayon-sm);
    font-size: 0.93rem;
    font-family: var(--police-corps);
    background: var(--feuille);
    color: var(--encre);
    transition: border-color .15s, box-shadow .2s, background-color .15s;
}
input:hover, select:hover, textarea:hover { border-color: var(--gris-clair); }
input:focus, select:focus, textarea:focus, .form-control:focus {
    outline: none;
    border-color: var(--focus, var(--encre));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus, var(--encre)) 14%, transparent);
}
input[readonly] { background: var(--papier); }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); }
select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236C6E75' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}
textarea { resize: vertical; }
input.champ-erreur, select.champ-erreur, textarea.champ-erreur {
    border-color: var(--rouge);
    box-shadow: 0 0 0 3px rgba(179,38,30,0.12);
    animation: secouer .38s;
}
@keyframes secouer {
    20%, 60% { transform: translateX(-4px); }
    40%, 80% { transform: translateX(4px); }
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: var(--btn-fond);
    color: var(--btn-texte);
    border: 1px solid var(--btn-fond);
    padding: 8px 16px;
    border-radius: var(--rayon-sm);
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: var(--police-corps);
    line-height: 1.4;
    vertical-align: middle;
    position: relative;
    overflow: hidden;
    transition: background-color .15s, transform .15s var(--ease), box-shadow .2s, border-color .15s;
    box-shadow: 0 1px 0 rgba(255,255,255,0.12) inset, 0 1px 2px rgba(23,24,27,0.2);
}
.btn:hover { background: var(--btn-survol); text-decoration: none; transform: translateY(-1px); box-shadow: 0 6px 14px -6px rgba(23,24,27,0.5); }
.btn:active { transform: translateY(0) scale(.98); box-shadow: none; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn + .btn { margin-left: 4px; }
.btn-secondary { background: var(--feuille); color: var(--encre); border-color: var(--trait-fort); box-shadow: var(--ombre-1); }
.btn-secondary:hover { background: var(--papier); border-color: var(--gris-clair); box-shadow: var(--ombre-2); }
.btn-danger { background: var(--rouge); border-color: var(--rouge); }
.btn-danger:hover { background: #8f1d17; }
.btn-sm { padding: 4px 11px; font-size: 0.8rem; }
.btn[disabled], .btn:disabled { opacity: .5; pointer-events: none; }

/* Onde au clic (ajoutée par ui.js) */
.onde {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    background: currentColor;
    opacity: .22;
    transform: scale(0);
    animation: onde .55s ease-out forwards;
}
@keyframes onde { to { transform: scale(2.6); opacity: 0; } }

.alert {
    padding: 12px 14px 12px 40px;
    border-radius: var(--rayon-sm);
    margin-bottom: 16px;
    font-size: 0.88rem;
    border: 1px solid transparent;
    position: relative;
}
.alert::before {
    content: "";
    position: absolute;
    left: 15px;
    top: 15px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 18%, transparent);
}
.alert-success { background: var(--vert-pale); color: var(--vert); border-color: #c9e3d6; }
.alert-error, .alert-danger { background: var(--rouge-pale); color: var(--rouge); border-color: #f2cbc7; }
.alert-info { background: var(--ocre-pale); color: var(--ocre); border-color: #ecdcbc; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.row { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; }
.col-12 { grid-column: 1 / -1; }
@media (max-width: 720px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }
@media (max-width: 960px) and (min-width: 721px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px) {
    .grid-4:has(> .stat-box) { grid-template-columns: 1fr 1fr; gap: 10px; }
    .grid-4 .stat-box { padding: 14px 14px 12px; }
    .grid-4 .stat-box .valeur { font-size: 1.05rem; white-space: normal; overflow-wrap: anywhere; }
}

/* Indicateurs chiffrés */
.stat-box {
    background: var(--feuille);
    border: 1px solid var(--trait);
    border-radius: var(--rayon);
    padding: 18px 18px 16px;
    text-align: left;
    position: relative;
    overflow: hidden;
    box-shadow: var(--ombre-1);
    transition: transform .25s var(--ease), box-shadow .25s;
}
.stat-box::before {
    content: "";
    position: absolute;
    left: 18px;
    top: 0;
    width: 28px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--accent);
    transform-origin: left;
    animation: trait-grandit .7s .25s var(--ease) backwards;
}
@keyframes trait-grandit { from { transform: scaleX(0); } }
.stat-box:hover { transform: translateY(-2px); box-shadow: var(--ombre-2); }
.stat-box .valeur {
    font-family: var(--police-chiffres);
    font-size: 1.55rem;
    font-weight: 600;
    color: var(--encre);
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    line-height: 1.25;
    margin-top: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.stat-box .label { font-size: 0.8rem; color: var(--gris); margin-top: 2px; }

/* Badges de statut */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 9px 2px 8px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 600;
    text-transform: capitalize;
    background: var(--papier-2);
    color: var(--encre-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-brouillon { background: var(--papier-2); color: var(--gris); }
.badge-emise { background: var(--vert-pale); color: var(--vert); }
.badge-annulee { background: var(--rouge-pale); color: var(--rouge); }
.badge-en_attente { background: var(--ocre-pale); color: var(--ocre); text-transform: none; }
.badge-devis-brouillon { background: var(--papier-2); color: var(--gris); }
.badge-devis-envoye { background: var(--ocre-pale); color: var(--ocre); }
.badge-devis-accepte { background: var(--vert-pale); color: var(--vert); }
.badge-devis-refuse { background: var(--rouge-pale); color: var(--rouge); }
.badge-devis-converti { background: var(--accent-pale); color: var(--accent-fonce); }
.badge-en_attente::before { animation: mcf-clignote 1.1s steps(2, jump-none) infinite; }

.text-right { text-align: right; }
.text-muted { color: var(--gris); }
.small { font-size: 0.82rem; }
.mb-0 { margin-bottom: 0 !important; }
.mb-4 { margin-bottom: 1.25rem; }

.footer {
    padding: 14px 26px 22px;
    font-size: 0.76rem;
    color: var(--gris-clair);
}
.footer p {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}
.footer-sep { color: var(--trait-fort); }

/* Mini-graphique en barres (listes de factures) */
.barre-jour {
    transform-origin: bottom;
    animation: barre-pousse .7s var(--ease) backwards;
    animation-delay: calc(200ms + var(--b, 0) * 35ms);
    transition: filter .15s;
}
.barre-jour:hover { filter: brightness(.85); }
@keyframes barre-pousse { from { transform: scaleY(0); } }

/* ---------------------------------------------------------------
   Tableau de bord
   --------------------------------------------------------------- */
.page-entete {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin: 6px 0 20px;
}
.page-entete h1 { margin: 0; }
.page-entete .surtitre {
    font-family: var(--police-mono);
    font-size: 0.75rem;
    color: var(--accent-fonce);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin: 0 0 4px;
}
.page-entete .sous-titre { margin: 4px 0 0; color: var(--gris); font-size: 0.9rem; }

.raccourcis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
@media (max-width: 720px) { .raccourcis { grid-template-columns: 1fr; } }
.raccourci {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--feuille);
    border: 1px solid var(--trait);
    border-radius: var(--rayon);
    color: var(--encre) !important;
    background-image: none !important;
    box-shadow: var(--ombre-1);
    transition: transform .25s var(--ease), box-shadow .25s, border-color .2s;
}
.raccourci:hover { transform: translateY(-2px); box-shadow: var(--ombre-2); border-color: var(--trait-fort); }
.raccourci .raccourci-ico {
    width: 38px; height: 38px;
    border-radius: 9px;
    display: grid; place-items: center;
    background: var(--papier);
    color: var(--encre);
    transition: background-color .2s, color .2s, transform .3s var(--ease-ressort);
}
.raccourci:hover .raccourci-ico { background: var(--accent); color: #fff; transform: rotate(-8deg); }
.raccourci.principal .raccourci-ico { background: var(--accent); color: #fff; }
.raccourci strong { display: block; font-size: 0.92rem; font-weight: 600; }
.raccourci small { display: block; color: var(--gris); font-size: 0.78rem; font-weight: 400; }
.raccourci .fleche { margin-left: auto; color: var(--gris-clair); transition: transform .25s var(--ease), color .2s; }
.raccourci:hover .fleche { transform: translateX(4px); color: var(--encre); }

.carte-entete { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.carte-entete h2 { margin: 0; }
.ref { font-family: var(--police-mono); font-size: 0.82rem; }
.type-code {
    font-family: var(--police-mono);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 6px;
    border: 1px solid var(--trait-fort);
    border-radius: 4px;
    color: var(--encre-2);
}
.vide {
    text-align: center;
    padding: 30px 10px !important;
    color: var(--gris);
}

/* Bandeau « dernière transmission DGI » du tableau de bord */
.bandeau-dgi {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    margin-bottom: 18px;
    background: var(--feuille);
    border: 1px solid var(--trait);
    border-left: 4px solid var(--vert);
    border-radius: var(--rayon);
    box-shadow: var(--ombre-1);
    font-size: 0.88rem;
}
.bandeau-dgi.en-retard { border-left-color: var(--rouge); background: var(--rouge-pale); }
.bandeau-dgi-ico { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--vert-pale); color: var(--vert); flex-shrink: 0; }
.bandeau-dgi.en-retard .bandeau-dgi-ico { background: var(--feuille); color: var(--rouge); }
.bandeau-dgi-texte { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bandeau-dgi.en-retard .bandeau-dgi-texte [data-dgi-alerte] { color: var(--rouge); font-weight: 500; }
.bandeau-dgi [data-dgi-alerte][hidden] { display: none; }
.bandeau-dgi .btn { flex-shrink: 0; }

/* ---------------------------------------------------------------
   Connexion — « sceau fiscal »
   Un registre de références défile en fond, un sceau se pose au
   chargement, le formulaire est une feuille perforée. Suit le thème.
   --------------------------------------------------------------- */
body.page-connexion {
    min-height: 100vh;
    overflow-x: hidden;
    background:
        radial-gradient(ellipse 70% 60% at 50% 45%, var(--papier) 30%, transparent 75%),
        var(--papier-2);
}
.cx-registre {
    position: fixed;
    inset: -10% -20%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 22px;
    transform: rotate(-8deg);
    pointer-events: none;
    -webkit-mask-image: radial-gradient(ellipse 60% 55% at 50% 50%, transparent 32%, #000 70%);
            mask-image: radial-gradient(ellipse 60% 55% at 50% 50%, transparent 32%, #000 70%);
}
.cx-ligne {
    display: flex;
    width: max-content;
    font-family: var(--police-mono);
    font-size: 13px;
    letter-spacing: 0.04em;
    white-space: nowrap;
    color: var(--encre);
    opacity: .09;
    animation: cx-defile calc(140s + var(--n) * 9s) linear infinite;
    animation-direction: normal;
}
.cx-ligne:nth-child(even) { animation-direction: reverse; opacity: .065; }
.cx-ligne:nth-child(3n) { color: var(--accent); opacity: .16; }
.cx-ligne span { padding-right: 48px; }
@keyframes cx-defile { to { transform: translateX(-50%); } }

.cx-centre {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 16px 28px;
}

/* Le sceau */
.cx-sceau {
    position: relative;
    width: 128px;
    height: 128px;
    margin-bottom: -46px;
    z-index: 2;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--feuille);
    box-shadow: 0 0 0 6px var(--papier), var(--ombre-2);
    animation: cx-tampon .9s .15s cubic-bezier(.2, 1.6, .4, 1) backwards;
}
@keyframes cx-tampon {
    0%   { transform: scale(1.9) rotate(-18deg); opacity: 0; filter: blur(3px); }
    55%  { transform: scale(.94) rotate(2deg); opacity: 1; filter: none; }
    100% { transform: none; }
}
.cx-sceau-anneau {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    animation: cx-tourne 60s linear infinite;
}
.cx-sceau-anneau text {
    font-family: var(--police-mono);
    font-size: 11.2px;
    font-weight: 600;
    letter-spacing: 0.06em;
    fill: var(--accent);
}
@keyframes cx-tourne { to { transform: rotate(360deg); } }
.cx-sceau-coeur {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--marque-fond, var(--encre));
    color: var(--marque-texte, #fff);
    font-family: var(--police-mono);
    font-weight: 700;
    font-size: 1.3rem;
    letter-spacing: 0.04em;
    box-shadow: inset 0 0 0 3px var(--feuille), inset 0 0 0 4px var(--accent);
}

/* La feuille perforée */
.cx-feuille {
    position: relative;
    width: 100%;
    max-width: 400px;
    background: var(--feuille);
    border-radius: var(--rayon);
    padding: 64px 32px 0;
    box-shadow: 0 30px 60px -30px rgba(15,20,30,0.45), 0 2px 6px rgba(15,20,30,0.06);
    animation: monter .7s .05s var(--ease) backwards;
}
/* perforations du bas, façon ticket détachable */
.cx-feuille::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: -7px;
    height: 14px;
    background: radial-gradient(circle at 7px 7px, var(--papier) 5px, transparent 5.5px) 0 0 / 18px 14px repeat-x;
}
.cx-entete { text-align: center; margin-bottom: 24px; }
.cx-surtitre {
    margin: 0 0 4px;
    font-family: var(--police-mono);
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
}
.cx-entete h1 { margin: 0; font-size: 1.75rem; }
.cx-entreprise { margin: 6px 0 0; color: var(--gris); font-size: 0.9rem; }

.cx-formulaire .form-group { margin-bottom: 16px; }
.cx-formulaire input { padding-top: 11px; padding-bottom: 11px; }
.cx-majuscules {
    margin: 6px 0 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--ocre);
    animation: monter .25s var(--ease);
}
.cx-majuscules[hidden] { display: none; }
.cx-bouton {
    width: 100%;
    justify-content: center;
    padding: 12px 16px;
    margin-top: 6px;
    font-size: 0.95rem;
}
.cx-bouton .ico { transition: transform .25s var(--ease); }
.cx-bouton:hover .ico { transform: translateX(4px); }
.cx-bouton.envoi { pointer-events: none; }
.cx-bouton.envoi span::after { content: "…"; }
.cx-bouton.envoi .ico { animation: cx-fleche .7s ease-in-out infinite; }
@keyframes cx-fleche { 50% { transform: translateX(6px); } }

.champ-mdp { position: relative; }
.champ-mdp input { padding-right: 76px; }
.voir-mdp {
    position: absolute;
    right: 6px; top: 50%;
    transform: translateY(-50%);
    background: none; border: none;
    font-family: var(--police-mono);
    font-size: 0.72rem;
    color: var(--gris);
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 5px;
}
.voir-mdp:hover { color: var(--encre); background: var(--papier); }

.cx-pied {
    margin: 26px -32px 0;
    padding: 14px 32px 20px;
    border-top: 1px dashed var(--trait-fort);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-size: 0.72rem;
    color: var(--gris);
}
.cx-horloge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--police-mono);
    font-size: 0.8rem;
}
.cx-horloge strong { color: var(--encre); font-weight: 600; font-variant-numeric: tabular-nums; }
.cx-mention { margin: 26px 0 0; font-size: 0.74rem; color: var(--gris); text-align: center; }

/* ---------- Pages de connexion : mot de passe oublié, double authentification ---------- */
.cx-label-ligne { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.cx-label-ligne label { margin-bottom: 6px; }
.cx-lien { font-size: 0.8rem; color: var(--accent); text-decoration: none; font-weight: 500; }
.cx-lien:hover { text-decoration: underline; }
.cx-lien-discret { color: var(--gris); }
.cx-liens { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.cx-liens:only-child, .cx-liens > :only-child { margin-inline: auto; }
.cx-texte { margin: -8px 0 18px; color: var(--gris); font-size: 0.88rem; line-height: 1.55; text-align: center; }
.cx-explication, .cx-confirmation { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; margin: -6px 0 20px; }
.cx-explication p, .cx-confirmation p { margin: 0; font-size: 0.9rem; line-height: 1.55; color: var(--encre); }
.cx-pastille-2fa {
    display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%;
    background: var(--accent-pale); color: var(--accent);
    animation: cx-pulsation 2.4s ease-in-out infinite;
}
.cx-pastille-ok { background: var(--vert-pale); color: var(--vert); }
@keyframes cx-pulsation { 50% { box-shadow: 0 0 0 8px color-mix(in srgb, currentColor 10%, transparent); } }
.cx-consignes { margin: 0; padding: 0 0 0 18px; text-align: left; font-size: 0.82rem; color: var(--gris); line-height: 1.55; }
.cx-consignes li + li { margin-top: 4px; }
.cx-confirmation + .cx-bouton, .cx-explication + .cx-bouton { display: flex; text-decoration: none; }
.cx-code {
    text-align: center; font-family: var(--police-mono); font-size: 1.6rem !important;
    letter-spacing: .45em; padding-left: .45em !important; font-variant-numeric: tabular-nums;
}
.cx-code-secours { font-size: 1.25rem !important; letter-spacing: .2em; text-transform: uppercase; }
.cx-code::placeholder { color: var(--trait-fort); }
.cx-delai { margin: 14px 0 0; text-align: center; font-size: 0.76rem; color: var(--gris); font-variant-numeric: tabular-nums; }
.cx-delai.urgent { color: var(--rouge); }

/* Jauge de robustesse du mot de passe */
.force-mdp { display: flex; align-items: center; gap: 10px; margin-top: 7px; min-height: 16px; }
.force-mdp i { flex: 1; height: 4px; border-radius: 4px; background: var(--trait); position: relative; overflow: hidden; }
.force-mdp i::after { content: ""; position: absolute; inset: 0; width: 0; border-radius: inherit; background: var(--rouge); transition: width .3s var(--ease, ease), background .3s; }
.force-mdp span { font-size: 0.74rem; color: var(--gris); min-width: 70px; text-align: right; }
.force-mdp:not([data-niveau]) i, .force-mdp[data-niveau="0"] i { visibility: hidden; }
.force-mdp[data-niveau="1"] i::after { width: 15%; }
.force-mdp[data-niveau="2"] i::after { width: 40%; background: var(--ocre); }
.force-mdp[data-niveau="3"] i::after { width: 62%; background: var(--ocre); }
.force-mdp[data-niveau="4"] i::after { width: 82%; background: var(--vert); }
.force-mdp[data-niveau="5"] i::after { width: 100%; background: var(--vert); }

/* ---------- Mon compte ---------- */
.sidebar-user-liens { display: flex; gap: 12px; flex-wrap: wrap; }
.sidebar-logout.actif { color: var(--sb-texte-fort, var(--encre)); }
.badge-etat {
    display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 0.74rem; font-weight: 600;
    background: var(--papier); color: var(--gris); border: 1px solid var(--trait); white-space: nowrap;
}
.badge-etat.ok { background: var(--vert-pale); color: var(--vert); border-color: transparent; }
.texte-alerte { color: var(--rouge); }
.compte-grille { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; margin-bottom: 20px; }
.compte-grille > .card { margin-bottom: 0; }
.compte-infos { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0 0 18px; font-size: 0.88rem; }
.compte-infos dt { color: var(--gris); }
.compte-infos dd { margin: 0; }
.compte-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.compte-2fa-entete { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: start; margin-bottom: 16px; }
.compte-2fa-entete h3 { margin: 0 0 4px; }
.compte-2fa-entete p, .compte-codes-entete p { margin: 0; max-width: 75ch; font-size: 0.88rem; line-height: 1.55; }
.compte-2fa-icone { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--papier); color: var(--gris); }
.compte-2fa.active .compte-2fa-icone { background: var(--vert-pale); color: var(--vert); }
.compte-2fa-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.compte-volet > summary { list-style: none; cursor: pointer; }
.compte-volet > summary::-webkit-details-marker { display: none; }
.compte-volet[open] > summary { opacity: .7; }
.compte-volet-contenu { margin-top: 12px; padding: 16px; border: 1px solid var(--trait); border-radius: var(--rayon, 10px); width: min(360px, 100%); animation: compte-ouvre .25s ease; }
@keyframes compte-ouvre { from { opacity: 0; transform: translateY(-4px); } }

.compte-etapes { counter-reset: etape; list-style: none; margin: 0; padding: 0; display: grid; gap: 22px; }
.compte-etapes > li { counter-increment: etape; position: relative; padding-left: 44px; font-size: 0.9rem; line-height: 1.55; }
.compte-etapes > li::before {
    content: counter(etape); position: absolute; left: 0; top: -2px; width: 28px; height: 28px; border-radius: 50%;
    display: grid; place-items: center; font-weight: 700; font-size: 0.82rem; background: var(--accent-pale); color: var(--accent);
}
.compte-qr-zone { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.compte-qr { width: 188px; height: 188px; padding: 8px; background: #fff; border: 1px solid var(--trait); border-radius: 12px; box-sizing: content-box; }
.compte-qr svg { display: block; width: 100%; height: 100%; }
.compte-cle { flex: 1; min-width: 220px; display: grid; gap: 8px; justify-items: start; }
.compte-cle p { margin: 0; }
.compte-cle-texte { font-family: var(--police-mono); font-size: 1rem; letter-spacing: .06em; padding: 8px 12px; background: var(--papier); border-radius: 8px; word-break: break-all; }
.compte-confirmation { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 260px)); gap: 0 16px; margin-top: 12px; align-items: end; }
.compte-confirmation .compte-actions { grid-column: 1 / -1; }
.code-otp { font-family: var(--police-mono); letter-spacing: .3em; font-size: 1.1rem; }

.compte-codes { border: 2px solid var(--ocre); background: var(--ocre-pale); }
.compte-codes h3 { margin: 0 0 6px; }
.compte-codes-liste {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 20px;
    margin: 16px 0; padding: 16px 16px 16px 40px; background: var(--feuille); border-radius: 10px;
    font-family: var(--police-mono); font-size: 1.05rem; letter-spacing: .08em;
}
@media (max-width: 600px) {
    .compte-2fa-entete { grid-template-columns: auto 1fr; }
    .compte-2fa-entete .badge-etat { grid-column: 2; justify-self: start; }
}
@media print {
    body:has(.compte-codes) .container > *:not(.compte-codes) { display: none !important; }
    .compte-codes { border: 1px solid #000; background: #fff; }
    .compte-codes .compte-actions { display: none; }
}

@media (max-width: 480px) {
    .cx-feuille { padding: 60px 20px 0; }
    .cx-pied { margin: 22px -20px 0; padding: 12px 20px 18px; }
    .cx-ligne { font-size: 11px; }
}

/* ---------------------------------------------------------------
   Facture / rapport imprimable, au format A4 (210mm) — reste sobre et
   strictement noir/blanc : c'est un document fiscal officiel, pas une
   page de l'interface. La palette de l'appli ne s'y applique pas.
   --------------------------------------------------------------- */
.facture-print {
    --encre: #111; --encre-2: #333; --gris: #666; --feuille: #fff; --papier: #f6f6f6;
    --trait: #ddd; --trait-fort: #bbb; --police-chiffres: var(--police-mono);
    color: #111;
    background: #fff;
    width: 210mm;
    max-width: 100%;
    margin: 0 auto;
    padding: 15mm;
    box-shadow: 0 1px 6px rgba(0,0,0,0.08);
    font-size: 0.95rem;
}
.facture-print h2 { margin-top: 0; font-family: var(--police-corps); }

.invoice-brand-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.invoice-brand-tag {
    border: 1px solid #333;
    border-radius: 4px;
    padding: 6px 12px;
    font-weight: 700;
    font-size: 0.78rem;
    line-height: 1.3;
    letter-spacing: 0.03em;
    color: #222;
}
.invoice-brand-tag span { font-weight: 400; font-size: 0.68rem; letter-spacing: 0.06em; color: #555; }
.invoice-brand-ref {
    flex: 1;
    text-align: right;
    font-size: 0.85rem;
    color: #444;
    border: 1px solid var(--couleur-bordure);
    border-radius: 4px;
    padding: 8px 14px;
}

.invoice-tags { margin-bottom: 10px; text-align: center; }
.invoice-ref-origine { text-align: center; font-size: 0.85rem; color: #444; margin: 0 0 12px; }

.invoice-simulation-warning {
    text-align: center;
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.03em;
    color: #7a2e00;
    background: #fff3e0;
    border: 2px dashed #c26a00;
    border-radius: 6px;
    padding: 8px 10px;
    margin-bottom: 14px;
}

.invoice-two-col {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid #333;
}
.invoice-entreprise { flex: 1; min-width: 220px; }
.invoice-entreprise h2 { margin: 0 0 6px; font-size: 1.1rem; color: #111; letter-spacing: 0.01em; }
.invoice-entreprise p { margin: 2px 0; font-size: 0.83rem; color: #444; }

.invoice-client-box {
    flex: 1;
    min-width: 220px;
    max-width: 320px;
    border: 1px solid #333;
    border-radius: 0;
    padding: 10px 14px;
}
.invoice-client-box h4 { margin: 0 0 6px; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.05em; color: #111; border-bottom: 1px solid var(--couleur-bordure); padding-bottom: 4px; }
.invoice-client-box table { width: 100%; }
.invoice-client-box td { border: none; padding: 2px 4px; font-size: 0.83rem; }
.invoice-client-box td.label { color: #777; font-style: italic; width: 70px; }

.invoice-title-block { text-align: center; margin-bottom: 14px; }
.invoice-title-block h3 { margin: 0 0 4px; font-family: var(--police-corps); letter-spacing: 0.08em; font-size: 1.05rem; color: #111; }
.invoice-title-block p { margin: 0; font-size: 0.88rem; color: #555; }

.invoice-lignes { border-top: 2px solid #222; border-bottom: 1px solid #333; }
.invoice-lignes th {
    background: none;
    color: #111;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid #333;
}
.invoice-lignes td { font-size: 0.85rem; vertical-align: top; border-bottom: 1px solid var(--couleur-bordure); }
.tag-ligne { font-size: 0.72rem; color: #777; }

.invoice-tax-summary {
    margin-top: 14px;
    padding-top: 10px;
    font-size: 0.85rem;
}
.invoice-tax-summary p { margin: 3px 0; display: flex; justify-content: space-between; max-width: 420px; }
.invoice-tax-summary .montant { font-variant-numeric: tabular-nums; }

.invoice-total-final {
    text-align: right;
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: 0.22em;
    color: #111;
    border-top: 1px solid #333;
    border-bottom: 3px double #333;
    padding: 10px 0;
    margin: 14px 0;
}

.invoice-lettres { font-style: italic; font-size: 0.83rem; margin: 10px 0; color: #444; }

.invoice-securite { margin-top: 20px; }
.securite-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px dashed #999;
    border-bottom: 1px dashed #999;
    padding: 6px 0;
    margin-bottom: 12px;
}
.securite-header .divider-text { font-style: italic; font-size: 0.76rem; color: #666; }
.securite-header .isf-tag { font-weight: 700; font-size: 0.8rem; color: #111; }

.securite-body { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.securite-code { text-align: center; flex-shrink: 0; }
.securite-code .label { margin: 0; font-size: 0.7rem; color: #777; }
.securite-code .code-value { margin: 2px 0 0; font-weight: 700; font-family: monospace; font-size: 0.8rem; color: #111; }
.securite-details { flex: 1; min-width: 220px; font-size: 0.78rem; }
.securite-details p { margin: 3px 0; display: flex; justify-content: space-between; max-width: 320px; }
.securite-details .label { color: #777; font-style: italic; }
.securite-details .value { font-weight: 700; font-family: monospace; color: #111; }

.qr-box { text-align: center; flex-shrink: 0; }
.qr-box img { width: 105px; height: 105px; border: 1px solid #333; padding: 3px; background: #fff; }

.invoice-footer-mentions {
    margin-top: 16px;
    padding-top: 10px;
    border-top: 1px solid #333;
    font-size: 0.78rem;
    color: #555;
    text-align: center;
}

.mention-tag { display:inline-block; border:1px solid #333; padding:2px 8px; font-weight:700; font-size:0.78rem; margin: 0 6px 6px 0; border-radius: 0; }

/* ---------------------------------------------------------------
   Impression : format A4 strict
   --------------------------------------------------------------- */
@page {
    size: A4;
    margin: 15mm;
}

@media print {
    *, *::before, *::after { animation: none !important; transition: none !important; }
    .no-print { display: none !important; }
    .popup-alerte-overlay { display: none !important; }
    .sidebar, .sidebar-voile, .topbar, .footer { display: none !important; }
    .app-shell { display: block; }
    body { background: #fff; margin: 0; }
    .main-wrapper { display: block; }
    .container { max-width: none; width: auto; padding: 0; margin: 0; }
    .card { border: none; box-shadow: none; overflow: visible; }
    .facture-print {
        width: 100%;
        max-width: 100%;
        padding: 0;
        margin: 0;
        box-shadow: none;
    }
}

/* ---------------------------------------------------------------
   Rôles & permissions
   --------------------------------------------------------------- */
.permission-module {
    border: 1px solid var(--trait);
    border-radius: var(--rayon-sm);
    padding: 12px 14px;
    margin-bottom: 10px;
    background: var(--feuille);
    transition: border-color .15s, box-shadow .2s;
}
.permission-module:hover { border-color: var(--trait-fort); box-shadow: var(--ombre-1); }
.permission-module h4 {
    margin: 0 0 8px;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gris);
}
.permission-item {
    display: flex;
    align-items: center;
    padding: 4px 0;
    font-size: 0.88rem;
    font-weight: normal;
    color: var(--encre);
    cursor: pointer;
}
.permission-item input {
    width: auto;
    margin-right: 9px;
}

/* ---------------------------------------------------------------
   Mouvement réduit : on coupe les animations pour qui le demande
   --------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-delay: 0ms !important;
        transition-duration: 0.01ms !important;
    }
    @view-transition { navigation: none; }
}
.topbar .mcf-etat + .topbar-horloge { margin-left: 0; }
