/* ==========================================================================
   Factures — styles de base (mobile-first)
   ========================================================================== */

/* ---- Design tokens ---------------------------------------------------- */
:root {
    /* Couleurs de la Côte d'Ivoire : orange #F77F00, blanc, vert #009E60 */
    --c-ink: #03331f;            /* fond marque : vert profond */
    --c-bg: #f4f6f9;
    --c-surface: #ffffff;
    --c-field: #ffffff;
    --c-text: #10201a;
    --c-muted: #5b6678;
    --c-border: #d9dee7;
    --c-border-strong: #b7c0cf;

    --c-brand: #f77f00;          /* orange CI ; texte foncé dessus (8:1) */
    --c-brand-hover: #e57200;
    --c-on-brand: #1f1300;
    --c-green: #009e60;          /* vert CI */
    --c-green-strong: #00804d;   /* vert AA sur blanc, pour bordures et icônes */
    --c-focus: rgba(247, 127, 0, .28);

    --c-danger: #b42318;
    --c-danger-bg: #fef3f2;
    --c-danger-border: #fecdca;
    --c-success: #00804d;
    --c-success-bg: #ecfdf3;
    --c-success-border: #abefc6;
    --c-warning: #93370d;

    --radius: 12px;
    --radius-lg: 24px;
    --shadow-card: 0 1px 2px rgba(15, 27, 45, .06), 0 12px 32px -12px rgba(15, 27, 45, .18);
    --tap: 48px;                 /* cible tactile minimale */
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --c-bg: #07120d;
        --c-surface: #0d1a14;
        --c-field: #091510;
        --c-text: #e8efeb;
        --c-muted: #9db0a6;
        --c-border: #20352b;
        --c-border-strong: #33503f;

        --c-ink: #022416;
        --c-brand: #f77f00;
        --c-brand-hover: #ff9020;
        --c-on-brand: #1f1300;
        --c-green-strong: #2fc489;
        --c-focus: rgba(247, 127, 0, .35);

        --c-danger: #fda29b;
        --c-danger-bg: rgba(180, 35, 24, .16);
        --c-danger-border: rgba(253, 162, 155, .35);
        --c-success: #75e0a7;
        --c-success-bg: rgba(6, 118, 71, .18);
        --c-success-border: rgba(117, 224, 167, .35);
        --c-warning: #fec84b;

        --shadow-card: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px -12px rgba(0, 0, 0, .6);
    }
}

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

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.5;
    color: var(--c-text);
    background: var(--c-bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

svg { display: block; flex: none; }
input, button { font: inherit; color: inherit; }
h1, h2, p { margin: 0; }
[hidden] { display: none !important; }

/* ---- Marque ----------------------------------------------------------- */
.brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-width: 0;
}
.brand__mark { width: 44px; height: 44px; }
.brand__text { display: flex; flex-direction: column; min-width: 0; }
.brand__name {
    font-weight: 700;
    font-size: 1.0625rem;
    letter-spacing: -.01em;
    line-height: 1.25;
}
.brand__tag {
    font-size: .8125rem;
    font-weight: 500;
    opacity: .72;
}

/* ==========================================================================
   Écran d'authentification
   Mobile : bandeau de marque + feuille blanche qui remonte (style appli)
   ≥ 960px : écran scindé en deux colonnes
   ========================================================================== */
.auth {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--c-ink);
}

.auth__brand {
    position: relative;
    color: #fff;
    padding:
        calc(1.5rem + env(safe-area-inset-top))
        max(1.25rem, env(safe-area-inset-right))
        3.25rem
        max(1.25rem, env(safe-area-inset-left));
    background:
        radial-gradient(110% 120% at 100% 0%, rgba(247, 127, 0, .5) 0%, rgba(247, 127, 0, 0) 55%),
        radial-gradient(90% 100% at 0% 100%, rgba(0, 158, 96, .55) 0%, rgba(0, 158, 96, 0) 60%),
        var(--c-ink);
    overflow: hidden;
}

/* Liseré orange · blanc · vert */
.auth__brand::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: linear-gradient(90deg, #f77f00 0 33.33%, #ffffff 33.33% 66.66%, #009e60 66.66%);
}

.auth__pitch,
.auth__legal { display: none; }

.auth__panel {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-top: -1.75rem;
    padding:
        2rem
        max(1.25rem, env(safe-area-inset-right))
        calc(1.5rem + env(safe-area-inset-bottom))
        max(1.25rem, env(safe-area-inset-left));
    background: var(--c-surface);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.auth__card {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
}

.auth__header { margin-bottom: 1.5rem; }

.auth__title {
    font-size: clamp(1.5rem, 1.2rem + 1.5vw, 2rem);
    line-height: 1.2;
    letter-spacing: -.02em;
    font-weight: 750;
    text-wrap: balance;
}

.auth__subtitle {
    margin-top: .375rem;
    color: var(--c-muted);
    text-wrap: pretty;
}

.auth__help {
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--c-border);
    font-size: .875rem;
    color: var(--c-muted);
    text-align: center;
    text-wrap: balance;
}

/* Page simple (ex. accueil provisoire) */
.auth--single { background: var(--c-bg); justify-content: center; }
.auth--single .auth__panel {
    flex: 0 1 auto;
    margin: 0;
    border-radius: 0;
    background: transparent;
}
.auth--single .auth__card {
    padding: 1.75rem 1.25rem;
    background: var(--c-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}
.auth--single .brand { margin-bottom: 1.5rem; }
.auth--single .auth__subtitle { margin-bottom: 1.5rem; }

/* Petits téléphones (≤ 360px) */
@media (max-width: 360px) {
    .auth__brand { padding-bottom: 2.75rem; }
    .auth__panel { padding-top: 1.5rem; }
    .brand__mark { width: 40px; height: 40px; }
}

/* Téléphone en paysage : on réduit le bandeau pour garder le formulaire visible */
@media (orientation: landscape) and (max-height: 520px) {
    .auth__brand { padding-top: calc(.875rem + env(safe-area-inset-top)); padding-bottom: 2.25rem; }
    .auth__panel { padding-top: 1.25rem; }
    .auth__header { margin-bottom: 1rem; }
}

/* Tablette : la feuille devient une carte centrée */
@media (min-width: 600px) and (max-width: 959.98px) {
    .auth__brand { padding-top: calc(2.5rem + env(safe-area-inset-top)); padding-bottom: 6rem; }
    .auth__brand .brand { max-width: 480px; margin: 0 auto; }
    .auth__panel {
        flex: 0 0 auto;
        width: calc(100% - 3rem);
        max-width: 480px;
        margin: -4rem auto 2rem;
        padding: 2.25rem 2rem;
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-card);
    }
    .auth { background: var(--c-bg); }
    .auth__brand { flex: 0 0 auto; }
}

/* Bureau : écran scindé */
@media (min-width: 960px) {
    .auth { flex-direction: row; background: var(--c-surface); }

    .auth__brand {
        flex: 0 0 min(46%, 640px);
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        gap: 3rem;
        padding: 3rem clamp(2.5rem, 4vw, 4rem);
    }
    .brand__mark { width: 48px; height: 48px; }
    .brand__name { font-size: 1.1875rem; }

    .auth__pitch { display: block; max-width: 30rem; }
    .auth__pitch-title {
        font-size: clamp(1.75rem, 1rem + 1.6vw, 2.5rem);
        line-height: 1.15;
        letter-spacing: -.025em;
        font-weight: 750;
        text-wrap: balance;
    }
    .auth__features {
        list-style: none;
        margin: 2rem 0 0;
        padding: 0;
        display: grid;
        gap: .875rem;
    }
    .auth__features li {
        display: flex;
        align-items: center;
        gap: .75rem;
        color: rgba(255, 255, 255, .86);
    }
    .auth__features svg {
        width: 28px;
        height: 28px;
        padding: 5px;
        border-radius: 50%;
        background: rgba(0, 158, 96, .28);
        color: #6ee7b7;
    }
    .auth__legal { display: block; font-size: .8125rem; color: rgba(255, 255, 255, .55); }

    .auth__panel {
        margin: 0;
        border-radius: 0;
        align-items: center;
        justify-content: center;
        padding: 3rem;
    }

    .auth--single .auth__panel { margin: auto; }
}

/* ==========================================================================
   Formulaires
   ========================================================================== */
.form { display: grid; gap: 1.125rem; }

.field__label {
    display: block;
    margin-bottom: .5rem;
    font-size: .9375rem;
    font-weight: 600;
}

.field__control { position: relative; }

.field__icon {
    position: absolute;
    left: .875rem;
    top: 50%;
    width: 20px;
    height: 20px;
    transform: translateY(-50%);
    color: var(--c-muted);
    pointer-events: none;
    transition: color .15s ease;
}

.input {
    display: block;
    width: 100%;
    min-height: 52px;
    padding: .75rem 1rem .75rem 2.875rem;
    font-size: 1rem;              /* ≥ 16px : évite le zoom automatique d'iOS */
    line-height: 1.4;
    color: var(--c-text);
    background: var(--c-field);
    border: 1.5px solid var(--c-border);
    border-radius: var(--radius);
    appearance: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.input::placeholder { color: var(--c-muted); opacity: .75; }
.input:hover { border-color: var(--c-border-strong); }
.input:focus {
    outline: none;
    border-color: var(--c-green-strong);
    box-shadow: 0 0 0 4px var(--c-focus);
}
.field__control:focus-within .field__icon { color: var(--c-green-strong); }
.input--password { padding-right: 3.5rem; }

/* Champ pré-rempli par le navigateur : on garde nos couleurs */
.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--c-text);
    -webkit-box-shadow: 0 0 0 1000px var(--c-field) inset;
    caret-color: var(--c-text);
}
.input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--c-field) inset, 0 0 0 4px var(--c-focus);
}

.field__toggle {
    position: absolute;
    top: 50%;
    right: 4px;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    transform: translateY(-50%);
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--c-muted);
    cursor: pointer;
    touch-action: manipulation;
}
.field__toggle:hover { color: var(--c-text); }
.field__toggle:focus-visible { outline: 2px solid var(--c-green-strong); outline-offset: -2px; }
.field__toggle svg { width: 22px; height: 22px; }
.field__toggle .icon-eye-off,
.field__toggle[aria-pressed="true"] .icon-eye { display: none; }
.field__toggle[aria-pressed="true"] .icon-eye-off { display: block; }

.field__error,
.field__hint {
    margin-top: .375rem;
    font-size: .875rem;
    line-height: 1.4;
}
.field__error { color: var(--c-danger); font-weight: 500; }
.field__error:empty { display: none; }
.field__hint { color: var(--c-warning); }

.field.is-invalid .input { border-color: var(--c-danger); }
.field.is-invalid .input:focus { box-shadow: 0 0 0 4px var(--c-danger-bg); }
.field.is-invalid .field__icon { color: var(--c-danger); }

/* Case à cocher */
.check {
    display: inline-flex;
    align-items: center;
    gap: .75rem;
    min-height: var(--tap);
    margin: -.25rem 0;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    justify-self: start;
}
.check input {
    width: 22px;
    height: 22px;
    margin: 0;
    accent-color: var(--c-green);
    cursor: pointer;
}

/* Libellé + lien sur la même ligne (ex. « Mot de passe oublié ? ») */
.field__label-row {
    margin-bottom: .5rem;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .75rem;
    flex-wrap: wrap;
}
.field__label-row .field__label { margin-bottom: 0; }
.field__label-row .link {
    margin: -.75rem -.5rem -.25rem auto;   /* zone tactile élargie sans décaler la mise en page */
    padding: .75rem .5rem .25rem;
}

.link {
    color: var(--c-green-strong);
    font-size: .9375rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: 6px;
}
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.link:focus-visible { outline: 2px solid var(--c-green-strong); outline-offset: 2px; }

/* Lien retour */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    min-height: 44px;
    margin: -.5rem 0 .75rem -.5rem;
    padding: 0 .5rem;
    color: var(--c-muted);
    font-size: .9375rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: 10px;
}
.back-link svg { width: 18px; height: 18px; }
.back-link:hover { color: var(--c-text); }
.back-link:focus-visible { outline: 2px solid var(--c-green-strong); }

/* Règles du mot de passe */
.rules {
    margin-top: -.375rem;
    padding: .875rem 1rem;
    border-radius: var(--radius);
    background: var(--c-bg);
    font-size: .875rem;
}
.rules__title { color: var(--c-muted); margin-bottom: .375rem; }
.rules__list { list-style: none; margin: 0; padding: 0; display: grid; gap: .25rem; }
.rules__list li {
    position: relative;
    padding-left: 1.625rem;
    color: var(--c-muted);
    transition: color .15s ease;
}
.rules__list li::before {
    content: "";
    position: absolute;
    left: 0;
    top: .2em;
    width: 1rem;
    height: 1rem;
    border: 1.5px solid var(--c-border-strong);
    border-radius: 50%;
    transition: background-color .15s ease, border-color .15s ease;
}
.rules__list li.is-met { color: var(--c-success); }
.rules__list li.is-met::before {
    border-color: var(--c-green);
    background: var(--c-green) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 8.2l2.3 2.3 4.7-4.9' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat;
}

/* États (e-mail envoyé, lien expiré…) */
.state { display: grid; gap: 1rem; }
.state .auth__subtitle { margin-top: -.5rem; }
.state__icon {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    border-radius: 20px;
}
.state__icon svg { width: 32px; height: 32px; }
.state__icon--success { background: var(--c-success-bg); color: var(--c-success); }
.state__icon--warning { background: rgba(247, 127, 0, .14); color: var(--c-brand-hover); }
.state__note { font-size: .9375rem; color: var(--c-muted); }
.state__dev {
    padding: .75rem 1rem;
    border: 1px dashed var(--c-border-strong);
    border-radius: var(--radius);
    font-size: .8125rem;
    color: var(--c-muted);
}
.state .btn:first-of-type { margin-top: .5rem; }

.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;
}

/* ==========================================================================
   Boutons
   ========================================================================== */
.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .625rem;
    min-height: 52px;
    padding: .75rem 1.25rem;
    border: 1.5px solid transparent;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 650;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    touch-action: manipulation;
    transition: background-color .15s ease, border-color .15s ease, transform .1s ease, opacity .15s ease;
}
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--c-focus); }
.btn:active { transform: scale(.985); }
.btn[disabled] { cursor: progress; opacity: .8; }
.btn--block { width: 100%; }

.btn--primary { background: var(--c-brand); color: var(--c-on-brand); }
.btn--primary:hover { background: var(--c-brand-hover); }

.btn--ghost { background: transparent; color: var(--c-text); border-color: var(--c-border-strong); }
.btn--ghost:hover { background: var(--c-bg); }

.btn__spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2.5px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
.btn.is-loading .btn__spinner { display: inline-block; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Alertes
   ========================================================================== */
.alert {
    display: flex;
    align-items: flex-start;
    gap: .625rem;
    margin-bottom: 1.25rem;
    padding: .875rem 1rem;
    border: 1px solid;
    border-radius: var(--radius);
    font-size: .9375rem;
    line-height: 1.45;
    animation: alert-in .25s ease-out;
}
.alert svg { width: 20px; height: 20px; margin-top: 1px; }
.alert--error { color: var(--c-danger); background: var(--c-danger-bg); border-color: var(--c-danger-border); }
.alert--success { color: var(--c-success); background: var(--c-success-bg); border-color: var(--c-success-border); }

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

/* ---- Accessibilité ---------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

@media (forced-colors: active) {
    .btn, .input { border: 1px solid CanvasText; }
}

/* ==========================================================================
   Espace connecté (mobile-first)
   Mobile/tablette : barre du haut + navigation du bas au pouce
   ≥ 1024px : barre latérale fixe
   ========================================================================== */
:root {
    --tabbar-h: 64px;
    --sidebar-w: 264px;
    --c-danger-strong: #b42318;
}
@media (prefers-color-scheme: dark) {
    :root { --c-danger-strong: #fda29b; }
}

.app-body { background: var(--c-bg); }

.skip-link {
    position: absolute;
    left: 1rem;
    top: -100px;
    z-index: 100;
    padding: .75rem 1rem;
    border-radius: var(--radius);
    background: var(--c-brand);
    color: var(--c-on-brand);
    font-weight: 600;
}
.skip-link:focus { top: calc(.75rem + env(safe-area-inset-top)); }

.shell { min-height: 100vh; min-height: 100dvh; }
.sidebar { display: none; }

/* ---- Barre du haut --------------------------------------------------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding:
        calc(.625rem + env(safe-area-inset-top))
        max(1rem, env(safe-area-inset-right))
        .625rem
        max(1rem, env(safe-area-inset-left));
    background: var(--c-ink);
    color: #fff;
    box-shadow: 0 1px 0 rgba(0, 0, 0, .08);
}
.topbar::before {          /* liseré tricolore */
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, #f77f00 0 33.33%, #ffffff 33.33% 66.66%, #009e60 66.66%);
}
.topbar__brand { color: inherit; text-decoration: none; min-width: 0; border-radius: var(--radius); }
.topbar__brand .brand__mark { width: 36px; height: 36px; }
.topbar__brand .brand__name { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__brand .brand__tag { display: none; }
.topbar__brand:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.avatar {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--c-brand);
    color: var(--c-on-brand);
    font-size: .875rem;
    font-weight: 750;
    letter-spacing: .02em;
}

/* Menu du compte (<details>, fonctionne sans JS) */
.menu { position: relative; }
.menu__trigger {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    list-style: none;
    cursor: pointer;
}
.menu__trigger::-webkit-details-marker { display: none; }
.menu__trigger:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.menu__panel {
    position: absolute;
    right: 0;
    top: calc(100% + .5rem);
    width: min(280px, calc(100vw - 2rem));
    padding: .5rem;
    border: 1px solid var(--c-border);
    border-radius: 16px;
    background: var(--c-surface);
    color: var(--c-text);
    box-shadow: var(--shadow-card);
    animation: alert-in .15s ease-out;
}
.menu__name { padding: .5rem .75rem 0; font-weight: 700; }
.menu__mail {
    padding: 0 .75rem .625rem;
    margin-bottom: .375rem;
    border-bottom: 1px solid var(--c-border);
    color: var(--c-muted);
    font-size: .875rem;
    overflow: hidden;
    text-overflow: ellipsis;
}
.menu__item {
    display: flex;
    align-items: center;
    gap: .75rem;
    width: 100%;
    min-height: 48px;
    padding: 0 .75rem;
    border: 0;
    border-radius: 10px;
    background: none;
    color: inherit;
    font-size: 1rem;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}
.menu__item:hover, .menu__item:focus-visible { background: var(--c-bg); outline: none; }
.menu__item--danger { color: var(--c-danger-strong); }

.icon { width: 22px; height: 22px; flex: none; }

/* ---- Navigation du bas ----------------------------------------------- */
.tabbar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding: 0 max(.25rem, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(.25rem, env(safe-area-inset-left));
    background: color-mix(in srgb, var(--c-surface) 92%, transparent);
    -webkit-backdrop-filter: saturate(1.6) blur(14px);
    backdrop-filter: saturate(1.6) blur(14px);
    border-top: 1px solid var(--c-border);
}
.tabbar__link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .1875rem;
    height: 100%;
    min-height: 48px;
    color: var(--c-muted);
    font-size: .6875rem;
    font-weight: 600;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}
.tabbar__link[aria-current="page"] { color: var(--c-green-strong); }
.tabbar__link[aria-current="page"] .icon { stroke-width: 2.2; }
.tabbar__link:focus-visible { outline: 2px solid var(--c-green-strong); outline-offset: -4px; border-radius: 12px; }
.tabbar__fab {
    justify-self: center;
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    margin-top: -22px;
    border-radius: 50%;
    background: var(--c-brand);
    color: var(--c-on-brand);
    box-shadow: 0 6px 16px -4px rgba(247, 127, 0, .6), 0 0 0 4px var(--c-bg);
    transition: transform .1s ease;
}
.tabbar__fab .icon { width: 28px; height: 28px; stroke-width: 2.4; }
.tabbar__fab:active { transform: scale(.94); }
.tabbar__fab:focus-visible { outline: 3px solid var(--c-green-strong); outline-offset: 3px; }

/* ---- Contenu --------------------------------------------------------- */
.page {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding:
        1.25rem
        max(1rem, env(safe-area-inset-right))
        calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 1.5rem)
        max(1rem, env(safe-area-inset-left));
}

.page__head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.page__eyebrow { color: var(--c-muted); font-size: .875rem; font-weight: 500; }
.page__title {
    font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2rem);
    font-weight: 750;
    letter-spacing: -.02em;
    line-height: 1.2;
}
.page__cta { display: none; }

/* Chiffres clés */
.kpis {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .75rem;
    margin-bottom: 1rem;
}
.kpi {
    display: flex;
    flex-direction: column;
    gap: .375rem;
    min-width: 0;
    padding: 1rem;
    border: 1px solid var(--c-border);
    border-radius: 16px;
    background: var(--c-surface);
}
.kpi__label {
    display: flex;
    align-items: center;
    gap: .4375rem;
    color: var(--c-muted);
    font-size: .8125rem;
    font-weight: 600;
    line-height: 1.25;
}
.kpi__label .icon { width: 18px; height: 18px; }
.kpi__value {
    font-size: clamp(1.125rem, .95rem + 1.2vw, 1.625rem);
    font-weight: 750;
    letter-spacing: -.02em;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}
.kpi__value small { font-size: .6em; font-weight: 600; color: var(--c-muted); letter-spacing: 0; }
.kpi__sub { margin-top: auto; color: var(--c-muted); font-size: .8125rem; line-height: 1.35; }

.kpi--brand {
    border-color: transparent;
    background:
        radial-gradient(120% 140% at 100% 0%, rgba(247, 127, 0, .45) 0%, rgba(247, 127, 0, 0) 60%),
        var(--c-ink);
    color: #fff;
}
.kpi--brand .kpi__label,
.kpi--brand .kpi__sub,
.kpi--brand .kpi__value small { color: rgba(255, 255, 255, .78); }
.kpi--danger { border-color: var(--c-danger-border); background: var(--c-danger-bg); }
.kpi--danger .kpi__value, .kpi--danger .kpi__label { color: var(--c-danger-strong); }

.trend { font-weight: 700; }
.trend--up { color: #6ee7b7; }
.trend--down { color: #fdba74; }

/* Actions rapides */
.quick {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .625rem;
    margin-bottom: 1rem;
}
.quick__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    min-height: 88px;
    padding: .75rem .5rem;
    border: 1px solid var(--c-border);
    border-radius: 16px;
    background: var(--c-surface);
    color: var(--c-text);
    font-size: .8125rem;
    font-weight: 650;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    transition: border-color .15s ease, transform .1s ease;
}
.quick__item .icon {
    width: 40px;
    height: 40px;
    padding: 9px;
    border-radius: 12px;
    background: rgba(0, 158, 96, .12);
    color: var(--c-green-strong);
}
.quick__item--primary .icon { background: var(--c-brand); color: var(--c-on-brand); }
.quick__item:hover { border-color: var(--c-border-strong); }
.quick__item:active { transform: scale(.98); }
.quick__item:focus-visible { outline: 2px solid var(--c-green-strong); outline-offset: 2px; }

/* Panneaux */
.dash-grid { display: grid; gap: 1rem; }

.panel {
    min-width: 0;
    border: 1px solid var(--c-border);
    border-radius: 16px;
    background: var(--c-surface);
    overflow: hidden;
}
.panel--alert { border-color: var(--c-danger-border); }
.panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1rem .5rem;
}
.panel__title { display: flex; align-items: center; gap: .5rem; font-size: 1.0625rem; font-weight: 700; }
.panel__hint { margin-top: .125rem; color: var(--c-muted); font-size: .8125rem; }
.count {
    display: inline-grid;
    place-items: center;
    min-width: 24px;
    height: 24px;
    padding: 0 .4375rem;
    border-radius: 999px;
    background: var(--c-danger-bg);
    color: var(--c-danger-strong);
    font-size: .8125rem;
    font-weight: 700;
}

/* Listes */
.list { list-style: none; margin: 0; padding: 0 0 .25rem; }
.list__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    min-height: 68px;
    padding: .75rem 1rem;
    border-top: 1px solid var(--c-border);
}
.list__item:first-child { border-top: 0; }
.list__main { min-width: 0; }
.list__title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;            /* 2 lignes max sur petits écrans */
    overflow: hidden;
    font-weight: 650;
    line-height: 1.3;
    overflow-wrap: anywhere;
}
.list__meta { color: var(--c-muted); font-size: .8125rem; }
.list__side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: .375rem;
    flex: none;
    text-align: right;
}
.list__amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.list__actions { display: flex; gap: .375rem; }
.text-danger { color: var(--c-danger-strong); font-weight: 600; }

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--c-muted);
    cursor: pointer;
    text-decoration: none;
}
.icon-btn:hover { background: var(--c-bg); color: var(--c-text); }
.icon-btn:focus-visible { outline: 2px solid var(--c-green-strong); outline-offset: 1px; }
.icon-btn--soft { width: 40px; height: 40px; background: var(--c-bg); color: var(--c-text); }
.icon-btn--whatsapp { width: 40px; height: 40px; background: rgba(0, 158, 96, .14); color: var(--c-green-strong); }
.icon-btn--whatsapp:hover { background: rgba(0, 158, 96, .24); color: var(--c-green-strong); }

/* Statuts */
.badge {
    display: inline-flex;
    align-items: center;
    padding: .1875rem .5625rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 650;
    line-height: 1.3;
    white-space: nowrap;
    background: var(--c-bg);
    color: var(--c-muted);
}
.badge--sent { background: rgba(56, 97, 170, .12); color: #2d5598; }
.badge--partial { background: rgba(247, 127, 0, .14); color: #a14f00; }
.badge--paid { background: var(--c-success-bg); color: var(--c-success); }
.badge--overdue { background: var(--c-danger-bg); color: var(--c-danger-strong); }
.badge--cancelled { text-decoration: line-through; }
@media (prefers-color-scheme: dark) {
    .badge--sent { background: rgba(120, 160, 230, .16); color: #a9c3f0; }
    .badge--partial { background: rgba(247, 127, 0, .18); color: #ffb366; }
}

/* États vides */
.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .625rem;
    padding: 2rem 1.25rem 2.25rem;
    text-align: center;
}
.empty__icon .icon {
    width: 56px;
    height: 56px;
    padding: 14px;
    border-radius: 18px;
    background: rgba(0, 158, 96, .12);
    color: var(--c-green-strong);
}
.empty__title { font-size: 1.0625rem; font-weight: 700; }
.empty__text { max-width: 34ch; color: var(--c-muted); font-size: .9375rem; text-wrap: balance; }
.empty .btn { margin-top: .5rem; }

/* Bouton avec icône */
.btn .icon { width: 20px; height: 20px; }

/* Très petits écrans */
@media (max-width: 359.98px) {
    .kpis { grid-template-columns: 1fr; }
    .quick__item { font-size: .75rem; }
}

/* Tablette */
@media (min-width: 640px) {
    .page { padding-top: 1.75rem; }
    .kpis { gap: 1rem; }
    .kpi { padding: 1.25rem; }
    .quick { grid-template-columns: repeat(3, minmax(0, 200px)); }
    .page__cta { display: inline-flex; }
    .quick__item--primary { display: none; }   /* doublon du bouton d'en-tête */
    .quick { grid-template-columns: repeat(2, minmax(0, 200px)); }
}

/* Ordinateur : barre latérale */
@media (min-width: 1024px) {
    .topbar, .tabbar { display: none; }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: var(--sidebar-w);
        display: flex;
        flex-direction: column;
        gap: 1.25rem;
        padding: 1.5rem 1rem 1rem;
        background: var(--c-ink);
        color: #fff;
    }
    .sidebar::before {
        content: "";
        position: absolute;
        inset: 0 0 auto 0;
        height: 3px;
        background: linear-gradient(90deg, #f77f00 0 33.33%, #ffffff 33.33% 66.66%, #009e60 66.66%);
    }
    .sidebar__brand { color: inherit; text-decoration: none; padding: 0 .5rem; border-radius: var(--radius); }
    .sidebar__brand .brand__mark { width: 40px; height: 40px; }
    .sidebar__brand:focus-visible { outline: 2px solid #fff; }
    .sidebar__cta { min-height: 48px; }
    .sidebar__nav { display: grid; gap: .25rem; }
    .sidebar__link {
        display: flex;
        align-items: center;
        gap: .75rem;
        min-height: 46px;
        padding: 0 .875rem;
        border-radius: 12px;
        color: rgba(255, 255, 255, .78);
        font-weight: 600;
        text-decoration: none;
    }
    .sidebar__link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
    .sidebar__link[aria-current="page"] {
        background: rgba(0, 158, 96, .28);
        color: #fff;
        box-shadow: inset 3px 0 0 #f77f00;
    }
    .sidebar__link:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }

    .sidebar__user {
        display: flex;
        align-items: center;
        gap: .625rem;
        margin-top: auto;
        padding: .75rem .5rem 0;
        border-top: 1px solid rgba(255, 255, 255, .12);
    }
    .sidebar__who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
    .sidebar__name { font-weight: 650; font-size: .9375rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .sidebar__mail { font-size: .75rem; color: rgba(255, 255, 255, .6); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .sidebar__user .icon-btn { color: rgba(255, 255, 255, .7); }
    .sidebar__user .icon-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }

    .shell__main { margin-left: var(--sidebar-w); }
    .page { padding: 2rem clamp(1.5rem, 3vw, 2.5rem) 3rem; }

    .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .quick { display: none; }                          /* le bouton « Nouvelle facture » est dans l'en-tête et la barre latérale */
    .dash-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
    .dash-grid > .panel:only-child { grid-column: 1 / -1; }
}

@media (min-width: 1280px) {
    .dash-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
}

/* ==========================================================================
   Clients : liste, fiche, formulaire
   ========================================================================== */
.btn--sm { min-height: 44px; padding: .5rem 1rem; font-size: .9375rem; }
.btn--danger { background: transparent; color: var(--c-danger-strong); border-color: var(--c-danger-border); }
.btn--danger:hover { background: var(--c-danger-bg); }
.show-xs { display: none; }
@media (max-width: 379.98px) {
    .hide-xs { display: none; }
    .show-xs { display: inline; }
}

/* Recherche */
.search { position: relative; margin-bottom: 1rem; }
.search__icon {
    position: absolute;
    left: .875rem;
    top: 50%;
    width: 20px;
    height: 20px;
    transform: translateY(-50%);
    color: var(--c-muted);
    pointer-events: none;
}
.search__input { padding-right: 3rem; border-radius: 14px; }
.search__input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search__clear {
    position: absolute;
    right: 4px;
    top: 50%;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    transform: translateY(-50%);
    border-radius: 10px;
    color: var(--c-muted);
}
.search__clear svg { width: 18px; height: 18px; }
.search__clear:hover { color: var(--c-text); }
.search__summary { margin: -.25rem 0 .75rem; color: var(--c-muted); font-size: .875rem; }

/* Liste cliquable */
.list > li > .list__item--link { border-top: 1px solid var(--c-border); }
.list > li:first-child > .list__item--link { border-top: 0; }
.list__item--link {
    color: inherit;
    text-decoration: none;
    gap: .875rem;
    transition: background-color .12s ease;
}
.list__item--link:hover { background: var(--c-bg); }
.list__item--link:active { background: var(--c-border); }
.list__item--link:focus-visible { outline: 2px solid var(--c-green-strong); outline-offset: -2px; }
.list__item--link .list__main { flex: 1; }
.list__chevron { width: 18px; height: 18px; color: var(--c-border-strong); margin-left: -.25rem; }
.list__amount--due { color: var(--c-danger-strong); }
.list__side .list__meta { margin-top: -.25rem; }

.avatar--soft { background: rgba(0, 158, 96, .14); color: var(--c-green-strong); }
.avatar--lg { width: 64px; height: 64px; font-size: 1.375rem; border-radius: 20px; }

.pager {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: .75rem;
    margin-top: 1rem;
}
.pager > :last-child { justify-self: end; }
.pager__info { color: var(--c-muted); font-size: .875rem; }

/* Fiche client */
.profile { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.profile__text { min-width: 0; }
.profile .page__title { overflow-wrap: anywhere; }

.actions {
    display: flex;
    gap: .5rem;
    margin-bottom: 1rem;
}
.action {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .375rem;
    min-height: 72px;
    padding: .625rem .25rem;
    border: 1px solid var(--c-border);
    border-radius: 14px;
    background: var(--c-surface);
    color: var(--c-text);
    font-size: .8125rem;
    font-weight: 650;
    text-decoration: none;
}
.action .icon { color: var(--c-green-strong); }
.action:hover { border-color: var(--c-border-strong); }
.action:active { transform: scale(.98); }
.action:focus-visible { outline: 2px solid var(--c-green-strong); outline-offset: 2px; }
.action--whatsapp { background: rgba(0, 158, 96, .1); border-color: rgba(0, 158, 96, .3); }

.stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 1rem;
    border: 1px solid var(--c-border);
    border-radius: 16px;
    background: var(--c-surface);
    overflow: hidden;
}
.stat { min-width: 0; padding: .875rem .75rem; }
.stat + .stat { border-left: 1px solid var(--c-border); }
.stat__label { color: var(--c-muted); font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat__value {
    margin-top: .25rem;
    font-size: clamp(.9375rem, .8rem + 1vw, 1.375rem);
    font-weight: 750;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
    line-height: 1.2;
}
.stat__value small { font-size: .65em; color: var(--c-muted); font-weight: 600; }
.stat__value--ok { color: var(--c-success); }
.stat--due { background: var(--c-danger-bg); }
.stat--due .stat__value { color: var(--c-danger-strong); }

.details { margin: 0; padding: 0 1rem .5rem; }
.details__row {
    display: grid;
    gap: .125rem;
    padding: .75rem 0;
    border-top: 1px solid var(--c-border);
}
.details__row:first-child { border-top: 0; }
.details dt { color: var(--c-muted); font-size: .8125rem; }
.details dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }
.details dd.is-empty { color: var(--c-muted); font-weight: 400; font-style: italic; }

.count--neutral { background: var(--c-bg); color: var(--c-muted); }
.panel__empty { padding: .5rem 1rem 1.25rem; color: var(--c-muted); }

/* Formulaire */
.form-card { padding: 1.25rem 1rem; }
.form-grid { display: grid; gap: 1.125rem; }
.input--plain { padding-left: 1rem; }
.field__optional { margin-left: .25rem; color: var(--c-muted); font-weight: 400; font-size: .875rem; }
.field__help { margin-top: .375rem; color: var(--c-muted); font-size: .8125rem; }
.form-actions {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: .75rem;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--c-border);
}

.danger-zone {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
    padding: 1.25rem 1rem;
    border-color: var(--c-danger-border);
}
.danger-zone .btn { width: 100%; }

@media (min-width: 640px) {
    .form-card { padding: 1.75rem; }
    .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1.25rem; }
    .form-grid__full { grid-column: 1 / -1; }
    .form-actions { display: flex; justify-content: flex-end; }
    .form-actions .btn { min-width: 160px; }
    .danger-zone { flex-direction: row; align-items: center; justify-content: space-between; padding: 1.25rem 1.75rem; }
    .danger-zone .btn { width: auto; }
    .action { flex: 0 1 150px; }
    .stat { padding: 1.125rem 1.25rem; }
}

@media (min-width: 1024px) {
    .form-card, .danger-zone { max-width: 760px; }
}
.list__item--link .list__main .list__meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ==========================================================================
   Facture : création
   ========================================================================== */
.invoice-form { display: grid; gap: 1rem; }
.invoice-form .form-card { margin: 0; }

.form-section {
    display: flex;
    align-items: center;
    gap: .625rem;
    margin: 0 0 1.125rem;
    font-size: 1.0625rem;
    font-weight: 700;
}
.form-section span {
    display: grid;
    place-items: center;
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0, 158, 96, .14);
    color: var(--c-green-strong);
    font-size: .875rem;
    font-weight: 750;
}
.form-error { margin: -.25rem 0 1rem; }

/* Liste déroulante et zone de texte */
.select {
    padding-right: 2.75rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235b6678' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .875rem center;
    background-size: 20px;
    cursor: pointer;
}
.textarea { min-height: 96px; resize: vertical; font-family: inherit; }

.input--num { font-variant-numeric: tabular-nums; }
.input-unit { position: relative; }
.input-unit .input { padding-right: 4rem; }
.input-unit__suffix {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--c-muted);
    font-size: .8125rem;
    font-weight: 600;
    pointer-events: none;
}
.field__label--sm { margin-bottom: .375rem; font-size: .8125rem; color: var(--c-muted); }

/* Échéance en un clic */
.chips { display: flex; flex-wrap: wrap; gap: .375rem; margin-top: .625rem; }
.chip {
    min-height: 40px;
    padding: .375rem .75rem;
    border: 1.5px solid var(--c-border);
    border-radius: 999px;
    background: var(--c-surface);
    color: var(--c-text);
    font: inherit;
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
}
.chip:hover { border-color: var(--c-border-strong); }
.chip:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--c-focus); }
.chip.is-active { border-color: var(--c-green-strong); background: rgba(0, 158, 96, .12); color: var(--c-green-strong); }

/* Lignes de prestations */
.items { display: grid; gap: .75rem; margin: 0 0 .875rem; padding: 0; list-style: none; }
.item {
    display: grid;
    gap: .75rem;
    padding: .875rem;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    background: var(--c-bg);
}
.item__head { display: flex; align-items: center; justify-content: space-between; min-height: 32px; }
.item__num {
    display: grid;
    place-items: center;
    min-width: 28px;
    height: 28px;
    padding: 0 .375rem;
    border-radius: 8px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    font-size: .8125rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.item__remove { width: 44px; height: 44px; margin: -6px -6px -6px 0; color: var(--c-danger-strong); }
.item__remove:hover { background: var(--c-danger-bg); color: var(--c-danger-strong); }
.item__remove[hidden] { display: none; }
.item .field__error { margin-top: .25rem; }

/* Qté | Prix unitaire, puis le total de la ligne sur toute la largeur */
.item__nums { display: grid; grid-template-columns: minmax(0, 5.5rem) minmax(0, 1fr); gap: .75rem; }
.item__total {
    grid-column: 1 / -1;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding-top: .625rem;
    border-top: 1px dashed var(--c-border-strong);
}
.item__total .field__label { margin: 0; }
.item__amount { font-size: 1.0625rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.item__amount::after { content: "FCFA"; margin-left: .25rem; color: var(--c-muted); font-size: .75rem; font-weight: 600; }

.btn--dashed { border-style: dashed; color: var(--c-green-strong); border-color: var(--c-green-strong); }
.btn--dashed:hover { background: rgba(0, 158, 96, .08); }

/* Interrupteur TVA */
.switch-field { align-self: end; }
.switch {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-height: 52px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track {
    position: relative;
    flex: none;
    width: 48px;
    height: 28px;
    border-radius: 999px;
    background: var(--c-border-strong);
    transition: background-color .15s ease;
}
.switch__track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
    transition: transform .18s ease;
}
.switch input:checked + .switch__track { background: var(--c-green); }
.switch input:checked + .switch__track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch__track { box-shadow: 0 0 0 4px var(--c-focus); }
.switch__label { font-weight: 600; }
.switch-field .field__help { margin-top: 0; }

/* Récapitulatif */
.totals { display: grid; gap: .5rem; margin: 1.25rem 0 0; padding-top: 1rem; border-top: 1px solid var(--c-border); }
.totals > div { display: flex; justify-content: space-between; gap: 1rem; }
.totals > div[hidden] { display: none; }
.totals dt { color: var(--c-muted); }
.totals dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Barre d'action collante : total + boutons, au-dessus de la navigation du bas */
.form-sticky {
    position: sticky;
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + .5rem);
    z-index: 5;
    display: grid;
    gap: .75rem;
    padding: .875rem 1rem;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    background: var(--c-surface);
    box-shadow: 0 -4px 24px -8px rgba(15, 27, 45, .25), var(--shadow-card);
}
.form-sticky__total { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.form-sticky__label { color: var(--c-muted); font-size: .875rem; font-weight: 600; }
.form-sticky__amount { font-size: 1.375rem; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.form-sticky__actions { display: flex; gap: .625rem; }
.form-sticky__actions .btn { flex: 1 1 0; min-width: 0; padding-left: .75rem; padding-right: .75rem; }
.form-sticky__actions .btn--primary { flex-grow: 1.6; }

@media (max-width: 379.98px) {
    .item { padding: .75rem; }
    .item__nums { grid-template-columns: minmax(0, 3.75rem) minmax(0, 1fr); gap: .5rem; }
    .item .input-unit .input { padding-right: 3rem; padding-left: .75rem; }
    .item .input-unit__suffix { right: .625rem; font-size: .6875rem; }
    .form-sticky { gap: .5rem; padding: .625rem .75rem; }
    .form-sticky__amount { font-size: 1.1875rem; }
    .form-sticky__actions .btn { min-height: 48px; font-size: .9375rem; white-space: nowrap; }
}

@media (min-width: 640px) {
    .item { padding: 1rem 1.125rem; }
    /* Ligne sur une rangée : Qté | Prix | Total */
    .item__nums { grid-template-columns: 6rem minmax(0, 1fr) minmax(8.5rem, auto); align-items: start; }
    .item__total {
        grid-column: auto;
        flex-direction: column;
        align-items: flex-end;
        padding-top: 0;
        border-top: 0;
    }
    .item__total .field__label { margin-bottom: .375rem; }
    .item__amount { display: flex; align-items: center; min-height: 52px; }
    .form-sticky { grid-template-columns: 1fr auto; align-items: center; padding: 1rem 1.25rem; }
    .form-sticky__total { flex-direction: column; gap: .125rem; }
    .form-sticky__actions .btn { flex: none; min-width: 150px; }
}

@media (min-width: 1024px) {
    .invoice-form { max-width: 760px; }
    .invoice-form .form-card { max-width: none; }
    .form-sticky { bottom: 1rem; }
}

@media (prefers-color-scheme: dark) {
    .select {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239db0a6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    }
    .item { background: var(--c-field); }
    .switch__track::after { background: #e8efeb; }
}

/* ==========================================================================
   Factures : liste
   ========================================================================== */
/* Filtres : défilement horizontal au pouce sur mobile */
.filters {
    display: flex;
    gap: .5rem;
    margin: 0 -1rem 1rem;
    padding: .125rem 1rem .375rem;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.filters::-webkit-scrollbar { display: none; }
.filter {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    flex: none;
    min-height: 44px;
    padding: .375rem .5rem .375rem .875rem;
    border: 1.5px solid var(--c-border);
    border-radius: 999px;
    background: var(--c-surface);
    color: var(--c-text);
    font-size: .875rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    scroll-snap-align: start;
}
.filter:hover { border-color: var(--c-border-strong); }
.filter:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--c-focus); }
.filter__count {
    min-width: 26px;
    padding: .125rem .5rem;
    border-radius: 999px;
    background: var(--c-bg);
    color: var(--c-muted);
    font-size: .75rem;
    font-variant-numeric: tabular-nums;
    text-align: center;
}
.filter[aria-current="page"] { border-color: var(--c-ink); background: var(--c-ink); color: #fff; }
.filter[aria-current="page"] .filter__count { background: rgba(255, 255, 255, .16); color: #fff; }
.filter--danger .filter__count { background: var(--c-danger-bg); color: var(--c-danger-strong); }

.sumbar {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1.5rem;
    margin-bottom: .75rem;
    padding: 0 .25rem;
    font-size: .875rem;
}
.sumbar div { display: flex; gap: .375rem; align-items: baseline; }
.sumbar span { color: var(--c-muted); }
.sumbar strong { font-variant-numeric: tabular-nums; }
.sumbar__due strong { color: var(--c-danger-strong); }

.list__meta--sub { font-size: .75rem; }
.list__amount--void { color: var(--c-muted); text-decoration: line-through; }
.list__amount--ok { color: var(--c-green-strong); }

@media (min-width: 640px) {
    .filters { flex-wrap: wrap; margin: 0 0 1rem; padding: 0; overflow: visible; }
}

/* ==========================================================================
   Facture : fiche
   ========================================================================== */
.inv-hero {
    margin-bottom: 1rem;
    padding: 1.125rem 1rem 1rem;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    background: var(--c-surface);
    box-shadow: var(--shadow-card);
}
.inv-hero__top { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .5rem; }
.inv-hero__number { color: var(--c-muted); font-size: .875rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.inv-hero__client { font-size: clamp(1.375rem, 1.1rem + 1.2vw, 1.75rem); font-weight: 750; letter-spacing: -.01em; line-height: 1.2; overflow-wrap: anywhere; }
.inv-hero__client a { color: inherit; text-decoration: none; }
.inv-hero__client a:hover { text-decoration: underline; text-underline-offset: 3px; }
.inv-hero__title { margin-top: .25rem; color: var(--c-muted); overflow-wrap: anywhere; }
.inv-hero__amount { display: flex; flex-direction: column; margin-top: 1rem; }
.inv-hero__amount span { color: var(--c-muted); font-size: .8125rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.inv-hero__amount strong { font-size: clamp(1.875rem, 1.4rem + 2.4vw, 2.5rem); font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.inv-hero__amount small { font-size: .9375rem; font-weight: 650; color: var(--c-muted); }
.inv-hero--overdue .inv-hero__amount strong { color: var(--c-danger-strong); }
.inv-hero--paid .inv-hero__amount strong { color: var(--c-green-strong); }
.inv-hero--cancelled .inv-hero__amount strong { color: var(--c-muted); text-decoration: line-through; }
.inv-hero__state { display: flex; align-items: center; flex-wrap: wrap; gap: .25rem; margin-top: .5rem; color: var(--c-muted); font-size: .875rem; }
.inv-hero--paid .inv-hero__state { color: var(--c-green-strong); font-weight: 600; }
.inv-hero__state .icon { width: 18px; height: 18px; }

.progress {
    display: block;
    width: 100%;
    height: 8px;
    margin-top: .875rem;
    border: 0;
    border-radius: 999px;
    background: var(--c-bg);
    overflow: hidden;
    appearance: none;
    -webkit-appearance: none;
}
.progress::-webkit-progress-bar { background: var(--c-bg); border-radius: 999px; }
.progress::-webkit-progress-value { background: var(--c-green); border-radius: 999px; }
.progress::-moz-progress-bar { background: var(--c-green); border-radius: 999px; }

/* Actions : tuiles ; le bouton d'un formulaire a la même allure qu'un lien */
.action-form { display: flex; flex: 1 1 0; min-width: 0; }
.action-form .action { width: 100%; }
button.action { font: inherit; font-size: .8125rem; font-weight: 650; cursor: pointer; }
.action[hidden] { display: none; }
.action--primary { background: var(--c-brand); border-color: var(--c-brand); color: var(--c-on-brand); }
.action--primary .icon { color: var(--c-on-brand); }
.action--primary:hover { background: var(--c-brand-hover); border-color: var(--c-brand-hover); }
.inv-hint { margin: -.25rem .25rem 1rem; color: var(--c-muted); font-size: .8125rem; }

/* Encaisser */
.paybox { margin-bottom: 1rem; scroll-margin-top: 5rem; }
.paybox__summary {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-height: 60px;
    padding: .75rem 1rem;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}
.paybox__summary::-webkit-details-marker { display: none; }
.paybox__summary > .icon:first-child { color: var(--c-green-strong); }
.paybox__summary span { flex: 1; }
.paybox__chevron { color: var(--c-muted); transition: transform .2s ease; }
.paybox[open] .paybox__chevron { transform: rotate(90deg); }
.paybox__form { display: grid; gap: 1.125rem; padding: .25rem 1rem 1.25rem; border-top: 1px solid var(--c-border); padding-top: 1.125rem; }
.input--lg { font-size: 1.375rem; font-weight: 700; min-height: 60px; }
.chip--sm { margin-top: .5rem; min-height: 36px; font-size: .8125rem; }

.methods { margin: 0; padding: 0; border: 0; min-width: 0; }
.methods__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.method { position: relative; display: block; cursor: pointer; }
.method input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.method span {
    display: flex;
    align-items: center;
    gap: .5rem;
    min-height: 48px;
    padding: .5rem .75rem;
    border: 1.5px solid var(--c-border);
    border-radius: var(--radius);
    background: var(--c-surface);
    font-size: .9375rem;
    font-weight: 600;
    transition: border-color .15s ease, background-color .15s ease;
}
.method span::before {
    content: "";
    flex: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--method, var(--c-muted));
}
.method--especes { --method: #6b7a8f; }
.method--orange_money { --method: #ff7900; }
.method--mtn_momo { --method: #ffcb05; }
.method--moov_money { --method: #0066b3; }
.method--wave { --method: #1dc8f2; }
.method--virement { --method: #009e60; }
.method--cheque { --method: #7a5af8; }
.method:hover span { border-color: var(--c-border-strong); }
.method input:checked + span { border-color: var(--c-green-strong); background: rgba(0, 158, 96, .1); box-shadow: inset 0 0 0 1px var(--c-green-strong); }
.method input:focus-visible + span { box-shadow: 0 0 0 4px var(--c-focus); }
.methods.is-invalid .method span { border-color: var(--c-danger-border); }

.pay-dot {
    display: grid;
    place-items: center;
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(0, 158, 96, .12);
    color: var(--c-green-strong);
}
.pay-dot .icon { width: 20px; height: 20px; }
.list__item .list__main { flex: 1; }
.icon-btn--danger { color: var(--c-danger-strong); }
.icon-btn--danger:hover { background: var(--c-danger-bg); color: var(--c-danger-strong); }
.danger-zone__text { color: var(--c-muted); font-size: .875rem; }

@media (min-width: 640px) {
    .inv-hero { padding: 1.5rem 1.75rem; }
    .methods__grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .paybox__summary { padding: .875rem 1.75rem; }
    .paybox__form { padding: 1.25rem 1.75rem 1.75rem; }
    .action { flex: 0 1 150px; }
    .action-form { flex: 0 1 150px; }
}
@media (min-width: 1024px) {
    .inv-hero, .paybox, .inv-hint, .doc { max-width: 820px; }
    .inv-hint { max-width: 820px; }
}

/* ---- Document (toujours sur « papier » blanc, même en mode sombre) ---- */
.doc {
    --d-ink: #10201a;
    --d-muted: #5b6678;
    --d-line: #e3e7ee;
    position: relative;
    margin: 1.5rem 0 1rem;
    padding: 1.5rem 1.125rem 1.25rem;
    border-radius: 6px;
    background: #fff;
    color: var(--d-ink);
    font-size: .875rem;
    line-height: 1.45;
    box-shadow: 0 1px 2px rgba(15, 27, 45, .08), 0 18px 40px -16px rgba(15, 27, 45, .28);
    overflow: hidden;
}
.doc__flag { position: absolute; top: 0; left: 0; right: 0; display: flex; height: 6px; }
.doc__flag span { flex: 1; }
.doc__flag span:nth-child(1) { background: #f77f00; }
.doc__flag span:nth-child(2) { background: #fff; }
.doc__flag span:nth-child(3) { background: #009e60; }

.doc[data-watermark]::after {
    content: attr(data-watermark);
    position: absolute;
    top: 38%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-24deg);
    padding: .25rem 1.5rem;
    border: 4px solid currentColor;
    border-radius: 12px;
    color: rgba(180, 35, 24, .16);
    font-size: clamp(2.5rem, 12vw, 5.5rem);
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
    white-space: nowrap;
    pointer-events: none;
}
.doc--draft::after { color: rgba(91, 102, 120, .16); }

.doc__head { display: grid; gap: 1.25rem; padding-bottom: 1.125rem; border-bottom: 2px solid var(--d-ink); }
.doc__from { display: flex; gap: .75rem; color: var(--d-muted); font-size: .8125rem; }
.doc__logo {
    display: grid;
    place-items: center;
    flex: none;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: #f77f00;
    color: #1f1300;
    font-weight: 800;
}
.doc__company { color: var(--d-ink); font-size: 1rem; font-weight: 800; }
.doc__kind { font-size: 1.5rem; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; color: #03331f; }
.doc__number { font-weight: 700; font-variant-numeric: tabular-nums; }
.doc__meta dl { display: flex; gap: 1.5rem; margin: .5rem 0 0; }
.doc__meta dt { color: var(--d-muted); font-size: .75rem; }
.doc__meta dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }

.doc__to { margin-top: 1.125rem; padding: .875rem 1rem; border-radius: 8px; background: #f4f7f5; color: var(--d-muted); font-size: .8125rem; overflow-wrap: anywhere; }
.doc__label { color: #00804d; font-size: .6875rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.doc__client { color: var(--d-ink); font-size: 1rem; font-weight: 750; }
.doc__object { margin-top: 1rem; overflow-wrap: anywhere; }

.doc__table { width: 100%; margin-top: 1rem; border-collapse: collapse; }
.doc__table th {
    padding: .5rem .375rem;
    border-bottom: 1.5px solid var(--d-ink);
    color: var(--d-muted);
    font-size: .6875rem;
    font-weight: 800;
    letter-spacing: .06em;
    text-align: left;
    text-transform: uppercase;
}
.doc__table td { padding: .625rem .375rem; border-bottom: 1px solid var(--d-line); vertical-align: top; overflow-wrap: anywhere; }
.doc__table th:first-child, .doc__table td:first-child { padding-left: 0; }
.doc__table th:last-child, .doc__table td:last-child { padding-right: 0; }
.doc__table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc__table td.num:last-child { font-weight: 700; }
.doc__sub { display: block; margin-top: .125rem; color: var(--d-muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
.doc__wide { display: none; }

.doc__bottom { display: grid; gap: 1rem; margin-top: 1rem; }
.doc__totals { display: grid; gap: .375rem; margin: 0; }
.doc__totals div { display: flex; justify-content: space-between; gap: 1rem; }
.doc__totals dt { color: var(--d-muted); }
.doc__totals dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.doc__grand { margin-top: .25rem; padding: .625rem .75rem; border-radius: 8px; background: #03331f; color: #fff; }
.doc__grand dt { color: rgba(255, 255, 255, .8) !important; font-weight: 700; }
.doc__grand dd { font-size: 1.125rem; font-weight: 800 !important; }
.doc__due dt, .doc__due dd { color: #b42318 !important; font-weight: 800 !important; }
.doc__words { order: 2; color: var(--d-muted); font-size: .8125rem; font-style: italic; }
.doc__words::first-letter { text-transform: uppercase; }
.doc__notes { margin-top: 1rem; padding-top: .75rem; border-top: 1px dashed var(--d-line); color: var(--d-muted); font-size: .8125rem; overflow-wrap: anywhere; }
/* À l'écran, le tableau de mise en page d'impression se comporte comme un simple bloc */
.doc__sheet, .doc__sheet > tbody, .doc__sheet > * > tr, .doc__sheet > * > tr > td { display: block; width: 100%; }
.doc__sheet > tfoot { display: none; }
.doc__foot { margin-top: 1.5rem; padding-top: .75rem; border-top: 1px solid var(--d-line); color: var(--d-muted); font-size: .75rem; text-align: center; }

@media (min-width: 560px) {
    .doc { padding: 2.25rem 2.25rem 1.75rem; font-size: .9375rem; }
    .doc__head { grid-template-columns: 1fr auto; align-items: start; }
    .doc__meta { text-align: right; }
    .doc__meta dl { justify-content: flex-end; }
    .doc__to { max-width: 60%; margin-left: auto; }
    .doc__wide { display: table-cell; }
    .doc__sub { display: none; }
    .doc__bottom { grid-template-columns: 1fr minmax(260px, 46%); align-items: start; }
    .doc__words { order: 0; padding-top: .5rem; }
}

/* ---- Impression / PDF : uniquement le document, au format A4 ---- */
@media print {
    @page { size: A4; margin: 12mm 12mm 10mm; }
    html, body, .app-body { background: #fff !important; }
    .sidebar, .topbar, .tabbar, .skip-link, .no-print { display: none !important; }
    .page { max-width: none; padding: 0 !important; margin: 0; }
    .shell__main { margin: 0 !important; padding: 0 !important; }
    .doc {
        margin: 0;
        padding: 6mm 0 0;
        max-width: none;
        box-shadow: none;
        border-radius: 0;
        font-size: 10.5pt;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .doc__head { grid-template-columns: 1fr auto; align-items: start; }
    .doc__meta { text-align: right; }
    .doc__meta dl { justify-content: flex-end; }
    .doc__to { max-width: 55%; margin-left: auto; }
    .doc__wide { display: table-cell; }
    .doc__sub { display: none; }
    .doc__bottom { grid-template-columns: 1fr 45%; align-items: start; break-inside: avoid; }
    .doc__words { order: 0; padding-top: .5rem; }
    .doc__table tr { break-inside: avoid; }
    /*
     * Pied de page légal toujours collé en bas de la feuille, quel que soit le contenu, et répété sur chaque page :
     * position: fixed le place en bas de chaque page imprimée, et le pied vide du tableau .doc__sheet
     * (répété lui aussi sur chaque page) lui réserve sa place pour que le contenu ne passe jamais dessous.
     */
    .doc__sheet { display: table; width: 100%; border-collapse: collapse; table-layout: fixed; }
    .doc__sheet > tbody { display: table-row-group; }
    .doc__sheet > tfoot { display: table-footer-group; }
    .doc__sheet > * > tr { display: table-row; }
    .doc__sheet > * > tr > td { display: table-cell; padding: 0; }
    .doc__sheet-space { height: 30mm; }
    .doc__foot {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        margin: 0;
        padding-top: 2.5mm;
        background: #fff;
        break-inside: avoid;
    }
}
.list__link { color: inherit; text-decoration: none; }
.list__link:hover { text-decoration: underline; text-underline-offset: 3px; }
.pay-item .list__title { white-space: nowrap; }
@media (max-width: 479.98px) {
    .pay-dot { display: none; }
    .methods__grid .method span { font-size: .875rem; padding: .5rem .625rem; }
}
@media (min-width: 1024px) {
    .inv-block, .inv-block.danger-zone { max-width: 820px; }
}

/* ==========================================================================
   Réglages
   ========================================================================== */
.settings-menu .list__item { min-height: 76px; }
.settings-menu__icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(0, 158, 96, .12);
    color: var(--c-green-strong);
}
.settings-menu .list__main { flex: 1; }
.settings-menu__desc { margin-top: .125rem; color: var(--c-muted); font-size: .8125rem; line-height: 1.35; }

.settings-me { display: flex; align-items: center; gap: .875rem; margin-top: 1rem; padding: 1rem; }
.settings-me__text { flex: 1; min-width: 0; }
.settings-me__text .list__meta { overflow-wrap: anywhere; }

.settings-form, .settings-stack { display: grid; gap: 1rem; }
.form-section span .icon { width: 16px; height: 16px; }

/* Aperçu de l'en-tête de facture */
.letterhead__label { margin: 0 .25rem .5rem; color: var(--c-muted); font-size: .8125rem; font-weight: 600; }
.letterhead__paper {
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.375rem 1.125rem 1.125rem;
    border-radius: 6px;
    background: #fff;
    color: #10201a;
    box-shadow: 0 1px 2px rgba(15, 27, 45, .08), 0 14px 32px -16px rgba(15, 27, 45, .3);
    overflow: hidden;
}
.letterhead__paper .doc__from { min-width: 0; color: #5b6678; overflow-wrap: anywhere; }
.letterhead__paper .doc__from p:empty { display: none; }
.letterhead__kind { flex: none; color: #03331f; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.doc__logo-img { flex: none; width: 52px; height: 52px; object-fit: contain; border-radius: 8px; }
.doc__logo-img[hidden], .doc__logo[hidden] { display: none; }

.logo-field__row { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; }
.logo-field__pick { position: relative; cursor: pointer; }
.logo-field__pick:focus-within { box-shadow: 0 0 0 4px var(--c-focus); }
.logo-field { margin-bottom: 1.125rem; }
.check--sm { min-height: 44px; margin: 0; font-size: .9375rem; }

/* Utilisateurs */
.user-row { align-items: flex-start; }
.user-row .avatar { margin-top: .125rem; }
.user-row .list__main { flex: 1; }
.user-row__email { overflow-wrap: anywhere; }
.user-row .list__meta { display: flex; flex-wrap: wrap; align-items: center; gap: .375rem; margin-top: .25rem; }
.user-row__me { color: var(--c-muted); font-weight: 500; }
.user-row__login { font-size: .75rem; }
.user-row.is-inactive .avatar, .user-row.is-inactive .list__title { opacity: .55; }
.user-row form { flex: none; align-self: center; }
.badge--role-admin { background: rgba(247, 127, 0, .14); color: #a14f00; }
.badge--role-agent { background: var(--c-bg); color: var(--c-muted); }

.roles { display: grid; gap: .5rem; margin: 0; padding: 0; border: 0; min-width: 0; }
.role-card { position: relative; display: block; cursor: pointer; }
.role-card input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.role-card__body {
    display: grid;
    gap: .125rem;
    padding: .75rem 1rem .75rem 2.75rem;
    border: 1.5px solid var(--c-border);
    border-radius: var(--radius);
    background: var(--c-surface);
    position: relative;
}
.role-card__body::before {
    content: "";
    position: absolute;
    left: 1rem;
    top: 1rem;
    width: 18px;
    height: 18px;
    border: 2px solid var(--c-border-strong);
    border-radius: 50%;
}
.role-card__body small { color: var(--c-muted); font-size: .8125rem; }
.role-card input:checked + .role-card__body { border-color: var(--c-green-strong); background: rgba(0, 158, 96, .08); }
.role-card input:checked + .role-card__body::before { border-color: var(--c-green-strong); border-width: 6px; }
.role-card input:focus-visible + .role-card__body { box-shadow: 0 0 0 4px var(--c-focus); }

@media (max-width: 479.98px) {
    .user-row { flex-wrap: wrap; }
    .user-row form { width: 100%; padding-left: calc(40px + .75rem); }
    .user-row form .btn { width: 100%; }
}
@media (min-width: 640px) {
    .letterhead__paper { padding: 1.75rem 2rem 1.5rem; }
    .roles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .roles legend { margin-bottom: .5rem; }
    .roles .field__error { grid-column: 1 / -1; }
}
@media (min-width: 1024px) {
    .settings-menu, .settings-me, .settings-form, .settings-stack, .settings-block { max-width: 760px; }
}
@media (max-width: 479.98px) {
    .settings-me { flex-wrap: wrap; }
    .settings-me form { width: 100%; }
    .settings-me form .btn { width: 100%; }
}

/* ==========================================================================
   Devis
   ========================================================================== */
/* Onglets Factures | Devis */
.segmented {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    margin-bottom: 1.25rem;
    padding: 4px;
    border-radius: 14px;
    background: var(--c-border);
}
.segmented__item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    min-height: 44px;
    border-radius: 10px;
    color: var(--c-muted);
    font-weight: 650;
    text-decoration: none;
}
.segmented__item .icon { width: 20px; height: 20px; }
.segmented__item:hover { color: var(--c-text); }
.segmented__item[aria-current="page"] { background: var(--c-surface); color: var(--c-text); box-shadow: 0 1px 3px rgba(15, 27, 45, .14); }
.segmented__item[aria-current="page"] .icon { color: var(--c-green-strong); }
.segmented__item:focus-visible { outline: 2px solid var(--c-green-strong); outline-offset: 1px; }

/* Statuts des devis */
.badge--q-draft { background: var(--c-bg); color: var(--c-muted); }
.badge--q-sent { background: rgba(56, 97, 170, .12); color: #2d5598; }
.badge--q-accepted { background: var(--c-success-bg); color: var(--c-success); }
.badge--q-invoiced { background: rgba(3, 51, 31, .1); color: var(--c-ink); }
.badge--q-declined { background: var(--c-danger-bg); color: var(--c-danger-strong); }
.badge--q-expired { background: rgba(247, 127, 0, .14); color: #a14f00; }
@media (prefers-color-scheme: dark) {
    .badge--q-sent { background: rgba(120, 160, 230, .16); color: #a9c3f0; }
    .badge--q-invoiced { background: rgba(255, 255, 255, .1); color: #e8efeb; }
    .badge--q-expired { background: rgba(247, 127, 0, .18); color: #ffb366; }
}
.inv-hero--q-accepted .inv-hero__state, .inv-hero--q-invoiced .inv-hero__state { color: var(--c-green-strong); font-weight: 600; }
.inv-hero--q-declined .inv-hero__amount strong { color: var(--c-muted); text-decoration: line-through; }

/* Jusqu'à 6 actions : grille de 3 sur mobile */
.actions--wrap { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.actions--wrap .action-form .action { height: 100%; }
.convert-bar { margin: -.25rem 0 1rem; }

/* Bon pour accord (devis imprimé) */
.doc__accept {
    margin: 1.25rem 0 0 auto;
    width: min(100%, 320px);
    min-height: 96px;
    padding: .625rem .75rem;
    border: 1.5px dashed #b7c0cf;
    border-radius: 8px;
    color: #5b6678;
    font-size: .75rem;
    break-inside: avoid;
}

@media (min-width: 640px) {
    .segmented { display: inline-grid; min-width: 320px; }
    .actions--wrap { display: flex; flex-wrap: wrap; }
    .convert-bar .btn { width: auto; }
}
@media (min-width: 1024px) {
    .convert-bar { max-width: 820px; }
}

/* ==========================================================================
   Relances
   ========================================================================== */

/* Onglets à trois entrées + pastille du nombre à relancer */
.segmented--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.segmented--3 .segmented__item { gap: .375rem; padding: 0 .25rem; font-size: .875rem; white-space: nowrap; }
.segmented__badge {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--c-brand);
    color: var(--c-on-brand);
    font-size: .75rem;
    font-weight: 750;
    line-height: 20px;
    text-align: center;
}
@media (max-width: 359px) {
    .segmented--3 .segmented__item .icon { display: none; }
}

.text-warn { color: var(--c-warning); font-weight: 600; }

/* Synthèse */
.rem-summary { margin-bottom: 1rem; padding: 1rem; }
.rem-summary__stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.rem-stat { min-width: 0; padding: .875rem; border-radius: 12px; background: var(--c-bg); }
.rem-stat__label { display: flex; align-items: center; gap: .375rem; color: var(--c-muted); font-size: .8125rem; font-weight: 600; line-height: 1.25; }
.rem-stat__label .icon { flex: none; width: 18px; height: 18px; }
.rem-stat__value {
    margin-top: .375rem;
    font-size: clamp(1.125rem, 1rem + 1vw, 1.5rem);
    font-weight: 750;
    letter-spacing: -.02em;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}
.rem-stat__value small { font-size: .6em; font-weight: 600; color: var(--c-muted); letter-spacing: 0; }
.rem-stat__sub { margin-top: .25rem; color: var(--c-muted); font-size: .8125rem; }
.rem-stat--danger { background: var(--c-danger-bg); }
.rem-stat--danger .rem-stat__label, .rem-stat--danger .rem-stat__value { color: var(--c-danger-strong); }

.rem-summary__title { margin: 1rem 0 .5rem; color: var(--c-muted); font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.aging { display: grid; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.aging__row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "label amount" "bar bar"; align-items: center; gap: .25rem .625rem; font-size: .8125rem; }
.aging__label { grid-area: label; }
.aging__amount { grid-area: amount; }
.aging__bar { grid-area: bar; }
.aging__label { color: var(--c-muted); }
.aging__amount { font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.aging__amount small { color: var(--c-muted); font-weight: 500; }
.aging__bar { width: 100%; height: 8px; border: 0; border-radius: 999px; background: var(--c-bg); overflow: hidden; appearance: none; }
.aging__bar::-webkit-progress-bar { background: var(--c-bg); border-radius: 999px; }
.aging__bar::-webkit-progress-value { border-radius: 999px; background: var(--aging, var(--c-brand)); }
.aging__bar::-moz-progress-bar { border-radius: 999px; background: var(--aging, var(--c-brand)); }
.aging__row--0 { --aging: #f5b041; }
.aging__row--1 { --aging: var(--c-brand); }
.aging__row--2 { --aging: #d9480f; }
.aging__row--3 { --aging: var(--c-danger); }

/* Cartes */
.rem-list { display: grid; gap: .75rem; margin: 0 0 1rem; padding: 0; list-style: none; }
.rem-card {
    min-width: 0;
    padding: 1rem;
    border: 1px solid var(--c-border);
    border-left: 4px solid var(--c-border-strong);
    border-radius: 16px;
    background: var(--c-surface);
    transition: opacity .2s;
}
.rem-card--l1 { border-left-color: #f5b041; }
.rem-card--l2 { border-left-color: var(--c-brand); }
.rem-card--l3 { border-left-color: var(--c-danger); }
.rem-card.is-reminded { opacity: .7; }
.rem-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; }
.rem-card__who { min-width: 0; }
.rem-card__client { font-size: 1.0625rem; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.rem-card__client a { color: inherit; text-decoration: none; }
.rem-card__client a:hover { text-decoration: underline; }
.rem-card__meta { margin-top: .125rem; color: var(--c-muted); font-size: .8125rem; overflow-wrap: anywhere; }
.rem-card .badge { flex: none; }
.rem-card__money { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .25rem .75rem; margin-top: .75rem; font-size: .875rem; }
.rem-card__money strong { font-size: 1.375rem; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.rem-card__money small { font-size: .6em; font-weight: 600; color: var(--c-muted); }
.rem-card__state { display: flex; align-items: center; gap: .375rem; margin-top: .5rem; color: var(--c-muted); font-size: .8125rem; }
.rem-card__state .icon { flex: none; width: 16px; height: 16px; }
.rem-card__state[hidden] { display: none; }
.is-reminded .rem-card__state { color: var(--c-success); font-weight: 600; }
.panel .rem-card__state { margin: 0 1rem .5rem; }
.rem-card__preview { margin-top: .625rem; font-size: .8125rem; }
.rem-card__preview summary { display: inline-flex; min-height: 32px; align-items: center; color: var(--c-green-strong); font-weight: 650; cursor: pointer; }
.rem-card__preview p { margin-top: .25rem; padding: .75rem; border-radius: 12px; background: var(--c-bg); line-height: 1.5; white-space: pre-line; }
.rem-card__actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin-top: .75rem; }
.rem-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .4375rem;
    min-height: 44px;
    padding: 0 .5rem;
    border: 1px solid var(--c-border);
    border-radius: 12px;
    background: var(--c-surface);
    color: var(--c-text);
    font-size: .875rem;
    font-weight: 650;
    text-decoration: none;
}
.rem-btn .icon { flex: none; width: 20px; height: 20px; color: var(--c-green-strong); }
.rem-btn:hover { border-color: var(--c-border-strong); }
.rem-btn:active { transform: scale(.98); }
.rem-btn:focus-visible { outline: 2px solid var(--c-green-strong); outline-offset: 2px; }
/* Sur mobile : WhatsApp en pleine largeur, les autres en tuiles (icône au-dessus) */
.rem-btn:not(.rem-btn--whatsapp) { flex-direction: column; gap: .125rem; min-height: 56px; font-size: .8125rem; }
.rem-btn--whatsapp { grid-column: 1 / -1; min-height: 48px; border-color: transparent; background: var(--c-green-strong); color: #fff; }
.rem-btn--whatsapp .icon { color: #fff; }
.rem-btn--whatsapp:hover { border-color: transparent; background: var(--c-green); }
.rem-card__nocontact { margin-top: .75rem; padding: .75rem; border-radius: 12px; background: var(--c-bg); color: var(--c-muted); font-size: .8125rem; }

/* Niveaux */
.badge--rem-0 { background: rgba(56, 97, 170, .12); color: #2d5598; }
.badge--rem-1 { background: rgba(245, 176, 65, .2); color: #8a5300; }
.badge--rem-2 { background: rgba(247, 127, 0, .16); color: #a14f00; }
.badge--rem-3 { background: var(--c-danger-bg); color: var(--c-danger-strong); }

/* Historique (fiche facture) */
.rem-dot { display: grid; flex: none; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--c-bg); color: var(--c-muted); }
.rem-dot .icon { width: 18px; height: 18px; }
.rem-dot--whatsapp { background: rgba(0, 158, 96, .14); color: var(--c-green-strong); }
.rem-history__none { padding: 0 1rem 1rem; }

@media (prefers-color-scheme: dark) {
    .rem-btn--whatsapp { background: #00804d; }
    .rem-btn--whatsapp:hover { background: #009e60; }
    .badge--rem-0 { background: rgba(120, 160, 230, .16); color: #a9c3f0; }
    .badge--rem-1 { background: rgba(245, 176, 65, .18); color: #f8c471; }
    .badge--rem-2 { background: rgba(247, 127, 0, .18); color: #ffb366; }
}

@media (min-width: 480px) {
    .aging__row { grid-template-columns: 7.5rem minmax(0, 1fr) auto; grid-template-areas: "label bar amount"; }
}
@media (min-width: 560px) {
    .rem-card__actions { grid-template-columns: 1.4fr repeat(3, minmax(0, 1fr)); }
    .rem-btn--whatsapp { grid-column: auto; }
    .rem-btn:not(.rem-btn--whatsapp) { flex-direction: row; gap: .4375rem; min-height: 48px; }
}
@media (min-width: 640px) {
    .segmented--3 { min-width: 420px; }
}
@media (min-width: 1024px) {
    .rem-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .rem-summary { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 1.5rem; align-items: start; }
    .rem-summary__title { grid-column: 2; grid-row: 1; margin-top: 0; }
    .aging { grid-column: 2; grid-row: 1; margin-top: 1.5rem; }
}

/* ==========================================================================
   Catalogue de prestations
   ========================================================================== */

.settings-intro { margin: 0 .25rem 1rem; color: var(--c-muted); font-size: .875rem; line-height: 1.5; }

.svc-group { margin-bottom: 1rem; }
.svc-group__title {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .875rem 1rem .25rem;
    color: var(--c-muted);
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}
.svc-row .list__main { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .5rem; }
.svc-row .list__title { overflow-wrap: anywhere; }
.svc-row.is-inactive .list__title, .svc-row.is-inactive .list__amount { opacity: .55; }
.svc-row .list__side .list__meta { text-align: right; }
.svc-starter { margin-bottom: 1rem; }
.svc-danger { display: grid; gap: .625rem; margin-top: 1rem; }

/* Unités : pastilles à cocher */
.unit-field { min-width: 0; margin: 0; padding: 0; border: 0; }
.unit-field legend { margin-bottom: .5rem; padding: 0; }
.unit-chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.unit-chip { position: relative; }
.unit-chip input { position: absolute; opacity: 0; pointer-events: none; }
.unit-chip span {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: .375rem .875rem;
    border: 1.5px solid var(--c-border);
    border-radius: 999px;
    background: var(--c-surface);
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
}
.unit-chip input:checked + span { border-color: var(--c-green-strong); background: rgba(0, 158, 96, .12); color: var(--c-green-strong); }
.unit-chip input:focus-visible + span { box-shadow: 0 0 0 4px var(--c-focus); }

/* Formulaire : « Ajouter une ligne » + « Catalogue » */
.items-add { display: grid; gap: .5rem; }
.items-add--2 { grid-template-columns: minmax(0, 1fr) auto; }
@media (max-width: 399.98px) {
    .items-add--2 { grid-template-columns: 1fr; }
    .items-add__catalog { width: 100%; }
}
.items-add__catalog { width: auto; padding-inline: 1rem; border-color: var(--c-brand); color: #a14f00; }
.items-add__catalog .icon { color: var(--c-brand); }
.items-add__catalog[hidden] { display: none; }
.items-hint { margin-top: .625rem; font-size: .8125rem; }
.items-hint .link { display: inline-flex; align-items: center; gap: .375rem; }
.items-hint .icon { width: 16px; height: 16px; }
.item.is-new { animation: item-flash 1.6s ease-out; }
@keyframes item-flash { 0%, 40% { box-shadow: 0 0 0 3px rgba(247, 127, 0, .45); } 100% { box-shadow: 0 0 0 0 rgba(247, 127, 0, 0); } }

/* Feuille (dialog) : bas d'écran sur mobile, fenêtre centrée sur ordinateur */
html.has-sheet { overflow: hidden; }
.sheet {
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    margin: auto 0 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--c-text);
}
.sheet::backdrop { background: rgba(3, 20, 12, .55); }
.sheet[open] .sheet__panel { animation: sheet-up .22s ease-out; }
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet__panel {
    position: relative;
    display: flex;
    flex-direction: column;
    max-height: 88dvh;
    border-radius: 20px 20px 0 0;
    background: var(--c-surface);
    box-shadow: 0 -8px 30px rgba(0, 0, 0, .18);
    padding-bottom: env(safe-area-inset-bottom);
}
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1rem .5rem; }
.sheet__head::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    width: 40px;
    height: 4px;
    margin-left: -20px;
    border-radius: 999px;
    background: var(--c-border-strong);
}
.sheet__title { font-size: 1.0625rem; font-weight: 700; }
.sheet__search { position: relative; padding: 0 1rem .75rem; border-bottom: 1px solid var(--c-border); }
.sheet__search .input { padding-left: 2.5rem; }
.sheet__search-icon { position: absolute; top: 50%; left: 1.75rem; width: 20px; height: 20px; margin-top: -16px; color: var(--c-muted); pointer-events: none; }
.sheet__body { flex: 1; min-height: 0; padding: .25rem 1rem 1rem; overflow-y: auto; overscroll-behavior: contain; }
.sheet__empty, .sheet__manage { padding: 1rem 0 0; color: var(--c-muted); font-size: .875rem; text-align: center; }
.sheet__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .75rem 1rem;
    border-top: 1px solid var(--c-border);
}
.sheet__count { color: var(--c-success); font-size: .875rem; font-weight: 650; }

.pick-group[hidden], .pick-list li[hidden] { display: none; }
.pick-group__title { padding: .875rem 0 .375rem; color: var(--c-muted); font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.pick-list { display: grid; gap: .375rem; margin: 0; padding: 0; list-style: none; }
.pick {
    display: flex;
    align-items: center;
    gap: .75rem;
    width: 100%;
    min-height: 56px;
    padding: .5rem .5rem .5rem .875rem;
    border: 1px solid var(--c-border);
    border-radius: 14px;
    background: var(--c-surface);
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    touch-action: manipulation;
}
.pick:hover { border-color: var(--c-border-strong); }
.pick:focus-visible { outline: 2px solid var(--c-green-strong); outline-offset: 1px; }
.pick__text { display: grid; flex: 1; min-width: 0; gap: .125rem; }
.pick__name { font-weight: 650; line-height: 1.3; overflow-wrap: anywhere; }
.pick__price { color: var(--c-muted); font-size: .8125rem; font-variant-numeric: tabular-nums; }
.pick__badge { padding: 0 .5rem; border-radius: 999px; background: var(--c-success-bg); color: var(--c-success); font-size: .8125rem; font-weight: 700; line-height: 24px; }
.pick__badge[hidden] { display: none; }
.pick__add { display: grid; flex: none; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--c-brand); color: var(--c-on-brand); }
.pick__add .icon { width: 20px; height: 20px; }
.pick.is-picked { animation: pick-ok .45s ease-out; }
@keyframes pick-ok { 0% { background: var(--c-success-bg); border-color: var(--c-success-border); } 100% { background: var(--c-surface); } }

@media (prefers-reduced-motion: reduce) {
    .sheet[open] .sheet__panel, .pick.is-picked, .item.is-new { animation: none; }
}

@media (min-width: 640px) {
    .sheet { width: min(560px, calc(100% - 2rem)); margin: auto; }
    .sheet__panel { max-height: min(720px, 85dvh); border-radius: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
    .sheet__head::before { display: none; }
    .svc-danger { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
    .svc-group, .svc-starter, .svc-danger, .settings-intro { max-width: 760px; }
}

/* ==========================================================================
   Rapports
   ========================================================================== */

.reports-head { align-items: flex-start; }
.reports-head__actions { display: flex; flex: none; gap: .5rem; }
.reports-head__actions [hidden] { display: none; }
.export-menu > summary { list-style: none; cursor: pointer; }
.export-menu > summary::-webkit-details-marker { display: none; }
.export-menu .menu__panel { z-index: 30; width: min(300px, calc(100vw - 2rem)); }
.export-menu__hint { padding: .5rem .75rem .25rem; color: var(--c-muted); font-size: .75rem; line-height: 1.4; }

.filter--plain { padding-right: .875rem; }

.period-custom { margin-bottom: 1rem; }
.period-custom__summary {
    display: flex;
    align-items: center;
    gap: .5rem;
    min-height: 48px;
    padding: 0 1rem;
    font-size: .875rem;
    font-weight: 650;
    list-style: none;
    cursor: pointer;
}
.period-custom__summary::-webkit-details-marker { display: none; }
.period-custom__summary .icon { width: 18px; height: 18px; color: var(--c-green-strong); }
.period-custom__chevron { margin-left: auto; transition: transform .2s; }
.period-custom[open] .period-custom__chevron { transform: rotate(90deg); }
.period-custom__form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; padding: 0 1rem 1rem; }
.period-custom__form .btn { grid-column: 1 / -1; }

.report-kpis .kpi:not(.kpi--brand) .trend--up { color: var(--c-success); }
.report-kpis .kpi:not(.kpi--brand) .trend--down { color: var(--c-danger-strong); }
.kpi--warn { border-color: rgba(247, 127, 0, .35); background: rgba(247, 127, 0, .07); }
.kpi--warn .kpi__value { color: #a14f00; }
.report-stats .stat__label { text-transform: none; letter-spacing: 0; font-size: .75rem; }

.kpis-more {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .375rem;
    min-height: 44px;
    margin: -.25rem 0 1rem;
    color: var(--c-green-strong);
    font-size: .875rem;
    font-weight: 650;
    text-decoration: none;
}
.kpis-more .icon { width: 18px; height: 18px; }

/* Graphique */
.chart-panel { margin-bottom: 1rem; }
.chart-panel .panel__head { flex-wrap: wrap; align-items: flex-start; }
.legend { display: flex; gap: .875rem; margin: 0; padding: 0; list-style: none; font-size: .8125rem; color: var(--c-muted); }
.legend__item { display: flex; align-items: center; gap: .375rem; }
.legend__item::before { content: ""; width: 10px; height: 10px; border-radius: 3px; }
.legend__item--invoiced::before { background: var(--c-green); }
.legend__item--collected::before { background: var(--c-brand); }
.chart { padding: .5rem 1rem 0; }
.chart__svg { display: block; width: 100%; height: 180px; overflow: visible; }
.chart__grid { stroke: var(--c-border); stroke-width: 1; stroke-dasharray: 4 6; vector-effect: non-scaling-stroke; }
.chart__axis { stroke: var(--c-border-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart__bar--invoiced { fill: var(--c-green); }
.chart__bar--collected { fill: var(--c-brand); }
.chart__months { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); margin: .375rem 0 0; padding: 0; list-style: none; color: var(--c-muted); font-size: .6875rem; text-align: center; }
.chart__m-long { display: none; }
.chart__detail { margin-top: .5rem; padding: 0 1rem 1rem; font-size: .875rem; }
.chart__detail summary { display: inline-flex; align-items: center; min-height: 40px; color: var(--c-green-strong); font-weight: 650; cursor: pointer; }
.report-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.report-table th, .report-table td { padding: .5rem .25rem; border-top: 1px solid var(--c-border); text-align: right; white-space: nowrap; }
.report-table th:first-child { text-align: left; font-weight: 550; }
.report-table thead th { border-top: 0; color: var(--c-muted); font-size: .75rem; font-weight: 600; }

/* Classements */
.report-grid { display: grid; gap: 1rem; }
.report-block { min-width: 0; }
.report-block .panel__head .link { flex: none; font-size: .8125rem; }
.rank { margin: 0; padding: 0 1rem 1rem; list-style: none; }
.rank__item { padding: .75rem 0; border-top: 1px solid var(--c-border); }
.rank__item:first-child { border-top: 0; }
.rank__item--method { display: flex; gap: .75rem; align-items: flex-start; }
.rank__body { flex: 1; min-width: 0; }
.rank__top { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; }
.rank__name { min-width: 0; color: inherit; font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
a.rank__name:hover { text-decoration: underline; }
.rank__amount { flex: none; font-variant-numeric: tabular-nums; }
.rank__bar { display: block; width: 100%; height: 6px; margin: .5rem 0 .375rem; border: 0; border-radius: 999px; background: var(--c-bg); overflow: hidden; appearance: none; }
.rank__bar::-webkit-progress-bar { background: var(--c-bg); border-radius: 999px; }
.rank__bar::-webkit-progress-value { background: var(--c-brand); border-radius: 999px; }
.rank__bar::-moz-progress-bar { background: var(--c-brand); border-radius: 999px; }
.rank__bar--green::-webkit-progress-value { background: var(--c-green); }
.rank__bar--green::-moz-progress-bar { background: var(--c-green); }
.rank__meta { color: var(--c-muted); font-size: .8125rem; }
.text-ok { color: var(--c-success); font-weight: 600; }
.report-empty { padding: 0 1rem 1rem; color: var(--c-muted); font-size: .875rem; }

@media (prefers-color-scheme: dark) {
    .kpi--warn .kpi__value { color: #ffb366; }
}

@media (min-width: 480px) {
    .chart__m-long { display: inline; }
    .chart__m-short { display: none; }
    .chart__svg { height: 220px; }
}
@media (min-width: 1024px) {
    .report-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .report-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
    .report-grid > :first-child { grid-row: span 2; }
}

@media print {
    .chart__svg { height: 200px; }
    .chart__detail summary { display: none; }
    .report-grid { grid-template-columns: 1fr 1fr; }
    .kpi--brand { background: #fff !important; color: var(--c-text) !important; border: 1px solid #ccc !important; }
    .kpi--brand .kpi__label, .kpi--brand .kpi__sub, .kpi--brand .kpi__value small { color: #555 !important; }
    .panel, .kpi, .stats { break-inside: avoid; box-shadow: none; }
    .report-kpis { grid-template-columns: repeat(4, 1fr); }
    .rank__bar, .chart__bar--invoiced, .chart__bar--collected { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .report-kpis .kpi__value { font-size: 15pt; overflow-wrap: normal; white-space: nowrap; }
    .report-kpis .trend--up { color: #067647 !important; }
    .report-kpis .trend--down { color: #b42318 !important; }
    .report-block { break-inside: auto; }
    .rank__item { break-inside: avoid; }
}
@media (max-width: 399.98px) {
    .reports-head { flex-wrap: wrap; }
    .reports-head__actions { width: 100%; }
    .reports-head__actions .export-menu { flex: 1; }
    .reports-head__actions .export-menu > summary { width: 100%; justify-content: center; }
    .report-stats { grid-template-columns: 1fr; }
    .report-stats .stat { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; }
    .report-stats .stat + .stat { border-left: 0; border-top: 1px solid var(--c-border); }
    .report-stats .stat__value { margin: 0; white-space: nowrap; }
}

/* ==========================================================================
   Application installable
   ========================================================================== */

.install-banner {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: .75rem .875rem;
    align-items: center;
    margin-bottom: 1rem;
    padding: .875rem 1rem;
    border: 1px solid rgba(0, 158, 96, .3);
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(0, 158, 96, .1), rgba(247, 127, 0, .08)), var(--c-surface);
}
.install-banner[hidden] { display: none; }
.install-banner__icon { width: 48px; height: 48px; border-radius: 12px; }
.install-banner__title { font-size: .9375rem; font-weight: 700; line-height: 1.3; }
.install-banner__desc { margin-top: .125rem; color: var(--c-muted); font-size: .8125rem; line-height: 1.4; }
.install-banner__desc--ios, .install-banner.is-ios .install-banner__desc--android, .install-banner.is-ios .install-banner__go { display: none; }
.install-banner.is-ios .install-banner__desc--ios { display: block; }
.install-banner__actions { display: flex; grid-column: 1 / -1; gap: .5rem; }
.install-banner__actions .btn { flex: 1; }
.menu__item[hidden] { display: none; }
@media (min-width: 640px) {
    .install-banner { grid-template-columns: auto minmax(0, 1fr) auto; }
    .install-banner__actions { grid-column: auto; }
}
/* Ouverte depuis l'écran d'accueil : la bannière n'a plus de sens */
@media (display-mode: standalone) {
    .install-banner { display: none !important; }
}

/* Page hors ligne */
.offline-body {
    display: grid;
    min-height: 100dvh;
    place-items: center;
    padding: max(1.5rem, env(safe-area-inset-top)) 1.25rem max(1.5rem, env(safe-area-inset-bottom));
    background:
        linear-gradient(90deg, var(--c-brand) 0 33.3%, #fff 33.3% 66.6%, var(--c-green) 66.6%) top / 100% 4px no-repeat,
        var(--c-bg);
}
.offline { width: min(420px, 100%); text-align: center; }
.offline__icon { width: 72px; height: 72px; margin: 0 auto 1.25rem; border-radius: 18px; box-shadow: 0 10px 30px rgba(247, 127, 0, .3); }
.offline__title { font-size: 1.5rem; font-weight: 750; letter-spacing: -.01em; }
.offline__text { margin-top: .75rem; line-height: 1.5; }
.offline__hint { margin: .75rem 0 1.5rem; color: var(--c-muted); font-size: .875rem; line-height: 1.5; }
.offline__status { min-height: 1.5em; margin-top: .75rem; color: var(--c-muted); font-size: .875rem; }
.panel--alert .panel__head .link { flex: none; }

/* Pages d'erreur (404, 500…) : même gabarit que la page hors ligne */
.error-page__code { margin-bottom: .35rem; color: var(--c-muted); font-size: .8125rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; }
.error-page__btn { margin-top: 1.5rem; }
.error-page__debug { margin-top: 1.5rem; text-align: left; font-size: .8125rem; }
.error-page__debug summary { cursor: pointer; color: var(--c-muted); }
.error-page__debug pre { overflow: auto; max-height: 50vh; margin-top: .5rem; padding: .75rem; border: 1px solid var(--c-border); border-radius: 10px; background: var(--c-surface); white-space: pre-wrap; word-break: break-word; }

/* Réglages > Sauvegardes */
.bk-state {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: .875rem;
    align-items: start;
    margin-bottom: 1rem;
    padding: 1rem;
    border: 1px solid var(--c-success-border);
    border-radius: 16px;
    background: var(--c-success-bg);
}
.bk-state__icon { display: grid; width: 40px; height: 40px; place-items: center; border-radius: 12px; background: var(--c-success); color: #fff; }
.bk-state__icon .icon { width: 22px; height: 22px; }
.bk-state__title { font-size: 1rem; font-weight: 700; line-height: 1.3; }
.bk-state__text { margin-top: .25rem; color: var(--c-text); font-size: .875rem; line-height: 1.5; }
.bk-state--stale, .bk-state--none { border-color: rgba(247, 127, 0, .45); background: rgba(247, 127, 0, .1); }
.bk-state--stale .bk-state__icon, .bk-state--none .bk-state__icon { background: var(--c-brand); color: var(--c-on-brand); }
.bk-list { margin-bottom: 1rem; }
.bk-row { gap: .75rem; }
.bk-row .btn { flex: none; }
.bk-tip { margin: 0 .25rem 1rem; color: var(--c-muted); font-size: .875rem; line-height: 1.5; }
.bk-tip__title { margin-bottom: .25rem; color: var(--c-text); font-size: .9375rem; font-weight: 700; }
.bk-tip__code { margin-top: .5rem; font-size: .8125rem; overflow-wrap: anywhere; }
@media (min-width: 1024px) {
    .bk-state, .bk-list, .bk-tip { max-width: 760px; }
}

/* ==========================================================================
   Dépenses
   ========================================================================== */

/* Onglets à quatre entrées : sur téléphone, icône au-dessus du libellé */
.segmented--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.segmented--4 .segmented__item { position: relative; flex-direction: column; gap: .125rem; min-height: 52px; padding: .25rem .125rem; font-size: .75rem; line-height: 1.2; }
.segmented--4 .segmented__item .icon { display: block; }
.segmented--4 .segmented__badge { position: absolute; top: 3px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; font-size: .6875rem; line-height: 18px; }
@media (min-width: 640px) {
    .segmented--4 { min-width: 520px; }
    .segmented--4 .segmented__item { flex-direction: row; gap: .375rem; min-height: 44px; padding: 0 .5rem; font-size: .875rem; }
    .segmented--4 .segmented__badge { position: static; }
}

/* Pastille de catégorie (liste, formulaire, fiche facture) */
.exp-ico { display: grid; flex: none; width: 40px; height: 40px; place-items: center; border-radius: 12px; background: var(--exp-bg, var(--c-bg)); color: var(--exp, var(--c-muted)); }
.exp-ico .icon { width: 20px; height: 20px; }
.exp-ico--transport { --exp: #2d5598; --exp-bg: rgba(56, 97, 170, .12); }
.exp-ico--carburant { --exp: #b54708; --exp-bg: rgba(247, 127, 0, .14); }
.exp-ico--hebergement { --exp: #6941c6; --exp-bg: rgba(122, 90, 248, .12); }
.exp-ico--repas { --exp: #a15c07; --exp-bg: rgba(245, 176, 65, .18); }
.exp-ico--materiel { --exp: #00804d; --exp-bg: rgba(0, 158, 96, .12); }
.exp-ico--pigistes { --exp: #c11574; --exp-bg: rgba(221, 37, 144, .1); }
.exp-ico--communication { --exp: #0e7090; --exp-bg: rgba(29, 200, 242, .14); }
.exp-ico--impression { --exp: #475467; --exp-bg: rgba(71, 84, 103, .12); }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .exp-ico { --exp: #e8efeb; }
    :root:not([data-theme="light"]) .exp-ico--carburant, :root:not([data-theme="light"]) .exp-ico--repas { --exp: #ffb366; }
    :root:not([data-theme="light"]) .exp-ico--materiel { --exp: #4fd1a1; }
    :root:not([data-theme="light"]) .exp-ico--transport { --exp: #a9c3f0; }
}

/* Mois : navigation, total, répartition */
.exp-month { margin-bottom: 1rem; padding: 1rem; }
.exp-month__nav { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin: -.375rem -.375rem .5rem; }
.exp-month__name { font-size: 1.0625rem; font-weight: 700; }
.icon-btn.is-disabled { opacity: .3; pointer-events: none; }
.exp-month__label { color: var(--c-muted); font-size: .8125rem; font-weight: 600; text-align: center; }
.exp-month__total { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; text-align: center; font-variant-numeric: tabular-nums; }
.exp-month__total small { color: var(--c-muted); font-size: .875rem; font-weight: 650; letter-spacing: 0; }
.exp-month__sub { margin-top: .25rem; color: var(--c-muted); font-size: .8125rem; text-align: center; }
.exp-split { display: grid; gap: .625rem; margin: 1rem 0 0; padding: 1rem 0 0; border-top: 1px solid var(--c-border); list-style: none; }
.exp-split__row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "label amount" "bar bar"; align-items: center; gap: .25rem .625rem; font-size: .8125rem; }
.exp-split__label { grid-area: label; display: flex; align-items: center; gap: .375rem; min-width: 0; }
.exp-split__label .icon { width: 16px; height: 16px; color: var(--c-muted); flex: none; }
.exp-split__amount { grid-area: amount; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.exp-split__bar { grid-area: bar; width: 100%; height: 8px; border: 0; border-radius: 999px; background: var(--c-bg); overflow: hidden; appearance: none; }
.exp-split__bar::-webkit-progress-bar { background: var(--c-bg); border-radius: 999px; }
.exp-split__bar::-webkit-progress-value { border-radius: 999px; background: var(--c-brand); }
.exp-split__bar::-moz-progress-bar { border-radius: 999px; background: var(--c-brand); }

/* Jours */
.exp-day { margin-bottom: .75rem; }
.exp-day__title { display: flex; justify-content: space-between; gap: 1rem; padding: .75rem 1rem .25rem; color: var(--c-muted); font-size: .8125rem; font-weight: 700; }
.exp-day__sum { font-variant-numeric: tabular-nums; white-space: nowrap; }
.exp-row { display: flex; align-items: center; border-top: 1px solid var(--c-border); }
.exp-day .exp-row:first-child { border-top: 0; }
.exp-row__main { flex: 1; min-width: 0; border-top: 0; color: inherit; text-decoration: none; }
.exp-row__main .list__meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exp-row__receipt { flex: none; margin-right: .5rem; color: var(--c-muted); }
.exp-row .list__amount { flex: none; }

/* Formulaire */
.exp-form__amount { font-size: 1.75rem; }
.cat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
.cat { position: relative; display: block; cursor: pointer; }
.cat input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.cat > span { display: flex; flex-direction: column; align-items: center; gap: .375rem; min-height: 84px; padding: .625rem .25rem; border: 1.5px solid var(--c-border); border-radius: 14px; background: var(--c-field); font-size: .8125rem; font-weight: 600; line-height: 1.2; text-align: center; overflow-wrap: anywhere; }
.cat:hover > span { border-color: var(--c-border-strong); }
.cat input:checked + span { border-color: var(--c-green-strong); background: rgba(0, 158, 96, .1); box-shadow: inset 0 0 0 1px var(--c-green-strong); }
.cat input:focus-visible + span { box-shadow: 0 0 0 4px var(--c-focus); }
.methods.is-invalid .cat > span { border-color: var(--c-danger-border); }
.receipt__input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.receipt__btn { position: relative; }
.receipt__btn:focus-within { box-shadow: 0 0 0 4px var(--c-focus); }
.receipt__preview, .receipt__thumb { display: block; max-width: 100%; max-height: 260px; margin-bottom: .5rem; border: 1px solid var(--c-border); border-radius: 12px; object-fit: contain; background: var(--c-bg); }
.receipt__preview[hidden] { display: none; }
.receipt__info { margin-bottom: .5rem; color: var(--c-success); font-size: .875rem; font-weight: 650; }
.receipt__info:empty { display: none; }
.receipt__current { display: grid; gap: .5rem; margin-bottom: .75rem; }
.receipt__current[hidden] { display: none; }
.receipt__current.is-removed .receipt__thumb, .receipt__current.is-removed .receipt__pdf { opacity: .35; }
.receipt__actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; }
.receipt__actions .check { margin: 0; }
.receipt__pdf { display: inline-flex; align-items: center; gap: .5rem; padding: .75rem 1rem; border-radius: 12px; background: var(--c-bg); font-weight: 600; }
.exp-delete { margin-top: 1rem; }
@media (min-width: 640px) {
    .cat-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
    .exp-month, .exp-day, .filters--exp { max-width: 820px; }
    .exp-form, .exp-delete { max-width: 760px; }
}

/* Fiche facture : rentabilité de la mission */
.mission__figures { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; padding: .25rem 1rem 1rem; }
.mission__fig { min-width: 0; padding: .625rem .75rem; border-radius: 12px; background: var(--c-bg); }
.mission__fig dt { color: var(--c-muted); font-size: .75rem; font-weight: 600; }
.mission__fig dd { margin: .125rem 0 0; font-weight: 750; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; line-height: 1.25; }
.mission__fig small { display: block; color: var(--c-muted); font-size: .75rem; font-weight: 600; }
.mission__fig--good dd { color: var(--c-success); }
.mission__fig--bad dd { color: var(--c-danger-strong); }
.mission .list__item .list__amount { color: var(--c-text); }
.mission__none { padding: 0 1rem 1rem; color: var(--c-muted); font-size: .875rem; }

/* Feuille « Créer » du bouton + */
.create-list { display: grid; gap: .5rem; margin: 0; padding: .25rem 1rem calc(1rem + env(safe-area-inset-bottom)); list-style: none; }
.create-item { display: flex; align-items: center; gap: .875rem; min-height: 64px; padding: .625rem .75rem; border: 1px solid var(--c-border); border-radius: 14px; color: var(--c-text); text-decoration: none; }
.create-item:hover { border-color: var(--c-border-strong); background: var(--c-bg); }
.create-item:focus-visible { outline: 3px solid var(--c-green-strong); outline-offset: 2px; }
.create-item strong { display: block; font-weight: 700; }
.create-item small { display: block; margin-top: .125rem; color: var(--c-muted); font-size: .8125rem; line-height: 1.35; }
.create-item__ico { display: grid; flex: none; width: 44px; height: 44px; place-items: center; border-radius: 12px; background: rgba(247, 127, 0, .14); color: #b54708; }
.create-item__ico--exp { background: rgba(0, 158, 96, .12); color: var(--c-green-strong); }
.create-item__ico .icon { width: 22px; height: 22px; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .create-item__ico { color: #ffb366; }
    :root:not([data-theme="light"]) .create-item__ico--exp { color: #4fd1a1; }
}

/* Rapports : dépenses et marge (pleine largeur, en fin de grille) */
.report-spending { grid-column: 1 / -1; }
.report-sub { padding: .75rem 1rem .25rem; border-top: 1px solid var(--c-border); color: var(--c-muted); font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.report-note { padding: 0 1rem 1rem; color: var(--c-muted); font-size: .8125rem; }
.rank__amount.text-danger { font-weight: 700; }
@media (max-width: 399px) {
    .exp-row .exp-ico { display: none; }
    .exp-row__main { gap: .5rem; padding-right: .5rem; }
    .exp-row .list__amount { font-size: .875rem; }
    .exp-row__receipt { width: 36px; height: 36px; margin-right: .25rem; }
    .cat > span { font-size: .75rem; }
}
.mission__fig dd { white-space: nowrap; }
@media (max-width: 399px) {
    .mission__figures { grid-template-columns: 1fr; gap: .375rem; }
    .mission__fig { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 .75rem; padding: .5rem .75rem; }
    .mission__fig dt { font-size: .8125rem; }
    .mission__fig small { flex-basis: 100%; text-align: right; }
}

/* Pied de page légal des factures et devis */
.doc__legal { margin-top: .125rem; font-size: .6875rem; line-height: 1.45; text-wrap: balance; overflow-wrap: anywhere; }
.footer-input { min-height: 7.5rem; font-size: .9375rem; line-height: 1.45; }
@media print {
    .doc__legal { font-size: 7.5pt; line-height: 1.35; }
}
.bk-update__btn { margin-top: .75rem; }
.update-notice { display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; padding: .75rem 1rem; border: 1px solid rgba(247, 127, 0, .45); border-radius: 14px; background: rgba(247, 127, 0, .1); font-size: .875rem; font-weight: 600; }
.update-notice .icon { flex: none; width: 20px; height: 20px; color: #b54708; }
.update-notice span { flex: 1; min-width: 0; }
.update-notice .link { flex: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .update-notice .icon { color: #ffb366; }
}

/* ---- Fenêtre de confirmation (remplace confirm() du navigateur) -------
   Feuille du bas sur mobile, carte centrée sur ordinateur. Variante « danger » pour supprimer / annuler. */
.confirm {
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    margin: auto 0 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--c-text);
    overflow: visible;
}
.confirm::backdrop { background: rgba(3, 20, 12, .6); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.confirm[open]::backdrop { animation: confirm-fade .22s ease-out; }
.confirm.is-closing::backdrop { animation: confirm-fade-out .2s ease-in forwards; }

.confirm__panel {
    position: relative;
    display: grid;
    justify-items: center;
    gap: .5rem;
    padding: 2rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom));
    border-radius: 24px 24px 0 0;
    background: var(--c-surface);
    box-shadow: 0 -12px 40px rgba(0, 0, 0, .22);
    text-align: center;
    overflow: hidden;
}
.confirm__panel::before {          /* liseré tricolore */
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: linear-gradient(90deg, #f77f00 0 33.33%, #ffffff 33.33% 66.66%, #009e60 66.66%);
}
.confirm__panel::after {           /* poignée de la feuille (mobile) */
    content: "";
    position: absolute;
    top: 12px;
    left: 50%;
    width: 40px;
    height: 4px;
    margin-left: -20px;
    border-radius: 999px;
    background: var(--c-border-strong);
}
.confirm[open] .confirm__panel { animation: confirm-up .36s cubic-bezier(.2, .9, .3, 1.12); }
.confirm.is-closing .confirm__panel { animation: confirm-down .2s ease-in forwards; }

.confirm__icon {
    position: relative;
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    margin: .25rem 0 .5rem;
    border-radius: 50%;
    background: rgba(247, 127, 0, .14);
    color: #c25e00;
}
.confirm__icon::after {            /* onde qui s'élargit à l'ouverture */
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border: 2px solid currentColor;
    opacity: 0;
}
.confirm[open] .confirm__icon { animation: confirm-pop .5s .08s cubic-bezier(.2, .9, .3, 1.35) both; }
.confirm[open] .confirm__icon::after { animation: confirm-ring .9s .25s ease-out; }
.confirm__icon .icon { width: 30px; height: 30px; }
.confirm__icon-default { display: none; }
.confirm__icon:not(.has-custom) .confirm__icon-default--primary { display: contents; }

.confirm--danger .confirm__icon { background: var(--c-danger-bg); color: var(--c-danger-strong); }
.confirm--danger .confirm__icon:not(.has-custom) .confirm__icon-default--primary { display: none; }
.confirm--danger .confirm__icon:not(.has-custom) .confirm__icon-default--danger { display: contents; }

.confirm__title { max-width: 30ch; margin: 0; font-size: 1.1875rem; font-weight: 750; line-height: 1.3; overflow-wrap: anywhere; }
.confirm__text { max-width: 38ch; margin: 0; color: var(--c-muted); font-size: .9375rem; line-height: 1.5; }
.confirm__text:empty { display: none; }

.confirm__actions { display: grid; gap: .625rem; width: 100%; margin-top: 1.25rem; }
.confirm__actions .btn { width: 100%; }
.confirm__actions [data-confirm-ok] { order: -1; }   /* mobile : action principale en haut, sous le pouce */

.btn--danger-solid { background: #b42318; color: #fff; }
.btn--danger-solid:hover { background: #912018; }
.btn--danger-solid:focus-visible { box-shadow: 0 0 0 4px rgba(180, 35, 24, .3); }

@keyframes confirm-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes confirm-fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes confirm-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes confirm-down { from { transform: none; } to { transform: translateY(100%); } }
@keyframes confirm-pop { 0% { transform: scale(.4); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes confirm-ring { 0% { transform: scale(1); opacity: .5; } 100% { transform: scale(1.6); opacity: 0; } }

@media (min-width: 640px) {
    .confirm { width: min(440px, calc(100% - 2rem)); margin: auto; }
    .confirm__panel { padding: 2.25rem 1.75rem 1.5rem; border-radius: 24px; box-shadow: 0 24px 70px rgba(0, 0, 0, .35); }
    .confirm__panel::after { display: none; }
    .confirm__actions { grid-template-columns: 1fr 1fr; }
    .confirm__actions [data-confirm-ok] { order: 0; }
    .confirm[open] .confirm__panel { animation: confirm-in .3s cubic-bezier(.2, .9, .3, 1.15); }
    .confirm.is-closing .confirm__panel { animation: confirm-out .18s ease-in forwards; }
}
@keyframes confirm-in { from { transform: translateY(12px) scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes confirm-out { from { transform: none; opacity: 1; } to { transform: scale(.96); opacity: 0; } }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .confirm__icon { background: rgba(247, 127, 0, .18); color: #ffb366; }
    :root:not([data-theme="light"]) .confirm--danger .confirm__icon { background: var(--c-danger-bg); color: var(--c-danger-strong); }
    :root:not([data-theme="light"]) .confirm__panel { box-shadow: 0 -12px 40px rgba(0, 0, 0, .6); border-top: 1px solid var(--c-border); }
}

@media (prefers-reduced-motion: reduce) {
    .confirm[open] .confirm__panel, .confirm.is-closing .confirm__panel, .confirm[open] .confirm__icon,
    .confirm[open] .confirm__icon::after, .confirm[open]::backdrop, .confirm.is-closing::backdrop { animation: none; }
}

/* ---- Lien client (fiche facture / devis) ------------------------------ */
.share-box {
    margin: 0 0 1rem;
    padding: 1rem;
    border: 1px solid var(--c-border);
    border-radius: 18px;
    background: var(--c-surface);
    box-shadow: var(--shadow-card);
}
.share-box__head { display: flex; gap: .75rem; align-items: flex-start; }
.share-box__ico { display: grid; flex: none; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--c-success-bg); color: var(--c-success); }
.share-box__ico .icon { width: 20px; height: 20px; }
.share-box__title { margin: 0; font-size: 1rem; font-weight: 700; }
.share-box__hint { margin: .125rem 0 0; color: var(--c-muted); font-size: .8125rem; line-height: 1.45; }
.share-box__row { display: flex; gap: .5rem; margin-top: .875rem; }
.share-box__url { flex: 1; min-width: 0; min-height: 48px; padding-inline: .875rem; font-size: .875rem; color: var(--c-muted); text-overflow: ellipsis; }
.share-box__copy { flex: none; min-height: 48px; padding-inline: 1rem; }
.share-box__copy .icon { width: 18px; height: 18px; }
.share-box__copy.is-done { background: var(--c-green); color: #fff; }
.share-box__actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.share-box__actions form { display: contents; }
.chip-btn {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    min-height: 40px;
    padding: .375rem .875rem;
    border: 1px solid var(--c-border-strong);
    border-radius: 999px;
    background: transparent;
    color: var(--c-text);
    font: inherit;
    font-size: .875rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    touch-action: manipulation;
}
.chip-btn:hover { background: var(--c-bg); }
.chip-btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--c-focus); }
.chip-btn .icon { width: 18px; height: 18px; }
.chip-btn[hidden] { display: none; }
@media (min-width: 1024px) {
    .share-box { max-width: 820px; }
}

/* ---- Page publique : document consulté par le client ------------------ */
.public-body { min-height: 100dvh; margin: 0; background: #eef1f5; color: #10201a; font-family: var(--font); }
.share-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #03331f;
    color: #fff;
    padding-top: env(safe-area-inset-top);
    box-shadow: 0 2px 12px rgba(0, 0, 0, .18);
}
.share-bar::before { content: ""; display: block; height: 3px; background: linear-gradient(90deg, #f77f00 0 33.33%, #ffffff 33.33% 66.66%, #009e60 66.66%); }
.share-bar__inner { display: flex; align-items: center; justify-content: space-between; gap: .75rem; max-width: 860px; margin: 0 auto; padding: .625rem 1rem; }
.share-bar__title { display: grid; min-width: 0; margin: 0; line-height: 1.25; }
.share-bar__title strong { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.share-bar__title span { color: rgba(255, 255, 255, .72); font-size: .8125rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.share-bar__btn { flex: none; min-height: 44px; padding: .5rem 1rem; font-size: .9375rem; }
.share-bar__btn .icon { width: 18px; height: 18px; }
.share-page__main { max-width: 860px; margin: 0 auto; padding: .75rem 1rem 2rem; }
.share-page__hint { margin: .5rem 0 0; color: #5b6678; font-size: .8125rem; text-align: center; }
.share-page__by { margin: 0; color: #5b6678; font-size: .75rem; text-align: center; }
@media (max-width: 379.98px) {
    .share-bar__btn { padding-inline: .75rem; font-size: .875rem; }
}
@media print {
    .public-body { background: #fff; }
    .share-page__main { max-width: none; padding: 0; }
}
