/* ═══════════════════════════════════════════════════
   DV-TEMPS – Style global (Glass Neon Sidebar layout)
   ═══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=DM+Sans:wght@400;500;600;700&display=swap');

:root {
    /* #pat21042026 — Light mode moins éclatant (off-white doux, moins de blanc pur) */
    --bg-page: #eceef3;
    --bg-surface: #f6f6f9;
    --bg-surface-solid: #f6f6f9;
    --bg-card: #f6f6f9;
    --bg-hover: #e8ebf1;
    --bg-active: #dde0e8;
    --text-primary: #1a1c2a;
    --text-secondary: #5b6274;
    --text-tertiary: #8a90a2;
    --border-color: #d9dde5;
    --border-strong: #c0c5d0;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.06);
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-light: rgba(99, 102, 241, 0.08);
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.08);
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.08);
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.08);
    --info: #06b6d4;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Legacy aliases (backward compat) */
    --primary: var(--accent);
    --primary-dark: var(--accent-hover);
    --primary-light: #a5b4fc;
    --primary-glow: var(--accent-light);
    --gold: var(--accent);
    --gold-light: #a5b4fc;
    --gold-dark: var(--accent-hover);
    --bg: var(--bg-page);
    --bg-main: var(--bg-page);
    --card-bg: var(--bg-card);
    --bg-dark: #1e1b4b;
    --text-dark: var(--text-primary);
    --text-light: #f1f5f9;
    --text-muted: var(--text-secondary);
    --border: var(--border-color);
    --border-gold: rgba(99,102,241,.12);
    --radius: var(--radius-lg);

    --font-body: 'DM Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: 'DM Sans', 'Inter', sans-serif;

    /* Glass Neon */
    --neon-primary: #6366f1;
    --neon-pink: #ec4899;
    --neon-cyan: #22d3ee;
    --neon-green: #34d399;
    --neon-orange: #fb923c;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(99, 102, 241, 0.12);
    --glass-hover: rgba(99, 102, 241, 0.06);
    --sidebar-bg: rgba(255, 255, 255, 0.92);
    --sidebar-text: rgba(15, 23, 42, 0.55);
    --sidebar-text-active: #0f172a;
    --sidebar-width-collapsed: 72px;
    --sidebar-width-expanded: 260px;
    --topbar-height: 60px;
}

[data-theme="dark"] {
    /* #pat21042026 — Dark mode palette "Glass Neon A2" (bleu nuit indigo, plus chaleureux) */
    --bg-page: #0a0a1e;
    --bg-surface: #12142c;
    --bg-surface-solid: #12142c;
    --bg-card: #141634;
    --bg-hover: #1e2145;
    --bg-active: #282c5a;
    --text-primary: #e0e3f5;
    --text-secondary: #9aa0bf;
    --text-tertiary: #6e7396;
    --border-color: rgba(99, 102, 241, 0.14);
    --border-strong: rgba(99, 102, 241, 0.26);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.35);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.4);
    --shadow-xl: 0 20px 25px rgba(0,0,0,0.45);
    --accent: #818cf8;
    --accent-hover: #6366f1;
    --accent-light: rgba(129, 140, 248, 0.12);
    --success-light: rgba(16, 185, 129, 0.12);
    --warning-light: rgba(245, 158, 11, 0.12);
    --danger-light: rgba(239, 68, 68, 0.12);

    /* Glass Neon dark — sidebar plus contrastee */
    --glass-bg: rgba(15, 15, 35, 0.6);
    --glass-border: rgba(99, 102, 241, 0.15);
    --glass-hover: rgba(99, 102, 241, 0.08);
    --sidebar-bg: rgba(22, 24, 50, 0.95);
    --sidebar-text: rgba(255, 255, 255, 0.55);
    --sidebar-text-active: #ffffff;
}

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

html {
    height: 100%;
}

body {
    font-family: var(--font-body);
    font-size: 13px;
    line-height: 1.4;
    color: var(--text-primary);
    background: var(--bg-page);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* #pat09062026 — Patrick : suppression totale sidebar + topbar.
       Plus aucune réservation d'espace (avant : margin-left 260px sidebar + padding-top 60px topbar).
       Tout le décalage des pages bureau qui oubliaient .win-iframe disparaît du même coup. */
    margin: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-left: 0;
    min-height: 100%;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
input, select, textarea { font: inherit; }

/* ── Main Content ── */
.main-content {
    /* Plus besoin de margin-top car body a padding-top: 44px */
    margin-top: 0;
}

/* ── Page Header ── */
.page-header {
    padding: 12px 24px 10px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-surface);
    flex-shrink: 0;
}

.page-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.page-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.page-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 1px;
}

.page-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-tertiary);
    margin-bottom: 4px;
}

.page-breadcrumb a {
    color: var(--text-secondary);
    text-decoration: none;
}

.page-breadcrumb a:hover {
    color: var(--accent);
}

.page-breadcrumb span {
    color: var(--text-tertiary);
}

.page-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ── Page Body ── */
.page-body {
    flex: 1;
    padding: 12px 24px;
    overflow-y: auto;
    min-height: 0;
}

/* ── Legacy topbar (still needed for breadcrumb in some pages) ── */
.topbar {
    /* Now handled by dock.css, but keep compat */
    display: none;
}

/* Legacy breadcrumb compat */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}
.breadcrumb a { color: var(--accent); }
.breadcrumb a:hover { text-decoration: underline; }

/* ── Cards ── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

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

.card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: 14px 16px;
}

.card-footer {
    padding: 10px 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Legacy card-lux */
.card-lux {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.card-lux-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}
.card-lux-title { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.card-lux-action { font-size: 12px; color: var(--accent); font-weight: 600; cursor: pointer; }
.card-lux-action:hover { color: var(--accent-hover); }

/* ── Grid layout ── */
.grid {
    display: grid;
    gap: 12px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ── Tables ── */
.table-wrapper {
    overflow: auto;
    max-height: calc(100vh - 220px);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

body.win-iframe .table-wrapper {
    max-height: calc(100vh - 150px);
}

/* #pat27042026 — Entête de tableau FIGÉE en haut au scroll
   S'applique à toutes les tables de listing du projet (data-table + classes spécifiques).
   Pour désactiver sur un tableau particulier : ajouter la classe `.no-sticky` au <table>. */
/* Sticky headers neutres (tableaux non-liste : dashboard, explorer, inbox...) */
.data-table thead th,
.ffr-table thead th,
.cl-table thead th,
.dash-inv-table thead th,
.explorer-table thead th,
.inbox-tbl thead th,
.kpi-compare-table thead th,
.linked-table thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bg-card, #fff);
    box-shadow: 0 1px 0 var(--border-color, #e5e7eb), 0 2px 4px rgba(0,0,0,.04);
}
[data-theme="dark"] .data-table thead th,
[data-theme="dark"] .ffr-table thead th,
[data-theme="dark"] .cl-table thead th,
[data-theme="dark"] .dash-inv-table thead th,
[data-theme="dark"] .explorer-table thead th,
[data-theme="dark"] .inbox-tbl thead th,
[data-theme="dark"] .kpi-compare-table thead th,
[data-theme="dark"] .linked-table thead th { background: var(--bg-card, #1f2937); }

/* #pat23052026 — Headers colorés primary + séparateurs (listes admin) */
.lic-table thead th,
.hist-table thead th,
.mg-tbl thead th,
.simu-table thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--primary, #6366f1) !important;
    color: #fff !important;
    box-shadow: none !important;
    border-bottom: 3px solid rgba(0,0,0,.12);
    border-right: 1px solid rgba(255,255,255,.18);
    font-size: .67rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    white-space: nowrap;
}
.lic-table thead th:last-child,
.hist-table thead th:last-child,
.mg-tbl thead th:last-child,
.simu-table thead th:last-child { border-right: none; }
.lic-table tbody td,
.hist-table tbody td,
.mg-tbl tbody td,
.simu-table tbody td { border-right: 1px solid var(--border); }
.lic-table tbody td:last-child,
.hist-table tbody td:last-child,
.mg-tbl tbody td:last-child,
.simu-table tbody td:last-child { border-right: none; }
/* Opt-out : désactive le sticky pour un tableau particulier */
.no-sticky thead th { position: static !important; box-shadow: none !important; }

.table-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: visible;
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

thead th {
    background: var(--bg-hover);
    padding: 6px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1;
}

/* #pat19052026 — En-têtes visibles pendant le scroll sur toutes les listes.
   Les pages historiques utilisent des classes variées ou des tableaux sans classe :
   cette règle complète les cas spécifiques ci-dessus sans toucher à la BDD. */
.table-wrapper,
.modal-list,
.lignes-scroll,
.win-list,
.table-scroll {
    overflow: auto;
}

:where(.table-wrapper, .modal-list, .lignes-scroll, .table-scroll, .tva-card, .table-card, .admin-content) table:not(.no-sticky) thead th {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--bg-card, var(--card-bg, #fff));
    box-shadow: 0 1px 0 var(--border-color, var(--border, #e5e7eb)), 0 2px 4px rgba(0,0,0,.05);
}

[data-theme="dark"] :where(.table-wrapper, .modal-list, .lignes-scroll, .table-scroll, .tva-card, .table-card, .admin-content) table:not(.no-sticky) thead th {
    background: var(--bg-card, var(--card-bg, #1f2937));
}

/* ═══════════════════════════════════════════════════════════════════════
   #pat19052026 — Pages de saisie SANS SCROLL GLOBAL
   ─────────────────────────────────────────────────────────────────────────
   Appliquer la classe `.form-fit-screen` au <body> d'une page de saisie pour:
     1. supprimer le scroll de la fenêtre (le viewport est figé à 100vh)
     2. ne faire scroller QUE le contenu interne du formulaire
     3. compacter les espacements (gain d'environ 30% de place verticale)
   Combiné avec un système d'onglets, ça permet à n'importe quel formulaire
   de tenir sur la hauteur écran, indépendamment de la résolution.
   ═══════════════════════════════════════════════════════════════════════ */
html:has(body.form-fit-screen),
body.form-fit-screen {
    height: 100vh;
    overflow: hidden;
}
/* #pat23052026 — Mode iframe (?win=1) : le body global a margin-left:260px (sidebar) +
   padding-top:60px (topbar). En mode iframe il n'y a NI sidebar NI topbar → ces marges
   décalent toutes les fiches/listes vers la droite et le bas. On les annule.
   La règle s'applique automatiquement à tout fichier qui détecte $winMode et ajoute la
   classe "win-iframe" ou "form-fit-screen" au body. */
body.win-iframe,
body.form-fit-screen.win-iframe {
    margin-left: 0;
    padding-top: 0;
    padding-bottom: 0;
}
body.form-fit-screen .main-content {
    height: 100vh;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}
body.form-fit-screen .admin-content {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
body.form-fit-screen .admin-content > form,
body.form-fit-screen .admin-content > .form-fit-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
}
/* Si la page utilise un système d'onglets : la barre d'onglets reste épinglée
   et c'est le tab-pane actif qui scrolle quand son contenu déborde. */
body.form-fit-screen .form-tabs-bar {
    position: sticky;
    top: 0;
    z-index: 35;
}
/* Compactage typo (gain ~30% de hauteur) */
body.form-fit-screen .form-section-title { margin-top: 10px; font-size: 0.85rem; }
body.form-fit-screen .form-group { margin-bottom: 7px; }
body.form-fit-screen label,
body.form-fit-screen .form-label { font-size: 11.5px; margin-bottom: 2px; line-height: 1.3; }
body.form-fit-screen input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
body.form-fit-screen select,
body.form-fit-screen textarea {
    font-size: 12.5px;
    padding: 5px 9px;
}
body.form-fit-screen .btn { padding: 5px 12px; font-size: 0.8rem; }
body.form-fit-screen h1 { font-size: 1rem; margin: 0; }
body.form-fit-screen h2 { font-size: 0.92rem; }
body.form-fit-screen h3 { font-size: 0.85rem; }
/* La rangée de boutons d'action en bas reste collée au bas du conteneur scrollable */
body.form-fit-screen .form-actions-bottom,
body.form-fit-screen .btn-save-bottom-wrap {
    position: sticky;
    bottom: 0;
    background: var(--bg-app, var(--card-bg));
    padding: 8px 0;
    border-top: 1px solid var(--border, var(--border-color, #e5e7eb));
    z-index: 10;
}

tbody td {
    padding: 5px 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

tbody tr:hover {
    background: var(--bg-hover);
}

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

/* Legacy data-table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.data-table thead th {
    background: var(--bg-hover);
    padding: 8px 10px;
    text-align: left;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}
.data-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background .1s;
}
.data-table tbody tr:hover { background: var(--accent-light); }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table td { padding: 6px 10px; vertical-align: middle; }

.ref-gold { font-weight: 600; color: var(--accent); }
.amount-lux {
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.table-actions { display: flex; align-items: center; justify-content: center; gap: 6px; }
.btn-icon {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    transition: all .15s;
    padding: 6px;
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-edit { color: var(--info); }
.btn-edit:hover { background: rgba(6,182,212,.08); }
.btn-delete { color: var(--danger); }
.btn-delete:hover { background: rgba(239,68,68,.08); }

/* ── Inputs ── */
input[type="text"],
input[type="number"],
input[type="date"],
input[type="password"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 5px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-surface-solid);
    color: var(--text-primary);
    font-size: 12px;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

input:disabled {
    background: var(--bg-hover);
    color: var(--text-secondary);
    cursor: not-allowed;
}

/* Legacy form-control */
.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-surface-solid);
    color: var(--text-primary);
    font-size: 13px;
    transition: border-color .15s, box-shadow .15s;
    outline: none;
    font-family: var(--font-body);
}
.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}
.form-control:read-only { background: var(--bg-hover); color: var(--text-secondary); }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.12s ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 1px 2px rgba(99,102,241,0.3);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 2px 4px rgba(99,102,241,0.4);
}

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

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

.btn-danger:hover {
    background: #dc2626;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    background: var(--bg-surface);
    color: var(--accent);
    border: 1px solid var(--border-color);
    transition: all .15s;
}
.btn-sm:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* Legacy gold buttons */
.btn-gold {
    background: linear-gradient(135deg, #6366f1, #06b6d4);
    color: #fff;
    border: none;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 700;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all .2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 12px rgba(99,102,241,.25);
}
.btn-gold:hover {
    box-shadow: 0 4px 20px rgba(99,102,241,.35);
    transform: translateY(-1px);
}
.btn-outline-gold {
    background: transparent;
    color: var(--accent);
    border: 1px solid rgba(99,102,241,.25);
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all .15s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.btn-outline-gold:hover {
    background: var(--accent-light);
    border-color: var(--accent);
}

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger  { background: var(--danger-light); color: var(--danger); }
.badge-info    { background: var(--accent-light); color: var(--accent); }
.badge-admin   { background: var(--accent-light); color: var(--accent); }

.badge-pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
}

/* Tags (statuts factures/devis) */
.tag-lux {
    display: inline-flex;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.tag-lux.paid    { background: #f0fdf4; color: #16a34a; border: 1px solid #dcfce7; }
.tag-lux.pending { background: #eef2ff; color: #6366f1; border: 1px solid #e0e7ff; }
.tag-lux.overdue { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.tag-lux.draft   { background: #f8fafc; color: #64748b; border: 1px solid #e2e8f0; }
[data-theme="dark"] .tag-lux.paid    { background: rgba(34,197,94,.08); color: #34d399; border-color: rgba(34,197,94,.15); }
[data-theme="dark"] .tag-lux.pending { background: rgba(99,102,241,.08); color: #a5b4fc; border-color: rgba(99,102,241,.15); }
[data-theme="dark"] .tag-lux.overdue { background: rgba(239,68,68,.08); color: #f87171; border-color: rgba(239,68,68,.15); }
[data-theme="dark"] .tag-lux.draft   { background: rgba(255,255,255,.04); color: #94a3b8; border-color: rgba(255,255,255,.08); }

.check-yes { color: var(--success); font-weight: 700; }

/* ── Stat Cards ── */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 12px 14px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s, transform 0.2s;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.stat-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.5px;
}

.stat-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.stat-icon.indigo { background: var(--accent-light); color: var(--accent); }
.stat-icon.green  { background: var(--success-light); color: var(--success); }
.stat-icon.amber  { background: var(--warning-light); color: var(--warning); }
.stat-icon.red    { background: var(--danger-light); color: var(--danger); }

/* ── Forms ── */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.form-group .required { color: var(--danger); }

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px !important;
    font-weight: 500 !important;
    color: var(--text-primary) !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
    width: 16px; height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}
.checkbox-label-large { font-size: 14px !important; font-weight: 600 !important; }

.form-grid { display: grid; gap: 16px; }
.form-grid-1 { grid-template-columns: 1fr; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 768px) {
    .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
}

/* ── Tabs ── */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-color);
    padding: 0 20px;
}

.tab {
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: all 0.12s;
    cursor: pointer;
}

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

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

.tab-content {
    display: none;
    padding: 16px 20px;
}

.tab-content.active {
    display: block;
}

/* ── Alerts / Flash ── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 16px;
}
.alert-danger {
    background: var(--danger-light);
    border: 1px solid rgba(239,68,68,.2);
    color: #b91c1c;
}
.alert-success {
    background: var(--success-light);
    border: 1px solid rgba(16,185,129,.2);
    color: #15803d;
}
.alert-warning {
    background: var(--warning-light);
    border: 1px solid rgba(245,158,11,.2);
    color: #92400e;
}
[data-theme="dark"] .alert-danger  { color: #f87171; }
[data-theme="dark"] .alert-success { color: #34d399; }
[data-theme="dark"] .alert-warning { color: #fbbf24; }

.flash {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin: 16px 24px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.flash-success {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid rgba(16,185,129,0.2);
}
.flash-error {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid rgba(239,68,68,0.2);
}

/* ── SelectSearch (autocomplete AJAX) — refondu #pat19052026 ── */
.ss-wrap { position: relative; }
.ss-field {
    position: relative;
    display: flex;
    align-items: center;
}
.ss-field::before {
    content: '';
    position: absolute;
    left: 11px; top: 50%;
    width: 14px; height: 14px;
    transform: translateY(-50%);
    background: currentColor;
    color: var(--text-secondary);
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>") no-repeat center / contain;
            mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>") no-repeat center / contain;
    pointer-events: none;
    opacity: .55;
}
.ss-text {
    width: 100%;
    padding: 9px 30px 9px 34px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-input, var(--bg-surface-solid));
    color: var(--text-primary);
    font-size: .875rem;
    transition: border-color .15s, box-shadow .15s;
    font-family: var(--font-body);
}
.ss-text:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.ss-text::placeholder { color: var(--text-muted, var(--text-secondary)); opacity: .7; }
.ss-clear {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    background: var(--bg-hover, transparent);
    border: none; cursor: pointer;
    color: var(--text-secondary); font-size: 13px;
    width: 22px; height: 22px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: .12s;
}
.ss-clear:hover { background: var(--danger-light, rgba(239,68,68,.12)); color: var(--danger, #ef4444); }
.ss-dropdown {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0;
    z-index: 600;
    background: var(--bg-card, var(--bg-surface-solid));
    border: 1px solid var(--border-color);
    border-radius: 8px;
    max-height: 280px; overflow-y: auto;
    box-shadow: 0 12px 32px rgba(15, 23, 42, .15), 0 0 0 1px rgba(255,255,255,.04) inset;
    display: none;
    animation: ss-slide .12s ease-out;
}
@keyframes ss-slide { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
[data-theme="dark"] .ss-dropdown {
    background: var(--bg-card, #1a1f2e);
    box-shadow: 0 12px 32px rgba(0, 0, 0, .5);
}
.ss-item {
    padding: 9px 14px; cursor: pointer;
    font-size: .85rem; color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    transition: background .08s;
    display: flex; align-items: center; gap: 8px;
}
.ss-item:last-child { border-bottom: none; }
.ss-item:hover {
    background: var(--bg-hover, rgba(0,0,0,.04));
}
.ss-item.ss-active {
    background: var(--accent-light, rgba(59,130,246,.15));
    color: var(--accent, #1d4ed8);
    font-weight: 500;
}
[data-theme="dark"] .ss-item.ss-active {
    background: rgba(59, 130, 246, .22);
    color: #dbeafe;
}
.ss-item mark {
    background: var(--accent-light, rgba(59,130,246,.25));
    color: inherit;
    padding: 0 1px;
    border-radius: 2px;
    font-weight: 600;
}
.ss-empty { padding: 18px 14px; font-size: .85rem; color: var(--text-secondary); font-style: italic; text-align: center; }

/* ── Text helpers ── */
.text-accent  { color: var(--accent) !important; font-weight: 600; }
.text-success { color: var(--success) !important; font-weight: 600; }
.text-warning { color: var(--warning) !important; font-weight: 600; }
.text-danger  { color: var(--danger)  !important; font-weight: 600; }
.text-muted   { color: var(--text-secondary) !important; }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-debit   { color: var(--danger); }
.text-credit  { color: var(--success); }
.text-sm      { font-size: 12px; }
.font-mono    { font-family: "SF Mono", "Fira Code", "Consolas", monospace; }
.gold-text    { color: var(--accent); font-weight: 700; }

/* ── Hero banner ── */
.hero-banner {
    background: linear-gradient(135deg, #1e1b4b, #312e81, #1e1b4b);
    border-radius: var(--radius-lg);
    padding: 24px 28px;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}
.hero-banner::before {
    content: '';
    position: absolute;
    top: -60px; right: -60px;
    width: 300px; height: 300px;
    background: radial-gradient(circle, rgba(6,182,212,.12), transparent 70%);
}
.hero-banner h1 {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 700;
    color: #fff;
    position: relative;
    z-index: 1;
}

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}
.empty-state svg {
    width: 48px;
    height: 48px;
    color: var(--text-tertiary);
    margin-bottom: 16px;
}
.empty-state h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.empty-state p {
    font-size: 13px;
}

/* ── Theme toggle icons ── */
.icon-moon { display: none; }
.icon-sun  { display: block; }
[data-theme="dark"] .icon-moon { display: block; }
[data-theme="dark"] .icon-sun  { display: none; }

/* ── Clock ── */
.clock {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-hover);
    padding: 6px 12px;
    border-radius: 20px;
    font-variant-numeric: tabular-nums;
    border: 1px solid var(--border-color);
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-strong);
}

/* ── Animations ── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.25s ease-out;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .main-content {
        margin-left: 0 !important;
    }
    .page-header,
    .page-body {
        padding-left: 16px;
        padding-right: 16px;
    }
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
}

.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-secondary);
    cursor: pointer;
}

/* ───────────────────────────────────────────────────────────────────────────
   #pat09062026 — Tri générique par clic sur l'entête de colonne
   Auto-appliqué par le script de app.js. Le style cible la classe
   .sortable-th que le script ajoute aux <th> triables.
   ─────────────────────────────────────────────────────────────────────────── */
table .sortable-th {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 22px;
}
table .sortable-th:hover { background: rgba(74, 144, 226, .12); }
table .sortable-th::after {
    content: '⇅';
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    opacity: .35; font-size: .8rem;
}
table .sortable-th.sort-asc::after  { content: '▲'; opacity: 1; color: #4a90e2; }
table .sortable-th.sort-desc::after { content: '▼'; opacity: 1; color: #4a90e2; }
