/* =====================================================================
   IkoDrive — styles applicatifs
   Source de vérité : docs/DESIGN.md (design system du 19/07/2026).
   Deux registres : l'UI utilitaire sur papier chaud (tables, formulaires),
   et la surface Blueprint (grille sombre) pour les moments de marque.
   ===================================================================== */

:root {
    /* ---- Couleurs (DESIGN.md, un-pour-un) ---- */
    --bg: #f5f4f0;
    --surface: #ffffff;
    --ink: #171a21;
    --muted: #6b7280;
    --line: #e4e2db;
    --line-strong: #c9c5b9;
    --accent: #3452e1;
    --accent-hover: #2a44c4;
    --accent-soft: #eef1fd;
    --accent-secondary: #e8b93c;
    --danger: #b3261e;
    --danger-soft: #fdecea;
    --success: #1e7d43;
    --success-soft: #e9f6ee;
    --warning: #8a6d1a;
    --warning-soft: #f7f0dc;

    /* ---- Rayons, ombres ---- */
    --radius: 10px;
    --radius-sm: 6px;
    --radius-pill: 999px;
    --shadow: 0 1px 2px rgba(23, 26, 33, 0.05), 0 8px 24px rgba(23, 26, 33, 0.06);
    --shadow-sm: 0 1px 2px rgba(23, 26, 33, 0.06);
    --shadow-lg: 0 4px 12px rgba(23, 26, 33, 0.08), 0 24px 48px rgba(23, 26, 33, 0.10);

    /* ---- Gabarit ---- */
    --topbar-h: 56px;
    --sidebar-w: 250px;
    --container-max: 1060px;

    /* ---- Typographie ---- */
    --font-sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

    /* ---- Blueprint (surface de marque) ---- */
    --bp-bg: #10131a;
    --bp-grid: rgba(52, 82, 225, 0.14);
    --bp-edge: #6f8cf5;
    --bp-ink: #c9d4fb;
    --bp-grid-size: 32px;

    --focus-ring: 2px solid var(--accent);

    /* ---- Contrôles de formulaire : deux tailles, partagées avec les boutons ---- */
    --control-h: 2.5rem;
    --control-h-sm: 2.1rem;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    letter-spacing: -0.01em;
}

:focus-visible {
    outline: var(--focus-ring);
    outline-offset: 1px;
}

/* ---------- Marque ---------- */

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
}

.brand-mark {
    width: 44px;
    height: 44px;
    display: block;
    flex: none;
}

.brand--compact .brand-mark {
    width: 28px;
    height: 28px;
}

.brand-name {
    font-size: 1.6rem;
    font-weight: 300;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.brand--compact .brand-name {
    font-size: 1.1rem;
}

.brand-name strong {
    font-weight: 700;
}

/* ---------- Blueprint : la surface de marque ----------
   Grille sombre + ticks de repérage + annotations mono. Pour la landing,
   les couvertures de rapport et les en-têtes — JAMAIS derrière les tables. */

.bp {
    position: relative;
    background-color: var(--bp-bg);
    background-image:
        linear-gradient(var(--bp-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--bp-grid) 1px, transparent 1px);
    background-size: var(--bp-grid-size) var(--bp-grid-size);
    color: var(--bp-ink);
}

.bp-tick {
    position: absolute;
    width: 16px;
    height: 16px;
    border: 0 solid var(--bp-edge);
    pointer-events: none;
}

.bp-tick.tl { top: 10px; left: 10px; border-top-width: 2px; border-left-width: 2px; }
.bp-tick.tr { top: 10px; right: 10px; border-top-width: 2px; border-right-width: 2px; }
.bp-tick.bl { bottom: 10px; left: 10px; border-bottom-width: 2px; border-left-width: 2px; }
.bp-tick.br { bottom: 10px; right: 10px; border-bottom-width: 2px; border-right-width: 2px; }

.bp-cross {
    position: absolute;
    top: 22px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--bp-edge);
    pointer-events: none;
}

.bp-titleblock {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: stretch;
    border-top: 1px solid rgba(159, 178, 248, 0.3);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.06em;
    color: var(--bp-edge);
}

.bp-titleblock span {
    padding: 0.55rem 1rem;
    border-right: 1px solid rgba(159, 178, 248, 0.3);
    white-space: nowrap;
}

.bp-titleblock span:first-child {
    color: #ffffff;
    flex: 1;
}

.bp-titleblock span:last-child {
    border-right: 0;
}

/* Le kicker mono : la langue Blueprint sur les écrans propres. */
.kicker {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.05em;
    color: var(--accent);
    margin: 0 0 0.3rem;
}

/* ---------- Landing (backdrop Blueprint) ---------- */

body.landing {
    background: var(--bp-bg);
}

.landing-wrap {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem 4rem;
}

.landing-panel {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
    position: relative;
}

.landing-brand {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.landing-brand .brand-name {
    color: #ffffff;
}

.baseline {
    margin: 0;
    color: var(--bp-ink);
    font-size: 0.98rem;
}

.login-card {
    color: var(--ink);
}

/* ---------- Cartes, alertes ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

.alert {
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.9rem;
    font-size: 0.92rem;
    margin-bottom: 1rem;
}

.alert-error {
    background: var(--danger-soft);
    color: var(--danger);
}

.alert-success {
    background: var(--success-soft);
    color: var(--success);
}

.alert-warning {
    background: var(--warning-soft);
    color: var(--warning);
}

/* ---------- Sélecteur de langue ---------- */

.locale-switch {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.locale-switch a {
    color: var(--bp-ink);
    text-decoration: none;
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-pill);
    transition: background-color 120ms cubic-bezier(0.2, 0, 0, 1), color 120ms cubic-bezier(0.2, 0, 0, 1);
}

.locale-switch a:hover,
.locale-switch a:focus {
    text-decoration: none;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

.locale-switch a.active {
    color: #ffffff;
    background: rgba(111, 140, 245, 0.25);
    font-weight: 600;
}

.locale-sep {
    color: var(--bp-edge);
}

/* ---------- Formulaires ---------- */

.form-row {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 1rem;
}

.form-row label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ink);
}

.form-row .help,
.form-row .form-help {
    font-size: 0.8rem;
    color: var(--muted);
    margin: 0;
}

/* ---------- BASE GLOBALE des contrôles ----------
   Tout input texte, select et textarea est stylé PAR DÉFAUT, sans classe
   (demande Thibault 24/07/2026 : un style de base partout, pas de styles
   au cas par cas). Même hauteur que les boutons (--control-h) ; taille
   compacte via .control-sm, appairée à .btn-sm. */
input[type='text'],
input[type='email'],
input[type='password'],
input[type='number'],
input[type='search'],
select,
textarea {
    appearance: none;
    background-color: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.75rem;
    min-height: var(--control-h);
    font: inherit;
    font-size: 0.92rem;
    color: var(--ink);
}

/* Les selects perdent leur flèche native avec appearance: none — on en
   redessine une (chevron SVG), sinon rien n'indique qu'ils s'ouvrent. */
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.65rem center;
    padding-right: 2.2rem;
}

input:focus,
select:focus,
textarea:focus {
    outline: var(--focus-ring);
    outline-offset: -1px;
    border-color: var(--accent);
}

/* Taille compacte (rangées denses, tableaux) — l'équivalent de .btn-sm.
   Les sélecteurs qualifiés (input.control-sm...) sont OBLIGATOIRES : la
   base `input[type='text']` a une spécificité supérieure à `.control-sm`
   seul — sans eux, les inputs compacts restent à la grande hauteur
   (bug d'alignement remonté par Thibault le 25/07/2026). */
input.control-sm,
select.control-sm,
textarea.control-sm,
.control-sm {
    min-height: var(--control-h-sm);
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
    font-size: 0.85rem;
}

/* Dans un formulaire vertical, les contrôles prennent toute la largeur. */
.form-row input,
.form-row select,
.form-row textarea {
    width: 100%;
}

.form-errors,
.form-row ul {
    margin: 0;
    padding: 0;
    list-style: none;
    color: var(--danger);
    font-size: 0.85rem;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.35rem 1rem;
}

.checkbox-grid label {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-weight: 400;
    font-size: 0.92rem;
}

/* Arbre org cochable : guides d'arborescence dessinés par des spans
   (.tree-guide) — un par niveau, le dernier porte le coude. */
.checkbox-tree {
    display: flex;
    flex-direction: column;
}

.checkbox-tree[hidden] {
    display: none;
}

.checkbox-tree label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.18rem 0;
    font-weight: 400;
    font-size: 0.92rem;
}

.tree-guide {
    flex: none;
    width: 1.15rem;
    align-self: stretch;
    position: relative;
}

.tree-guide::before {
    content: '';
    position: absolute;
    left: 0.55rem;
    top: -0.18rem;
    bottom: -0.18rem;
    border-left: 1px solid var(--line);
}

.tree-guide-elbow::after {
    content: '';
    position: absolute;
    left: 0.55rem;
    top: 50%;
    width: 0.45rem;
    border-top: 1px solid var(--line);
}

/* Nœud impliqué par un ancêtre coché : inclus d'office, non modifiable. */
.checkbox-tree label.implied {
    color: var(--muted);
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1rem;
}

@media (max-width: 640px) {
    .form-grid-2 {
        grid-template-columns: 1fr;
    }
}

/* ---------- Onglets (page compte, extensible) ---------- */

.tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--line);
    margin-bottom: 1.25rem;
}

.tabs a {
    padding: 0.55rem 0.9rem;
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 120ms cubic-bezier(0.2, 0, 0, 1), border-color 120ms cubic-bezier(0.2, 0, 0, 1);
}

.tabs a:hover,
.tabs a:focus {
    text-decoration: none;
    color: var(--ink);
}

.tabs a.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ---------- Boutons & liens stylisés ----------
   Règle maison : jamais de text-decoration au survol d'un lien stylisé en
   bouton/carte — le feedback passe par la couleur et l'élévation. */

/* Un bouton se reconnaît SANS survol : fond, bordure visible, ombre légère
   (retour Thibault 23/07 — le style doit être « rapide à comprendre »). */
.btn,
a.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    padding: 0.45rem 1rem;
    min-height: var(--control-h);
    box-shadow: var(--shadow-sm);
    font: inherit;
    font-weight: 600;
    font-size: 0.92rem;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 120ms cubic-bezier(0.2, 0, 0, 1), border-color 120ms cubic-bezier(0.2, 0, 0, 1), box-shadow 120ms cubic-bezier(0.2, 0, 0, 1);
}

.btn:hover,
.btn:focus {
    border-color: var(--muted);
}

.btn .icon {
    width: 1em;
    height: 1em;
    flex: none;
}

.btn:hover,
.btn:focus,
.btn:active,
a.btn:hover,
a.btn:focus,
a.btn:active {
    text-decoration: none;
}

.btn-primary,
a.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover,
.btn-primary:focus,
a.btn-primary:hover,
a.btn-primary:focus {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #fff;
}

.btn-primary,
a.btn-primary {
    border-color: var(--accent);
}

.btn-ghost,
a.btn-ghost {
    background: transparent;
    color: var(--ink);
    border-color: var(--line-strong);
    box-shadow: none;
}

.btn-ghost:hover,
.btn-ghost:focus,
a.btn-ghost:hover,
a.btn-ghost:focus {
    background: var(--surface);
    border-color: var(--muted);
    color: var(--ink);
}

.btn-danger,
a.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--line-strong);
}

.btn-danger:hover,
.btn-danger:focus {
    background: var(--danger-soft);
    border-color: var(--danger);
    color: var(--danger);
}

/* a.btn-sm qualifié : la base `a.btn` (hauteur standard) a la même
   spécificité qu'un `.btn-sm` seul et gagnerait sur les liens-boutons. */
.btn-sm,
a.btn-sm {
    padding: 0.25rem 0.65rem;
    min-height: var(--control-h-sm);
    font-size: 0.85rem;
}

.btn-block {
    width: 100%;
}

/* ---------- Shell admin : sidebar + topbar ---------- */

.shell {
    display: flex;
    min-height: 100dvh;
}

.nav-toggle {
    display: none;
}

.sidebar {
    width: var(--sidebar-w);
    flex: none;
    background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100dvh;
    overflow-y: auto;
}

/* Le bloc marque de la sidebar a exactement la hauteur de la topbar :
   les deux hairlines se rejoignent au pixel. */
.sidebar .brand-link {
    height: var(--topbar-h);
    flex: none;
    display: flex;
    align-items: center;
    padding: 0 18px;
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid var(--line);
}

.sidebar .brand-link:hover,
.sidebar .brand-link:focus,
.topbar-brand:hover,
.topbar-brand:focus {
    text-decoration: none;
}

.side-nav {
    padding: 0.9rem 0.7rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.nav-group-label {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 0 0.5rem 0.35rem;
}

.side-nav a {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    color: var(--ink);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.93rem;
    padding: 0.42rem 0.6rem;
    border-radius: var(--radius-sm);
    transition: background-color 120ms cubic-bezier(0.2, 0, 0, 1), color 120ms cubic-bezier(0.2, 0, 0, 1);
}

.side-nav a .icon {
    color: var(--muted);
}

.side-nav a.active .icon {
    color: inherit;
}

.side-nav a:hover,
.side-nav a:focus {
    text-decoration: none;
    background: var(--bg);
}

.side-nav a.active {
    color: var(--accent);
    background: var(--accent-soft);
}

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

.topbar {
    height: var(--topbar-h);
    flex: none;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex: none;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--ink);
    font-size: 16px;
    cursor: pointer;
    user-select: none;
}

/* Le logo dans la topbar : uniquement quand la sidebar est repliée (mobile). */
.topbar-brand {
    display: none;
    color: inherit;
    text-decoration: none;
    flex: none;
}

.workspace-label {
    font-size: 13px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.workspace-label strong {
    color: var(--ink);
    font-weight: 600;
}

/* ---------- Menu utilisateur (avatar + dropdown, sans JS) ---------- */

.user-menu {
    position: relative;
    flex: none;
}

.user-menu summary {
    display: flex;
    align-items: center;
    gap: 9px;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    padding: 4px 10px 4px 4px;
    cursor: pointer;
    list-style: none;
    transition: border-color 120ms cubic-bezier(0.2, 0, 0, 1), background-color 120ms cubic-bezier(0.2, 0, 0, 1);
}

.user-menu summary::-webkit-details-marker {
    display: none;
}

.user-menu summary:hover {
    border-color: var(--muted);
}

.user-menu[open] summary {
    background: var(--bg);
}

.avatar {
    width: 28px;
    height: 28px;
    flex: none;
    border-radius: var(--radius-pill);
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

.user-menu .user-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--ink);
    white-space: nowrap;
}

.user-menu .chevron {
    color: var(--muted);
    font-size: 11px;
}

@keyframes ikd-pop {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: none; }
}

.user-menu .menu {
    position: absolute;
    top: 46px;
    right: 0;
    width: 210px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 20;
    animation: ikd-pop 120ms cubic-bezier(0.2, 0, 0, 1);
}

.user-menu .menu-email {
    padding: 8px 10px 6px;
    font-size: 12px;
    color: var(--muted);
    font-family: var(--font-mono);
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-menu .menu-link {
    display: block;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--ink);
    text-decoration: none;
    transition: background-color 120ms cubic-bezier(0.2, 0, 0, 1);
}

.user-menu .menu-link:hover,
.user-menu .menu-link:focus {
    text-decoration: none;
    background: var(--bg);
}

.user-menu .menu-divider {
    height: 1px;
    background: var(--line);
    margin: 6px 4px;
}

.user-menu .menu-signout {
    display: block;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--danger);
    text-decoration: none;
    transition: background-color 120ms cubic-bezier(0.2, 0, 0, 1);
}

.user-menu .menu-signout:hover,
.user-menu .menu-signout:focus {
    text-decoration: none;
    background: var(--danger-soft);
}

.admin-main {
    /* Pleine largeur (Thibault 23/07/2026) : les écrans riches (revue de
       modèle 50/50, listes) exploitent tout l'espace disponible. */
    max-width: none;
    width: 100%;
    margin: 0 auto;
    padding: 1.75rem 1.25rem 3rem;
}

.nav-overlay {
    display: none;
}

@media (max-width: 860px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 30;
        transform: translateX(-100%);
        transition: transform 160ms cubic-bezier(0.2, 0, 0, 1);
        box-shadow: var(--shadow);
    }

    .nav-toggle:checked ~ .sidebar {
        transform: translateX(0);
    }

    .nav-toggle:checked ~ .nav-overlay {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 20;
        background: rgba(23, 26, 33, 0.35);
        cursor: pointer;
    }

    .hamburger {
        display: inline-flex;
    }

    /* Sidebar repliée : le logo prend la priorité dans la topbar. */
    .topbar-brand {
        display: inline-flex;
    }
}

@media (max-width: 640px) {
    /* Le logo garde la priorité : le libellé workspace s'efface d'abord… */
    .workspace-label {
        display: none;
    }
}

@media (max-width: 480px) {
    /* …puis le nom d'utilisateur — l'avatar reste. */
    .user-menu .user-name {
        display: none;
    }
}

/* ---------- Têtes de page ---------- */

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.page-head h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
}

.page-head .sub {
    color: var(--muted);
    font-size: 0.9rem;
    margin: 0.15rem 0 0;
}

/* ---------- Tables ---------- */

.table-card {
    padding: 0;
    overflow-x: auto;
}

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.93rem;
}

table.data th {
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--line);
    background: #faf9f6;
}

table.data td {
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

table.data tr:last-child td {
    border-bottom: none;
}

table.data td.actions {
    text-align: right;
    white-space: nowrap;
}

.tree-indent {
    color: var(--line);
    margin-right: 0.25rem;
}

/* ---------- Badges ---------- */

.badge {
    display: inline-block;
    border-radius: var(--radius-pill);
    padding: 0.1rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.badge-group {
    background: var(--ink);
    color: #fff;
}

.badge-region {
    background: var(--accent-soft);
    color: var(--accent);
}

.badge-site {
    background: var(--success-soft);
    color: var(--success);
}

.badge-code {
    background: var(--warning-soft);
    color: var(--warning);
    font-family: var(--font-mono);
    font-weight: 500;
}

.badge-danger {
    background: var(--danger-soft);
    color: var(--danger);
}

/* ---------- Icônes (sprite Lucide, templates/_icons.html.twig) ---------- */

.icon {
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: none;
}

/* ---------- Champs à suggestions (datalist) ----------
   Un champ texte qui propose AUSSI une liste : même habillage que nos
   inputs, mais un double chevron (haut/bas) pour dire « tapez librement
   ou choisissez » — distinct du chevron simple des selects. */
/* Datalist (« tapez ou choisissez ») : la base globale + un DOUBLE chevron
   haut/bas, distinct du chevron simple des selects. */
input[list] {
    padding-right: 2rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='m4.5 6 3.5-3.5L11.5 6'/%3E%3Cpath fill='none' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='m4.5 10 3.5 3.5L11.5 10'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.55rem center;
}

input[list]:focus {
    outline: var(--focus-ring);
    outline-offset: -1px;
    border-color: var(--accent);
}

/* WebKit ajoute sa propre flèche de datalist : masquée, la nôtre suffit. */
input[list]::-webkit-calendar-picker-indicator {
    display: none !important;
}

/* Fiche d'information (page de détail) : libellé / valeur sur deux colonnes. */
.info-grid {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.45rem 1.5rem;
    margin: 0;
    font-size: 0.9rem;
}

.info-grid dt {
    color: var(--muted);
}

.info-grid dd {
    margin: 0;
}

/* ---------- Menu « Actions » des pages de détail ----------
   Un seul bouton, les actions dedans — jamais une rangée infinie. */
.actions-menu {
    position: relative;
}

.actions-menu > summary {
    list-style: none;
    cursor: pointer;
}

.actions-menu > summary::-webkit-details-marker {
    display: none;
}

.actions-menu .menu {
    position: absolute;
    right: 0;
    margin-top: 0.35rem;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 0.35rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 15rem;
    z-index: 40;
}

.actions-menu .menu form {
    display: contents;
}

.actions-menu .menu .btn {
    width: 100%;
    justify-content: flex-start;
    text-align: left;
    white-space: nowrap;
    border-color: transparent;
    box-shadow: none;
    background: transparent;
}

.actions-menu .menu .btn:hover,
.actions-menu .menu .btn:focus {
    background: var(--bg);
    border-color: transparent;
}

/* ---------- Revue de modèle : écran 50/50 ---------- */

.mapping-layout {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    gap: 1rem;
    align-items: start;
}

.mapping-side {
    position: sticky;
    top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
}

.side-title {
    margin: 0 0 0.35rem;
    font-size: 0.98rem;
}

.side-help {
    margin: 0 0 0.6rem;
    font-size: 0.82rem;
}

/* Checklist des obligatoires : ✗ gris -> ✓ vert quand l'exigence est couverte. */
.req-row[hidden],
.dict-field[hidden],
[data-dict-group][hidden] {
    display: none;
}

.req-row {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.3rem 0;
    font-size: 0.88rem;
}

.req-mark::before {
    content: '✗';
    color: var(--muted);
    font-weight: 700;
}

.req-row.req-ok .req-mark::before {
    content: '✓';
    color: var(--success);
}

.req-alt {
    display: block;
    font-size: 0.75rem;
    font-family: var(--font-mono);
}

/* Dictionnaire de données : champs cochés quand ils sont mappés. */
.dict-panel {
    padding: 1rem 1.25rem;
}

.dict-search {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.65rem;
    font: inherit;
    font-size: 0.88rem;
    margin-bottom: 0.5rem;
}

.dict-group-title {
    margin: 0.75rem 0 0.2rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.dict-field {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.18rem 0;
    font-size: 0.85rem;
}

.dict-check::before {
    content: '○';
    color: var(--line-strong);
}

.dict-field.covered .dict-check::before {
    content: '●';
    color: var(--success);
}

.dict-field.covered .dict-label {
    color: var(--success);
}

.dict-field .badge-code {
    margin-left: auto;
}

.custom-badge {
    display: inline-block;
    margin-top: 0.25rem;
}

.profile-line {
    font-size: 0.78rem;
    margin-top: 0.25rem;
}

@media (max-width: 1100px) {
    .mapping-layout {
        grid-template-columns: 1fr;
    }

    .mapping-side {
        position: static;
        max-height: none;
    }
}

/* ---------- KPI (bandeaux de comptage en tête d'écran) ---------- */

/* Bandeau supérieur des écrans de flux : les KPI à gauche, la carte
   d'action (dépôt) qui absorbe TOUT l'espace restant — pas de vide. */
.import-top {
    display: flex;
    gap: 0.75rem;
    align-items: stretch;
    flex-wrap: wrap;
}

.import-top .upload-card {
    flex: 1 1 24rem;
    padding: 0.85rem 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.45rem;
}

.upload-card h2 {
    margin: 0;
    font-size: 0.95rem;
}

.upload-hint {
    font-weight: 400;
    font-size: 0.8rem;
}

.upload-form {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-top: 0.35rem;
}

.upload-form input[type='file'] {
    flex: 1 1 14rem;
    font-size: 0.85rem;
}

/* Barre d'actions de liste : sélection à gauche, actions à droite. */
.list-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.6rem;
}

.list-actions .list-toolbar {
    margin-bottom: 0;
}

.list-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.kpi-accent .kpi-value {
    color: var(--accent);
}

.kpi {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.15rem;
    padding: 0.85rem 1.25rem;
    min-width: 11rem;
}

.kpi-value {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.kpi-label {
    font-size: 0.83rem;
    color: var(--muted);
}

.kpi-of {
    font-size: 1rem;
    font-weight: 600;
    color: var(--muted);
}

.kpi-danger .kpi-value {
    color: var(--danger, #b4231f);
}

/* ---------- Barre de pipeline des imports (4 segments par fichier) ----------
   Vert = étape finie · bleu animé = en cours · bleu partiel = % réel ·
   ambre = main à l'humain (modèle à créer) · rouge = erreur · gris = à venir. */

.pipe-bar {
    display: flex;
    gap: 3px;
    margin-top: 0.5rem;
    height: 5px;
}

.pipe-seg {
    flex: 1;
    position: relative;
    border-radius: 999px;
    background: var(--line);
    overflow: hidden;
}

.pipe-done { background: var(--success); }
.pipe-error { background: var(--danger); }
.pipe-wait { background: var(--accent-secondary); }

.pipe-current {
    background: var(--accent-soft);
}

.pipe-dot.pipe-current { background: var(--accent); }

/* L'animation appartient au SEGMENT de barre, jamais à la pastille du
   popover qui réutilise les mêmes classes d'état : sans le `.pipe-seg`,
   le ::after (position: absolute) s'échappait de la pastille — non
   positionnée — et venait recouvrir tout le popover d'un dégradé bleu
   animé (bug remonté par Thibault le 26/07/2026). */
.pipe-seg.pipe-current:not(:has(.pipe-fill))::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    animation: pipe-sweep 1.4s ease-in-out infinite;
}

/* Ceinture et bretelles : une pastille ne laisse rien s'en échapper. */
.pipe-dot { position: relative; overflow: hidden; }

.pipe-partial { background: var(--line); }

.pipe-fill {
    position: absolute;
    inset: 0 auto 0 0;
    background: var(--accent);
    border-radius: inherit;
    transition: width 0.4s ease;
}

/* Partiel = TERMINÉ avec un taux de couverture (vert), pas « en cours » —
   le reste n'attend rien dans le pipeline (inclassables, revue humaine). */
.pipe-partial .pipe-fill { background: var(--success); }

/* Popover d'explication : survol de la barre -> l'état de chaque étape. */
.pipe-wrap { position: relative; }

.pipe-pop {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    z-index: 20;
    padding: 0.65rem 0.85rem;
    min-width: 17rem;
    box-shadow: var(--shadow-lg);
    font-size: 0.83rem;
}

.pipe-wrap:hover .pipe-pop { display: block; }

.pipe-pop-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.15rem 0;
}

.pipe-pop-name { font-weight: 600; flex: 1; }

.pipe-dot {
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    flex: none;
    background: var(--line);
}

.pipe-dot.pipe-done, .pipe-dot.pipe-partial { background: var(--success); }
.pipe-dot.pipe-current { background: var(--accent); }
.pipe-dot.pipe-wait { background: var(--accent-secondary); }
.pipe-dot.pipe-error { background: var(--danger); }

@keyframes pipe-sweep {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ---------- Rapport de transformation (page de détail d'import) ----------
   Rail de synthèse sticky à gauche, la preuve champ par champ à droite —
   la composition tient le grand écran au lieu de s'étirer. */

.report-layout {
    display: grid;
    grid-template-columns: minmax(19rem, 23rem) minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}

@media (max-width: 1100px) {
    .report-layout { grid-template-columns: minmax(0, 1fr); }
}

.report-rail {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    position: sticky;
    top: calc(var(--topbar-h) + 1rem);
}

@media (max-width: 1100px) {
    .report-rail { position: static; }
}

.rail-title {
    margin: 0 0 0.75rem;
    font-size: 0.95rem;
}

.rail-note { margin: 0.75rem 0 0; font-size: 0.83rem; }

/* Stepper VERTICAL : ligne connectrice + pastilles. */
.vstepper {
    list-style: none;
    margin: 0;
    padding: 0;
}

.vstep {
    display: flex;
    gap: 0.65rem;
    position: relative;
    padding-bottom: 1rem;
}

.vstep:last-child { padding-bottom: 0; }

.vstep::before {
    content: '';
    position: absolute;
    left: 0.72rem;
    top: 1.6rem;
    bottom: 0.1rem;
    width: 2px;
    background: var(--line);
}

.vstep:last-child::before { display: none; }
.vstep-done::before, .vstep-partial::before { background: var(--success); }

.vstep-body { flex: 1; min-width: 0; }
.vstep .step-name { display: block; }
.vstep .step-bar { margin-top: 0.3rem; }

/* Le flux brut -> produit. */
.flow-source {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.flow-arrow {
    color: var(--muted);
    padding: 0.15rem 0 0.15rem 0.3rem;
    font-size: 0.9rem;
}

.flow-out {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.flow-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.88rem;
}

.flow-item .icon { color: var(--accent); flex: none; }
.flow-item.muted .icon { color: var(--muted); }

/* Le tableau unifié champ par champ. */
.report-table-card { padding: 0; }

.report-table-head {
    padding: 1.25rem 1.5rem 0.75rem;
}

.report-table-head h2 { margin: 0 0 0.25rem; font-size: 1.05rem; }
.report-table-head p { margin: 0; font-size: 0.85rem; }

.report-group td {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    background: var(--accent-soft);
    padding-top: 0.45rem;
    padding-bottom: 0.45rem;
}

.report-synthesis td { background: color-mix(in srgb, var(--accent-soft) 40%, transparent); }
.report-synthesis .report-field { font-weight: 600; }

.report-bar-cell { min-width: 12rem; }

.bar-line {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.bar-pct { font-size: 0.9rem; font-variant-numeric: tabular-nums; }

.report-bar-cell .quality-bar { display: block; width: 100%; margin: 0; }

.report-breakdown { font-size: 0.74rem; margin-top: 0.25rem; }

.report-asis { font-size: 0.83rem; }
.report-transform { display: block; font-size: 0.76rem; margin-top: 0.15rem; }
.report-counts { font-size: 0.76rem; font-variant-numeric: tabular-nums; }
.verdict-file-low { background: var(--danger-soft); color: var(--danger); }
.report-foot { margin: 0; padding: 0.75rem 1.5rem 1.1rem; font-size: 0.82rem; }

.verdict {
    display: inline-block;
    padding: 0.12rem 0.55rem;
    border-radius: var(--radius-pill);
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.verdict-ok { background: var(--success-soft); color: var(--success); }
.verdict-file { background: var(--warning-soft); color: var(--warning); }
.verdict-learn { background: var(--accent-soft); color: var(--accent); }
.verdict-bad { background: var(--danger-soft); color: var(--danger); }
.verdict-stored { background: var(--bg); color: var(--muted); }

/* ---------- Stepper d'avancement (page de détail d'import) ---------- */

.stepper {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: 1.25rem;
}

.step-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.45rem;
}

.step-dot {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 700;
    background: var(--line);
    color: var(--muted);
    flex: none;
}

.step-dot.pipe-done, .step-dot.pipe-partial { background: var(--success); color: #fff; }
.step-dot.pipe-current { background: var(--accent); color: #fff; }
.step-dot.pipe-wait { background: var(--accent-secondary); color: #fff; }
.step-dot.pipe-error { background: var(--danger); color: #fff; }

.step-name { font-weight: 600; font-size: 0.9rem; }
.step-bar { margin: 0 0 0.35rem; }
.step-state { font-size: 0.8rem; display: block; }

.step-sweep {
    width: 40%;
    animation: pipe-sweep 1.4s ease-in-out infinite;
    background: var(--accent);
}

.step-wait { background: var(--accent-secondary); }

/* Tuiles de stats avec icône. */
.stat-icon {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
}

.stat-ic {
    width: 1.15rem;
    height: 1.15rem;
    color: var(--accent);
    margin-top: 0.3rem;
    flex: none;
}

.stat-warn .stat-ic { color: var(--warning); }

.match-good { color: var(--success); }
.match-mid { color: var(--warning); }
.match-low { color: var(--danger); }

/* ---------- Check qualité d'un fichier (page de détail d'import) ---------- */

.quality-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
    gap: 1.5rem 2.5rem;
}

.quality-group {
    margin: 0 0 0.5rem;
    font-size: 0.9rem;
}

.quality-row {
    display: grid;
    grid-template-columns: 11rem 1fr 3.2rem;
    align-items: center;
    gap: 0.6rem;
    padding: 0.18rem 0;
    font-size: 0.85rem;
}

.quality-label { color: var(--muted); }
.quality-bar { margin: 0; }
.quality-pct { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.kpi-bar-fill.quality-good { background: var(--success); }
.kpi-bar-fill.quality-mid { background: var(--accent-secondary); }
.kpi-bar-fill.quality-low { background: var(--danger); }

/* ---------- Section Données (aperçu couche 3) ---------- */

.data-search {
    display: flex;
    gap: 0.6rem;
}

.data-search input[type='search'] {
    flex: 1;
    max-width: 26rem;
}

.attach-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* ---------- Tableau de bord des imports (étapes du pipeline) ---------- */

.dash-step-head {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    margin-bottom: 1rem;
}

.dash-step-head > div { flex: 1; }
.dash-step-head h2 { margin: 0; font-size: 1.02rem; }
.dash-step-head p { margin: 0.15rem 0 0; font-size: 0.85rem; }

.dash-step-no {
    flex: none;
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.stat-row {
    /* Grille auto-alignée : colonnes uniformes, jamais de KPI orphelin qui
       « saute » — une rangée incomplète garde les mêmes largeurs. */
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    gap: 1.25rem 1.75rem;
    align-items: start;
}

.stat { min-width: 0; }

.stat-value {
    display: block;
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.stat-label { font-size: 0.82rem; color: var(--muted); }
.stat-live .stat-value { color: var(--accent); }
.stat-warn .stat-value { color: var(--warning); }
.stat-danger .stat-value { color: var(--danger); }

.dash-table { margin-top: 1rem; }

/* Règle générale (Thibault 24/07/2026) : un tableau posé dans une card
   REMPLIE (padding 1.5rem) file bord à bord — il déborde du padding et
   prend 100 % de la largeur de la card. Les cards 100 % tableau utilisent
   .table-card (padding: 0), déjà bord à bord. */
.card:not(.table-card) > table.data {
    width: calc(100% + 3rem);
    max-width: none;
    margin-left: -1.5rem;
    margin-right: -1.5rem;
}

.card:not(.table-card) > table.data:last-child {
    margin-bottom: -1.5rem;
}

/* Le bas du tableau épouse les coins arrondis de la card. */
.card:not(.table-card) > table.data:last-child tr:last-child td:first-child { border-bottom-left-radius: var(--radius); }
.card:not(.table-card) > table.data:last-child tr:last-child td:last-child { border-bottom-right-radius: var(--radius); }

.dash-progress { margin-top: 1rem; }
.dash-progress-text { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.35rem; }

/* La tuile de progression porte un libellé long : elle doit pouvoir
   rétrécir (min-width: 0) pour rester sur la rangée du bandeau. */
.kpi-progress {
    flex: 1 1 16rem;
    min-width: 0;
}

/* Barre d'avancement du traitement (tuile KPI pendant qu'un dépôt tourne). */
.kpi-bar {
    display: block;
    height: 5px;
    border-radius: 999px;
    background: var(--line);
    overflow: hidden;
    margin-top: 0.35rem;
}

.kpi-bar-fill {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
    transition: width 0.4s ease;
}

/* ---------- Listes en cards (objets riches / affichage par état) ---------- */

.list-toolbar {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    cursor: pointer;
    margin-bottom: 0.6rem;
    user-select: none;
}

.import-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.import-card {
    display: flex;
    align-items: flex-start;
    gap: 0.9rem;
    padding: 0.85rem 1.1rem;
}

.import-select {
    width: 1.1rem;
    padding-top: 0.15rem;
}

.import-main {
    flex: 1;
    min-width: 0;
}

.import-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.import-name {
    font-size: 0.88rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.import-meta {
    font-size: 0.83rem;
    margin-top: 0.2rem;
}

.import-detail {
    font-size: 0.83rem;
    margin-top: 0.35rem;
}

.import-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
    align-items: center;
}

@media (max-width: 640px) {
    .import-card {
        flex-wrap: wrap;
    }

    .import-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

.badge-warning {
    background: var(--warning-soft);
    color: var(--warning);
}

.badge-success {
    background: var(--success-soft);
    color: var(--success);
}
.muted {
    color: var(--muted);
}

/* Revue de template : échantillons de valeurs source et helper de dictionnaire */
.samples-cell {
    max-width: 22rem;
}

.sample-chip {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
    margin: 0.1rem 0.25rem 0.1rem 0;
    padding: 0.05rem 0.45rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-family: var(--font-mono);
    font-size: 0.76rem;
    color: var(--muted);
}

.target-help {
    display: block;
    margin-top: 0.3rem;
    font-size: 0.78rem;
    min-height: 1em;
}

/* Onglets de section (Flow : Imports / Templates) */
.tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.1rem;
    border-bottom: 1px solid var(--line);
}

.tabs a {
    padding: 0.45rem 0.9rem;
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.tabs a:hover,
.tabs a:focus {
    color: var(--ink);
    text-decoration: none;
}

.tabs a.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.mono {
    font-family: var(--font-mono);
}

.inline-form {
    display: inline;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.row-form {
    display: flex;
    gap: 0.6rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.row-form .form-row {
    margin-bottom: 0;
    flex: 1 1 140px;
}

.form-actions {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    margin-top: 1.25rem;
}

/* ---- Revue unifiée : menu des dictionnaires à gauche + liste ---- */
.review-layout {
    display: grid;
    grid-template-columns: minmax(15rem, 18rem) minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}
.review-rail {
    position: sticky;
    top: calc(var(--topbar-h) + 1rem);
}
.review-scopes { display: flex; flex-direction: column; gap: 0.6rem; }
.review-scope-group {
    border: 1px solid color-mix(in srgb, var(--ink) 10%, transparent);
    border-radius: 8px;
    padding: 0.4rem 0.5rem;
}
.review-scope-group.active { border-color: color-mix(in srgb, var(--ink) 35%, transparent); }
.review-scope-group .scope-name {
    display: block;
    font-weight: 600;
    font-size: 0.88rem;
    padding: 0.1rem 0.35rem 0.25rem;
}
.scope-view {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.28rem 0.35rem;
    border-radius: 6px;
    text-decoration: none;
    color: inherit;
    font-size: 0.85rem;
}
.scope-view:hover, .scope-view:focus, .scope-view:active {
    text-decoration: none;
    background: color-mix(in srgb, var(--ink) 6%, transparent);
}
.scope-view.active { background: color-mix(in srgb, var(--ink) 10%, transparent); font-weight: 600; }
.scope-view.done { color: color-mix(in srgb, var(--ink) 55%, transparent); }
.review-context-title { margin: 0 0 0.35rem; font-size: 1rem; }
/* Tous les selects d'action à la MÊME largeur, quelle que soit l'option. */
.review-table .review-col-action { width: 17rem; }
.review-table .review-select { width: 100%; max-width: 17rem; }
@media (max-width: 1100px) {
    .review-layout { grid-template-columns: minmax(0, 1fr); }
    /* Sur écran étroit, le menu passe AU-DESSUS de la liste, en grille
       compacte : on choisit le dictionnaire avant de classer. */
    .review-rail { position: static; }
    .review-scopes {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(8.25rem, 1fr));
        gap: 0.6rem;
    }
    .review-scope-group .scope-name { font-size: 0.82rem; }
    .scope-view { font-size: 0.78rem; padding: 0.24rem 0.25rem; white-space: nowrap; }
    .scope-view .badge { font-size: 0.68rem; }
}

/* Onglets sur écran étroit : ils défilent horizontalement au lieu de
   déborder de la page (le débordement forçait un scroll de tout l'écran). */
@media (max-width: 900px) {
    .tabs { overflow-x: auto; }
    .tabs a { white-space: nowrap; flex: 0 0 auto; }
    .review-table .review-col-action { width: auto; }
    .review-table .review-select { max-width: 100%; min-width: 11rem; }
}

/* Fiche d'entrée de référentiel : ajout manuel d'une référence. */
.entry-add { display: flex; align-items: center; gap: 0.75rem; padding: 0.85rem 1rem; }
@media (max-width: 700px) { .entry-add { flex-wrap: wrap; } }

/* Échantillon des données sources (revue / fiche) */
.sample-btn {
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    padding: 0.1rem 0.25rem;
    border-radius: 4px;
    vertical-align: middle;
}
.sample-btn:hover, .sample-btn:focus { color: var(--accent); background: color-mix(in srgb, var(--ink) 6%, transparent); }
.sample-panel { margin-top: 0.45rem; font-family: var(--font-sans); }
.sample-cards { display: flex; flex-direction: column; gap: 0.4rem; }
.sample-card {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0.45rem 0.6rem;
    background: color-mix(in srgb, var(--ink) 2.5%, var(--surface));
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: 0.1rem 1rem;
}
.sample-pair { display: flex; gap: 0.5rem; font-size: 0.8rem; min-width: 0; }
.sample-pair code { color: var(--muted); flex: none; }
.sample-pair span { overflow-wrap: anywhere; }

/* Raccourci « Confirmer » à côté du sélecteur d'action */
.review-col-action { white-space: nowrap; }
.confirm-quick { vertical-align: middle; margin-right: 0.3rem; padding-inline: 0.45rem; }
.review-col-action:has(.confirm-quick) .review-select { width: calc(100% - 2.6rem); }

/* Champ « créer une entrée » de la revue : en BLOC sous le sélecteur —
   jamais en ligne (la cellule est nowrap, il ferait déborder le tableau). */
.review-create { display: block; margin-top: 0.35rem; width: 100%; max-width: 17rem; }
.review-create[hidden] { display: none; }

/* Filtres des pages Catalogue */
.catalog-filters { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.catalog-filters input[name="q"] { min-width: 16rem; }

/* ---- Marquage de l'intention dans la revue (valider / changer / retirer) ----
   Le fond porte la couleur sur les CELLULES (une couleur posée sur <tr> est
   masquée par le fond des <td>), plus un liseré à gauche de la ligne. */
tr.row-confirm > td { background: var(--success-soft); }
tr.row-change  > td { background: var(--warning-soft); }
tr.row-retire  > td { background: var(--danger-soft); }
tr.row-confirm > td:first-child { box-shadow: inset 3px 0 0 var(--success); }
tr.row-change  > td:first-child { box-shadow: inset 3px 0 0 var(--warning); }
tr.row-retire  > td:first-child { box-shadow: inset 3px 0 0 var(--danger); }

/* ---- Revue en CARDS (règle cards vs table : l'affichage varie selon
   l'état de la référence — verdict IA, volumes, actions conditionnelles). */
.review-cards { display: flex; flex-direction: column; gap: 0.55rem; }

.review-card {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 3px solid transparent;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 0.8rem 1rem;
}
.review-card.row-confirm { background: var(--success-soft); border-left-color: var(--success); }
.review-card.row-change  { background: var(--warning-soft); border-left-color: var(--warning); }
.review-card.row-retire  { background: var(--danger-soft);  border-left-color: var(--danger); }

.review-card-body { min-width: 0; flex: 1; }
.review-card-raw { margin: 0; display: flex; align-items: center; gap: 0.35rem; }
.review-card-raw .mono { font-size: 0.9rem; overflow-wrap: anywhere; }

.review-card-meta {
    margin: 0.3rem 0 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1rem;
    font-size: 0.83rem;
    color: var(--muted);
}
.meta-item { display: inline-flex; align-items: center; gap: 0.3rem; white-space: nowrap; }
.meta-item .icon { width: 0.95em; height: 0.95em; }
.meta-item strong { color: var(--ink); }
.meta-verdict strong { font-weight: 600; }

.review-card-action { flex: none; width: 17rem; }
.review-card-picker { display: flex; align-items: center; gap: 0.3rem; }
.review-card-action .review-select { flex: 1; min-width: 0; }
.review-card-action .review-create { max-width: none; }

@media (max-width: 800px) {
    .review-card { flex-direction: column; gap: 0.6rem; }
    .review-card-action { width: 100%; }
}

.row-flag {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    border-radius: var(--radius-pill);
    padding: 0.1rem 0.5rem;
    width: fit-content;
}
.row-flag[hidden] { display: none; }
.row-flag-confirm { background: var(--success); color: #fff; }
.row-flag-change  { background: var(--warning); color: #fff; }
.row-flag-retire  { background: var(--danger); color: #fff; }

/* Progression globale du traitement (page Imports) */
.global-progress { padding: 0.9rem 1.1rem; }
.gp-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.gp-title { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 600; }
.gp-figures { display: inline-flex; align-items: baseline; gap: 0.5rem; }
.gp-figures strong { font-size: 1.15rem; }
.gp-bar { display: block; margin-top: 0.5rem; }
.gp-note { margin: 0.45rem 0 0; font-size: 0.83rem; }
.gp-spin { animation: gp-rotate 1.4s linear infinite; }
@keyframes gp-rotate { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .gp-spin { animation: none; } }

.gp-sep { opacity: 0.5; }

/* ---------- Section Données (Radar · Data) : fiches et listes ----------
   Retenue par Thibault le 15/09/2026 parmi huit maquettes (école apple-design,
   rhabillée avec la charte) : hiérarchie par le poids, une matière
   translucide pour la barre, l'identité sur la surface Blueprint, feedback au
   pointer-down. Un chiffre = un document. */

.data { display: flex; flex-direction: column; gap: 1.25rem; }

.data-bar {
    position: sticky;
    top: 0;
    z-index: 5;
    margin: -1.75rem -1.25rem 0;
    padding: 0.7rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    font-size: 0.9rem;
    background: rgba(245, 244, 240, 0.78);
    backdrop-filter: blur(18px) saturate(160%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    border-bottom: 1px solid rgba(201, 197, 185, 0.5);
}

.data-bar a { color: var(--accent); font-weight: 500; text-decoration: none; transition: opacity 100ms; }
.data-bar a:hover, .data-bar a:focus { text-decoration: none; }
.data-bar a:active { opacity: 0.4; }
.data-bar .mono { flex: 1; text-align: center; font-weight: 600; letter-spacing: 0.02em; }
.data-bar-ph { width: 5rem; }
.data-bar .tabs { margin: 0; border: 0; }
.data-bar .data-search { margin-left: auto; }
.data-bar .data-search input[type='search'] { height: var(--control-h-sm); min-width: 14rem; }
.data-bar .data-search select { height: var(--control-h-sm); }
.data-grid > .data-k { grid-column: span 12; margin: 0.25rem 0 -0.25rem; }
.data-plate-amount { font-family: var(--font-mono); font-size: clamp(30px, 4.5vw, 42px); font-weight: 600; letter-spacing: -0.02em; color: #ffffff; margin: 0 0 0.6rem; line-height: 1.05; }
.data-table a { color: var(--ink); text-decoration: none; font-weight: 500; }
.data-table a:hover, .data-table a:focus { color: var(--accent); text-decoration: none; }
.data-table tr.is-muted td { color: var(--muted); }
.data-tl-n.is-plain { font-family: var(--font-mono); font-weight: 500; }

.data-plate {
    border-radius: var(--radius);
    overflow: hidden;
    padding: 2.25rem 1.75rem 1.9rem;
}

.data-plate h1 {
    margin: 0 0 0.6rem;
    font-size: clamp(30px, 4.5vw, 42px);
    line-height: 1.05;
    letter-spacing: -0.02em;
    font-weight: 700;
    color: #ffffff;
    text-wrap: balance;
}

.data-plate .kicker { color: var(--bp-edge); margin: 0 0 0.4rem; }

.data-plate-sub {
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
    align-items: center;
    font-size: 0.9rem;
    color: var(--bp-ink);
}

.data-plate-sub .mono { color: #ffffff; font-size: 0.85rem; letter-spacing: 0.03em; }

.data-pill {
    display: inline-block;
    padding: 1px 9px;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    border: 1px solid var(--bp-edge);
    color: #ffffff;
}

.data-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1rem;
}

.data-grid .card { min-width: 0; padding: 1.25rem; }
.data-c4 { grid-column: span 4; }
.data-c6 { grid-column: span 6; }
.data-c8 { grid-column: span 8; }
.data-c12 { grid-column: span 12; }

.data-k {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.05em;
    color: var(--accent);
    margin: 0 0 0.75rem;
}

.vehicle-big {
    font-family: var(--font-mono);
    font-size: clamp(34px, 4.5vw, 48px);
    line-height: 1;
    letter-spacing: -0.02em;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.vehicle-big small {
    font-family: var(--font-sans);
    font-size: 0.4em;
    font-weight: 500;
    color: var(--muted);
    letter-spacing: 0;
    margin-left: 6px;
}

.data-meta { color: var(--muted); font-size: 0.9rem; margin: 0.4rem 0 0; }

.data-dl {
    margin: 1rem 0 0;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem 1rem;
    font-size: 0.9rem;
}

.data-dl dt { color: var(--muted); }
.data-dl dd { margin: 0; font-weight: 500; }

.data-col { display: flex; flex-direction: column; gap: 1rem; }
.data-fill { flex: 1; }

/* La courbe prend la hauteur de la colonne voisine : le SVG s'étire
   (preserveAspectRatio none), les points et libellés restent en HTML. */
.vehicle-chart-card { display: flex; flex-direction: column; }
.vehicle-chart-wrap { position: relative; flex: 1; min-height: 200px; }
.vehicle-chart { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.vehicle-chart-layer { position: absolute; inset: 0; }

.vehicle-chart-y {
    position: absolute;
    right: 0;
    transform: translateY(-100%);
    padding-bottom: 3px;
    font-size: 11px;
    color: var(--muted);
}

.vehicle-dot {
    position: absolute;
    width: 11px;
    height: 11px;
    margin: -5.5px 0 0 -5.5px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--accent);
    transition: transform 120ms ease-out;
}

.vehicle-dot.is-last { background: var(--accent); width: 13px; height: 13px; margin: -6.5px 0 0 -6.5px; }
.vehicle-dot.is-drop { border-color: var(--accent-secondary); border-style: dashed; }
.vehicle-dot:hover, .vehicle-dot:focus-visible { transform: scale(1.4); z-index: 1; }
.vehicle-dot:focus-visible { outline: var(--focus-ring); outline-offset: 3px; }

.vehicle-dot-tip {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.3rem 0.55rem;
    border-radius: var(--radius-sm);
    background: var(--ink);
    color: #ffffff;
    font-size: 0.75rem;
    font-family: var(--font-sans);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 150ms ease-out;
}

.vehicle-dot:hover .vehicle-dot-tip, .vehicle-dot:focus-visible .vehicle-dot-tip { opacity: 1; }

.vehicle-chart-axis {
    position: relative;
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 11px;
    color: var(--muted);
}

.vehicle-chart-tick { position: absolute; transform: translateX(-50%); }

/* Frise des clients : un rail, un point coloré par classe de payeur. */
.data-tl { list-style: none; margin: 0; padding: 0; position: relative; }

.data-tl::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: var(--line);
    border-radius: 1px;
}

.data-tl li {
    position: relative;
    padding: 0.5rem 0.5rem 0.5rem 1.75rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px 0.75rem;
    align-items: baseline;
    border-radius: var(--radius-sm);
    transition: transform 120ms ease-out, background 120ms;
}

.data-tl li:active { transform: scale(0.985); background: var(--accent-soft); }

.data-tl li::before {
    content: '';
    position: absolute;
    left: 2px;
    top: 15px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--surface);
    border: 3px solid var(--dot, var(--accent));
    /* `* { box-sizing }` ne touche pas les pseudo-éléments : sans ceci la
       bordure élargit le point de 6 px et le décale du rail. */
    box-sizing: border-box;
}

.data-tl-n { font-weight: 600; color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-tl-n:hover, .data-tl-n:focus { color: var(--accent); text-decoration: none; }
.data-tl-n.is-empty { color: var(--muted); font-weight: 400; font-style: italic; }
.data-tl-d { grid-row: 2; color: var(--muted); font-size: 0.82rem; font-family: var(--font-mono); }
.data-tl-a { font-family: var(--font-mono); font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.data-tl-p { grid-column: 2; grid-row: 2; font-size: 0.75rem; font-weight: 600; text-align: right; color: var(--pc, var(--accent)); }

/* Dépenses : une barre par catégorie, sa part du plus gros poste. */
.data-tot {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin: 0 0 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--line);
}

.data-tot .data-meta { margin: 0; }
.data-tot .mono { font-weight: 600; font-size: 1.1rem; font-variant-numeric: tabular-nums; }

.vehicle-sp { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }

.vehicle-sp li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px 0.75rem;
    align-items: baseline;
}

.vehicle-sp-l { font-size: 0.9rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vehicle-sp-v { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 600; font-size: 0.9rem; }

.vehicle-sp-b {
    grid-column: 1 / -1;
    height: 8px;
    border-radius: 4px;
    background: var(--bg);
    border: 1px solid var(--line);
    overflow: hidden;
}

.vehicle-sp-b i {
    display: block;
    height: 100%;
    width: var(--w);
    background: var(--c, var(--accent));
    transform-origin: left;
    animation: vehicle-grow 600ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes vehicle-grow { from { transform: scaleX(0); } }

.vehicle-sp-m { grid-column: 1 / -1; font-size: 0.75rem; color: var(--muted); margin-top: -2px; }
.vehicle-sp-zero { margin-top: 0.9rem; font-size: 0.8rem; }

/* Documents : la preuve, ligne par ligne. */
.data-tw { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
}

.data-table th {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
    text-align: left;
    padding: 0 0.6rem 0.6rem;
    white-space: nowrap;
}

.data-table td { padding: 0.6rem; border-top: 1px solid var(--line); vertical-align: baseline; }
.data-table th.r, .data-table td.r { text-align: right; }
.data-table td:first-child, .data-table th:first-child { padding-left: 0; }
.data-table td:last-child, .data-table th:last-child { padding-right: 0; }
.data-table tr:active td { background: var(--accent-soft); }
.data-table td.is-drop { color: var(--warning); font-weight: 600; }
.data-dash { color: var(--line-strong); }

.data-type {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-soft);
    border-radius: var(--radius-sm);
    padding: 2px 7px;
    white-space: nowrap;
}

.data-type.is-sale { color: var(--success); background: var(--success-soft); }

@media (max-width: 900px) {
    .data-c4, .data-c6, .data-c8 { grid-column: span 12; }
}

@media (max-width: 640px) {
    .data-grid .card { padding: 1rem; }
    .data-plate { padding: 1.75rem 1.25rem 1.5rem; }
    .data-table .hide-s { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .vehicle-sp-b i { animation: none; }
    .data-tl li, .data-bar a, .vehicle-dot, .vehicle-dot-tip { transition: none; }
}

@media (prefers-reduced-transparency: reduce) {
    .data-bar { background: var(--bg); backdrop-filter: none; }
}
