/* =========================================================================
   FACTURA - feuille de style de l'application (chargée APRÈS bootstrap.min.css)
   Toute la personnalisation graphique est ici, pilotée par des variables CSS.
   Référence visuelle : fond blanc, navigation latérale, icônes fines, tableaux très épurés,
   onglets horizontaux, boutons noirs, couleurs neutres, espacements généreux.
   ========================================================================= */

/* ---- Polices hébergées localement (Inter, variable) ---- */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('../fonts/inter-latin-ext-wght-normal.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('../fonts/inter-latin-wght-normal.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---- Variables centralisées ---- */
:root {
    --primary: #202020;
    --primary-hover: #000000;
    --background: #FFFFFF;
    --surface: #FFFFFF;
    --surface-secondary: #F8F9FA;
    --text: #202020;
    --text-muted: #777777;
    --border: #E8E8E8;
    --accent: #F1EDFF;
    --accent-text: #3F2F94;
    --success: #198754;
    --warning: #D97706;
    --danger: #DC3545;
    --success-soft: #E7F5EE;
    --warning-soft: #FEF3E2;
    --danger-soft: #FDECEE;
    --neutral-soft: #F3F3F1;

    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 14px;
    --control-h: 44px;
    --sidebar-w: 264px;
    --topbar-h: 60px;
    --gutter: 40px;
    --shadow-sm: 0 1px 2px rgba(20, 20, 20, .05);
    --shadow-md: 0 10px 30px rgba(20, 20, 20, .10);
    --focus-ring: 0 0 0 3px rgba(32, 32, 32, .12);

    /* Surcharge des variables Bootstrap */
    --bs-body-font-family: var(--font);
    --bs-body-font-size: .9375rem;
    --bs-body-color: var(--text);
    --bs-body-bg: var(--background);
    --bs-border-color: var(--border);
    --bs-link-color: var(--text);
    --bs-link-hover-color: #000;
    --bs-border-radius: var(--radius);
    --bs-secondary-color: var(--text-muted);
}

*, *::before, *::after { -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font);
    font-feature-settings: 'cv11', 'ss01';
    color: var(--text);
    background: var(--background);
    letter-spacing: -.003em;
    overflow-x: hidden;
}
h1, h2, h3, h4, h5 { font-weight: 600; letter-spacing: -.02em; color: var(--text); }
a { color: var(--text); text-underline-offset: 3px; }
.text-muted, .text-secondary { color: var(--text-muted) !important; }
.tabular { font-variant-numeric: tabular-nums; }
.visually-hidden-focusable:focus { position: fixed; top: 8px; left: 8px; z-index: 2000; background: #fff; padding: 8px 12px; border-radius: 6px; box-shadow: var(--shadow-md); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---- Icônes (Lucide, traits fins) ---- */
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; }
.icon-sm { width: 16px; height: 16px; vertical-align: -3px; }
.icon-lg { width: 24px; height: 24px; }
.icon-xl { width: 40px; height: 40px; stroke-width: 1.25; }

/* =========================================================================
   Mise en page : navigation latérale (ordinateur) / barre + offcanvas (mobile)
   ========================================================================= */
.app-shell { min-height: 100vh; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 100;
    display: none; flex-direction: column; padding: 24px 16px 20px;
    background: var(--surface); border-right: 1px solid var(--border);
}
@media (min-width: 992px) {
    .sidebar { display: flex; }
    .app-main { margin-left: var(--sidebar-w); }
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 12px 28px; text-decoration: none; color: var(--text); }
.brand:hover { color: var(--text); }
.brand-icon { display: block; height: 30px; width: auto; flex: none; }
.brand-text { display: block; min-width: 0; }
.brand-wordmark { display: block; height: 20px; width: auto; }
.brand-sub { display: block; font-size: .75rem; font-weight: 400; color: var(--text-muted); letter-spacing: 0; margin-top: 3px; max-width: 168px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.nav-item-link {
    display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: var(--radius);
    color: var(--text); text-decoration: none; font-weight: 500; font-size: 1rem;
    transition: background-color .12s ease;
}
.nav-item-link .icon { color: #4a4a4a; }
.nav-item-link:hover { background: var(--surface-secondary); color: var(--text); }
.nav-item-link.active { background: var(--accent); }
.nav-item-link.active .icon { color: var(--text); }
.sidebar-foot { margin-top: auto; padding: 16px 12px 0; font-size: .75rem; color: var(--text-muted); }

.topbar {
    position: sticky; top: 0; z-index: 90; height: var(--topbar-h); display: flex; align-items: center; gap: 8px;
    padding: 0 16px; background: rgba(255, 255, 255, .96); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
@media (min-width: 992px) { .topbar { display: none; } }
.topbar-title { flex: 1; min-width: 0; margin: 0; font-size: 1.125rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
    width: 44px; height: 44px; display: inline-grid; place-items: center; flex: none; border: 0; background: transparent;
    border-radius: 50%; color: var(--text); cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--surface-secondary); color: var(--text); }
.fab {
    width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
    background: var(--primary); color: #fff; border: 0; text-decoration: none;
}
.fab:hover { background: var(--primary-hover); color: #fff; }

.offcanvas { --bs-offcanvas-width: min(300px, 86vw); border-right: 0; box-shadow: var(--shadow-md); }
.offcanvas .sidebar-inner { display: flex; flex-direction: column; height: 100%; padding: 20px 16px; }

.page-header { display: none; align-items: center; justify-content: space-between; gap: 16px; padding: 36px var(--gutter) 0; }
@media (min-width: 992px) { .page-header { display: flex; } }
.page-title { margin: 0; font-size: 2rem; font-weight: 600; letter-spacing: -.03em; line-height: 1.15; }
.page-subtitle { margin: 6px 0 0; color: var(--text-muted); }
.header-actions { display: flex; align-items: center; gap: 12px; flex: none; }
.page-body { padding: 20px 16px 64px; }
@media (min-width: 768px) { .page-body { padding-left: 28px; padding-right: 28px; } }
@media (min-width: 992px) { .page-body { padding: 28px var(--gutter) 72px; } }
.page-body.narrow { max-width: 880px; }
.page-body.medium { max-width: 1120px; }

/* Menu du compte */
.account-toggle {
    display: inline-flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px; border: 1px solid var(--border);
    border-radius: 999px; background: #fff; color: var(--text); font-weight: 500; font-size: .875rem; cursor: pointer;
}
.account-toggle:hover { background: var(--surface-secondary); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--accent-text); display: inline-grid; place-items: center; font-size: .8125rem; font-weight: 600; flex: none; }

/* =========================================================================
   Composants
   ========================================================================= */

/* ---- Boutons ---- */
.btn {
    --bs-btn-padding-x: 20px; --bs-btn-padding-y: 0; --bs-btn-font-weight: 500; --bs-btn-border-radius: var(--radius);
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--control-h);
    font-size: .9375rem; line-height: 1; white-space: nowrap; letter-spacing: -.005em;
    transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}
.btn:focus-visible { box-shadow: var(--focus-ring); outline: none; }
.btn-primary { --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: var(--primary-hover); --bs-btn-hover-border-color: var(--primary-hover); --bs-btn-active-bg: #000; --bs-btn-active-border-color: #000; --bs-btn-disabled-bg: #6b6b6b; --bs-btn-disabled-border-color: #6b6b6b; --bs-btn-color: #fff; --bs-btn-hover-color: #fff; --bs-btn-active-color: #fff; }
.btn-secondary, .btn-light { --bs-btn-bg: #fff; --bs-btn-color: var(--text); --bs-btn-border-color: var(--border); --bs-btn-hover-bg: var(--surface-secondary); --bs-btn-hover-color: var(--text); --bs-btn-hover-border-color: #d6d6d6; --bs-btn-active-bg: var(--surface-secondary); --bs-btn-active-color: var(--text); --bs-btn-active-border-color: #cfcfcf; }
.btn-danger { --bs-btn-bg: var(--danger); --bs-btn-border-color: var(--danger); --bs-btn-hover-bg: #b92b39; --bs-btn-hover-border-color: #b92b39; }
.btn-ghost { --bs-btn-bg: transparent; --bs-btn-color: var(--text); --bs-btn-border-color: transparent; --bs-btn-hover-bg: var(--surface-secondary); --bs-btn-hover-color: var(--text); --bs-btn-hover-border-color: transparent; }
.btn-link-danger { color: var(--danger); }
.btn-sm { height: 36px; --bs-btn-padding-x: 14px; font-size: .875rem; }
.btn-lg { height: 52px; font-size: 1rem; }
.btn-icon { width: 36px; padding: 0; }
.btn-block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .55; }
.btn .spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

/* ---- Formulaires ---- */
.form-label { font-size: .8125rem; font-weight: 500; color: #3a3a3a; margin-bottom: 6px; }
.form-label .req { color: var(--danger); margin-left: 2px; }
.form-control, .form-select {
    height: var(--control-h); border: 1px solid var(--border); border-radius: var(--radius); background-color: #fff;
    padding: 0 14px; font-size: 1rem; color: var(--text); box-shadow: none;
}
textarea.form-control { height: auto; min-height: 96px; padding: 12px 14px; line-height: 1.5; }
.form-select { padding-right: 40px; }
.form-control::placeholder { color: #b0b0b0; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: var(--focus-ring); background-color: #fff; color: var(--text); }
.form-control:disabled, .form-control[readonly], .form-select:disabled { background: var(--surface-secondary); color: #6a6a6a; }
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--danger); background-image: none; padding-right: 14px; }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(220, 53, 69, .15); }
.invalid-feedback { font-size: .8125rem; color: var(--danger); margin-top: 6px; }
.form-text { font-size: .8125rem; color: var(--text-muted); margin-top: 6px; }
.form-check-input { width: 1.15em; height: 1.15em; margin-top: .2em; border-color: #bdbdbd; }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.form-check-input:focus { box-shadow: var(--focus-ring); border-color: var(--primary); }
.input-group .form-control { border-radius: var(--radius) 0 0 var(--radius); }
.input-group .input-group-text { background: var(--surface-secondary); border: 1px solid var(--border); border-left: 0; color: var(--text-muted); border-radius: 0 var(--radius) var(--radius) 0; }
.input-affix { position: relative; }
.input-affix .form-control { padding-right: 46px; }
.input-affix .affix-btn { position: absolute; right: 4px; top: 4px; }
.form-grid { display: grid; gap: 18px; grid-template-columns: 1fr; }
@media (min-width: 768px) {
    .form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .span-2 { grid-column: span 2; }
    .span-3 { grid-column: span 3; }
    .span-all { grid-column: 1 / -1; }
}
.form-section { padding: 28px 0; border-top: 1px solid var(--border); }
.form-section:first-of-type { border-top: 0; padding-top: 4px; }
.form-section h2 { font-size: 1.0625rem; margin: 0 0 4px; }
.form-section .section-help { color: var(--text-muted); margin: 0 0 20px; font-size: .875rem; }
.segmented { display: inline-flex; padding: 4px; background: var(--neutral-soft); border-radius: 10px; gap: 2px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label { padding: 9px 18px; border-radius: 8px; font-weight: 500; cursor: pointer; color: #555; font-size: .9375rem; margin: 0; }
.segmented input:checked + label { background: #fff; color: var(--text); box-shadow: var(--shadow-sm); }
.segmented input:focus-visible + label { outline: 2px solid var(--primary); }
.strength { height: 4px; border-radius: 4px; background: var(--border); overflow: hidden; margin-top: 8px; }
.strength > span { display: block; height: 100%; width: 0; background: var(--danger); transition: width .2s, background-color .2s; }

/* ---- Cartes ---- */
.card-plain { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.card-body-lg { padding: 24px; }
@media (min-width: 768px) { .card-body-lg { padding: 28px; } }
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-title-row h2 { font-size: 1rem; margin: 0; }
.kpi-grid { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 1200px) { .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi { padding: 20px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: #fff; min-width: 0; }
.kpi-label { color: var(--text-muted); font-size: .8125rem; font-weight: 500; }
.kpi-value { font-size: 1.375rem; font-weight: 600; letter-spacing: -.02em; margin-top: 8px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
@media (min-width: 768px) { .kpi-value { font-size: 1.625rem; } }
.kpi-note { color: var(--text-muted); font-size: .8125rem; margin-top: 4px; }
.kpi.is-danger .kpi-value { color: var(--danger); }

/* ---- Onglets horizontaux ---- */
.tabs { display: flex; gap: 28px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0 16px; }
.tabs::-webkit-scrollbar { display: none; }
@media (min-width: 768px) { .tabs { margin: 0; padding: 0; gap: 32px; } }
.tab { position: relative; padding: 14px 2px 13px; color: var(--text-muted); font-weight: 500; font-size: 1rem; text-decoration: none; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--text); }
.tab .count { font-size: .75rem; color: var(--text-muted); margin-left: 6px; font-weight: 500; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 16px 0; }
.toolbar .search { flex: 1 1 200px; max-width: 420px; position: relative; }
.toolbar .search .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.toolbar .search .form-control { padding-left: 42px; }
.toolbar .spacer { flex: 1; }

/* ---- Tableaux épurés ---- */
.table-clean { width: 100%; border-collapse: collapse; }
.table-clean th {
    padding: 14px 16px; font-size: .8125rem; font-weight: 500; color: var(--text-muted); text-align: left; white-space: nowrap;
    border-bottom: 1px solid var(--border); background: #fff;
}
.table-clean th a { display: inline-flex; align-items: center; gap: 4px; color: inherit; text-decoration: none; }
.table-clean th a:hover { color: var(--text); }
.table-clean th.sorted { color: var(--text); font-weight: 600; }
.table-clean th .icon { width: 14px; height: 14px; stroke-width: 1.75; }
.table-clean td { padding: 0 16px; height: 64px; vertical-align: middle; border-bottom: 1px solid var(--border); }
.table-clean tbody tr[data-href] { cursor: pointer; }
.table-clean tbody tr:hover td { background: var(--surface-secondary); }
.table-clean .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-clean .center { text-align: center; }
.table-clean .primary-cell { font-weight: 500; }
.table-clean .muted-cell { color: var(--text-muted); font-size: .875rem; }
.table-clean.compact td { height: 52px; }
.table-clean th:first-child, .table-clean td:first-child { padding-left: 4px; }
.table-clean th:last-child, .table-clean td:last-child { padding-right: 4px; }
.table-scroll { overflow-x: auto; }
.table-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 0 0; color: var(--text-muted); font-size: .9375rem; }

/* Liste mobile (à la place du tableau) */
.mlist { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.mlist-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 14px; padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; }
.mlist-item:last-child { border-bottom: 0; }
.mlist-item:active, .mlist-item:hover { background: var(--surface-secondary); color: var(--text); }
.mlist-title { font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.mlist-amount { text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mlist-meta { font-size: .8125rem; color: var(--text-muted); min-width: 0; overflow-wrap: anywhere; }
.mlist-meta.end { text-align: right; }
@media (max-width: 767.98px) { body.has-mlist { background: var(--surface-secondary); } .has-mlist .tabs { background: #fff; } }
.only-mobile { display: block; }
.only-desktop { display: none; }
@media (min-width: 768px) { .only-mobile { display: none; } .only-desktop { display: block; } }

/* ---- Pagination ---- */
.page-size { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.page-size a { padding: 8px 14px; color: var(--text-muted); text-decoration: none; font-size: .9375rem; border-right: 1px solid var(--border); }
.page-size a:last-child { border-right: 0; }
.page-size a.active { background: var(--neutral-soft); color: var(--text); font-weight: 500; }
.page-size a:hover { color: var(--text); }
.pager { display: inline-flex; gap: 6px; align-items: center; }
.pager a, .pager span.btn-page { width: 36px; height: 36px; display: inline-grid; place-items: center; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; color: var(--text); text-decoration: none; }
.pager a:hover { background: var(--surface-secondary); }
.pager .disabled { opacity: .4; pointer-events: none; }

/* ---- Badges ---- */
.badge-soft { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 6px; font-size: .8125rem; font-weight: 500; line-height: 1.2; background: var(--neutral-soft); color: #3a3a3a; white-space: nowrap; }
.badge-soft.success { background: var(--success-soft); color: #146c43; }
.badge-soft.warning { background: var(--warning-soft); color: #b45309; }
.badge-soft.danger { background: var(--danger-soft); color: #b02a37; }
.badge-soft.accent { background: var(--accent); color: var(--accent-text); }
.badge-soft.dark { background: #2b2b2b; color: #fff; }
.badge-soft .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-stack { display: inline-flex; flex-wrap: wrap; gap: 6px; }

/* ---- Alertes et notifications ---- */
.alert { border-radius: var(--radius); border: 1px solid var(--border); padding: 14px 16px; font-size: .9375rem; display: flex; gap: 12px; align-items: flex-start; }
.alert .icon { margin-top: 1px; }
.alert-success { background: var(--success-soft); border-color: #c7e6d6; color: #0f5132; }
.alert-danger { background: var(--danger-soft); border-color: #f5c6cb; color: #842029; }
.alert-warning { background: var(--warning-soft); border-color: #f7dcae; color: #7a4a05; }
.alert-info { background: var(--accent); border-color: #ddd5fb; color: var(--accent-text); }
.alert-neutral { background: var(--surface-secondary); color: var(--text); }
.alert a { font-weight: 500; }
.toast-stack { position: fixed; z-index: 1080; right: 16px; left: 16px; bottom: 16px; display: grid; gap: 10px; pointer-events: none; }
@media (min-width: 768px) { .toast-stack { left: auto; right: 24px; top: 24px; bottom: auto; width: 380px; } }
.toast-item { pointer-events: auto; background: #202020; color: #fff; border-radius: 12px; padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start; box-shadow: var(--shadow-md); font-size: .9375rem; animation: toast-in .25s ease; }
.toast-item.success .icon { color: #6ee7a8; } .toast-item.danger .icon { color: #ff8a94; } .toast-item.warning .icon { color: #ffc069; }
.toast-item .toast-close { margin-left: auto; background: transparent; border: 0; color: #bbb; padding: 0; cursor: pointer; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---- Menus déroulants ---- */
.dropdown-menu { border: 1px solid var(--border); border-radius: 12px; padding: 6px; box-shadow: var(--shadow-md); min-width: 220px; font-size: .9375rem; }
.dropdown-item { border-radius: 8px; padding: 9px 12px; display: flex; align-items: center; gap: 10px; font-weight: 450; color: var(--text); }
.dropdown-item:hover, .dropdown-item:focus { background: var(--surface-secondary); color: var(--text); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-divider { margin: 6px 4px; border-color: var(--border); }
.dropdown-header { font-size: .75rem; color: var(--text-muted); padding: 8px 12px 4px; }

/* ---- Modales et confirmations ---- */
.modal-content { border: 0; border-radius: 18px; box-shadow: var(--shadow-md); }
.modal-header { border: 0; padding: 24px 24px 8px; }
.modal-title { font-size: 1.125rem; font-weight: 600; }
.modal-body { padding: 8px 24px 8px; color: #444; }
.modal-footer { border: 0; padding: 16px 24px 24px; gap: 8px; }
.modal-footer .btn { min-width: 110px; }
.modal-backdrop.show { opacity: .35; }

/* ---- États vides, sections, listes de définitions ---- */
.empty-state { text-align: center; padding: 56px 16px; color: var(--text-muted); }
.empty-state .icon-xl { color: #b9b9b9; margin-bottom: 12px; }
.empty-state h2 { font-size: 1.0625rem; color: var(--text); margin-bottom: 6px; }
.dl { display: grid; grid-template-columns: 1fr; gap: 14px 24px; margin: 0; }
@media (min-width: 576px) { .dl.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.dl dt { font-size: .8125rem; color: var(--text-muted); font-weight: 500; margin-bottom: 2px; }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.section-title { font-size: 1rem; font-weight: 600; margin: 0 0 12px; }
.stack { display: grid; gap: 24px; }
.split { display: grid; gap: 24px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) { .split { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; } }
.timeline { list-style: none; margin: 0; padding: 0 0 0 20px; border-left: 1px solid var(--border); display: grid; gap: 18px; }
.timeline li { position: relative; }
.timeline li::before { content: ''; position: absolute; left: -25px; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: #fff; border: 2px solid #bdbdbd; }
.timeline li.ok::before { border-color: var(--success); } .timeline li.err::before { border-color: var(--danger); }
.timeline .when { font-size: .75rem; color: var(--text-muted); }
.breadcrumb-back { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); text-decoration: none; font-size: .9375rem; margin-bottom: 8px; }
.breadcrumb-back:hover { color: var(--text); }
.detail-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.detail-head h1 { font-size: 1.5rem; margin: 0 0 8px; }
@media (min-width: 768px) { .detail-head h1 { font-size: 1.75rem; } }
.action-bar { display: flex; flex-wrap: wrap; gap: 10px; }
@media (max-width: 575.98px) { .action-bar .btn { flex: 1 1 auto; } .action-bar .btn-primary { flex-basis: 100%; } .action-bar .btn-icon { flex: 0 0 44px; } .action-bar .dropdown { flex: 0 0 auto; } }

/* =========================================================================
   Éditeur de facture
   ========================================================================= */
.autocomplete { position: relative; }
.autocomplete-list { position: absolute; z-index: 50; left: 0; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-md); max-height: 320px; overflow-y: auto; padding: 6px; display: none; }
.autocomplete-list.open { display: block; }
.autocomplete-list button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.autocomplete-list button:hover, .autocomplete-list button.hl { background: var(--surface-secondary); }
.autocomplete-list .sub { display: block; font-size: .8125rem; color: var(--text-muted); }
.autocomplete-empty { padding: 12px; color: var(--text-muted); font-size: .9375rem; }
.client-chip { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-secondary); }

.lines-head { display: none; }
.line { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: #fff; }
.line + .line { margin-top: 12px; }
.line .f-desc { grid-column: 1 / -1; }
.line .f-qty, .line .f-unit, .line .f-price, .line .f-disc, .line .f-vat, .line .f-total { grid-column: span 3; }
.line .f-tools { grid-column: 1 / -1; display: flex; gap: 6px; justify-content: flex-end; }
.line .mlabel { display: block; font-size: .75rem; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
.line .line-total { height: var(--control-h); display: flex; align-items: center; justify-content: flex-end; font-weight: 600; font-variant-numeric: tabular-nums; }
.line textarea.form-control { min-height: 44px; height: 44px; resize: none; overflow: hidden; padding-top: 11px; }
.line .handle { display: none; }
/* Tablette et petits ordinateurs : les six champs numériques tiennent sur une ligne sous la description */
@media (min-width: 576px) {
    .line { grid-template-columns: repeat(12, minmax(0, 1fr)); }
    .line .f-qty, .line .f-unit, .line .f-price, .line .f-disc, .line .f-vat, .line .f-total { grid-column: span 4; }
}
@media (min-width: 768px) {
    .line .f-qty, .line .f-unit, .line .f-price, .line .f-disc, .line .f-vat, .line .f-total { grid-column: span 2; }
}
/* Grand écran (la barre latérale occupe déjà 264 px) : une seule ligne par prestation, en-têtes de colonnes visibles */
@media (min-width: 1300px) {
    .lines-head, .line { display: grid; grid-template-columns: 28px minmax(200px, 1fr) 76px 90px 110px 72px 92px 110px 72px; gap: 8px; align-items: start; }
    .lines-head { padding: 0 16px 8px; font-size: .75rem; color: var(--text-muted); font-weight: 500; }
    .line { padding: 12px 16px; }
    .line .f-desc, .line .f-qty, .line .f-unit, .line .f-price, .line .f-disc, .line .f-vat, .line .f-total, .line .f-tools { grid-column: auto; }
    .line .mlabel { display: none; }
    .line .f-tools { justify-content: flex-end; flex-wrap: nowrap; }
    .line .handle { display: grid; place-items: center; height: var(--control-h); color: #b0b0b0; }
}
.line.removing { opacity: .4; }
.totals-card { margin-left: auto; width: 100%; max-width: 420px; }
.totals-row { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; font-variant-numeric: tabular-nums; }
.totals-row.grand { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 16px; font-size: 1.125rem; font-weight: 600; }
.totals-row .label { color: var(--text-muted); }
.totals-row.grand .label { color: var(--text); }
.sticky-actions { position: sticky; bottom: 0; z-index: 20; background: rgba(255,255,255,.96); backdrop-filter: blur(8px); border-top: 1px solid var(--border); margin: 24px -16px 0; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
@media (min-width: 768px) { .sticky-actions { margin-left: -28px; margin-right: -28px; padding-left: 28px; padding-right: 28px; } }
@media (min-width: 992px) { .sticky-actions { margin-left: calc(var(--gutter) * -1); margin-right: calc(var(--gutter) * -1); padding-left: var(--gutter); padding-right: var(--gutter); } }
@media (max-width: 575.98px) { .sticky-actions .btn { flex: 1 1 0; min-width: 0; padding-left: 12px; padding-right: 12px; } }

/* =========================================================================
   Authentification et installateur
   ========================================================================= */
.auth-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: var(--surface-secondary); }
.auth-card { width: 100%; max-width: 440px; background: #fff; border: 1px solid var(--border); border-radius: 20px; padding: 32px 24px; box-shadow: var(--shadow-sm); }
@media (min-width: 480px) { .auth-card { padding: 40px; } }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.auth-brand-center { justify-content: center; }
.auth-logo { display: block; width: 260px; max-width: 100%; height: auto; }
.auth-brand-row { flex-wrap: wrap; row-gap: 8px; }
.auth-brand-row .brand-icon { height: 40px; }
.auth-brand-row .brand-wordmark { height: 22px; }
.auth-brand-note { margin-left: 4px; font-size: .8125rem; color: var(--text-muted); }
.auth-card h1 { font-size: 1.5rem; margin: 0 0 6px; }
.auth-card .lead { color: var(--text-muted); margin-bottom: 24px; }
.auth-card .foot { margin-top: 22px; text-align: center; font-size: .9375rem; color: var(--text-muted); }
.error-page { text-align: center; padding: 72px 0; }
.error-code { font-size: 4.5rem; font-weight: 700; letter-spacing: -.05em; line-height: 1; color: var(--text); }

.install-wrap { min-height: 100vh; padding: 32px 16px 64px; background: var(--surface-secondary); }
.install-card { max-width: 760px; margin: 0 auto; background: #fff; border: 1px solid var(--border); border-radius: 20px; padding: 28px 20px; box-shadow: var(--shadow-sm); }
@media (min-width: 576px) { .install-card { padding: 40px; } }
.stepper { list-style: none; display: flex; gap: 8px; padding: 0; margin: 0 0 32px; }
.stepper li { flex: 1; min-width: 0; text-align: center; font-size: .75rem; color: var(--text-muted); }
.stepper .bar { height: 4px; border-radius: 4px; background: var(--border); margin-bottom: 8px; }
.stepper li.done .bar { background: var(--primary); }
.stepper li.current .bar { background: var(--primary); }
.stepper li.current { color: var(--text); font-weight: 600; }
.stepper .lbl { display: none; }
@media (min-width: 576px) { .stepper .lbl { display: block; } }
.check-group { margin-bottom: 24px; }
.check-group h3 { font-size: .8125rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: 8px; font-weight: 600; }
.check-row { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: .9375rem; }
.check-row:last-child { border-bottom: 0; }
.check-row .st { flex: none; margin-top: 1px; }
.check-row.ok .st { color: var(--success); } .check-row.bad .st { color: var(--danger); } .check-row.warn .st { color: var(--warning); }
.check-row .detail { margin-left: auto; color: var(--text-muted); font-size: .8125rem; text-align: right; }
.code-box { background: var(--surface-secondary); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8125rem; overflow-wrap: anywhere; }

/* ---- Divers ---- */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .875em; }
.logo-preview { max-height: 72px; max-width: 220px; object-fit: contain; border: 1px solid var(--border); border-radius: 10px; padding: 8px; background: #fff; }
.divider { height: 1px; background: var(--border); margin: 24px 0; }
.link-plain { text-decoration: none; }
.link-plain:hover { text-decoration: underline; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-fit { width: fit-content; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

/* Sécurité d'affichage : jamais de défilement horizontal de la page entière */
img, svg, video { max-width: 100%; }
.page-body, .app-main { min-width: 0; }
input, select, textarea, button { max-width: 100%; }
@media (max-width: 767.98px) {
    .form-control, .form-select, textarea.form-control { font-size: 16px; } /* évite le zoom automatique d'iOS */
    .btn { height: 48px; }
    .btn-sm { height: 40px; }
    .modal-dialog { margin: 12px; }
}
@media print { .sidebar, .topbar, .page-header, .sticky-actions, .toast-stack { display: none !important; } .app-main { margin: 0; } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
