/* ============================================================ */
/*  Oryx Nova ERP — feuille de style v2 (sidebar layout)          */
/* ============================================================ */

:root {
    /* === Couleurs primaires (identité Oryx conservée) === */
    --color-primary: #a01a1a;
    --color-primary-dark: #7d1414;
    --color-primary-light: #c93d3d;
    --color-primary-soft: #fef2f2;

    /* === Surfaces === */
    --color-bg: #f4f5f7;
    --color-bg-soft: #fafbfc;
    --color-bg-dark: #1a1d23;
    --color-surface: #ffffff;
    --color-surface-alt: #f9fafb;

    /* === Sidebar light premium (aligné identité Oryx Nova rouge & blanc) === */
    --color-sidebar-bg: #ffffff;
    --color-sidebar-bg-hover: #f3f4f6;
    --color-sidebar-bg-active: rgba(160, 26, 26, 0.10);
    --color-sidebar-text: #1f2937;
    --color-sidebar-text-muted: #6b7280;
    --color-sidebar-text-active: #a01a1a;
    --color-sidebar-border: #e5e7eb;
    --color-sidebar-section: #6b7280; /* a11y : 2.54 -> 4.83 de contraste (audit A4) */

    /* === Texte === */
    --color-text: #111827;
    --color-text-light: #374151;
    --color-muted: #6b7280;
    --color-muted-strong: #4b5563;

    /* === Bordures === */
    --color-border: #e5e7eb;
    --color-border-light: #f3f4f6;
    --color-border-strong: #d1d5db;

    /* === Statuts (couleurs sémantiques modernisées) === */
    --color-success: #059669;
    --color-success-dark: #047857;
    --color-success-bg: #d1fae5;
    --color-success-soft: #ecfdf5;
    --color-warning: #d97706;
    --color-warning-dark: #b45309;
    --color-warning-bg: #fef3c7;
    --color-warning-soft: #fffbeb;
    --color-danger: #dc2626;
    --color-danger-dark: #b91c1c;
    --color-danger-bg: #fee2e2;
    --color-danger-soft: #fef2f2;
    --color-info: #2563eb;
    --color-info-bg: #dbeafe;
    --color-info-soft: #eff6ff;

    /* === Typographie (system font stack — pas de dépendance externe) === */
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Helvetica Neue", "Arial", sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.375rem;
    --text-2xl: 1.75rem;
    --text-3xl: 2.25rem;
    --text-display: 3rem;
    --leading-tight: 1.25;
    --leading-normal: 1.5;
    --leading-relaxed: 1.65;

    /* === Radius === */
    --radius-sm: 6px;
    --radius: 8px;
    --radius-md: 10px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* === Shadows === */
    --shadow-xs: 0 1px 2px rgba(17, 24, 39, 0.05);
    --shadow-sm: 0 1px 3px rgba(17, 24, 39, 0.08), 0 1px 2px rgba(17, 24, 39, 0.04);
    --shadow: 0 4px 8px -2px rgba(17, 24, 39, 0.08), 0 2px 4px -1px rgba(17, 24, 39, 0.04);
    --shadow-md: 0 10px 15px -3px rgba(17, 24, 39, 0.1), 0 4px 6px -2px rgba(17, 24, 39, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(17, 24, 39, 0.12), 0 10px 10px -5px rgba(17, 24, 39, 0.04);
    --shadow-focus: 0 0 0 3px rgba(160, 26, 26, 0.15);

    /* === Espacement === */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    /* === Layout === */
    --sidebar-width: 256px;
    --sidebar-width-collapsed: 64px;
    --topbar-height: 60px;
    --max-width: 1400px;

    /* === Transitions === */
    --transition-fast: 0.12s ease;
    --transition-base: 0.18s ease;
    --transition-slow: 0.25s ease;

    font-family: var(--font-sans);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--color-primary); }
a:hover { text-decoration: underline; }

[x-cloak] { display: none !important; }

/* ============================================================ */
/*                       APP LAYOUT                               */
/* ============================================================ */

.app-layout {
    display: flex;
    min-height: 100vh;
}

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ============================================================ */
/*                          SIDEBAR                               */
/* ============================================================ */

.app-sidebar {
    width: var(--sidebar-width);
    background: var(--color-sidebar-bg);
    border-right: 1px solid var(--color-sidebar-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    transition: width var(--transition-base);
    z-index: 50;
}
.app-sidebar.is-collapsed { width: var(--sidebar-width-collapsed); }

.sidebar-brand {
    padding: 0 1rem;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: 0.65rem;
    border-bottom: 1px solid var(--color-sidebar-border);
    text-decoration: none;
    color: var(--color-sidebar-text-active);
    flex-shrink: 0;
}
.sidebar-brand:hover { text-decoration: none; }

.sidebar-brand__logo-img {
    /* Sidebar light : logo rouge directement sur fond blanc — contraste
       naturel, capsule retirée car redondante. Le fichier logo reste intact. */
    height: 36px;
    width: auto;
    flex-shrink: 0;
    max-width: 100%;
    object-fit: contain;
}
.sidebar-brand__name {
    font-weight: 700;
    color: var(--color-sidebar-text);
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    line-height: 1.1;
}
.sidebar-brand__sub {
    color: var(--color-sidebar-text-muted);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 0.15rem;
}
.is-collapsed .sidebar-brand__name,
.is-collapsed .sidebar-brand__sub { display: none; }
/* Mode collapsed : centre le logo dans les 64px de sidebar et limite sa taille
   pour qu'il tienne sans être coupé. */
.is-collapsed .sidebar-brand {
    padding: 0;
    justify-content: center;
    gap: 0;
    overflow: hidden;
}
.is-collapsed .sidebar-brand__logo-img {
    /* Mode collapsed : logo dimensionné par la largeur (max 52px) pour rester
       centré dans les 64px de sidebar sans déborder. height auto préserve l'aspect. */
    width: auto;
    max-width: 52px;
    height: auto;
    max-height: 32px;
    flex-shrink: 1;
}

.sidebar-nav {
    flex: 1;
    padding: 0.5rem 0.5rem 1rem;
    overflow-y: auto;
}

.sidebar-section {
    color: var(--color-sidebar-section);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 1rem 0.85rem 0.4rem;
    user-select: none;
}
.is-collapsed .sidebar-section {
    text-align: center;
    padding: 0.5rem 0;
    border-top: 1px solid var(--color-sidebar-border);
    margin-top: 0.5rem;
    font-size: 0;
}
.is-collapsed .sidebar-section::after {
    content: "•";
    font-size: 0.8rem;
    color: var(--color-sidebar-border);
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.85rem;
    color: var(--color-sidebar-text);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.1rem;
    transition: background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
    white-space: nowrap;
    position: relative;
}
.sidebar-item:hover {
    background: var(--color-sidebar-bg-hover);
    color: var(--color-sidebar-text-active);
    text-decoration: none;
}
.sidebar-item.is-active {
    background: var(--color-sidebar-bg-active);
    color: var(--color-sidebar-text-active);
    box-shadow: inset 3px 0 0 var(--color-primary);
    font-weight: 600;
}
.sidebar-item.is-active:hover {
    background: var(--color-sidebar-bg-active);
    color: var(--color-sidebar-text-active);
    box-shadow: inset 3px 0 0 var(--color-primary);
    font-weight: 600;
}
.sidebar-item__icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}
.is-collapsed .sidebar-item { justify-content: center; padding: 0.5rem 0; }
.is-collapsed .sidebar-item__label { display: none; }
.is-collapsed .sidebar-item:hover::after {
    content: attr(data-label);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: var(--color-bg-dark);
    color: white;
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 100;
    margin-left: 0.5rem;
}

/* Backdrop mobile */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 40;
}

@media (max-width: 768px) {
    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }
    .app-sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .sidebar-backdrop.is-visible { display: block; }
}

/* ============================================================ */
/*                          TOPBAR                                */
/* ============================================================ */

.topbar {
    background: white;
    border-bottom: 1px solid var(--color-border);
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 30;
    box-shadow: var(--shadow-xs);
}
.topbar-toggle {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--color-muted);
    transition: background 0.15s;
    flex-shrink: 0;
    padding: 0;
}
.topbar-toggle:hover { background: var(--color-bg); color: var(--color-primary); }

.topbar-search {
    flex: 1;
    max-width: 480px;
    position: relative;
}
.topbar-search input {
    width: 100%;
    padding: 0.5rem 4rem 0.5rem 2.25rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    background: var(--color-bg);
    transition: all 0.15s;
    cursor: pointer;
}
.topbar-search input:hover { background: white; border-color: var(--color-border); }
.topbar-search input:focus {
    outline: none;
    background: white;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(160, 26, 26, 0.08);
}
.topbar-search__icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-muted);
    pointer-events: none;
    width: 16px;
    height: 16px;
}
.topbar-search__shortcut {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    font-size: 0.7rem;
    color: var(--color-muted);
    font-family: ui-monospace, monospace;
    pointer-events: none;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--color-text);
    font-size: 0.85rem;
    flex-shrink: 0;
}
.topbar-user__info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.2;
}
.topbar-user__email {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-text);
}
.topbar-user__role {
    font-size: var(--text-xs);
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}
.topbar-user__logout {
    color: var(--color-primary);
    text-decoration: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.topbar-user__logout:hover { background: var(--color-danger-bg); text-decoration: none; }

@media (max-width: 600px) {
    .topbar-search { display: none; }
    .topbar-user__email { display: none; }
}

/* ============================================================ */
/*                          LAYOUT                                */
/* ============================================================ */

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1.25rem 1.5rem;
    width: 100%;
    flex: 1;
}

h1 { margin-top: 0; font-weight: 700; letter-spacing: -0.02em; font-size: var(--text-2xl); }
h2 { font-weight: 700; letter-spacing: -0.015em; font-size: var(--text-xl); }
h3 { font-weight: 600; font-size: var(--text-lg); margin-top: 1.5rem; margin-bottom: 0.75rem; }
h3:first-child { margin-top: 0; }

/* ============================================================ */
/*                      BREADCRUMBS                               */
/* ============================================================ */

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0 0 0.75rem;
    color: var(--color-muted);
    font-size: 0.85rem;
    flex-wrap: wrap;
}
.breadcrumbs a {
    color: var(--color-muted);
    text-decoration: none;
}
.breadcrumbs a:hover {
    color: var(--color-primary);
    text-decoration: underline;
}
.breadcrumbs__sep {
    color: var(--color-border);
    user-select: none;
}
.breadcrumbs__current {
    color: var(--color-text);
    font-weight: 500;
}

/* ============================================================ */
/*                       PAGE HEADER                              */
/* ============================================================ */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.page-header h1 { margin: 0; }

/* ============================================================ */
/*                          CARDS                                 */
/* ============================================================ */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-6);
    box-shadow: var(--shadow-xs);
    margin-bottom: 1rem;
}

/* ============================================================ */
/*                         MESSAGES                               */
/* ============================================================ */

.messages { margin-bottom: 1rem; }
.msg {
    padding: var(--space-3) var(--space-4);
    border-left: 4px solid transparent;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    font-weight: 500;
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
}
.msg svg.lucide {
    flex-shrink: 0;
    margin-top: 2px;
    width: 18px;
    height: 18px;
}
.msg--success { background: var(--color-success-soft); border-color: var(--color-success); color: var(--color-success-dark); }
.msg--info    { background: var(--color-info-soft); border-color: var(--color-info); color: #1e40af; }
.msg--warning { background: var(--color-warning-soft); border-color: var(--color-warning); color: var(--color-warning-dark); }
.msg--danger  { background: var(--color-danger-soft); border-color: var(--color-danger); color: var(--color-danger-dark); }

/* ============================================================ */
/*                          FOOTER                                */
/* ============================================================ */

.footer {
    text-align: center;
    color: var(--color-muted);
    padding: 1.5rem 1rem 1.25rem;
    border-top: 1px solid var(--color-border);
    background: white;
}

/* ============================================================ */
/*                           FORMS                                */
/* ============================================================ */

.form-row { margin-bottom: 1rem; }
.form-row label {
    display: block;
    font-weight: 600;
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
    color: var(--color-text-light);
}
.form-row input, .form-row select, .form-row textarea {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: var(--text-base);
    font-family: inherit;
    background: var(--color-surface);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: var(--shadow-focus);
}

.form-row-2, .form-row-3 {
    display: grid;
    gap: 1rem;
}
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 700px) {
    .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
}

/* ============================================================ */
/*                         BUTTONS                                */
/* ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1.1rem;
    border-radius: var(--radius);
    font-weight: 500;
    text-decoration: none;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    font-size: var(--text-sm);
    font-family: inherit;
    transition: all var(--transition-fast);
    line-height: 1.4;
    min-height: 38px;
}
.btn:hover { background: var(--color-bg-soft); border-color: var(--color-border-strong); text-decoration: none; }
.btn:focus-visible { box-shadow: var(--shadow-focus); outline: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
    box-shadow: 0 1px 2px rgba(160, 26, 26, 0.2);
}
.btn--primary:hover {
    background: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
    color: white;
    box-shadow: 0 4px 8px -2px rgba(160, 26, 26, 0.3);
    transform: translateY(-1px);
}

.btn--success {
    background: var(--color-success);
    border-color: var(--color-success);
    color: white;
}
.btn--success:hover { background: var(--color-success-dark); border-color: var(--color-success-dark); color: white; }

.btn--danger {
    background: var(--color-danger);
    border-color: var(--color-danger);
    color: white;
}
.btn--danger:hover { background: var(--color-danger-dark); border-color: var(--color-danger-dark); color: white; }

.btn--warning {
    background: var(--color-warning);
    border-color: var(--color-warning);
    color: white;
}
.btn--warning:hover { background: var(--color-warning-dark); border-color: var(--color-warning-dark); color: white; }

.btn--ghost {
    border-color: transparent;
    background: transparent;
}
.btn--ghost:hover { background: var(--color-bg); }

.btn--sm {
    padding: 0.3rem 0.6rem;
    font-size: var(--text-xs);
    min-height: 30px;
}

.btn--block { width: 100%; }

.btn--lg {
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-base);
    min-height: 48px;
}

.btn-icon {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 0.25rem 0.55rem;
    font-size: 1rem;
    line-height: 1;
    color: var(--color-muted);
    text-decoration: none;
    display: inline-block;
    transition: all 0.15s;
}
.btn-icon:hover { background: var(--color-bg); color: var(--color-primary); }

/* ============================================================ */
/*                  LOGIN — Corporate Premium                     */
/* ============================================================ */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
    position: relative;
    overflow: hidden;
}
/* Backdrop pattern radial sobre */
.login-page__bg {
    position: absolute;
    inset: 0;
    /* Opacités remontées (0.05 → 0.12/0.10) pour rendre le pattern radial
       réellement perceptible tout en restant subtile et professionnelle. */
    background:
        radial-gradient(ellipse at 20% 20%, rgba(160, 26, 26, 0.12), transparent 55%),
        radial-gradient(ellipse at 80% 80%, rgba(31, 41, 55, 0.10), transparent 55%),
        linear-gradient(180deg, #f9fafb 0%, #f4f5f7 100%);
    z-index: 0;
}
.login-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-6);
}
.login-brand { text-align: center; }
.login-brand__logo {
    max-height: 80px;
    max-width: 280px;
    width: auto;
    height: auto;
}
.login-brand__name {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--color-primary);
    letter-spacing: -0.025em;
    margin: 0;
}
.login-brand__tagline {
    color: var(--color-muted-strong);
    font-size: var(--text-sm);
    margin-top: var(--space-2);
    letter-spacing: 0.04em;
}
.login-card {
    width: 100%;
    padding: var(--space-8);
    box-shadow: var(--shadow-md);
    border-radius: var(--radius-lg);
    margin-bottom: 0;
}
.login-card__title {
    margin: 0 0 var(--space-1) 0;
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.02em;
}
.login-card__subtitle {
    color: var(--color-muted-strong);
    margin: 0 0 var(--space-6) 0;
    font-size: var(--text-sm);
}
.login-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}
.login-card__hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    margin-top: var(--space-6);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border-light);
    color: var(--color-muted-strong);
    font-size: var(--text-xs);
}
.login-card__hint svg.lucide {
    width: 14px;
    height: 14px;
    color: var(--color-success);
}
.login-footer {
    color: var(--color-muted);
    font-size: var(--text-xs);
    text-align: center;
}

/* === Field component (input avec icône + actions) === */
.field {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}
.field__label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text-light);
}
.field__control {
    position: relative;
    display: flex;
    align-items: center;
}
.field__control input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: var(--text-base);
    font-family: inherit;
    background: var(--color-surface);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.field__control--with-icon input { padding-left: 2.5rem; }
.field__control--with-action input { padding-right: 2.75rem; }
.field__control input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: var(--shadow-focus);
}
/* Override Chrome/Edge autofill : neutralise le fond bleu pâle automatique
   pour préserver l'esthétique propre de la card login. */
.field__control input:-webkit-autofill,
.field__control input:-webkit-autofill:hover,
.field__control input:-webkit-autofill:focus,
.field__control input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 1000px var(--color-surface) inset;
    -webkit-text-fill-color: var(--color-text);
    caret-color: var(--color-text);
    transition: background-color 9999s ease-in-out 0s;
}
.field__icon {
    position: absolute;
    left: var(--space-3);
    width: 18px;
    height: 18px;
    color: var(--color-muted);
    pointer-events: none;
}
.field__action {
    position: absolute;
    right: var(--space-2);
    background: none;
    border: none;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--color-muted);
    border-radius: var(--radius-sm);
    padding: 0;
    transition: all var(--transition-fast);
}
.field__action:hover {
    background: var(--color-bg);
    color: var(--color-text);
}
.field__action svg.lucide {
    width: 18px;
    height: 18px;
}

/* ============================================================ */
/*                          GRID                                  */
/* ============================================================ */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.grid--2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
@media (max-width: 900px) {
    .grid--2 { grid-template-columns: 1fr; }
}

.card .table { table-layout: auto; width: 100%; }
.card .table td, .card .table th {
    padding: 0.5rem 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
}
.card .table--compact { font-size: 0.85rem; }

.kpi {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--color-primary);
    margin: 0;
    letter-spacing: -0.02em;
}
.card--alert {
    border-left: 4px solid var(--color-danger);
    background: var(--color-danger-bg);
}
.card--alert h3 { color: var(--color-danger); margin-top: 0; }

/* ============================================================ */
/*                         TABLES                                 */
/* ============================================================ */

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
    font-variant-numeric: tabular-nums;
}
.table th, .table td {
    padding: 0.65rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border-light);
    vertical-align: top;
}
.table th {
    background: var(--color-bg-soft);
    font-weight: 600;
    color: var(--color-muted-strong);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid var(--color-border);
    position: sticky;
    top: var(--topbar-height);
    z-index: 5;
}
/* Le sticky thead global (ci-dessus) casse dans les conteneurs en carte / repliables :
   le header se détache et flotte au milieu du tableau. On le neutralise partout dans
   .card / details / .section / .section-card / conteneurs scrollables pour ne plus
   jamais avoir à le corriger page par page.
   (2026-07-20 : .section-card manquait — l'en-tête flottait au milieu du tableau des
   paliers sur /missions ; .section-card est utilisé par 20+ templates.) */
.card .table th,
details .table th,
.section .table th,
.section-card .table th,
.table-scroll .table th {
    position: static;
    top: auto;
    z-index: auto;
}
.table tr:hover td { background: var(--color-surface-alt); }
.table code { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace; font-size: 0.9em; color: var(--color-text); }

.table th.sortable a {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
.table th.sortable a:hover { color: var(--color-primary); }
.table th.is-sorted a { color: var(--color-primary); }
.table th .sort-icon { width: 12px; height: 12px; opacity: 0.5; }
.table th.is-sorted .sort-icon { opacity: 1; }

/* ============================================================ */
/*                         BADGES                                 */
/* ============================================================ */

.badge {
    display: inline-block;
    padding: 0.2rem 0.625rem;
    border-radius: 99px;
    font-size: var(--text-xs);
    font-weight: 600;
    line-height: 1.5;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}
.badge--success { background: var(--color-success-bg); color: #166534; }
.badge--info    { background: var(--color-info-bg); color: #1e40af; }
.badge--warning { background: var(--color-warning-bg); color: #92400e; }
.badge--danger  { background: var(--color-danger-bg); color: var(--color-danger); }
.badge--muted   { background: #e5e7eb; color: #374151; }

/* ============================================================ */
/*       PHASE 4.10 — STANDARD FILTRES UNIFIÉ (additif)           */
/* ============================================================ */
/* Approche: classes CSS communes utilisables directement dans les
   templates, sans composant include avec {% block %}. Les pages
   utilisent .filter-panel + .filter-row + .filter-advanced +
   .filter-actions pour une présentation cohérente. La classe
   historique .filters reste utilisable pour les pages non refondues.
*/

.filter-panel {
    background: var(--color-card-bg, #ffffff);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.filter-panel form { display: contents; } /* pour que les enfants direct du form héritent du flex */

/* Zone 1 — Presets (boutons rapides type "Cette année" / "30 jours") */
.filter-presets {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    padding-bottom: 0.55rem;
    border-bottom: 1px dashed var(--color-border);
}
.filter-presets__label {
    font-size: 0.85rem;
    color: var(--color-muted);
    font-weight: 600;
    margin-right: 0.25rem;
}
.filter-presets__hint {
    font-size: 0.75rem;
    color: var(--color-muted);
    margin-left: auto;
}

/* Zone 2 + Zone 3 — Lignes de filtres (essentiels OU avancés) */
.filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}
.filter-row > label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.88rem;
    color: var(--color-muted);
    white-space: nowrap;
}
.filter-row > label > input,
.filter-row > label > select { margin-left: 0.15rem; }
.filter-row input[type="search"] {
    flex: 1;
    min-width: 220px;
}
.filter-row input[type="date"] { width: 140px; }
.filter-row input[type="number"] { width: 110px; }
.filter-row input[type="month"] { width: 145px; }
.filter-row input[type="text"]:not([style]) { width: 140px; }
.filter-row > select { min-width: 130px; }

/* Zone 3 — Bloc "Filtres avancés" collapsible (basé sur <details>) */
.filter-advanced {
    border-top: 1px dashed var(--color-border);
    padding-top: 0.55rem;
}
.filter-advanced[open] { padding-bottom: 0.3rem; }
.filter-advanced > summary {
    cursor: pointer;
    user-select: none;
    font-size: 0.85rem;
    color: var(--color-muted);
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    list-style: none;
    padding: 0.15rem 0;
}
.filter-advanced > summary::-webkit-details-marker { display: none; }
.filter-advanced > summary::marker { content: ''; }
.filter-advanced > summary::before {
    content: "▸";
    font-size: 0.8em;
    transition: transform 0.15s;
    display: inline-block;
}
.filter-advanced[open] > summary::before { transform: rotate(90deg); }
.filter-advanced > summary:hover { color: var(--color-primary); }
.filter-advanced > .filter-row { margin-top: 0.55rem; }

/* Zone 4 — Actions du panel (Filtrer / Réinit à gauche, Export à droite) */
.filter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    border-top: 1px solid var(--color-border);
    padding-top: 0.55rem;
}
.filter-actions__export {
    margin-left: auto;
}

/* Inputs dans .filter-panel : style cohérent identique à .filters */
.filter-panel input[type="search"],
.filter-panel input[type="text"],
.filter-panel input[type="number"],
.filter-panel input[type="date"],
.filter-panel input[type="month"],
.filter-panel select {
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    background: white;
}

/* ============================================================ */
/*                  CLASSE HÉRITÉE .filters                       */
/* ============================================================ */

.filters {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

/* ===== Phase 3.7 — Grille exports /export/index.html ===== */
.export-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.5rem;
    margin-top: 0.75rem;
}
.export-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    text-decoration: none;
    transition: all 0.15s;
}
.export-link:hover {
    border-color: var(--color-primary);
    background: rgba(160, 26, 26, 0.03);
    color: var(--color-text);
    text-decoration: none;
    transform: translateY(-1px);
}
.export-link i {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    color: var(--color-primary);
}
.export-link strong {
    display: block;
    color: var(--color-text);
    font-size: 0.95rem;
}
.export-link small {
    display: block;
    color: var(--color-muted);
    font-size: 0.78rem;
    margin-top: 0.15rem;
}

/* ===== Phase 3.3 — Presets dashboard (raccourcis rapides) ===== */
.dashboard-presets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.5rem;
}
.preset-link {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.65rem 0.85rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-size: 0.88rem;
    text-decoration: none;
    transition: all 0.15s;
}
.preset-link:hover {
    border-color: var(--color-primary);
    background: rgba(160, 26, 26, 0.04);
    color: var(--color-primary);
    transform: translateY(-1px);
    text-decoration: none;
}
.preset-link i {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}
.preset-link--danger {
    border-left: 3px solid var(--color-danger);
}
.preset-link--danger:hover {
    border-color: var(--color-danger);
    background: rgba(220, 38, 38, 0.04);
    color: var(--color-danger);
}
.preset-link--warning {
    border-left: 3px solid var(--color-warning);
}
.preset-link--warning:hover {
    border-color: var(--color-warning);
    background: rgba(217, 119, 6, 0.04);
    color: var(--color-warning);
}

/* ===== Phase 3.2 — Chips filtres actifs ===== */
.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    padding: 0.5rem 0.75rem;
    margin: 0 0 0.75rem;
    background: #fafbfc;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}
.filter-chips__label {
    font-weight: 600;
    color: var(--color-muted);
    margin-right: 0.25rem;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.6rem;
    background: rgba(160, 26, 26, 0.08);
    border: 1px solid rgba(160, 26, 26, 0.2);
    border-radius: var(--radius-full, 999px);
    color: var(--color-text);
    font-size: 0.82rem;
    line-height: 1.4;
}
.chip strong {
    color: var(--color-primary);
    font-weight: 600;
}
.chip__remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(160, 26, 26, 0.15);
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 700;
    line-height: 1;
    margin-left: 0.15rem;
    transition: background 0.15s;
}
.chip__remove:hover {
    background: var(--color-primary);
    color: white;
    text-decoration: none;
}
.filter-chips__clear {
    margin-left: auto;
    color: var(--color-muted);
    font-size: 0.78rem;
    text-decoration: underline;
}
.filter-chips__clear:hover {
    color: var(--color-primary);
}
.filters input[type="search"], .filters select, .filters input[type="number"], .filters input[type="date"] {
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    background: white;
}

/* ============================================================ */
/*                       PAGINATION                               */
/* ============================================================ */

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0 0;
    flex-wrap: wrap;
    gap: 0.75rem;
    color: var(--color-muted);
    font-size: 0.85rem;
}
.pagination-info { color: var(--color-muted); }
.pagination-pages {
    display: flex;
    gap: 0.25rem;
}
.pagination-page {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: white;
    text-decoration: none;
    color: var(--color-text);
    font-size: 0.85rem;
    transition: all 0.15s;
}
.pagination-page:hover {
    background: var(--color-bg);
    border-color: var(--color-primary-light);
    text-decoration: none;
}
.pagination-page.is-active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}
.pagination-page.is-disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* ============================================================ */
/*                  DEFINITION LISTS (FICHE DETAIL)               */
/* ============================================================ */

.dl {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.5rem 1.25rem;
    margin: 0;
    align-items: start;
}
.dl dt {
    color: var(--color-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    padding-top: 0.15rem;
}
.dl dd { margin: 0; }

/* ============================================================ */
/*                      KPI CARDS (DASHBOARD)                     */
/* ============================================================ */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-sm);
    /* Default neutre (anthracite) — harmonise avec la sidebar.
       Variantes --success / --danger / --warning gardent leurs couleurs sémantiques. */
    border-left: 4px solid var(--color-sidebar-bg);
    transition: transform 0.15s, box-shadow 0.15s;
    text-decoration: none;
    color: inherit;
    display: block;
    /* min-width:0 indispensable dans une grille flex/grid : permet aux cartes
       de se réduire et au texte interne de wrapper correctement. */
    min-width: 0;
}
.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
}
.kpi-card--primary { border-left-color: var(--color-primary); }
.kpi-card--danger  { border-left-color: var(--color-danger); }
.kpi-card--success { border-left-color: var(--color-success); }
.kpi-card--warning { border-left-color: var(--color-warning); }

.kpi-card__label {
    color: var(--color-muted);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    /* Évite que les longs labels poussent la carte en largeur */
    min-width: 0;
}
.kpi-card__label svg.lucide { flex-shrink: 0; }
.kpi-card__value {
    /* Taille fixe (pas de vw) : prédictible sur tous viewports.
       Sur grille de 5 KPIs (max-width container 1400px), chaque carte
       fait ~257px. Avec padding 48px + border 4px = 205px de contenu.
       À 1.375rem (22px) avec tabular-nums, "234 222,60 MAD" (14 chars NBSP)
       fait ~190px → tient sans wrap. */
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.02em;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    /* Filet de sécurité pour montants extrêmes (millions+) :
       autorise un retour à la ligne propre sans casser au milieu d'un nombre. */
    overflow-wrap: break-word;
    word-break: normal;
}
/* Sur très grands écrans (≥1600px), on agrandit légèrement la valeur
   pour donner plus d'impact visuel sans risque de débordement. */
@media (min-width: 1600px) {
    .kpi-card__value { font-size: 1.625rem; }
}
.kpi-card--danger .kpi-card__value { color: var(--color-danger); }
.kpi-card--success .kpi-card__value { color: var(--color-success); }
.kpi-card__sub {
    color: var(--color-muted);
    font-size: 0.8rem;
    margin-top: 0.4rem;
}

/* ============================================================ */
/*                       QUICK ACTIONS                            */
/* ============================================================ */

.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
}
.quick-action {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--color-text);
    transition: all 0.15s;
}
.quick-action:hover {
    background: white;
    border-color: var(--color-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
}
.quick-action__icon {
    color: var(--color-primary);
    flex-shrink: 0;
}
.quick-action__icon [data-lucide] { width: 24px; height: 24px; }
.quick-action__title {
    font-weight: 600;
    font-size: 0.95rem;
}
.quick-action__sub {
    color: var(--color-muted);
    font-size: 0.8rem;
}

/* ============================================================ */
/*                       SEARCH MODAL                             */
/* ============================================================ */

.search-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 12vh;
    z-index: 100;
}
.search-modal__panel {
    background: white;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 580px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.search-modal__input-wrap {
    position: relative;
    border-bottom: 1px solid var(--color-border);
}
.search-modal__input-wrap [data-lucide] {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-muted);
    width: 18px; height: 18px;
}
.search-modal__input {
    border: none;
    padding: 1rem 1.25rem 1rem 2.75rem;
    font-size: 1rem;
    outline: none;
    width: 100%;
    background: transparent;
}
.search-modal__results {
    overflow-y: auto;
    padding: 0.5rem 0;
}
.search-modal__group-title {
    color: var(--color-muted);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.5rem 1.25rem 0.25rem;
}
.search-modal__item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.25rem;
    text-decoration: none;
    color: var(--color-text);
    cursor: pointer;
    border-left: 3px solid transparent;
}
.search-modal__item:hover,
.search-modal__item.is-selected {
    background: var(--color-bg);
    border-left-color: var(--color-primary);
    text-decoration: none;
    color: inherit;
}
.search-modal__item-icon {
    color: var(--color-muted);
    width: 18px; height: 18px;
    flex-shrink: 0;
}
.search-modal__item-title { font-weight: 500; }
.search-modal__item-sub {
    color: var(--color-muted);
    font-size: 0.8rem;
    margin-left: auto;
}
.search-modal__hint {
    padding: 0.5rem 1.25rem;
    color: var(--color-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--color-border-light);
    background: var(--color-bg-soft);
    display: flex;
    gap: 1rem;
}
.search-modal__hint kbd {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 3px;
    padding: 0.05rem 0.35rem;
    font-family: ui-monospace, monospace;
    font-size: 0.75rem;
}
.search-modal__empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--color-muted);
}

/* ============================================================ */
/*                       HTMX INDICATOR                           */
/* ============================================================ */

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: inline-flex; }

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}
.btn .spinner { width: 14px; height: 14px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================ */
/*                       UTILITIES                                */
/* ============================================================ */

.text-right   { text-align: right !important; }
.text-center  { text-align: center !important; }
.text-left    { text-align: left !important; }
.text-muted   { color: var(--color-muted) !important; }
.text-success { color: var(--color-success) !important; }
.text-danger  { color: var(--color-danger) !important; }
.text-warning { color: var(--color-warning) !important; }
.text-primary { color: var(--color-primary) !important; }
.font-bold    { font-weight: 700 !important; }
.font-medium  { font-weight: 500 !important; }
.font-mono    { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace; }
.nowrap       { white-space: nowrap !important; }
.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.mt-1 { margin-top: 0.5rem !important; }
.mb-1 { margin-bottom: 0.5rem !important; }
.mt-2 { margin-top: 1rem !important; }
.mb-2 { margin-bottom: 1rem !important; }
.flex { display: flex !important; }
.gap-1 { gap: 0.5rem !important; }
.gap-2 { gap: 1rem !important; }
.items-center { align-items: center !important; }

/* Lucide icon defaults — cible à la fois <i data-lucide> avant transformation
   et <svg class="lucide"> généré par lucide.createIcons() */
[data-lucide], svg.lucide {
    width: 16px;
    height: 16px;
    stroke-width: 1.75;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: middle;
}
.kpi-card__label svg.lucide { width: 14px; height: 14px; }
.quick-action__icon svg.lucide { width: 24px; height: 24px; }
.sidebar-item__icon, .sidebar-item__icon svg.lucide { width: 18px; height: 18px; }
.search-modal__input-wrap svg.lucide { width: 18px; height: 18px; }
.btn svg.lucide { width: 14px; height: 14px; }

/* ============================================================ */
/*                       DIALOGS (modals natifs HTML5)            */
/* ============================================================ */

/* Centrage robuste cross-browser : on positionne explicitement.
   `inset: 0; margin: auto;` est l'astuce qui marche dans tous les navigateurs
   modernes pour centrer un <dialog> ouvert via .showModal(). */
dialog {
    position: fixed;
    inset: 0;
    margin: auto;
    border: none;
    border-radius: 12px;
    padding: 1.5rem;
    width: 92vw;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25), 0 4px 16px rgba(0, 0, 0, 0.12);
    color: var(--color-text, #1f2024);
    background: white;
    box-sizing: border-box;
}

/* Fond assombri OBLIGATOIRE — !important pour contrer un éventuel reset agent */
dialog::backdrop {
    background-color: rgba(0, 0, 0, 0.55) !important;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

/* Animation d'ouverture */
dialog[open] {
    animation: dialog-pop 0.18s ease-out;
}
@keyframes dialog-pop {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

/* Bloque le scroll de la page derrière la modal */
html:has(dialog[open]) {
    overflow: hidden;
}

/* Composants internes du dialog */
.dialog-header {
    margin: 0 0 0.75rem 0;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--color-text);
}

.dialog-body {
    margin-bottom: 1rem;
}

.dialog-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
    flex-wrap: wrap;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-border, #e5e5e5);
}

/* Le contenu du dialog ne doit pas déborder horizontalement */
dialog * {
    max-width: 100%;
    box-sizing: border-box;
}
dialog textarea,
dialog input,
dialog select {
    width: 100%;
    box-sizing: border-box;
}

/* Mobile : full-width avec marge */
@media (max-width: 640px) {
    dialog {
        width: 95vw;
        max-height: 90vh;
        padding: 1rem;
    }
    .dialog-actions {
        flex-direction: column-reverse;
    }
    .dialog-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================================ */
/*                       TABS (onglets)                           */
/* ============================================================ */

.tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.tab {
    padding: 0.5rem 1rem;
    border-bottom: 2px solid transparent;
    text-decoration: none;
    color: var(--color-muted);
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--color-text); text-decoration: none; }
.tab--active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    font-weight: 600;
}
.tab svg.lucide { width: 16px; height: 16px; }

/* ============================================================ */
/*                       TABLE WRAPPER (overflow horizontal)      */
/* ============================================================ */

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -0.5rem;
    padding: 0 0.5rem;
}
@media (max-width: 768px) {
    .card .table { font-size: 0.9rem; }
}

/* ============================================================ */
/*                       VARIANTES BTN MANQUANTES                 */
/* ============================================================ */

.btn--warning-soft {
    background: var(--color-warning-bg, #fffbeb);
    border-color: #fde68a;
    color: #92400e;
}
.btn--warning-soft:hover {
    background: #fde68a;
    color: #78350f;
}

/* ============================================================ */
/*                       FORM ACTIONS STANDARD                    */
/* ============================================================ */

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
    align-items: center;
}
.form-actions--right {
    justify-content: flex-end;
}

/* Page-header : actions à droite ont du gap */
.page-header > div:last-child:not(:only-child) {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

/* ============================================================ */
/*                       FOCUS VISIBLE GLOBAL (a11y)              */
/* ============================================================ */

*:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm, 4px);
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline-offset: 0;
}

/* ============================================================ */
/*                       EMPTY STATE                              */
/* ============================================================ */

.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--color-muted);
}
.empty-state svg.lucide {
    width: 40px;
    height: 40px;
    opacity: 0.4;
    margin-bottom: 0.75rem;
}

/* ============================================================ */
/*                       MOBILE & A11Y                            */
/* ============================================================ */

@media (hover: none) and (pointer: coarse) {
    .btn,
    .btn-icon,
    .pagination-page,
    .sidebar-item {
        min-height: 40px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================================ */
/*                       PRINT                                    */
/* ============================================================ */

@media print {
    .app-sidebar, .topbar, .footer, .filters, .pagination, .btn, .topbar-toggle { display: none !important; }
    .container { max-width: 100%; padding: 0; }
    .card { box-shadow: none; border: none; padding: 0; }
    dialog { display: none !important; }
}


/* ===== Refonte 16/07 — accessibilité & anti double-soumission ===== */
.skip-link {
    position: absolute; left: -9999px; top: 0; z-index: 2000;
    background: var(--color-primary); color: #fff; padding: 0.6rem 1rem;
    border-radius: 0 0 8px 0; text-decoration: none; font-weight: 600;
}
.skip-link:focus { left: 0; }
button.is-loading { opacity: 0.6; cursor: progress; }

/* ── Couverture de la créance (composant partagé mobile + desktop) ───────────
   Barre : échéancé (vert, ferme) / promis (ambre) / à relancer (rouge, non couvert).
   Alimenté par app/services/couverture.py. Aucune couleur en dur (rule #6). */
.couv { margin: .5rem 0; }
.couv__title { font-size: var(--text-sm); color: var(--color-muted); margin-bottom: 6px; }
.couv__title b { color: var(--color-text); }
.couv__bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--color-border); }
.couv__seg { display: block; min-width: 3px; }
.couv__seg--ech { background: var(--color-success); }
.couv__seg--prom { background: var(--color-warning); }
.couv__seg--non { background: var(--color-danger); }
.couv__seg.is-retard { box-shadow: inset 0 0 0 2px var(--color-danger); }
.couv__legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: var(--text-xs); line-height: 1.4; }
.couv__item { display: inline-flex; align-items: center; gap: 6px; color: var(--color-muted); }
.couv__item b { color: var(--color-text); font-weight: 700; }
.couv__dot { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.couv__dot--ech { background: var(--color-success); }
.couv__dot--prom { background: var(--color-warning); }
.couv__dot--non { background: var(--color-danger); }
.couv__flag { color: var(--color-danger-dark); font-weight: 700; }
.couv__item--alert b { color: var(--color-danger-dark); }

/* === Avatar (photo de profil) ============================================ */
.avatar {
    border-radius: 50%;
    object-fit: cover;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    vertical-align: middle;
    background: var(--color-surface-alt);
}
.avatar--initials {
    background: var(--color-primary-soft);
    color: var(--color-primary);
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    border: 1px solid var(--color-border);
    user-select: none;
}
.topbar-user__avatar {
    display: inline-flex;
    text-decoration: none;
    border-radius: 50%;
    box-shadow: 0 0 0 2px var(--color-border);
}
.topbar-user__avatar:hover { box-shadow: 0 0 0 2px var(--color-primary); }
