/* =========================================================================
   Sinistres Équidés — Design system (espace d'administration SaaS)
   Direction : clair & aéré, moderne. Une couleur d'accent (vert émeraude),
   cartes arrondies, ombres douces, typographie et espacements cohérents.
   Les noms de classes et hooks `data-testid` sont un contrat stable (tests
   fonctionnels) : on fait évoluer le style, jamais les sélecteurs.
   ========================================================================= */

:root {
    /* Accent unique — vert émeraude (univers équin / nature) */
    --accent: #0d7d63;
    --accent-strong: #0a6650;
    --accent-dark: #084d3d;
    --accent-soft: #e4f3ee;
    --accent-tint: #eff8f4;
    --accent-ring: rgba(13, 125, 99, .18);

    /* Neutres */
    --bg: #f5f7f9;
    --surface: #ffffff;
    --surface-2: #f8fafb;
    --surface-3: #f2f5f7;
    --border: #e7ebef;
    --border-strong: #d4dae1;
    --text: #131a26;
    --text-soft: #515c6b;
    --text-mute: #8b94a3;

    /* États sémantiques */
    --danger: #c2362a;
    --danger-tint: #fdecea;
    --danger-border: #f4c7c1;
    --success: #14794a;
    --success-tint: #e6f5ec;
    --success-border: #bfe5cd;
    --warning: #a96a12;
    --warning-tint: #fcf2e1;
    --warning-border: #ecd6ad;
    --info: #1565a6;
    --info-tint: #e8f1fa;
    --info-border: #c2dbf0;

    /* Rayons */
    --radius-lg: 16px;
    --radius: 12px;
    --radius-sm: 9px;
    --radius-xs: 6px;

    /* Ombres douces */
    --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04), 0 2px 6px rgba(16, 24, 40, .05);
    --shadow-md: 0 4px 14px rgba(16, 24, 40, .08);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12);

    /* Échelle d'espacement */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-7: 32px;
    --space-8: 40px;

    --sidebar-w: 264px;
    --content-max: 1480px;

    --font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* ---------- Shell ---------------------------------------------------------- */

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

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    color: var(--text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 22px 16px;
    font-weight: 800;
    font-size: 17px;
}
.sidebar__logo {
    font-size: 22px;
    line-height: 1;
    width: 40px; height: 40px;
    display: grid; place-items: center;
    background: var(--accent-soft);
    border-radius: var(--radius);
}
.sidebar__brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.sidebar__brand-text small { font-size: 11px; font-weight: 600; color: var(--accent); letter-spacing: .6px; text-transform: uppercase; }

.sidebar__nav { flex: 1; padding: 8px 14px; overflow-y: auto; }
.sidebar__section {
    margin: 18px 10px 6px;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--text-mute);
    font-weight: 700;
}

.nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-soft);
    font-weight: 600;
    font-size: 13.5px;
    margin-bottom: 2px;
    transition: background .14s, color .14s;
}
.nav-link:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav-link.is-active { background: var(--accent-soft); color: var(--accent-strong); }
.nav-link.is-active::before {
    content: "";
    position: absolute;
    left: -14px; top: 8px; bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--accent);
}
.nav-link__icon { width: 20px; text-align: center; font-size: 15px; opacity: .9; }
.nav-link.is-disabled { color: var(--text-mute); cursor: default; }
.nav-link.is-disabled:hover { background: none; color: var(--text-mute); }
.nav-link__soon {
    margin-left: auto;
    font-size: 10px;
    font-style: normal;
    background: var(--surface-3);
    color: var(--text-mute);
    padding: 1px 7px;
    border-radius: 999px;
}

.sidebar__footer { padding: 12px 14px; border-top: 1px solid var(--border); }
.user-card { display: flex; align-items: center; gap: 10px; padding: 6px; }
.user-card__avatar {
    width: 36px; height: 36px; flex: 0 0 36px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: grid; place-items: center;
    font-weight: 700;
}
.user-card__meta { display: flex; flex-direction: column; min-width: 0; }
.user-card__email { font-size: 12.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 132px; }
.user-card__role { font-size: 11px; color: var(--text-mute); }
.user-card__logout { margin-left: auto; color: var(--text-mute); font-size: 18px; padding: 4px; border-radius: var(--radius-xs); }
.user-card__logout:hover { color: var(--danger); background: var(--danger-tint); text-decoration: none; }

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

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 32px;
    background: rgba(255, 255, 255, .82);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 10;
}
.topbar__title { min-width: 0; }
.topbar__title h1 { margin: 0; font-size: 21px; font-weight: 800; }
.topbar__actions { display: flex; gap: 10px; align-items: center; flex-shrink: 0; }

.breadcrumb { display: inline-block; font-size: 12.5px; font-weight: 600; color: var(--text-mute); margin-bottom: 3px; }
.breadcrumb a { color: var(--text-mute); }
.breadcrumb a:hover { color: var(--accent); }

.content {
    padding: 28px 32px 56px;
    flex: 1;
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
}

/* ---------- Layout : grilles ----------------------------------------------- */

.grid { display: grid; gap: var(--space-5); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
/* Contenu principal large + colonne latérale (pages de détail) */
.grid--main-aside { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); align-items: start; }
.grid--aside-main { grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr); align-items: start; }

.col-span-2 { grid-column: span 2; }
.col-span-full { grid-column: 1 / -1; }

/* Colonne verticale d'espacement homogène (cartes empilées) */
.stack { display: flex; flex-direction: column; gap: var(--space-5); }
.stack--sm { gap: var(--space-3); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }

@media (max-width: 1080px) {
    .grid--3, .grid--4, .grid--main-aside, .grid--aside-main { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
    .grid--2 { grid-template-columns: 1fr; }
    .col-span-2 { grid-column: auto; }
}

/* ---------- Cards ---------------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.card__header {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.card__header h2 { margin: 0; font-size: 14.5px; font-weight: 700; letter-spacing: -.01em; }
.card__header h2 small { display: block; font-size: 12px; font-weight: 500; color: var(--text-mute); letter-spacing: 0; }
.card__body { padding: 20px; }
.card__body--flush { padding: 0; }
.card__body + .card__body, .card__body + .card__body--flush { border-top: 1px solid var(--border); }

/* Sous-section au sein d'une carte : titre de section au-dessus d'un tableau flush */
.card__subhead { padding: 16px 20px 8px; border-top: 1px solid var(--border); }
.card__subhead h3 { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: -.01em; }
.card__subhead p { margin: 4px 0 0; font-size: 12px; color: var(--text-mute); }
.card__subhead + .card__body--flush { border-top: 0; }

/* Carte « accent » (mise en avant, ex. raccourci principal) */
.card--accent { background: linear-gradient(135deg, var(--accent-tint), var(--surface) 70%); border-color: var(--accent-soft); }

/* ---------- KPI / Tableau de bord ------------------------------------------ */

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(212px, 1fr)); gap: var(--space-5); }

.kpi {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
}
.kpi__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kpi__icon {
    width: 38px; height: 38px;
    display: grid; place-items: center;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: 18px;
}
.kpi__label { font-size: 12.5px; font-weight: 600; color: var(--text-mute); }
.kpi__value { font-size: 30px; font-weight: 800; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi__hint { font-size: 12px; color: var(--text-soft); }
.kpi--danger .kpi__icon { background: var(--danger-tint); color: var(--danger); }
.kpi--warning .kpi__icon { background: var(--warning-tint); color: var(--warning); }
.kpi--info .kpi__icon { background: var(--info-tint); color: var(--info); }

/* Raccourcis d'action */
.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-4); }
.action-tile {
    display: flex; align-items: center; gap: 14px;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-xs);
    transition: border-color .14s, box-shadow .14s, transform .14s;
}
.action-tile:hover { text-decoration: none; border-color: var(--accent-soft); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.action-tile__icon {
    width: 42px; height: 42px; flex: 0 0 42px;
    display: grid; place-items: center;
    border-radius: var(--radius-sm);
    background: var(--accent-soft); color: var(--accent-strong);
    font-size: 20px;
}
.action-tile__title { font-weight: 700; font-size: 14px; }
.action-tile__desc { font-size: 12px; color: var(--text-mute); }

/* ---------- Alerts --------------------------------------------------------- */

.alert {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
    border: 1px solid transparent;
    font-weight: 500;
}
.alert::before { font-weight: 700; line-height: 1.4; }
/* Convention : le corps d'une alerte à contenu riche vit dans un unique enfant (ex. <p>) pour ne
   compter que comme un seul flex item à côté de l'icône ; on neutralise sa marge par défaut. */
.alert > p { margin: 0; }
.alert--success { background: var(--success-tint); color: var(--success); border-color: var(--success-border); }
.alert--success::before { content: "✓"; }
.alert--danger, .alert--error { background: var(--danger-tint); color: var(--danger); border-color: var(--danger-border); }
.alert--danger::before, .alert--error::before { content: "⚠"; }
.alert--warning { background: var(--warning-tint); color: var(--warning); border-color: var(--warning-border); }
.alert--warning::before { content: "⚠"; }
.alert--info, .alert--notice { background: var(--info-tint); color: var(--info); border-color: var(--info-border); }
.alert--info::before, .alert--notice::before { content: "ℹ"; }

/* ---------- Buttons -------------------------------------------------------- */

.btn {
    display: inline-flex; align-items: center; gap: 7px;
    font: inherit; font-weight: 600;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .14s, border-color .14s, color .14s, box-shadow .14s, transform .05s;
    text-decoration: none;
    line-height: 1.2;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-xs); }
.btn--primary:hover { background: var(--accent-strong); color: #fff; }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn--secondary:hover { background: var(--surface-2); border-color: var(--text-mute); }
.btn--ghost { background: transparent; color: var(--text-soft); }
.btn--ghost:hover { background: var(--surface-3); color: var(--text); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: #a52a20; color: #fff; }
.btn--sm { padding: 6px 11px; font-size: 12.5px; }
.btn--icon { padding: 7px 9px; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }

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

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 12px 20px; text-align: left; border-bottom: 1px solid var(--border); }
.table thead th {
    background: var(--surface-2);
    font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
    color: var(--text-mute); font-weight: 700;
    position: sticky; top: 0;
}
.table tbody tr { transition: background .12s; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--accent-tint); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn + .btn, .table .actions .btn + form, .table .actions form + .btn { margin-left: 4px; }

/* ---------- Forms ---------------------------------------------------------- */

.form { display: flex; flex-direction: column; gap: 18px; max-width: 560px; }
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row > label { font-weight: 600; font-size: 13px; color: var(--text); }
.form-row .help { font-size: 12px; color: var(--text-mute); }

.input, input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="tel"], select, textarea {
    width: 100%;
    font: inherit;
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    transition: border-color .14s, box-shadow .14s;
}
.input:focus, input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}
textarea { min-height: 96px; resize: vertical; }

.input-group { display: flex; align-items: stretch; }
.input-group .addon {
    display: grid; place-items: center;
    padding: 0 12px;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-left: none;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-mute);
    font-weight: 600;
}
.input-group input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }

.form-error { color: var(--danger); font-size: 12.5px; }
.form-row.has-error input, .form-row.has-error select, .form-row.has-error textarea { border-color: var(--danger); }
ul.form-errors { margin: 4px 0 0; padding-left: 0; list-style: none; }
ul.form-errors li { color: var(--danger); font-size: 12.5px; }

.form-actions { display: flex; gap: 10px; padding-top: 4px; align-items: center; }

/* Groupe de boutons côte à côte (ex. en-tête de carte : importer / saisir). */
.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; }

/* Formulaire compact en ligne (ex. dépôt d'un document). */
.form-inline { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; }
.form-inline .form-row { gap: 6px; }
.form-inline .form-actions { padding-top: 0; }

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

.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: 999px;
    font-size: 12px; font-weight: 600; line-height: 1.45;
    background: var(--surface-3); color: var(--text-soft);
    border: 1px solid transparent;
}
.badge--money { background: var(--accent-tint); color: var(--accent-dark); font-variant-numeric: tabular-nums; }
.badge--statut-actif { background: var(--success-tint); color: var(--success); }
.badge--statut-suspendu { background: var(--warning-tint); color: var(--warning); }
.badge--statut-resilie { background: var(--danger-tint); color: var(--danger); }
/* Statuts de sinistre */
.badge--statut-ouvert { background: var(--info-tint); color: var(--info); }
.badge--statut-en_attente_documents { background: var(--warning-tint); color: var(--warning); }
.badge--statut-demande_euthanasie { background: var(--warning-tint); color: var(--warning); }
.badge--statut-euthanasie_accordee { background: var(--info-tint); color: var(--info); }
.badge--statut-euthanasie_refusee { background: var(--danger-tint); color: var(--danger); }
.badge--statut-en_analyse { background: var(--info-tint); color: var(--info); }
.badge--statut-accord { background: var(--success-tint); color: var(--success); }
.badge--statut-accord_partiel { background: var(--warning-tint); color: var(--warning); }
.badge--statut-refus { background: var(--danger-tint); color: var(--danger); }
.badge--statut-paye { background: var(--accent-tint); color: var(--accent-dark); }
.badge--statut-cloture { background: var(--surface-3); color: var(--text-soft); }

/* Statuts de décision de ligne de facture */
.badge--decision-en_attente { background: var(--warning-tint); color: var(--warning); }
.badge--decision-accepte { background: var(--success-tint); color: var(--success); }
.badge--decision-refuse { background: var(--danger-tint); color: var(--danger); }

/* ---------- Factures : saisie des lignes ----------------------------------- */

.facture-ligne {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}
.facture-ligne__fields {
    flex: 1;
    display: grid;
    grid-template-columns: 1.4fr .8fr 1.2fr;
    gap: 14px;
}
.facture-ligne__remove { flex: 0 0 auto; margin-top: 26px; }

@media (max-width: 720px) {
    .facture-ligne__fields { grid-template-columns: 1fr; }
}

/* Suggestions d'autocomplétion : rattachées à <body> et positionnées en `position:fixed`
   (left/top/width) par le contrôleur Stimulus, pour échapper au rognage des conteneurs ancêtres
   (`overflow:hidden` des cartes, `overflow-x:auto` du tableau de lignes). */
.autocomplete__results {
    position: fixed;
    z-index: 100;
    margin: 4px 0 0;
    padding: 4px;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    max-height: 220px;
    overflow-y: auto;
}
.autocomplete__item {
    padding: 7px 10px;
    border-radius: var(--radius-xs);
    cursor: pointer;
}
.autocomplete__item:hover { background: var(--accent-tint); }

/* ---------- Factures : instruction ligne à ligne --------------------------- */

.facture {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    padding: 16px;
}
.facture + .facture { margin-top: 4px; }
.facture__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.facture .table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.facture__totals { display: flex; gap: 8px; align-items: center; }
.facture__trace { font-size: 11.5px; }

.line-decision { display: flex; flex-direction: column; gap: 8px; min-width: 240px; }
.line-decision__row { display: flex; gap: 8px; align-items: center; }
.line-decision__row input { font-size: 13px; padding: 7px 10px; }

/* Ligne déjà instruite : le formulaire est replié derrière une action discrète. */
.decision-edit { min-width: 240px; }
.decision-edit > summary { display: inline-flex; cursor: pointer; list-style: none; }
.decision-edit > summary::-webkit-details-marker { display: none; }
.decision-edit[open] > summary { margin-bottom: 8px; }

/* ---------- Fieldset ------------------------------------------------------- */

.fieldset, .form-fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px 18px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
    background: var(--surface-2);
}
.fieldset > legend, .form-fieldset > legend {
    padding: 0 8px;
    font-weight: 700;
    font-size: 12.5px;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: .4px;
}

/* ---------- Choix client (contrat) : bascule existant / nouveau ------------ */

.role-choice { display: flex; flex-direction: column; gap: 16px; }
.role-choice__block { display: flex; flex-direction: column; gap: 18px; }
.role-choice__block[hidden] { display: none; }

/* Contrôle segmenté construit sur les radios d'un ChoiceType étendu. */
.segmented { display: inline-flex; align-self: flex-start; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.segmented input[type="radio"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.segmented label {
    margin: 0;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-soft);
    background: var(--surface);
    border-right: 1px solid var(--border-strong);
    cursor: pointer;
    transition: background .14s, color .14s;
}
.segmented label:last-of-type { border-right: none; }
.segmented input[type="radio"]:checked + label { background: var(--accent); color: #fff; }
.segmented input[type="radio"]:focus-visible + label { box-shadow: inset 0 0 0 2px var(--accent-strong); }

/* ---------- Wizard (formulaire multi-étapes, purement visuel) -------------- */

.wizard { display: flex; flex-direction: column; gap: var(--space-6); max-width: none; }

.wizard__progress {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: step;
    gap: 4px;
    flex-wrap: wrap;
}
.wizard__progress li {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 150px;
    color: var(--text-mute);
    font-weight: 600;
    font-size: 13px;
}
.wizard__progress li::before {
    counter-increment: step;
    content: counter(step);
    width: 28px; height: 28px; flex: 0 0 28px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--surface-3);
    color: var(--text-mute);
    font-size: 13px; font-weight: 700;
    border: 1px solid var(--border-strong);
    transition: background .14s, color .14s, border-color .14s;
}
.wizard__progress li::after {
    content: "";
    flex: 1;
    height: 2px;
    background: var(--border);
    border-radius: 2px;
}
.wizard__progress li:last-child::after { display: none; }
.wizard__progress li.is-active { color: var(--accent-strong); }
.wizard__progress li.is-active::before { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.wizard__progress li.is-done { color: var(--text-soft); }
.wizard__progress li.is-done::before { content: "✓"; background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent-soft); }
.wizard__progress li.is-done::after { background: var(--accent-soft); }

.wizard__step { display: flex; flex-direction: column; gap: 18px; }
.wizard__step[hidden] { display: none; }
.wizard__step-head { margin-bottom: 2px; }
.wizard__step-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.wizard__step-head p { margin: 2px 0 0; color: var(--text-mute); font-size: 13px; }

.wizard__nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--border); padding-top: 18px; }
.wizard__nav .spacer { flex: 1; }

.wizard__recap { display: grid; grid-template-columns: 200px 1fr; gap: 10px 16px; margin: 0; }
.wizard__recap dt { font-weight: 600; color: var(--text-soft); }
.wizard__recap dd { margin: 0; color: var(--text); }
.wizard__recap .muted { color: var(--text-mute); }

@media (max-width: 640px) {
    .wizard__progress li { min-width: 0; }
    .wizard__progress li span { display: none; }
    .wizard__recap { grid-template-columns: 1fr; gap: 2px 0; }
    .wizard__recap dt { margin-top: 8px; }
}

/* ---------- Parcours du sinistre (bandeau de suivi / stepper) -------------- */

.parcours {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* Permet au stepper de défiler horizontalement sur les écrans étroits sans casser. */
.parcours__track { overflow-x: auto; }

.parcours__steps {
    display: flex;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
    min-width: min-content;
}

.parcours__step {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1 1 0;
    min-width: 132px;
}
/* Connecteur vers l'étape suivante. */
.parcours__step::after {
    content: "";
    flex: 1;
    min-width: 24px;
    height: 2px;
    background: var(--border);
    border-radius: 2px;
}
.parcours__step:last-child { flex: 0 0 auto; }
.parcours__step:last-child::after { display: none; }

.parcours__marker {
    flex: 0 0 30px;
    width: 30px; height: 30px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--surface-3);
    color: var(--text-mute);
    font-size: 13px; font-weight: 700;
    border: 1px solid var(--border-strong);
    font-variant-numeric: tabular-nums;
    transition: background .14s, color .14s, border-color .14s, box-shadow .14s;
}

.parcours__body { display: flex; flex-direction: column; gap: 4px; }
.parcours__libelle { font-weight: 600; font-size: 13px; color: var(--text-mute); white-space: nowrap; }

.parcours__step.is-fait .parcours__marker {
    background: var(--accent-soft);
    color: var(--accent-strong);
    border-color: var(--accent-soft);
}
.parcours__step.is-fait .parcours__libelle { color: var(--text-soft); }
.parcours__step.is-fait::after { background: var(--accent-soft); }

.parcours__step.is-courant .parcours__marker {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-ring);
}
.parcours__step.is-courant .parcours__libelle { color: var(--text); font-weight: 700; }

.parcours__actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    border-top: 1px solid var(--border);
    padding-top: 16px;
}
.parcours__actions-label { font-weight: 600; font-size: 13px; color: var(--text-soft); }
.parcours__actions-buttons { display: flex; flex-wrap: wrap; gap: 10px; }
.parcours__actions form { margin: 0; }

@media (max-width: 640px) {
    .parcours__actions { align-items: stretch; }
    .parcours__actions-buttons { width: 100%; }
    .parcours__actions-buttons .btn { flex: 1 1 auto; justify-content: center; }
}

/* ---------- Empty state ---------------------------------------------------- */

.empty-state { text-align: center; padding: 52px 24px; color: var(--text-mute); }
.empty-state__icon {
    font-size: 28px;
    width: 60px; height: 60px;
    margin: 0 auto;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--surface-3);
}
.empty-state h3 { margin: 16px 0 4px; color: var(--text); font-size: 16px; }
.empty-state p { margin: 0 0 18px; }

/* ---------- Auth (login) --------------------------------------------------- */

.auth {
    min-height: 100%;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(1200px 600px at 15% -10%, var(--accent-soft), transparent 60%),
        radial-gradient(900px 500px at 100% 110%, var(--accent-tint), transparent 55%),
        var(--bg);
}
.auth__card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 34px 30px;
}
.auth__brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.auth__logo {
    font-size: 24px;
    width: 44px; height: 44px;
    display: grid; place-items: center;
    background: var(--accent-soft);
    border-radius: var(--radius);
}
.auth__brand-text { font-weight: 800; font-size: 18px; color: var(--text); line-height: 1.1; }
.auth__brand-text small { display: block; font-weight: 600; font-size: 11px; color: var(--accent); text-transform: uppercase; letter-spacing: .6px; }
.auth__title { margin: 0 0 4px; font-size: 22px; font-weight: 800; color: var(--text); }
.auth__subtitle { margin: 0 0 24px; color: var(--text-soft); font-size: 13px; }
.auth .form { max-width: none; }
.auth .form-actions { margin-top: 6px; }
.auth .btn--primary { width: 100%; justify-content: center; padding: 11px 16px; }

/* ---------- Key/value list ------------------------------------------------- */

.kv {
    display: grid;
    grid-template-columns: 190px 1fr;
    gap: 12px 16px;
    margin: 0;
}
.kv dt { font-weight: 600; color: var(--text-soft); }
.kv dd { margin: 0; color: var(--text); }

@media (max-width: 540px) {
    .kv { grid-template-columns: 1fr; gap: 2px 0; }
    .kv dt { margin-top: 10px; }
}

/* ---------- Utilities ------------------------------------------------------ */

.page-intro { color: var(--text-soft); margin: -4px 0 22px; max-width: 70ch; }
.muted { color: var(--text-mute); }
.mono { font-family: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }

/* Indicateur d'analyse de l'import de facture (contrôleur Stimulus facture-import). */
.extraction-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text-soft);
    font-weight: 500;
}
.extraction-progress[hidden] { display: none; }
.extraction-progress__spinner {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    border: 2px solid var(--accent-ring);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: extraction-spin .7s linear infinite;
}
@keyframes extraction-spin {
    to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
    .extraction-progress__spinner { animation-duration: 2s; }
}
[data-facture-import-target="zone"][aria-busy="true"] {
    opacity: .55;
    pointer-events: none;
}

/* ---------- Analyse IA du dossier ------------------------------------------ */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.card__header--actions form { margin: 0; }

[data-analyse-dossier-target="resultat"][aria-busy="true"] {
    opacity: .55;
    pointer-events: none;
}

.badge-list { display: flex; flex-wrap: wrap; gap: 6px; }

.badge--verdict-ok { background: var(--success-tint); color: var(--success); }
.badge--verdict-alerte { background: var(--warning-tint); color: var(--warning); }
.badge--verdict-neutre { background: var(--surface-3); color: var(--text-soft); }

.analyse__section { padding: 16px 0; border-top: 1px solid var(--border); }
.analyse__section:first-child { border-top: 0; padding-top: 0; }
.analyse__section h3 {
    margin: 0 0 8px;
    font-size: 13px; font-weight: 700; letter-spacing: -.01em;
    text-transform: uppercase; color: var(--text-mute);
}
.analyse__horodatage { margin: 0 0 4px; font-size: 12px; }
.analyse__explication { margin: 0; line-height: 1.6; color: var(--text); }
.analyse__points { margin: 8px 0 0; padding-left: 18px; color: var(--text-soft); }
.analyse__points li { margin-bottom: 4px; }

/* Chat */
.analyse-chat__fil {
    display: flex; flex-direction: column; gap: 10px;
    max-height: 360px; overflow-y: auto;
    padding: 4px;
    margin-bottom: 12px;
}
.analyse-message {
    display: flex; flex-direction: column; gap: 3px;
    max-width: 85%;
    padding: 9px 13px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface-2);
}
.analyse-message--utilisateur {
    align-self: flex-end;
    background: var(--accent-tint);
    border-color: var(--accent-soft);
}
.analyse-message--assistant { align-self: flex-start; }
.analyse-message__auteur {
    font-size: 11px; font-weight: 700; letter-spacing: .02em;
    text-transform: uppercase; color: var(--text-mute);
}
.analyse-message__contenu { line-height: 1.55; color: var(--text); white-space: pre-line; }

.analyse-chat__form { display: flex; gap: 8px; align-items: flex-end; }
.analyse-chat__form textarea {
    flex: 1 1 auto;
    resize: vertical;
    min-height: 42px;
}
