/* Inter, self-hosted (no request to Google Fonts: GDPR + works offline). */
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("fonts/InterVariable.2bf3d951bf9d.woff2") format("woff2");
}

/* --- Design tokens --------------------------------------------------------
   Light by default. Dark applies when the OS asks for it (unless the user
   forced light with the toggle), or when the user forced dark. */
:root {
    color-scheme: light;
    --bg: #f5f5fb;
    --surface: #ffffff;
    --surface-2: #f9fafc;
    --text: #17172b;
    --text-muted: #6b6b85;
    --border: #e6e6f0;

    --primary: #6d5bf6;
    --primary-hover: #5a48e8;
    --primary-soft: #efecfe;
    --primary-contrast: #ffffff;

    --accent: #ff7a59;

    --success: #16a34a;
    --success-soft: #dcfce7;
    --success-text: #14532d;

    --warning: #d97706;
    --warning-soft: #fef3c7;
    --warning-text: #78350f;

    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --danger-text: #7f1d1d;

    --info: #2563eb;
    --info-soft: #dbeafe;
    --info-text: #1e3a8a;

    --neutral-soft: #eceef3;
    --neutral-text: #3f3f52;

    /* Chart series (validated for colour-vision deficiencies, see dataviz check). */
    --serie-n: #6d5bf6;
    --serie-n1: #e0714f;
    --grille: #ececf3;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(23, 23, 43, 0.06), 0 4px 16px rgba(23, 23, 43, 0.06);
    --sidebar-w: 232px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #131320;
        --surface: #1b1b2c;
        --surface-2: #222236;
        --text: #f2f2f8;
        --text-muted: #9d9db3;
        --border: #2c2c40;
        --primary: #8b7bff;
        --primary-hover: #a294ff;
        --primary-soft: #2a2450;
        --success-soft: #103822;
        --success-text: #86efac;
        --warning-soft: #3a2a08;
        --warning-text: #fcd34d;
        --danger-soft: #3a1414;
        --danger-text: #fca5a5;
        --info-soft: #122a4d;
        --info-text: #93c5fd;
        --neutral-soft: #26263a;
        --neutral-text: #c7c7dc;
        --serie-n: #8b7bff;
        --serie-n1: #d9704f;
        --grille: #2a2a3e;
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 20px rgba(0, 0, 0, 0.35);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #131320;
    --surface: #1b1b2c;
    --surface-2: #222236;
    --text: #f2f2f8;
    --text-muted: #9d9db3;
    --border: #2c2c40;
    --primary: #8b7bff;
    --primary-hover: #a294ff;
    --primary-soft: #2a2450;
    --success-soft: #103822;
    --success-text: #86efac;
    --warning-soft: #3a2a08;
    --warning-text: #fcd34d;
    --danger-soft: #3a1414;
    --danger-text: #fca5a5;
    --info-soft: #122a4d;
    --info-text: #93c5fd;
    --neutral-soft: #26263a;
    --neutral-text: #c7c7dc;
    --serie-n: #8b7bff;
    --serie-n1: #d9704f;
    --grille: #2a2a3e;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 20px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
    font-family: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
    font-feature-settings: "tnum" 1, "cv11" 1;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
}

a { color: var(--primary); }

.icone {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* --- Sidebar --- */

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1.25rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--text);
    text-decoration: none;
    padding: 0.4rem 0.6rem 1rem;
}

.sidebar .brand .brand-icon { width: 24px; height: 24px; object-fit: contain; }

.sidebar .search { margin-bottom: 0.75rem; }
.sidebar .search input {
    width: 100%;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    background: var(--surface-2);
    color: var(--text);
    font-family: inherit;
}
.sidebar .search input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.sidebar nav { display: flex; flex-direction: column; gap: 0.1rem; }

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    padding: 0.5rem 0.65rem;
    border-radius: var(--radius-sm);
    transition: background 0.15s ease, color 0.15s ease;
}
.sidebar nav a:hover { background: var(--surface-2); color: var(--text); }
.sidebar nav a.active { background: var(--primary-soft); color: var(--primary); }

.nav-section {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 1rem 0.65rem 0.3rem;
    opacity: 0.8;
}

.sidebar .spacer { flex: 1; }

.sidebar-footer { display: flex; gap: 0.4rem; align-items: center; padding-top: 0.75rem; border-top: 1px solid var(--border); }
.sidebar-footer form { flex: 1; }

.theme-toggle, .logout {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 500;
    padding: 0.5rem 0.65rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.logout { width: 100%; }
.theme-toggle:hover { background: var(--surface-2); color: var(--text); }
.logout:hover { background: var(--danger-soft); color: var(--danger-text); }

/* Show the icon of the theme the toggle switches TO. */
.icone-lune { display: none; }
:root[data-theme="light"] .icone-soleil, :root:not([data-theme]) .icone-soleil { display: none; }
:root[data-theme="light"] .icone-lune, :root:not([data-theme]) .icone-lune { display: block; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) .icone-soleil { display: block; }
    :root:not([data-theme]) .icone-lune { display: none; }
}

/* --- Main --- */

main {
    flex: 1;
    min-width: 0;
    max-width: 1140px;
    margin: 0 auto;
    padding: 2.25rem 2rem 3rem;
    width: 100%;
}

h1 { font-size: 1.6rem; font-weight: 800; margin: 0 0 1.25rem; letter-spacing: -0.02em; }
h2 { font-weight: 700; letter-spacing: -0.01em; }
.toolbar h1 { margin: 0; }

.sous-titre { color: var(--text-muted); margin: -0.75rem 0 1.25rem; font-size: 0.92rem; }
.muted { color: var(--text-muted); }
.petit { font-size: 0.82rem; }

.bandeau-demo {
    background: var(--warning-soft);
    color: var(--warning-text);
    border: 1px solid color-mix(in srgb, var(--warning) 35%, transparent);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.9rem;
    font-size: 0.87rem;
    margin-bottom: 1.25rem;
}
.bandeau-demo a { color: inherit; font-weight: 700; }

/* --- Tables --- */

.table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

table { width: 100%; min-width: 560px; border-collapse: collapse; background: var(--surface); }

th, td {
    text-align: left;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
}
th.num, td.num { text-align: right; white-space: nowrap; }

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

th {
    background: var(--surface-2);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: none; }

.actions { display: flex; flex-wrap: wrap; gap: 0.5rem 0.75rem; align-items: center; }
td.actions { justify-content: flex-end; }
.actions a { font-size: 0.85rem; font-weight: 600; }
.actions form { display: inline; margin: 0; }

.vide {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}
.vide p { margin: 0 0 1rem; }

/* --- Buttons --- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.05rem;
    background: var(--primary);
    color: var(--primary-contrast);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font: inherit;
    font-size: 0.87rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.05s ease;
    white-space: nowrap;
}
.btn:hover { background: var(--primary-hover); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, a:focus-visible, button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b91c1c; }
.btn.petit { padding: 0.35rem 0.7rem; font-size: 0.8rem; }

.btn-lien { background: none; border: none; padding: 0; color: var(--primary); font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer; }
.btn-lien:hover { text-decoration: underline; }

.toolbar {
    margin-bottom: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.toolbar .actions form { display: inline; }

.filters { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 1rem; }
.filters select, .selecteur {
    width: auto;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: 0.85rem;
    background: var(--surface);
    color: var(--text);
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.25rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.pagination a { font-weight: 600; }

/* --- Cards --- */

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; font-size: 1rem; }

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}
.cards .card { margin-bottom: 0; border-left: 3px solid var(--primary); }
.cards .card .value { font-size: 1.55rem; font-weight: 800; letter-spacing: -0.02em; white-space: nowrap; }
.cards .card.alerte { border-left-color: var(--danger); }
.cards .card.alerte .value { color: var(--danger); }
.card .sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.2rem; }
.card .sub.variation { font-weight: 700; }
.card .sub.variation.up { color: var(--success); }
.card .sub.variation.down { color: var(--danger); }

.colonnes { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.colonnes .card { margin-bottom: 0; }

/* Label/value pairs on detail pages */
.infos { display: grid; grid-template-columns: max-content 1fr; gap: 0.45rem 1.25rem; margin: 0; font-size: 0.9rem; }
.infos dt { color: var(--text-muted); font-weight: 500; }
.infos dd { margin: 0; }

.totaux { margin: 1rem 0 0 auto; width: min(100%, 340px); font-size: 0.92rem; }
.totaux div { display: flex; justify-content: space-between; padding: 0.35rem 0; gap: 1rem; }
.totaux .total-final { border-top: 2px solid var(--text); margin-top: 0.3rem; padding-top: 0.6rem; font-weight: 800; font-size: 1.1rem; }
.total { font-weight: 800; font-size: 1.15rem; text-align: right; margin-top: 0.75rem; }

.mention { color: var(--text-muted); font-size: 0.85rem; font-style: italic; }

/* --- Forms --- */

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem 1.25rem;
    margin-bottom: 1.25rem;
}
.form-grid .field.large { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.field.checkbox { flex-direction: row; align-items: flex-start; gap: 0.6rem; grid-column: 1 / -1; }
.field.checkbox label { color: var(--text); font-size: 0.88rem; }
.field label, form label { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); }
.field .aide { font-size: 0.78rem; color: var(--text-muted); line-height: 1.4; }
.field .erreur, .errorlist { color: var(--danger); font-size: 0.8rem; font-weight: 600; list-style: none; padding: 0; margin: 0; }
.field.en-erreur input, .field.en-erreur select, .field.en-erreur textarea { border-color: var(--danger); }
.requis { color: var(--danger); }

form input, form select, form textarea {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: 0.9rem;
    background: var(--surface);
    color: var(--text);
}
form input[type="checkbox"], form input[type="radio"] { width: auto; margin-top: 0.15rem; accent-color: var(--primary); }
form input[type="file"] { padding: 0.45rem; }
form input:focus, form select:focus, form textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.boutons-form { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 1.25rem; }

fieldset.card { min-width: 0; }
fieldset.card legend { font-weight: 700; font-size: 1rem; padding: 0 0.35rem; }

/* --- Line items editor --- */

.ligne-formset { margin: 0.5rem 0 1rem; }
.ligne-formset .table-scroll { box-shadow: none; }
.ligne-formset table { min-width: 720px; }
.ligne-formset td { padding: 0.45rem 0.5rem; vertical-align: top; }
.ligne-formset th { padding: 0.55rem 0.5rem; }
.ligne-formset input, .ligne-formset select { min-width: 0; padding: 0.45rem 0.55rem; }
.ligne-formset .col-description { width: 44%; }
.ligne-formset .col-quantite { width: 9%; }
.ligne-formset .col-unite { width: 11%; }
.ligne-formset .col-prix { width: 13%; }
.ligne-formset .col-tva { width: 8%; }
.ligne-formset .col-total { width: 12%; text-align: right; white-space: nowrap; padding-top: 0.95rem; font-weight: 600; }
.ligne-formset .col-actions { width: 40px; }
.ligne-formset .errorlist { margin-top: 0.25rem; }
.ligne-outils { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin-top: 0.75rem; }
.ligne-outils select { width: auto; max-width: 320px; }

.btn-remove-line {
    background: none;
    border: 1px solid var(--border);
    color: var(--danger);
    border-radius: var(--radius-sm);
    width: 30px;
    height: 30px;
    line-height: 1;
    cursor: pointer;
    font-size: 0.9rem;
}
.btn-remove-line:hover { background: var(--danger-soft); }
.delete-checkbox { display: none; }

/* --- Messages --- */

.messages { list-style: none; padding: 0; margin: 0 0 1.25rem; display: flex; flex-direction: column; gap: 0.5rem; }
.message {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.65rem 0.75rem 0.65rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--info-soft);
    color: var(--info-text);
    font-size: 0.9rem;
    font-weight: 500;
    border-left: 3px solid var(--info);
    transition: opacity 0.3s ease;
}
.message.success { background: var(--success-soft); color: var(--success-text); border-left-color: var(--success); }
.message.warning { background: var(--warning-soft); color: var(--warning-text); border-left-color: var(--warning); }
.message.error { background: var(--danger-soft); color: var(--danger-text); border-left-color: var(--danger); }
.message-close { background: none; border: none; color: inherit; cursor: pointer; font-size: 0.85rem; opacity: 0.7; padding: 0 0.2rem; }
.message-close:hover { opacity: 1; }
.message.masque { opacity: 0; }

/* --- Status badges --- */

.statut {
    display: inline-block;
    padding: 0.18rem 0.6rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    background: var(--neutral-soft);
    color: var(--neutral-text);
    white-space: nowrap;
}
.statut-brouillon { background: var(--neutral-soft); color: var(--neutral-text); }
.statut-envoye, .statut-envoyee { background: var(--info-soft); color: var(--info-text); }
.statut-accepte, .statut-payee { background: var(--success-soft); color: var(--success-text); }
.statut-refuse { background: var(--danger-soft); color: var(--danger-text); }
.statut-en_retard { background: var(--danger-soft); color: var(--danger-text); }
.statut-expire { background: var(--warning-soft); color: var(--warning-text); }

.section-title { margin-top: 2.25rem; margin-bottom: 0.75rem; font-size: 1.1rem; }

.notice { background: var(--info-soft); color: var(--info-text); border: 1px solid transparent; font-size: 0.9rem; }
.notice.warning { background: var(--warning-soft); color: var(--warning-text); }
.notice.danger { background: var(--danger-soft); color: var(--danger-text); }
.notice a { color: inherit; text-decoration: underline; font-weight: 600; }
.notice p:first-child { margin-top: 0; }
.notice p:last-child { margin-bottom: 0; }

/* --- Progress bars --- */

.progress-group { margin-bottom: 1.5rem; }
.progress-group .progress-label { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font-size: 0.85rem; margin-bottom: 0.35rem; }
.progress-group .progress-label .pct { font-weight: 700; color: var(--text-muted); }
.progress-track { background: var(--neutral-soft); border-radius: 999px; height: 10px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), var(--accent)); }
.progress-bar.danger { background: linear-gradient(90deg, var(--warning), var(--danger)); }

/* --- Charts --- */

.graphique { position: relative; }
.graphique svg { width: 100%; height: auto; display: block; overflow: visible; }
.graphique .grille line { stroke: var(--grille); stroke-width: 1; }
.graphique .axe-texte { fill: var(--text-muted); font-size: 11px; font-family: inherit; }
.graphique .axe-texte.droite { text-anchor: end; }
.graphique .axe-texte.centre { text-anchor: middle; }
.graphique .serie-n { fill: var(--serie-n); stroke: var(--serie-n); }
.graphique .serie-n1 { fill: var(--serie-n1); stroke: var(--serie-n1); }
.graphique path.serie-n, .graphique path.serie-n1 { stroke: none; }
.graphique polyline.serie-n, .graphique polyline.serie-n1 { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.graphique .point-fin { stroke: var(--surface); stroke-width: 2; }
.graphique .etiquette-fin { fill: var(--text); font-size: 11px; font-weight: 700; }
.graphique .zone-survol { fill: transparent; cursor: crosshair; }
.graphique .zone-survol:hover { fill: color-mix(in srgb, var(--text) 5%, transparent); }
.graphique .curseur { stroke: var(--text-muted); stroke-width: 1; opacity: 0; pointer-events: none; }

.legende { display: flex; gap: 1.1rem; flex-wrap: wrap; font-size: 0.82rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.legende span { display: inline-flex; align-items: center; gap: 0.4rem; }
.legende i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legende i.serie-n { background: var(--serie-n); }
.legende i.serie-n1 { background: var(--serie-n1); }

.infobulle {
    position: absolute;
    pointer-events: none;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.65rem;
    font-size: 0.8rem;
    white-space: nowrap;
    transform: translate(-50%, calc(-100% - 10px));
    opacity: 0;
    transition: opacity 0.1s ease;
    z-index: 5;
}
.infobulle.visible { opacity: 1; }
.infobulle strong { display: block; margin-bottom: 0.2rem; }
.infobulle .ligne-serie { display: flex; align-items: center; gap: 0.4rem; justify-content: space-between; }
.infobulle i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 0.3rem; }

details.tableau-donnees { margin-top: 0.75rem; font-size: 0.85rem; }
details.tableau-donnees summary { cursor: pointer; color: var(--text-muted); font-weight: 600; }
details.tableau-donnees table { margin-top: 0.5rem; min-width: 0; }

/* --- Dialogs --- */

dialog {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: min(520px, calc(100vw - 2rem));
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
dialog::backdrop { background: rgba(15, 15, 30, 0.45); }
dialog h2 { margin-top: 0; font-size: 1.15rem; }
dialog .infos { margin: 1rem 0; }

/* --- Public pages (client-facing) --- */

body.public { display: block; }
body.public main { max-width: 820px; }
.public-entete { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.5rem; }
.public-entete img { width: 44px; height: 44px; }

/* --- Responsive --- */

@media (max-width: 900px) {
    :root { --sidebar-w: 200px; }
    main { padding: 2rem 1.25rem; }
    .cards { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}

/* Mobile top bar + drawer menu (hidden on larger screens) */
.barre-mobile, .voile-menu { display: none; }

/* Phone: the sidebar becomes a slide-in drawer opened from a top bar */
@media (max-width: 640px) {
    body { flex-direction: column; }
    .barre-mobile {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        position: sticky;
        top: 0;
        z-index: 30;
        padding: 0.6rem 1rem;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
    }
    .barre-mobile .brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 800; color: var(--text); text-decoration: none; flex: 1; }
    .barre-mobile .brand-icon { width: 24px; height: 24px; }
    .bouton-menu {
        width: 40px; height: 40px;
        display: inline-flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px;
        background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer;
    }
    .bouton-menu span { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 2px; }
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 50;
        width: min(82vw, 300px);
        height: 100dvh;
        transform: translateX(-105%);
        transition: transform 0.2s ease;
        box-shadow: var(--shadow);
    }
    body.menu-ouvert .sidebar { transform: none; }
    .voile-menu { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(10, 10, 25, 0.45); }
    .voile-menu[hidden] { display: none; }
    .sidebar nav a { padding: 0.7rem 0.65rem; font-size: 0.95rem; }
    main { padding: 1.25rem 1rem 2.5rem; }
    h1 { font-size: 1.3rem; }
    .toolbar { align-items: stretch; }
    .toolbar .actions { flex-wrap: wrap; }
    .toolbar .actions .btn { flex: 1 1 auto; justify-content: center; }
    .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
    .card { padding: 1rem; }
    .cards .card .value { font-size: 1.2rem; }
    .form-grid { grid-template-columns: 1fr; }
    .infos { grid-template-columns: 1fr; gap: 0.1rem; }
    .infos dd { margin-bottom: 0.5rem; }
    /* No horizontal page overflow: flex items may shrink below their content width */
    .toolbar > *, .toolbar .actions { min-width: 0; max-width: 100%; }
    .toolbar .actions { width: 100%; }
    .btn { white-space: normal; text-align: center; }

    /* Main lists become stacked cards (labels copied from the header by app.js) */
    .table-scroll:has(.tableau-cartes) { box-shadow: none; border: none; overflow: visible; }
    table.tableau-cartes { min-width: 0; background: none; }
    table.tableau-cartes thead { display: none; }
    table.tableau-cartes tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.35rem 1rem;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 0.85rem 1rem;
        margin-bottom: 0.6rem;
    }
    table.tableau-cartes td { display: block; padding: 0; border: none; font-size: 0.9rem; text-align: left; white-space: normal; }
    table.tableau-cartes td[data-label]:not([data-label=""])::before {
        content: attr(data-label);
        display: block;
        font-size: 0.7rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        color: var(--text-muted);
    }
    table.tableau-cartes td:first-child { grid-column: 1 / -1; font-weight: 700; font-size: 1rem; }
    table.tableau-cartes td.actions { grid-column: 1 / -1; justify-content: flex-start; border-top: 1px solid var(--border); padding-top: 0.5rem; margin-top: 0.2rem; }
    table.tableau-cartes td.actions:empty { display: none; }

    /* Tap targets of at least 44px */
    .btn, .filters select, form input, form select { min-height: 44px; }
    td.actions a { display: inline-block; padding: 0.4rem 0; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}

/* Printing (GDPR register, lists): content only */
@media print {
    .sidebar, .barre-mobile, .voile-menu, .toolbar .actions, .toolbar .btn, .bandeau-demo, .messages { display: none !important; }
    body { display: block; background: #fff; color: #000; }
    main { max-width: none; padding: 0; }
    .card { box-shadow: none; break-inside: avoid; border-color: #ccc; }
}
