/* =============================================================
   Lexavaxa — Design System (identité « institutionnelle sobre »)
   Plateforme juridique OHADA — Bénin

   Principes : ardoise et anthracite, un seul accent bordeaux, polices auto-hébergées
   (Inter pour l'interface, Source Serif 4 pour les titres), filets fins plutôt que
   ombres, couleurs sémantiques discrètes, contrastes conformes WCAG AA
   (vérifiés par apps/accounts/tests/test_design_refresh.py).
   ============================================================= */

/* --- Polices auto-hébergées (licence SIL OFL, voir static/fonts/LICENSE.txt) --- */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/inter-latin-400-normal.da03732a27e1.woff2") format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/inter-latin-500-normal.51205681a1ba.woff2") format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("../fonts/inter-latin-600-normal.2ede57db1a3a.woff2") format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/inter-latin-700-normal.8ca0a5155296.woff2") format('woff2');
}
@font-face {
    font-family: 'Source Serif 4';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("../fonts/source-serif-4-latin-600-normal.beb0c8d8bee8.woff2") format('woff2');
}
@font-face {
    font-family: 'Source Serif 4';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/source-serif-4-latin-700-normal.45959eeff97f.woff2") format('woff2');
}

/* --- Design tokens --- */
:root {
    /* Échelle d'ardoise / anthracite */
    --ink-950: #12171d;
    --ink-900: #1a212a;
    --ink-800: #252d38;
    --ink-700: #38424f;
    --ink-600: #4a5563;
    --ink-500: #5b6573;
    --ink-400: #98a1ad;
    --ink-300: #c9d0d8;
    --ink-200: #dde2e8;
    --ink-100: #ebeef2;
    --ink-50: #f4f6f8;

    /* Accent unique : bordeaux */
    --accent: #7b2232;
    --accent-hover: #651b29;
    --accent-soft: #f6ecee;
    --accent-border: #e3c8ce;

    /* Rôles historiques (les gabarits et le JavaScript y font référence) */
    --primary: var(--accent);
    --primary-dark: var(--ink-900);
    --primary-light: var(--accent-soft);
    --primary-hover: var(--accent-hover);

    /* Boutons principaux : anthracite */
    --btn-primary-bg: var(--ink-900);
    --btn-primary-hover: #2c3643;
    --btn-primary-text: #ffffff;

    /* Couleurs sémantiques discrètes (texte sur teinte ≥ 7:1) */
    --success: #1e6b4a;
    --success-bg: #eaf4ef;
    --success-border: #bcdccc;
    --success-text: #174f38;
    --warning: #8a5a00;
    --warning-bg: #fbf4e4;
    --warning-border: #ecd9a8;
    --warning-text: #5e3c00;
    --danger: #b3261e;
    --danger-bg: #fbeeed;
    --danger-border: #efc4c1;
    --danger-text: #86201a;
    --info: #2b5b86;
    --info-bg: #eaf1f7;
    --info-border: #c3d5e6;
    --info-text: #1d4668;

    /* Neutres */
    --bg-body: var(--ink-50);
    --bg-white: #ffffff;
    --bg-muted: var(--ink-100);
    --border: var(--ink-200);
    --border-strong: var(--ink-300);
    --border-light: var(--ink-100);
    --text-primary: var(--ink-900);
    --text-secondary: var(--ink-600);
    --text-muted: var(--ink-500);
    --text-light: var(--ink-400);

    /* Dimensions : angles discrets, ton institutionnel */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 6px;
    --radius-xl: 8px;
    --radius-full: 9999px;

    /* Ombres quasi absentes : la structure vient des filets */
    --shadow-sm: 0 1px 0 rgba(26, 33, 42, 0.03);
    --shadow-md: 0 2px 6px rgba(26, 33, 42, 0.06);
    --shadow-lg: 0 8px 24px rgba(26, 33, 42, 0.10);

    /* Typographie */
    --font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;

    /* Barre latérale */
    --sidebar-width: 256px;
    --sidebar-bg: #1a212a;
    --sidebar-text: #c4ccd6;
    --sidebar-label: #8d97a5;
    --sidebar-hover-bg: #232b36;
    --sidebar-active-bg: #2a3340;
    --sidebar-active-text: #ffffff;
    --sidebar-active: #d9a6b0;
    --sidebar-border: rgba(255, 255, 255, 0.07);
}

/* --- Reset & base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family);
    font-size: 0.9375rem;
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.55;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
    color: var(--text-primary);
    line-height: 1.25;
}

h1, h2 {
    font-family: var(--font-serif);
    font-weight: 600;
    letter-spacing: -0.01em;
}

h3, h4 {
    font-weight: 600;
}

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

a:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
}

img {
    max-width: 100%;
    height: auto;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.icon {
    flex-shrink: 0;
    vertical-align: -0.2em;
}

/* --- Layout application (barre latérale + contenu) --- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
    transition: transform 0.25s ease;
}

.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

.app-content {
    flex: 1;
    padding: 2.25rem 2.5rem;
    max-width: 1240px;
    width: 100%;
    margin: 0 auto;
}

/* --- Barre latérale --- */
.sidebar-brand {
    padding: 1.4rem 1.4rem 1.25rem;
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.sidebar-brand-mark {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-md);
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-brand h2 {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin: 0;
    line-height: 1.1;
}

.sidebar-brand p {
    font-size: 0.68rem;
    color: var(--sidebar-label);
    margin: 0.3rem 0 0 0;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.sidebar-user {
    padding: 1rem 1.4rem;
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--sidebar-active-bg);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.sidebar-user-info {
    overflow: hidden;
}

.sidebar-user-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.sidebar-user-role {
    font-size: 0.68rem;
    color: var(--sidebar-label);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    display: block;
}

.sidebar-nav {
    flex: 1;
    padding: 0.6rem 0 1rem;
}

.sidebar-section-label {
    padding: 1.1rem 1.4rem 0.4rem;
    font-size: 0.66rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--sidebar-label);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 1.4rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-link:hover {
    background: var(--sidebar-hover-bg);
    color: #fff;
    text-decoration: none;
}

.sidebar-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    border-left-color: var(--sidebar-active);
    font-weight: 600;
}

.sidebar-link-icon {
    width: 20px;
    display: inline-flex;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0.85;
}

.sidebar-link.active .sidebar-link-icon,
.sidebar-link:hover .sidebar-link-icon {
    opacity: 1;
}

.sidebar-footer {
    padding: 0.9rem 1.4rem 1.1rem;
    border-top: 1px solid var(--sidebar-border);
}

.sidebar-logout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.25rem;
    background: transparent;
    color: var(--sidebar-text);
    border: none;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s ease;
    font-family: var(--font-family);
}

.sidebar-logout-btn:hover {
    color: #fff;
}

/* --- Bouton de menu mobile --- */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 200;
    background: var(--sidebar-bg);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    width: 40px;
    height: 40px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(18, 23, 29, 0.55);
    z-index: 90;
}

.sidebar-close {
    display: none;
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    padding: 0.35rem;
    border-radius: var(--radius-sm);
}
.sidebar-close:hover { color: #fff; background: var(--sidebar-hover-bg); }
.sidebar-toggle[aria-expanded="true"] { visibility: hidden; }

/* --- Conteneurs --- */
.container-narrow {
    max-width: 680px;
    margin: 0 auto;
}

.container-medium {
    max-width: 960px;
    margin: 0 auto;
}

.container-wide {
    max-width: 1080px;
    margin: 0 auto;
}

/* --- En-tête de page --- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.75rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--ink-900);
    margin: 0;
    line-height: 1.2;
}

.page-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin: 0.35rem 0 0 0;
    max-width: 62ch;
}

.page-actions {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    flex-wrap: wrap;
}

/* --- Fil d'Ariane --- */
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1.1rem;
}

.breadcrumb a {
    color: var(--ink-600);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--accent);
    text-decoration: underline;
}

.breadcrumb-separator {
    color: var(--ink-400);
}

/* --- Cartes --- */
.card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border);
}

.card-header h2, .card-header h3 {
    margin: 0;
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0;
    color: var(--text-primary);
}

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

/* --- Indicateurs (KPI) --- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.kpi-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-top: 2px solid var(--ink-900);
    border-radius: var(--radius-lg);
    padding: 1.2rem 1.3rem 1.1rem;
    box-shadow: var(--shadow-sm);
}

.kpi-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 600;
    margin: 0.4rem 0 0.2rem 0;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

.kpi-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* --- Boutons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.55rem 1.1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    line-height: 1.4;
    letter-spacing: 0.005em;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background-color: var(--btn-primary-bg);
    color: var(--btn-primary-text);
}

.btn-primary:hover {
    background-color: var(--btn-primary-hover);
    color: var(--btn-primary-text);
}

.btn-secondary {
    background-color: var(--bg-white);
    color: var(--ink-800);
    border-color: var(--border-strong);
}

.btn-secondary:hover {
    background-color: var(--bg-muted);
    border-color: var(--ink-400);
}

.btn-success {
    background-color: var(--success);
    color: #fff;
}

.btn-success:hover {
    background-color: #17583d;
    color: #fff;
}

.btn-danger {
    background-color: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background-color: #96201a;
    color: #fff;
}

.btn-outline {
    background: var(--bg-white);
    color: var(--ink-900);
    border-color: var(--ink-900);
}

.btn-outline:hover {
    background: var(--ink-900);
    color: #fff;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
}

.btn-lg {
    padding: 0.72rem 1.5rem;
    font-size: 0.95rem;
}

.btn-block {
    width: 100%;
}

/* --- Formulaires --- */
.form-group {
    margin-bottom: 1.2rem;
}

.form-label {
    display: block;
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--ink-700);
    margin-bottom: 0.35rem;
}

.form-control,
input[type="text"].form-control,
input[type="email"].form-control,
input[type="password"].form-control,
input[type="number"].form-control,
input[type="tel"].form-control,
input[type="url"].form-control,
input[type="date"].form-control,
textarea.form-control {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--bg-white);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    line-height: 1.5;
}

.form-control:hover {
    border-color: var(--ink-400);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-control::placeholder {
    color: var(--ink-400);
}

.form-select,
select.form-select {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--bg-white);
    appearance: auto;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-check-input {
    width: 1rem;
    height: 1rem;
    accent-color: var(--accent);
}

.form-error {
    color: var(--danger-text);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

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

fieldset.form-fieldset {
    border: none;
    padding: 0;
    margin-bottom: 2rem;
}

fieldset.form-fieldset legend {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.55rem;
    width: 100%;
}

/* --- Alertes et messages --- */
.alert {
    padding: 0.8rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    border-left-width: 3px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
}

.alert-success {
    background-color: var(--success-bg);
    color: var(--success-text);
    border-color: var(--success-border);
    border-left-color: var(--success);
}

.alert-error, .alert-danger {
    background-color: var(--danger-bg);
    color: var(--danger-text);
    border-color: var(--danger-border);
    border-left-color: var(--danger);
}

.alert-warning {
    background-color: var(--warning-bg);
    color: var(--warning-text);
    border-color: var(--warning-border);
    border-left-color: var(--warning);
}

.alert-info {
    background-color: var(--info-bg);
    color: var(--info-text);
    border-color: var(--info-border);
    border-left-color: var(--info);
}

.messages-container {
    margin-bottom: 1.5rem;
}

/* --- Badges d'état --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.18rem 0.55rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1.5;
    white-space: nowrap;
}

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

.badge-success {
    background: var(--success-bg);
    color: var(--success-text);
    border-color: var(--success-border);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning-text);
    border-color: var(--warning-border);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger-text);
    border-color: var(--danger-border);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info-text);
    border-color: var(--info-border);
}

.badge-neutral {
    background: var(--bg-muted);
    color: var(--ink-600);
    border-color: var(--border);
}

/* --- Tableaux --- */
.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.875rem;
}

.table thead {
    background-color: var(--ink-50);
    border-bottom: 1px solid var(--border-strong);
}

.table thead th {
    padding: 0.7rem 1rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    white-space: nowrap;
}

.table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.1s ease;
}

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

.table tbody tr:hover {
    background-color: var(--ink-50);
}

.table tbody td {
    padding: 0.8rem 1rem;
    color: var(--text-secondary);
    vertical-align: middle;
}

.table tbody td strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* --- Jauges de progression --- */
.progress-track {
    background: var(--ink-100);
    border-radius: var(--radius-full);
    height: 6px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 0.4s ease;
}

.progress-fill-primary { background: var(--ink-700); }
.progress-fill-success { background: var(--success); }
.progress-fill-warning { background: var(--warning); }
.progress-fill-danger { background: var(--danger); }
.progress-fill-info { background: var(--info); }

/* --- Zone de danger --- */
.danger-zone {
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    border-left: 3px solid var(--danger);
    border-radius: var(--radius-md);
    padding: 1.5rem;
}

.danger-zone h3 {
    color: var(--danger-text);
    font-size: 1rem;
    margin: 0 0 0.25rem 0;
}

.danger-zone p {
    color: var(--danger-text);
    font-size: 0.85rem;
    margin: 0;
}

/* --- État vide --- */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    background: var(--bg-white);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-md);
}

.empty-state p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

/* --- Pied de page --- */
.app-footer {
    padding: 1.25rem 2.5rem;
    border-top: 1px solid var(--border);
    background: var(--bg-white);
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.app-footer a {
    color: var(--text-muted);
    text-decoration: none;
    margin: 0 0.5rem;
}

.app-footer a:hover {
    color: var(--accent);
    text-decoration: underline;
}

.footer-links {
    margin-bottom: 0.3rem;
}

/* --- Utilitaires --- */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--accent); }
.text-primary-dark { color: var(--ink-900); }
.font-bold { font-weight: 600; }
.font-extrabold { font-weight: 700; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; }

.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.85rem; }
.text-md { font-size: 0.9rem; }
.text-lg { font-size: 1.1rem; }
.text-xl { font-size: 1.5rem; }
.text-base { font-size: 1rem; }
.font-medium { font-weight: 500; }
.text-info { color: var(--ink-700); }
.text-secondary { color: var(--text-muted); }
.text-orange { color: var(--warning); font-weight: 600; }
.text-danger-dark { color: var(--danger-text); }
.d-block { display: block; }
.m-0 { margin: 0; }
.mb-sm { margin-bottom: 0.25rem; }
.mb-md { margin-bottom: 1.25rem; }
.my-sm { margin: 0.75rem 0; }
.my-xs { margin: 0.25rem 0; }
.ml-xs { margin-left: 0.25rem; }
.ml-sm { margin-left: 0.5rem; }
.pt-md { padding-top: 1.25rem; }
.nowrap { white-space: nowrap; }
.italic { font-style: italic; }
.leading-relaxed { line-height: 1.55; }
.flex-col { display: flex; flex-direction: column; }
.flex-center { align-items: center; }
.gap-lg { gap: 1.25rem; }
.justify-end { justify-content: flex-end; }
.justify-center { justify-content: center; }
.is-hidden { display: none; }
.is-disabled { opacity: 0.55; pointer-events: none; cursor: not-allowed; }
.inline-form { display: inline-block; }
.border-top-light { border-top: 1px solid var(--border); }
.table-scroll { overflow-x: auto; }
.title-md { font-size: 1.25rem; }
.title-sm { font-size: 1.05rem; margin: 0; }

/* --- Composants dérivés --- */
.btn-dark { background-color: var(--ink-900); color: #fff; }
.btn-dark:hover { background-color: var(--btn-primary-hover); color: #fff; }
.btn-pill { border-radius: var(--radius-full); padding: 0.45rem 1.2rem; }
.btn-ghost { background: transparent; border-color: transparent; }

.badge-lg { font-size: 0.8rem; padding: 0.4rem 1rem; }

.kpi-unit { font-size: 0.95rem; font-weight: 500; color: var(--text-muted); }
.kpi-value-lg { font-size: 1.6rem; }

.card-flush { padding: 0; overflow: hidden; }
.card-section-header { padding: 1.1rem 1.5rem; border-bottom: 1px solid var(--border); }
.card-action { display: flex; flex-direction: column; justify-content: space-between; }
.card-centered { display: flex; flex-direction: column; justify-content: center; align-items: center; }
.card-muted { background: var(--ink-50); }
.card-roomy { padding: 3rem 2rem; }
.card-desc { font-size: 0.9rem; line-height: 1.5; margin-bottom: 1.5rem; }

.icon-tile {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--bg-muted);
    color: var(--ink-800);
    border: 1px solid var(--border);
}
.icon-tile-purple { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-border); }

.list-plain { list-style: none; padding: 0; margin: 0; line-height: 2.2; }
.list-row { border-bottom: 1px solid var(--border); padding: 0.25rem 0; }
.list-row:last-child { border-bottom: none; }

.stat-tile { background: var(--ink-50); border: 1px solid var(--border); padding: 1rem; border-radius: var(--radius-sm); }
.stat-value { display: block; font-size: 1.4rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.panel-muted { background: var(--ink-50); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1.25rem; }
.section-subtitle { margin: 0 0 1rem 0; font-size: 1rem; }

.callout {
    background: var(--ink-50);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 1rem;
}
.callout-label { display: block; font-size: 0.8rem; margin-bottom: 0.25rem; }
.callout-text { font-size: 0.9rem; line-height: 1.55; margin: 0; font-style: italic; }

.clause-card { border-left: 4px solid var(--success); margin-bottom: 0; }
.clause-card.risk-critique { border-left-color: var(--danger); }
.clause-card.risk-eleve { border-left-color: var(--warning); }
.clause-card.risk-moyen { border-left-color: #a3790d; }
.clause-ref { font-size: 0.8rem; color: var(--accent); font-weight: 600; margin-bottom: 0.75rem; }

.page-header-block { display: block; margin-bottom: 2.5rem; border-bottom: none; padding-bottom: 0; }
.lead-narrow { max-width: 650px; margin: 0 auto; }

.filter-grow { flex: 1; min-width: 200px; }
.filter-field { min-width: 180px; }
.cell-wrap { max-width: 320px; }
.code-ref { color: var(--ink-900); font-size: 0.82rem; display: block; font-variant-numeric: tabular-nums; }

/* --- Abonnements --- */
.billing-toggle {
    margin-top: 1.5rem;
    display: inline-flex;
    background: var(--bg-muted);
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    gap: 0.25rem;
    border: 1px solid var(--border);
}
.billing-toggle .btn { border-radius: var(--radius-sm); padding: 0.45rem 1.1rem; color: var(--ink-700); }
.billing-toggle .btn:hover { background: var(--ink-200); }
.billing-toggle .is-active, .billing-toggle .is-active:hover { background: var(--ink-900); color: #fff; }

.plan-grid { align-items: stretch; }
.plan-card { position: relative; }
.plan-card-featured { border-color: var(--ink-900); border-top: 3px solid var(--accent); }
.plan-ribbon {
    position: absolute;
    top: -11px;
    right: 18px;
    padding: 0.2rem 0.7rem;
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.plan-ribbon-current { background: var(--success); border-color: var(--success); color: #fff; }
.plan-ribbon-expired { background: var(--danger); border-color: var(--danger); color: #fff; }
.plan-title { font-size: 1.35rem; margin-bottom: 0.5rem; }
.plan-desc { font-size: 0.9rem; line-height: 1.5; margin-bottom: 1.5rem; min-height: 40px; }
.plan-features { border-top: 1px solid var(--border); padding-top: 1.25rem; margin-bottom: 2rem; }
.feature-list { list-style: none; padding: 0; margin: 0; font-size: 0.9rem; line-height: 2; }
.plan-name { font-size: 1.5rem; margin: 0.25rem 0; }

.price-total { font-size: 1.9rem; }
.choice-label { cursor: pointer; display: flex; align-items: center; gap: 0.45rem; font-size: 0.9rem; }
.choice-card {
    padding: 0.85rem 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    margin-bottom: 0;
}
.choice-card-start { align-items: flex-start; padding: 1rem; }

.success-circle {
    width: 64px;
    height: 64px;
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid var(--success-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem auto;
}

/* --- Assistant de génération en étapes --- */
.wizard-progress { margin-bottom: 1.5rem; }
.wizard-dots { display: flex; gap: 0.5rem; list-style: none; padding: 0; margin: 0 0 0.75rem 0; }
.wizard-dot {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--bg-white);
    color: var(--text-muted);
    border: 1px solid var(--border-strong);
}
.wizard-dot.is-current { background: var(--ink-900); color: #fff; border-color: var(--ink-900); }
.wizard-dot.is-done { background: var(--success-bg); color: var(--success-text); border-color: var(--success); }
.wizard-bar { transition: width 0.3s ease; }
.wizard-step.is-hidden { display: none; }
.wizard-actions {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    border-top: 1px solid var(--border);
    padding-top: 1.5rem;
    margin-top: 1.5rem;
}
.wizard-actions .btn-lg { margin-left: auto; }
.wizard-actions-plain { border-top: 1px solid var(--border); padding-top: 1.5rem; margin-top: 1.5rem; }

/* --- Document juridique --- */
.doc-card { padding: 2.75rem 3rem; margin-top: 1rem; }
.doc-header { border-bottom: 2px solid var(--ink-900); padding-bottom: 1.5rem; margin-bottom: 2rem; }
.doc-title { font-size: 1.45rem; color: var(--text-primary); margin: 0.35rem 0 0 0; }
.doc-body {
    white-space: pre-wrap;
    font-family: var(--font-serif);
    font-weight: 400;
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text-primary);
}

/* --- Consentement --- */
.form-consent .form-check-label {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    font-size: 0.875rem;
    line-height: 1.5;
    cursor: pointer;
}
.form-consent .form-check-input { margin-top: 0.2rem; flex-shrink: 0; }

/* --- Authentification : coque à deux colonnes --- */
.auth-shell {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    min-height: 100vh;
}

.auth-aside {
    background: var(--ink-900);
    color: var(--sidebar-text);
    padding: 3rem 3.25rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: sticky;
    top: 0;
    height: 100vh;
    align-self: start;
}

.auth-aside-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    color: #fff;
    text-decoration: none;
}
.auth-aside-brand:hover { text-decoration: none; }

.auth-aside-brand .sidebar-brand-mark { width: 38px; height: 38px; }

.auth-aside-name {
    font-family: var(--font-serif);
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.auth-aside h2 {
    font-size: 2rem;
    line-height: 1.2;
    color: #fff;
    font-weight: 600;
    margin-bottom: 1.1rem;
    max-width: 18ch;
}

.auth-aside p { color: var(--sidebar-text); max-width: 38ch; }

.auth-points {
    list-style: none;
    margin-top: 2rem;
    display: grid;
    gap: 0.9rem;
}

.auth-points li {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    font-size: 0.9rem;
    color: var(--sidebar-text);
}

.auth-points .icon { color: var(--sidebar-active); margin-top: 0.15rem; }

.auth-aside-foot { font-size: 0.75rem; color: var(--sidebar-label); }
.auth-aside-foot a { color: var(--sidebar-text); margin-right: 1rem; }

.auth-panel {
    background: var(--bg-body);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.auth-topbar {
    display: flex;
    justify-content: flex-end;
    padding: 1.25rem 2rem;
}

.auth-back {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.auth-back:hover { color: var(--accent); }

.auth-main { flex: 1; padding: 0 2rem 2rem; }

.auth-legal {
    padding: 1.25rem 2rem;
    border-top: 1px solid var(--border);
    font-size: 0.78rem;
    color: var(--text-muted);
    text-align: center;
}
.auth-legal a { color: var(--text-muted); margin: 0 0.5rem; }
.auth-legal a:hover { color: var(--accent); }

.auth-brand { color: var(--ink-900); font-family: var(--font-serif); font-weight: 700; font-size: 1.25rem; text-decoration: none; }
.auth-header { display: none; }
.auth-container { padding: 1rem 0 2rem; }
.auth-container-lg { padding: 2.5rem 0; }
.auth-title { font-size: 1.75rem; }

/* --- Bandeau d'abonnement --- */
.subscription-notice { margin-bottom: 1.25rem; }

/* --- Accessibilité : respecte « réduire les animations » --- */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* --- Robustesse : les enfants de grille ne doivent jamais élargir la page --- */
.grid-2 > *, .grid-3 > *, .grid-auto > *, .card-grid > *, .kpi-grid > * { min-width: 0; }

/* --- Responsive --- */
@media (max-width: 960px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
    .auth-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 1rem 1.25rem;
        background: var(--bg-white);
        border-bottom: 1px solid var(--border);
    }
    .auth-topbar { display: none; }
    .auth-main { padding: 0 1.25rem 1.5rem; }
}

@media (max-width: 768px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: flex; }
    .sidebar-close { display: inline-flex; }
    .sidebar-overlay.open { display: block; }
    .app-main { margin-left: 0; }
    .app-content { padding: 1rem; padding-top: 3.5rem; }
    .app-footer { padding: 1rem; }
    .page-header { flex-direction: column; }
    .form-grid-2, .grid-2 { grid-template-columns: 1fr; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .table { font-size: 0.8rem; }
    .table thead th, .table tbody td { padding: 0.5rem; }
    .doc-card { padding: 1.5rem 1.25rem; }
}

@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr; }
}
