/* La console du support, avec les jetons des apps (core/designsystem : AfreeColors, AfreeText, AfreeSpacing).
   Un tableau de bord : barre latérale à gauche dès 1024 px (repliable en icônes), barre d'application en haut avec la
   recherche, onglets en bas sur un téléphone. Clair par défaut, sombre avec les jetons sombres des apps. Pas de framework. */

@font-face {
    font-family: "Manrope";
    src: url("fonts/manrope.ttf") format("truetype");
    font-weight: 200 800;
    font-style: normal;
    font-display: swap;
}

:root {
    /* AfreeColors */
    --screen-background: #F8F9FA;
    --header-blue: #002455;
    --accent-blue: #0D47A1;
    --card-grey: #F5F5F5;
    --divider: #DDDDDD;
    --label-grey: #757575;
    --label-dark-grey: #555555;
    --text-dark: #333333;
    --footer-grey: #9E9E9E;
    --success-green: #4CAF50;
    --failure-red: #EF5350;
    --pay-green: #12B24A;
    --warn-amber: #FFB300;
    --on-blue: #FFFFFF;
    --on-blue-muted: #FFFFFFB3;
    --on-blue-faint: #FFFFFF33;
    --error-on-blue: #FFB4AB;
    --canvas: #002455;
    --surface: #0B3468;
    --surface-high: #17458A;
    --card: #FFFFFF;

    /* Les rôles de la page, dérivés des jetons ; le mode sombre ne change que ceux-ci */
    --bg: var(--screen-background);
    --fg: var(--text-dark);
    --fg-muted: var(--label-grey);
    --fg-strong: var(--label-dark-grey);
    --line: var(--divider);
    --panel: var(--card);
    --panel-alt: var(--card-grey);
    --link: var(--accent-blue);
    --focus: var(--accent-blue);
    --side-bg: var(--header-blue);
    --side-fg: var(--on-blue);
    --side-muted: var(--on-blue-muted);
    --side-faint: var(--on-blue-faint);
    --ok-bg: #4CAF5026; --ok-fg: #2E7D32;
    --bad-bg: #EF535026; --bad-fg: #C62828;
    --warn-bg: #FFB30026; --warn-fg: #8A5A00;
    --info-bg: #0D47A11A; --info-fg: #0D47A1;
    --shadow: 0 1px 2px #00245514, 0 1px 0 #00245508;

    /* AfreeSpacing */
    --space-xs: 4px;
    --space-s: 8px;
    --space-m: 12px;
    --space-l: 16px;
    --space-xl: 20px;
    --space-xxl: 24px;
    --space-xxxl: 32px;

    /* Rayons et tailles */
    --radius-card: 12px;
    --radius-chip: 16px;
    --radius-pill: 28px;
    --touch: 44px;
    --appbar: 56px;
    --sidebar: 248px;
    --sidebar-narrow: 72px;
    --tabbar: 60px;
    --gutter: 16px;
    --content-max: 1100px;

    /* AfreeText */
    --font: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
    --text-screen-title: 22px;
    --text-sheet-title: 18px;
    --text-row-title: 16px;
    --text-body: 15px;
    --text-row-sub: 14px;
    --text-label: 12px;
    --text-kpi: 32px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: var(--canvas);
        --fg: #FFFFFF;
        --fg-muted: var(--on-blue-muted);
        --fg-strong: #FFFFFFD9;
        --line: #FFFFFF26;
        --panel: var(--surface);
        --panel-alt: var(--surface-high);
        --link: #9FC3FF;
        --focus: #FFFFFF;
        --side-bg: #001A3F;
        --ok-bg: #4CAF5033; --ok-fg: #9BE3A0;
        --bad-bg: #EF535033; --bad-fg: #FFB4AB;
        --warn-bg: #FFB30033; --warn-fg: #FFD98A;
        --info-bg: #FFFFFF1F; --info-fg: #C9DCFF;
        --shadow: none;
    }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font);
    font-size: var(--text-body);
    line-height: 22px;
}

body.canvas { background: var(--canvas); color: var(--on-blue); }

a { color: var(--link); }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
    border-radius: var(--space-xs);
}
.canvas a:focus-visible, .canvas button:focus-visible, .canvas input:focus-visible, .sidebar a:focus-visible, .sidebar button:focus-visible, .tabbar a:focus-visible {
    outline-color: var(--on-blue);
}

/* Le lien d'évitement : invisible jusqu'au focus clavier */
.skip { position: absolute; left: var(--space-l); top: -60px; z-index: 50; background: var(--panel); color: var(--fg); padding: var(--space-s) var(--space-l); border-radius: var(--radius-chip); box-shadow: var(--shadow); }
.skip:focus { top: var(--space-s); }

/* La coque : barre latérale fixe + colonne de contenu ; la case à cocher cachée replie la barre sans script */
.nav-toggle { position: absolute; opacity: 0; width: 1px; height: 1px; overflow: hidden; }
.shell { min-height: 100vh; display: flex; }

.sidebar {
    display: none;
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar);
    background: var(--side-bg);
    color: var(--side-fg);
    flex-direction: column;
    z-index: 20;
}
.brand { display: flex; align-items: center; gap: var(--space-m); min-height: var(--appbar); padding: 0 var(--space-l); color: var(--side-fg); text-decoration: none; }
/* Le logo AfreePay (flèche verte, PNG transparent) : sa hauteur suit le texte qu'il accompagne, sa largeur suit son ratio. */
.brand-logo { height: 28px; width: auto; flex: 0 0 auto; }
.brand-name { font-size: 18px; font-weight: 800; letter-spacing: -0.3px; white-space: nowrap; }
.brand-app { display: block; font-size: var(--text-label); font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: var(--side-muted); line-height: 14px; }
.sidenav { flex: 1 1 auto; overflow-y: auto; padding: var(--space-s) var(--space-m) var(--space-l); }
.sidenav h2 { font-size: var(--text-label); font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: var(--side-muted); margin: var(--space-l) var(--space-m) var(--space-xs); white-space: nowrap; overflow: hidden; }
.sidenav a {
    display: flex;
    align-items: center;
    gap: var(--space-m);
    min-height: var(--touch);
    padding: 0 var(--space-m);
    border-radius: var(--radius-chip);
    color: var(--side-muted);
    text-decoration: none;
    font-weight: 700;
    white-space: nowrap;
}
.sidenav a:hover { color: var(--side-fg); background: var(--side-faint); }
.sidenav a[aria-current="page"] { color: var(--side-fg); background: var(--side-faint); }
.sidenav svg, .tabbar svg { width: 22px; height: 22px; flex: 0 0 auto; }
.sidenav .badge { margin-left: auto; font-size: var(--text-label); font-weight: 800; background: var(--warn-amber); color: var(--header-blue); border-radius: var(--radius-chip); padding: 0 var(--space-s); line-height: 20px; }
.sidefoot { border-top: 1px solid var(--side-faint); padding: var(--space-m) var(--space-l); display: flex; align-items: center; gap: var(--space-m); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-high); color: var(--on-blue); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: var(--text-row-sub); text-transform: uppercase; flex: 0 0 auto; }
.who { min-width: 0; flex: 1 1 auto; line-height: 18px; }
.who .login { display: block; font-weight: 700; color: var(--side-fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-row-sub); }
.role { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--side-muted); background: var(--side-faint); border-radius: var(--radius-chip); padding: 0 var(--space-s); line-height: 18px; }
.sidefoot form { margin: 0; }
button.link { background: none; border: 0; color: var(--side-muted); font: inherit; font-size: var(--text-row-sub); cursor: pointer; min-height: var(--touch); padding: 0 var(--space-s); text-decoration: underline; }
button.link:hover { color: var(--side-fg); }
.collapse { display: none; }

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

/* La barre d'application : le titre de la page et son fil, la recherche, l'action principale */
.appbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    min-height: var(--appbar);
    display: flex;
    align-items: center;
    gap: var(--space-m);
    padding: var(--space-s) var(--gutter);
    flex-wrap: wrap;
}
.appbar .wordmark { color: var(--fg); font-weight: 800; font-size: 18px; text-decoration: none; letter-spacing: -0.3px; }
.crumbs { display: flex; align-items: center; gap: var(--space-s); margin: 0; padding: 0; list-style: none; font-size: var(--text-row-sub); color: var(--fg-muted); min-width: 0; flex-wrap: wrap; }
.crumbs a { color: var(--fg-muted); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs li + li::before { content: "›"; margin-right: var(--space-s); color: var(--footer-grey); }
.crumbs [aria-current] { color: var(--fg); font-weight: 700; }
.search { margin-left: auto; display: flex; align-items: center; gap: var(--space-s); flex: 1 1 220px; max-width: 420px; }
.search label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.search input[type="search"] {
    width: 100%;
    min-height: 40px;
    padding: 0 var(--space-l) 0 40px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--panel-alt);
    color: var(--fg);
    font: inherit;
    font-size: var(--text-row-sub);
}
.search .field { position: relative; flex: 1 1 auto; }
.search .field svg { position: absolute; left: 14px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--fg-muted); pointer-events: none; }
.search kbd { font: inherit; font-size: 11px; color: var(--fg-muted); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; line-height: 18px; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); }
.search input[type="search"]:focus-visible { border-color: var(--focus); outline-offset: 0; border-radius: var(--radius-pill); }

/* La page : 1200 px au plus, 24 px entre les blocs, 12 px dans une carte */
.page { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: var(--space-xxl) var(--gutter) calc(var(--tabbar) + var(--space-xxxl)); }
.page > * + * { margin-top: var(--space-xxl); }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--space-m) var(--space-l); }
.page-head .titles { flex: 1 1 320px; min-width: 0; }
.page-head .titles > * + * { margin-top: var(--space-xs); }
.page-head .actions { flex: 0 0 auto; }
.screen-title { font-size: var(--text-screen-title); font-weight: 700; line-height: 28px; margin: 0; overflow-wrap: anywhere; }
.subtitle { color: var(--fg-muted); margin: 0; font-size: var(--text-row-sub); }
.section-label { font-size: var(--text-label); font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: var(--fg-muted); margin: 0; }
.row-title { font-size: var(--text-row-title); font-weight: 700; color: var(--fg); margin: 0; overflow-wrap: anywhere; }
a.row-title { color: var(--link); text-decoration: none; }
a.row-title:hover { text-decoration: underline; }
.row-sub { font-size: var(--text-row-sub); line-height: 20px; color: var(--fg-muted); margin: 0; overflow-wrap: anywhere; }
.row-sub strong { color: var(--fg-strong); }
.muted { color: var(--fg-muted); margin: 0; }
.num { font-feature-settings: "tnum" 1; font-variant-numeric: tabular-nums; }
.num.small { font-size: var(--text-row-sub); color: var(--fg-strong); word-break: break-all; margin: 0; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: var(--text-row-sub); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.back { margin: 0; }
.back a { text-decoration: none; font-weight: 700; display: inline-flex; align-items: center; min-height: var(--touch); }
.back + * { margin-top: var(--space-s); }

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    padding: var(--space-l);
    box-shadow: var(--shadow);
}
.card > * + * { margin-top: var(--space-m); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-s) var(--space-l); }
.card-head .section-label { flex: 1 1 auto; }
.card-head .count { color: var(--fg-muted); font-size: var(--text-row-sub); }
.grid { display: grid; gap: var(--space-l); grid-template-columns: 1fr; align-items: start; }
.grid > * { margin: 0; min-width: 0; }

/* Composant _EmptyState : une icône, un titre, une phrase, au plus une action ; en carte seule ou dans une liste */
.empty { text-align: center; padding: var(--space-xxxl) var(--space-l); }
.empty svg { width: 40px; height: 40px; color: var(--footer-grey); }
.empty .row-title { margin: var(--space-m) 0 var(--space-xs); }
.empty .btn { margin-top: var(--space-l); }

/* Composant _ErrorBanner : le refus en bandeau (avec « Réessayer » sur une liste) ou en erreur de champ */
.banner { margin: 0; padding: var(--space-m) var(--space-l); border-radius: var(--radius-card); font-weight: 600; display: flex; flex-wrap: wrap; gap: var(--space-s) var(--space-l); align-items: center; }
.banner > span { flex: 1 1 auto; }
.banner-error { background: var(--bad-bg); color: var(--bad-fg); border: 1px solid #EF535066; }
.banner-ok { background: var(--ok-bg); color: var(--ok-fg); border: 1px solid #4CAF5066; }
.banner.on-blue { background: var(--on-blue-faint); color: var(--error-on-blue); border-color: transparent; }
.banner a { color: inherit; font-weight: 700; }
.field-error { font-size: var(--text-row-sub); color: var(--bad-fg); font-weight: 700; margin: var(--space-xs) 0 0; }

/* Composant _Toast : le message éphémère après un POST (PRG), fermable */
.toast { position: relative; margin: 0; padding: var(--space-m) 48px var(--space-m) var(--space-l); border-radius: var(--radius-card); font-weight: 600; border: 1px solid transparent; }
.toast-ok { background: var(--ok-bg); color: var(--ok-fg); border-color: #4CAF5066; }
.toast-warn { background: var(--warn-bg); color: var(--warn-fg); border-color: #FFB30066; }
.toast-error { background: var(--bad-bg); color: var(--bad-fg); border-color: #EF535066; }
.toast .dismiss { position: absolute; right: var(--space-s); top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border: 0; background: transparent; color: inherit; font-size: 20px; cursor: pointer; border-radius: 50%; }
.toast .dismiss:hover { background: #00000014; }

/* Composant _Pill : un ton doux à 15 % et toujours un mot, jamais la couleur seule */
/* Une pastille longue revient à la ligne dans sa carte ; dans un tableau elle reste sur une ligne (table.data .pill) */
.pills { display: inline-flex; flex-wrap: wrap; gap: var(--space-xs); margin: 0; vertical-align: middle; }
.pill { display: inline-block; font-size: var(--text-label); font-weight: 700; line-height: 16px; padding: var(--space-xs) var(--space-m); border-radius: var(--radius-chip); white-space: normal; max-width: 100%; }
.pill-ok { background: var(--ok-bg); color: var(--ok-fg); }
.pill-bad { background: var(--bad-bg); color: var(--bad-fg); }
.pill-warn { background: var(--warn-bg); color: var(--warn-fg); }
.pill-info { background: var(--info-bg); color: var(--info-fg); }
.pill-neutral { background: var(--panel-alt); color: var(--fg-strong); }

/* Composant _FilterChips : des liens qui gardent les autres paramètres ; la puce en cours est pleine, une puce à croix retire son filtre */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-s); margin: var(--space-l) 0; padding: 0; list-style: none; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: var(--space-xs); min-height: 32px; padding: 0 var(--space-m); border-radius: var(--radius-chip); border: 1.5px solid var(--line); color: var(--fg-strong); text-decoration: none; font-size: var(--text-row-sub); font-weight: 700; background: var(--panel); }
.chip:hover { border-color: var(--link); color: var(--link); }
.chip[aria-current="true"] { background: var(--accent-blue); border-color: var(--accent-blue); color: var(--on-blue); }
.chips .reset { margin-left: var(--space-xs); font-size: var(--text-row-sub); }

/* Boutons : pilule 28 px, 44 px de haut au moins */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-s); min-height: var(--touch); padding: 0 var(--space-xxl); border-radius: var(--radius-pill); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; border: 1.5px solid transparent; white-space: nowrap; }
.btn:focus-visible { border-radius: var(--radius-pill); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--accent-blue); color: var(--on-blue); }
.btn-primary:hover { background: var(--surface-high); }
.btn-secondary { background: transparent; color: var(--link); border-color: var(--link); }
.btn-secondary:hover { background: var(--info-bg); }
.btn-danger { background: transparent; color: var(--bad-fg); border-color: var(--failure-red); }
.btn-danger:hover { background: #EF535014; }
.btn-danger-solid { background: var(--failure-red); color: var(--on-blue); }
.btn-danger-solid:hover { background: #C62828; }
.btn-small { min-height: 36px; padding: 0 var(--space-l); font-size: var(--text-row-sub); }
.btn-wide { width: 100%; min-height: 56px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: var(--space-m); align-items: center; }
/* Les actions d'une ligne de tableau : serrées, et qui passent à la ligne plutôt que de déborder de la carte. */
table.data .actions { gap: var(--space-s); }
.actions form { margin: 0; }

/* Formulaires : libellé au-dessus, aide dessous (l'erreur en ligne est dans _ErrorBanner) */
label { display: block; font-size: var(--text-row-sub); font-weight: 700; color: var(--fg-strong); margin: var(--space-m) 0 var(--space-xs); }
.field-help { font-size: var(--text-label); color: var(--fg-muted); margin: var(--space-xs) 0 0; }
input[type="text"], input[type="password"], input[type="search"], input[type="date"], textarea, select {
    width: 100%;
    font: inherit;
    font-size: var(--text-row-title);
    color: var(--fg);
    background: var(--panel);
    border: 1.5px solid var(--line);
    border-radius: var(--radius-card);
    padding: var(--space-m) var(--space-l);
    min-height: var(--touch);
}
input:focus-visible, textarea:focus-visible, select:focus-visible { border-color: var(--focus); outline-offset: 0; border-radius: var(--radius-card); }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--failure-red); }
textarea { resize: vertical; }
input.code { letter-spacing: 6px; font-weight: 700; }
/* Les filtres : les champs alignés par le haut (un texte d'aide ne décale plus ses voisins), la période en un seul
   groupe, et les boutons sur leur propre ligne, à droite, jamais dans une case de la grille. */
.filters { display: grid; gap: var(--space-xs) var(--space-l); grid-template-columns: 1fr; align-items: start; }
.filters label { margin-top: var(--space-s); }
.filters .range { display: grid; gap: 0 var(--space-m); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.filters .range > .field-help { grid-column: 1 / -1; }
.filters .actions { grid-column: 1 / -1; justify-content: flex-end; margin-top: var(--space-l); padding-top: var(--space-l); border-top: 1px solid var(--line); }
.form-grid { display: grid; gap: 0 var(--space-l); grid-template-columns: 1fr; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-size: var(--text-row-sub); font-weight: 700; color: var(--fg-strong); padding: 0; margin: var(--space-m) 0 var(--space-xs); }
.radios { display: flex; flex-wrap: wrap; gap: var(--space-m); }
.radios label { display: inline-flex; align-items: center; gap: var(--space-s); margin: 0; font-weight: 600; min-height: var(--touch); }
.radios input { width: 20px; height: 20px; }

/* Composant _ConfirmPanel : la confirmation sans script, dépliée par un paramètre de l'adresse, le motif saisi dans la même carte */
.confirm { padding: var(--space-l); border-radius: var(--radius-card); background: var(--panel-alt); border: 1px solid var(--line); }
.confirm > * + * { margin-top: var(--space-m); }
/* Un paiement à vérifier (B33 #110) : la marque ouverte se voit en tête de la fiche, le mot le dit aussi */
.attention-open { border-left: 4px solid var(--warn-amber); }
.attention .card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-m); }
.attention form.confirm { margin-top: var(--space-m); }
/* Une phrase d'explication dans une carte de liste, alignée sur l'en-tête de la carte */
.card-note { padding: var(--space-m) var(--space-l); margin: 0; }

/* Les tableaux : tri par lien, chiffres à droite, la ligne entière cliquable ; l'en-tête ne colle qu'au large, où le
   tableau ne défile pas de côté (un conteneur qui défile rendrait l'en-tête collant dans la carte, par-dessus la première ligne) */
.list { padding: 0; }
.list > * + * { margin-top: 0; }
.list .card-head { padding: var(--space-m) var(--space-l); border-bottom: 1px solid var(--line); }
.list .pager, .list .empty { padding: var(--space-m) var(--space-l); border-top: 1px solid var(--line); }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: var(--text-row-sub); }
table.data th, table.data td { padding: var(--space-m) var(--space-m); text-align: left; vertical-align: top; border-top: 1px solid var(--line); }
table.data time, table.data .pill { white-space: nowrap; }
/* L'âge d'un dossier : ambre passé 24 h (la promesse de l'app), rouge passé 72 h. */
table.data time.late { color: var(--warn-fg); font-weight: 700; }
table.data time.very-late { color: var(--bad-fg); font-weight: 700; }
.queue-summary { margin: 0 0 var(--space-m); color: var(--fg-muted); font-size: var(--text-row-sub); }
.queue-summary a { color: inherit; }
.queue-summary strong { color: var(--fg-strong); }
.queue-summary .late-link strong { color: var(--warn-fg); }
.queue-summary .sep { margin: 0 var(--space-s); }
table.data tr.link.focused { outline: 2px solid var(--link); outline-offset: -2px; }
/* Un nom long se coupe par des points, le nom entier au survol : une colonne ne pousse jamais le tableau en largeur. */
table.data td.name { white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
table.data td .row-sub { white-space: normal; }
table.data th:first-child, table.data td:first-child { padding-left: var(--space-l); }
table.data th:last-child, table.data td:last-child { padding-right: var(--space-l); }
table.data thead th { background: var(--panel-alt); color: var(--fg-muted); font-size: var(--text-label); font-weight: 700; letter-spacing: 1px; text-transform: uppercase; border-top: 0; z-index: 1; white-space: nowrap; }
/* Composant _SortableHeader : l'en-tête de colonne est un lien, la flèche suit aria-sort */
table.data th a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: var(--space-xs); }
table.data th a:hover { color: var(--link); }
table.data th[aria-sort="ascending"] a::after { content: "▲"; font-size: 9px; }
table.data th[aria-sort="descending"] a::after { content: "▼"; font-size: 9px; }
table.data th.num, table.data td.num { text-align: right; }
table.data tbody tr:hover { background: var(--panel-alt); }
table.data tbody tr.link { position: relative; }
table.data td a.cover { color: var(--link); font-weight: 700; text-decoration: none; }
table.data td a.cover::after { content: ""; position: absolute; inset: 0; }
table.data td .row-sub { font-size: var(--text-label); }
table.data .role { color: var(--fg-strong); background: var(--panel-alt); }
table.data .pill { vertical-align: middle; }
table.data td .btn-small, table.data td form, table.data td a.above { position: relative; z-index: 2; }
table.data td form { display: inline; }

/* Composant _Pager : le compte et les liens de page, qui gardent le tri et les filtres */
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-s) var(--space-l); font-size: var(--text-row-sub); color: var(--fg-muted); }
.pager .count { flex: 1 1 auto; }
.pager nav { display: flex; gap: var(--space-xs); align-items: center; }
.pager a, .pager span.cur { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; min-height: 36px; padding: 0 var(--space-s); border-radius: var(--radius-chip); text-decoration: none; font-weight: 700; }
.pager a:hover { background: var(--panel-alt); }
.pager span.cur { background: var(--accent-blue); color: var(--on-blue); }

/* Composant _KpiCard : une carte de chiffre du tableau de bord, le ton colore la valeur */
.kpis { display: grid; gap: var(--space-l); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpi { margin: 0; display: flex; flex-direction: column; gap: var(--space-xs); text-decoration: none; color: inherit; }
.kpi .label { font-size: var(--text-label); font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: var(--fg-muted); }
.kpi .value { font-size: var(--text-kpi); font-weight: 800; line-height: 36px; letter-spacing: -0.5px; }
.kpi .hint { font-size: var(--text-row-sub); color: var(--fg-muted); }
.kpi.alert .value { color: var(--bad-fg); }
.kpi.warn .value { color: var(--warn-fg); }
.kpi.ok .value { color: var(--ok-fg); }
a.kpi:hover { border-color: var(--link); }
.tallies { display: grid; gap: var(--space-s) var(--space-l); grid-template-columns: auto 1fr auto; align-items: baseline; margin: 0; }
.tallies dt, .tallies dd { margin: 0; }

/* Le dossier : des paires libellé / valeur, en deux colonnes dès 700 px ; _MaskedPhone y est un simple .num */
.dossier-head > * + * { margin-top: var(--space-xs); }
.fields { display: grid; grid-template-columns: 1fr; gap: var(--space-xs) 0; margin: 0; }
.fields dt { font-size: var(--text-label); font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--fg-muted); }
.fields dt + dd { margin-bottom: var(--space-s); }
.fields dt:last-of-type + dd { margin-bottom: 0; }
.fields dd { margin: 0; font-size: var(--text-row-title); overflow-wrap: anywhere; }
.fields dd .pills { margin-left: var(--space-s); }
/* Les pièces en vignettes : la décision reste au-dessus du pli, la grande image s'ouvre dans la visionneuse (site.js). */
/* B41 : le logo d'une boutique, une vignette carrée à bords arrondis, jamais un rond (ce n'est pas une personne) */
.logo-thumb { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; vertical-align: middle; margin-right: var(--space-m); border: 1px solid var(--line); background: #fff; }
.logo-row { display: flex; align-items: center; gap: var(--space-l); flex-wrap: wrap; }
.logo-large { width: 128px; height: 128px; border-radius: 24px; object-fit: cover; border: 1px solid var(--line); background: #fff; }
.photos { display: flex; flex-wrap: wrap; gap: var(--space-l); }
.photo { margin: 0; width: 160px; }
.photo a { display: block; border-radius: var(--radius-card); }
.photo img { display: block; width: 160px; height: 120px; object-fit: cover; border-radius: var(--radius-card); border: 1px solid var(--line); background: var(--panel-alt); }
form.inline { display: inline; margin-left: var(--space-s); }
.note-form { margin-top: var(--space-l); padding-top: var(--space-l); border-top: 1px solid var(--line); }
.note-form textarea { width: 100%; }
.checks { list-style: none; margin: 0 0 var(--space-m); padding: 0; display: grid; gap: var(--space-xs); }
.check { display: flex; gap: var(--space-s); align-items: flex-start; font-size: var(--text-row-sub); }
.check .mark { flex: 0 0 22px; width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 800; font-size: 13px; background: var(--panel-alt); color: var(--fg-strong); }
.check.ok .mark { background: var(--ok-bg); color: var(--ok-fg); }
.check.bad .mark { background: var(--bad-bg); color: var(--bad-fg); }
.check.warn .mark { background: var(--warn-bg); color: var(--warn-fg); }
.check-text { line-height: 22px; }
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(5, 12, 30, 0.92); display: grid; grid-template-rows: auto 1fr; }
.lightbox .bar { display: flex; gap: var(--space-s); align-items: center; padding: var(--space-m) var(--space-l); color: var(--on-blue); }
.lightbox .bar .title { flex: 1 1 auto; font-weight: 700; }
.lightbox .stage { display: grid; place-items: center; overflow: hidden; padding: var(--space-l); }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; transition: transform 150ms ease; }
.lightbox img.rot-90 { transform: rotate(90deg); max-height: 100vw; }
.lightbox img.rot-180 { transform: rotate(180deg); }
.lightbox img.rot-270 { transform: rotate(270deg); max-height: 100vw; }
@media (prefers-reduced-motion: reduce) { .lightbox img { transition: none; } }
.photo figcaption { margin-top: var(--space-s); display: flex; flex-direction: column; gap: 2px; }
.copy { display: inline-flex; align-items: center; gap: var(--space-s); flex-wrap: wrap; }
.copy .btn-small { padding: 0 var(--space-m); }

/* Composant _Timeline : la frise d'un dossier, un point par événement, le ton le colore */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
.timeline li { position: relative; padding: 0 0 var(--space-l) var(--space-xxl); }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: 2px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--panel); border: 2px solid var(--link); }
.timeline li.ok::before { border-color: var(--success-green); background: var(--success-green); }
.timeline li.bad::before { border-color: var(--failure-red); background: var(--failure-red); }
.timeline li.warn::before { border-color: var(--warn-amber); background: var(--warn-amber); }
.timeline time { display: block; font-size: var(--text-label); color: var(--fg-muted); }

/* Le code d'enrôlement et le secret TOTP, montrés une fois, en grand */
.reveal { text-align: center; border: 2px dashed var(--line); }
.reveal .big { font-size: 40px; font-weight: 800; letter-spacing: 6px; font-family: ui-monospace, "SF Mono", Menlo, monospace; margin: var(--space-s) 0; overflow-wrap: anywhere; }
.reveal .uri { word-break: break-all; text-align: left; background: var(--panel-alt); padding: var(--space-m); border-radius: var(--radius-card); }
.qr { width: 220px; height: 220px; max-width: 100%; display: block; margin: var(--space-m) auto; border-radius: var(--space-s); }

/* Les onglets du bas, sur un téléphone : quatre pages et « Plus », qui déplie les autres sans script (case à cocher cachée) */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--side-bg); color: var(--side-fg); display: flex; min-height: var(--tabbar); padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -1px 0 var(--side-faint); }
.tabbar > a, .tabbar .more { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--side-muted); text-decoration: none; font-size: 11px; font-weight: 700; min-height: var(--tabbar); margin: 0; cursor: pointer; }
.tabbar > a[aria-current="page"], .tabbar .more.current { color: var(--side-fg); }
.more-sheet { display: none; position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); background: var(--side-bg); border-top: 1px solid var(--side-faint); padding: var(--space-s) var(--space-m) var(--space-m); flex-direction: column; box-shadow: 0 -8px 24px #00000033; }
.more-sheet a { display: flex; align-items: center; gap: var(--space-m); min-height: var(--touch); padding: 0 var(--space-m); border-radius: var(--radius-chip); color: var(--side-muted); text-decoration: none; font-weight: 700; }
.more-sheet a[aria-current="page"] { color: var(--side-fg); background: var(--side-faint); }
.more-sheet svg { width: 22px; height: 22px; }
#more-toggle:checked ~ .more-sheet { display: flex; }
#more-toggle:focus-visible ~ .more { outline: 3px solid var(--on-blue); outline-offset: -3px; }

/* La connexion, sur la toile bleue comme l'écran d'entrée des apps */
.signin { max-width: 400px; margin: var(--space-xxxl) auto 0; background: var(--surface); border-radius: var(--radius-card); padding: var(--space-xxl); color: var(--on-blue); }
.signin-logo { display: block; height: 56px; width: auto; margin: 0 auto var(--space-l); }
.signin-title { font-size: var(--text-screen-title); font-weight: 700; margin: 0; text-align: center; }
.signin-sub { color: var(--on-blue-muted); margin: var(--space-xs) 0 var(--space-xl); text-align: center; }
.signin .banner { margin-bottom: var(--space-l); }
.signin label { color: var(--on-blue-muted); }
.signin input { background: var(--surface-high); border-color: transparent; color: var(--on-blue); }
.signin input:focus-visible { border-color: var(--on-blue); }
.signin .btn-primary { margin-top: var(--space-xxl); background: var(--on-blue); color: var(--header-blue); }
.signin .btn-primary:hover { background: var(--on-blue-muted); }
.canvas .page { padding-bottom: var(--space-xxxl); }
.canvas .wordmark-top { color: var(--on-blue); text-decoration: none; font-weight: 800; font-size: 20px; display: inline-flex; align-items: center; gap: var(--space-m); padding: var(--space-l) var(--gutter); }

@media (min-width: 700px) {
    .fields { grid-template-columns: 160px 1fr; gap: var(--space-s) var(--space-l); align-items: baseline; }
    .fields dt + dd, .fields dt:last-of-type + dd { margin-bottom: 0; }
    .fields dt { padding-top: 2px; }
    .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filters .range { grid-column: span 2; }
    .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
    .sidebar { display: flex; }
    .main { margin-left: var(--sidebar); }
    .tabbar { display: none; }
    .appbar .wordmark { display: none; }
    .collapse { display: inline-flex; align-items: center; justify-content: center; width: var(--touch); height: var(--touch); border-radius: 50%; color: var(--fg-muted); cursor: pointer; }
    .collapse:hover { background: var(--panel-alt); }
    .collapse svg { width: 22px; height: 22px; }
    .nav-toggle:checked ~ .shell .sidebar { width: var(--sidebar-narrow); }
    .nav-toggle:checked ~ .shell .main { margin-left: var(--sidebar-narrow); }
    .nav-toggle:checked ~ .shell .brand-name, .nav-toggle:checked ~ .shell .brand-app, .nav-toggle:checked ~ .shell .sidenav h2,
    .nav-toggle:checked ~ .shell .sidenav a span, .nav-toggle:checked ~ .shell .who, .nav-toggle:checked ~ .shell .sidefoot button { display: none; }
    .nav-toggle:checked ~ .shell .sidenav a { justify-content: center; padding: 0; }
    .nav-toggle:checked ~ .shell .sidefoot { justify-content: center; }
    .nav-toggle:focus-visible ~ .shell .collapse { outline: 3px solid var(--focus); outline-offset: 2px; }
    .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .filters { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .page { padding-bottom: var(--space-xxxl); }
    .list .table-wrap { overflow: visible; }
    .list table.data thead th { position: sticky; top: var(--appbar); z-index: 1; }
}

@media (max-width: 1023px) {
    .page { padding-top: var(--space-l); }
    .appbar .crumbs { flex-basis: 100%; order: 3; }
}

@media (max-width: 699px) {
    .search { flex-basis: 100%; max-width: none; margin-left: 0; order: 2; }
    .search kbd { display: none; }
}

/* À l'impression : le papier blanc, les barres et les boutons en moins, les cartes qui ne se coupent pas */
@media print {
    body { background: #FFFFFF; color: #000000; }
    .sidebar, .tabbar, .appbar, .back, .actions, .confirm, .skip, .toast .dismiss, .pager nav, .chips { display: none !important; }
    .main { margin-left: 0; }
    .page { max-width: none; padding: 0; }
    .card { break-inside: avoid; border-color: #999999; box-shadow: none; }
    a { color: inherit; text-decoration: none; }
    .pill { border: 1px solid currentColor; }
    .photo img { max-width: 240px; }
}

/* La réussite d'un réseau sur la page Statistiques : une jauge native, sans style en ligne. */
td meter { width: 4rem; height: 0.75rem; vertical-align: middle; margin-right: var(--space-xs); }
/* Parcours : un plantage, une ligne par version touchée */
.crash-version { display: block; }
/* Un code de raison d'échec (`INSUFFICIENT_FUNDS`) : coupé aux soulignés plutôt qu'au milieu d'un mot. */
.code-label { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: var(--text-row-sub); overflow-wrap: anywhere; }
