/*
 * ╔══════════════════════════════════════════╗
 * ║  SEiiA — Trésorerie                      ║
 * ║  seiia.eu                                ║
 * ║  Dark Corporate / Teal Accents           ║
 * ║  Brand: #0097af · #002c30                ║
 * ╚══════════════════════════════════════════╝
 */

/* ============================================
   VARIABLES
   ============================================ */
:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a2235;
    --bg-card-hover: #1f2a40;
    --bg-sidebar: #002c30;
    --bg-input: #1e293b;

    --gold: #0097af;
    --gold-light: #00b8d4;
    --gold-dark: #007a8f;
    --gold-glow: rgba(0, 151, 175, 0.15);

    --blue: #3b82f6;
    --blue-dark: #1e40af;
    --green: #10b981;
    --green-dark: #047857;
    --red: #ef4444;
    --red-dark: #b91c1c;
    --orange: #f59e0b;
    --orange-light: rgba(245, 158, 11, 0.15);
    --purple: #8b5cf6;

    /* Alias sémantiques (compatibilité templates) */
    --success: var(--green);
    --danger: var(--red);
    --info: var(--blue);
    --warning: var(--orange);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-gold: var(--gold);

    --border: #1e293b;
    --border-gold: rgba(0, 151, 175, 0.3);

    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-gold: 0 0 20px rgba(0, 151, 175, 0.12);

    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Typography scale */
    --font-xs: 10px;
    --font-sm: 11px;
    --font-base: 13px;
    --font-md: 14px;
    --font-lg: 16px;
    --font-xl: 18px;
    --font-2xl: 24px;
    --font-3xl: 28px;
    --font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;

    /* Chart defaults (shared across all dashboards) */
    --chart-text: #94a3b8;
    --chart-grid: rgba(30, 41, 59, 0.5);
    --chart-font-size: 11px;
    --chart-legend-size: 11px;
}

/* ============================================
   LIGHT THEME
   ============================================ */
[data-theme="light"] {
    --bg-primary: #f1f5f9;
    --bg-secondary: #e2e8f0;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --bg-sidebar: #002c30;
    --bg-input: #f8fafc;

    --gold: #007a8f;
    --gold-light: #0097af;
    --gold-dark: #005f70;
    --gold-glow: rgba(0, 122, 143, 0.1);

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-gold: var(--gold);

    --border: #cbd5e1;
    --border-gold: rgba(0, 122, 143, 0.3);

    --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    --shadow-gold: 0 0 20px rgba(0, 122, 143, 0.08);

    --orange-light: rgba(245, 158, 11, 0.1);
}

/* Keep sidebar & top-bar dark in light mode */
[data-theme="light"] .sidebar,
[data-theme="light"] .top-bar {
    --bg-sidebar: #002c30;
    --border: #004050;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --gold: #0097af;
    --gold-light: #00b8d4;
    --gold-dark: #007a8f;
    --gold-glow: rgba(0, 151, 175, 0.15);
    --border-gold: rgba(0, 151, 175, 0.3);
}
[data-theme="light"] .top-bar {
    background: #002c30;
    border-bottom-color: #004050;
}
[data-theme="light"] .ws-dropdown {
    background: #0a2a2d;
    border-color: #004050;
}
/* Dropdown entreprise top-bar : doit utiliser les couleurs PAGE, pas top-bar */
[data-theme="light"] #tb-ent-dropdown {
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --bg-card: #ffffff;
    --bg-secondary: #f1f5f9;
    --border: #e2e8f0;
    --shadow: 0 4px 16px rgba(0,0,0,0.12);
    --gold-glow: rgba(0,151,175,0.1);
    --gold: #0097af;
}
[data-theme="light"] #tb-ent-dropdown a {
    color: #1e293b !important;
}
[data-theme="light"] #tb-ent-dropdown span {
    color: #1e293b;
}

[data-theme="light"] .data-table th {
    background: #e2e8f0;
    color: #007a8f;
    border-bottom-color: #007a8f;
}

[data-theme="light"] .login-page {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 50%, #cbd5e1 100%);
}

[data-theme="light"] .login-box {
    background: #ffffff;
    border-color: rgba(0, 122, 143, 0.3);
}

[data-theme="light"] .form-input,
[data-theme="light"] .form-select {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #0f172a;
}

[data-theme="light"] .matrix-table th {
    background: #e2e8f0;
    color: #007a8f;
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--gold); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--gold-light); }

/* ============================================
   LAYOUT
   ============================================ */
.app-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.app-body {
    display: flex;
    flex: 1;
    margin-top: 40px;
}

/* Top bar */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px 0 16px;
    z-index: 110;
}
.top-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.top-bar-left img {
    height: 22px;
    max-width: 100px;
    object-fit: contain;
}
.top-bar-left .top-bar-sep {
    width: 1px;
    height: 18px;
    background: var(--border);
}
.top-bar-left .top-bar-app {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.5px;
}
.top-bar-center {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.3px;
    font-family: 'JetBrains Mono', monospace;
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex-shrink: 1;
}
.top-bar-center .clock-sep {
    opacity: 0.4;
}
.top-bar-right {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.top-bar-right .tb-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    text-decoration: none;
    position: relative;
}
.top-bar-right .tb-btn:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-primary);
}
.top-bar-right .tb-sep {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 4px;
}
.top-bar-right .tb-user {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--gold-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    color: var(--bg-primary);
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}
.top-bar-right .tb-user:hover {
    border-color: var(--gold);
}

/* Sidebar */
.sidebar {
    width: 220px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 88px;
    height: calc(100vh - 88px);
    z-index: 105;
    transition: var(--transition);
}

/* Workspace selector (style Monday) */
.workspace-selector {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}
.ws-current {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}
.ws-current:hover {
    background: rgba(255,255,255,0.06);
}
.ws-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
    color: #fff;
    flex-shrink: 0;
}
.ws-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.ws-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ws-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.ws-chevron {
    color: var(--text-muted);
    font-size: 12px;
    flex-shrink: 0;
    transition: transform 0.2s;
}
.ws-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    z-index: 200;
    margin-top: 4px;
    padding: 6px;
    max-height: 280px;
    overflow-y: auto;
}
.ws-dropdown.open { display: block; }
.ws-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}
.ws-dropdown-item:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text-primary);
}
.ws-dropdown-item.active {
    background: rgba(212,168,67,0.1);
    color: var(--gold);
    font-weight: 600;
}
.ws-dropdown-item .ws-avatar-sm {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 11px;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-brand {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
    text-align: center;
}

.sidebar-brand h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 3px;
    text-transform: uppercase;
}

.sidebar-brand .subtitle {
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-top: 4px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
}

.nav-section {
    padding: 8px 20px 4px;
    font-size: 10px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.55); /* couleur fixe sur fond sidebar sombre */
    text-transform: uppercase;
    letter-spacing: 1.5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    transition: color 0.2s;
    margin-top: 4px;
}
.nav-section:hover { color: var(--gold-light); }
.nav-section .nav-chevron {
    font-size: 10px;
    transition: transform 0.25s ease;
    display: inline-block;
}
.nav-section.collapsed .nav-chevron { transform: rotate(-90deg); }
.nav-group {
    overflow: hidden;
    max-height: 600px;
    transition: max-height 0.3s ease, opacity 0.25s ease;
    opacity: 1;
}
.nav-group.collapsed {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 16px;
    color: var(--text-secondary);
    transition: var(--transition);
    border-left: 3px solid transparent;
    font-size: 12px;
}
.nav-item .icon { font-size: 14px; width: 20px; text-align: center; }

.nav-item:hover {
    background: var(--gold-glow);
    color: var(--gold-light);
    border-left-color: var(--gold);
}

.nav-item.active {
    background: var(--gold-glow);
    color: var(--gold);
    border-left-color: var(--gold);
    font-weight: 600;
}

.nav-item .icon { font-size: 18px; width: 24px; text-align: center; }

.nav-badge {
    margin-left: auto;
    background: var(--red);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

/* Main content */
.main-content {
    flex: 1;
    margin-left: 220px;
    padding: 32px;
    min-height: 100vh;
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    transition: var(--transition);
}

.card:hover {
    border-color: var(--border-gold);
    box-shadow: var(--shadow-gold);
}

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

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gold);
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-gold);
    border-color: var(--border-gold);
}

.kpi-card .kpi-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.kpi-card .kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.kpi-card .kpi-sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.kpi-card.green::before { background: var(--green); }
.kpi-card.red::before { background: var(--red); }
.kpi-card.blue::before { background: var(--blue); }
.kpi-card.orange::before { background: var(--orange); }
.kpi-card.purple::before { background: var(--purple); }

/* ============================================
   TABLES
   ============================================ */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    background: var(--bg-secondary);
    color: var(--gold);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 2px solid var(--gold-dark);
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    transition: var(--transition);
}

.data-table tr:hover td {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.data-table .row-orange td {
    background: var(--orange-light);
    border-left: 3px solid var(--orange);
}

.data-table .amount { text-align: right; font-family: 'JetBrains Mono', monospace; }
.data-table .amount.positive { color: var(--green); }
.data-table .amount.negative { color: var(--red); }

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-gold {
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    color: #ffffff;
}
.btn-gold:hover {
    background: linear-gradient(135deg, var(--gold-light), var(--gold));
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 151, 175, 0.3);
    color: #ffffff;
}

.btn-blue { background: var(--blue); color: white; }
.btn-blue:hover { background: #2563eb; }

.btn-green { background: var(--green); color: white; }
.btn-green:hover { background: #059669; }

.btn-red { background: var(--red); color: white; }
.btn-red:hover { background: #dc2626; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-gold);
    color: var(--gold);
}
.btn-outline:hover {
    background: var(--gold-glow);
    border-color: var(--gold);
    color: var(--gold-light);
}

.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ============================================
   FORMS
   ============================================ */
.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
}

.form-input, .form-select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    transition: var(--transition);
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-glow);
}

/* ============================================
   CONTROLE BANQUE
   ============================================ */
/* Contrôle Banque — tableau compact */
.ctrl-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.ctrl-table thead th {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    text-align: center;
    white-space: nowrap;
}
.ctrl-table thead th:first-child { text-align: left; }
.ctrl-table tbody td {
    padding: 8px 6px;
    border-bottom: 1px solid var(--border);
    text-align: center;
    vertical-align: middle;
}
.ctrl-table tbody tr:last-child td { border-bottom: none; }
.ctrl-table tbody tr:hover { background: rgba(148,163,184,0.04); }
.ctrl-bank-name { text-align: left !important; }
.ctrl-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}
.ctrl-compact {
    padding: 4px 6px !important;
    font-size: 12px !important;
    text-align: center;
    max-width: 130px;
}
.btn-extract-solde {
    background: none;
    border: 1px solid var(--gold);
    border-radius: 4px;
    color: var(--gold);
    font-size: 12px;
    padding: 2px 6px;
    cursor: pointer;
    line-height: 1;
    flex-shrink: 0;
}
.btn-extract-solde:hover { background: rgba(212,175,55,0.1); }

.status-ok { color: var(--green); font-weight: 700; }
.status-ecart { color: var(--red); font-weight: 700; }
.status-attente { color: var(--text-muted); font-style: italic; }

/* ============================================
   ALERTS / FLASH
   ============================================ */
.alert {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s ease-out;
}

.alert-success { background: rgba(16, 185, 129, 0.15); border: 1px solid var(--green-dark); color: var(--green); }
.alert-error { background: rgba(239, 68, 68, 0.15); border: 1px solid var(--red-dark); color: var(--red); }
.alert-warning { background: rgba(245, 158, 11, 0.15); border: 1px solid var(--orange); color: var(--orange); }
.alert-info { background: rgba(59, 130, 246, 0.15); border: 1px solid var(--blue-dark); color: var(--blue); }

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0a0e17 0%, #111827 50%, #0d1321 100%);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 40%, rgba(0, 151, 175, 0.07) 0%, transparent 50%),
                radial-gradient(circle at 70% 60%, rgba(0, 44, 48, 0.05) 0%, transparent 50%);
    animation: bgPulse 15s ease-in-out infinite alternate;
}

@keyframes bgPulse {
    from { transform: scale(1) rotate(0deg); }
    to { transform: scale(1.1) rotate(5deg); }
}

.login-box {
    background: var(--bg-card);
    border: 1px solid var(--border-gold);
    border-radius: 16px;
    padding: 48px;
    width: 420px;
    text-align: center;
    position: relative;
    box-shadow: var(--shadow), var(--shadow-gold);
}

.login-box h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 4px;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.login-box .login-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 32px;
}

.login-divider {
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    margin: 24px auto;
}

.btn-oauth {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 12px;
    text-decoration: none;
}

.btn-oauth:hover {
    border-color: var(--gold);
    background: var(--gold-glow);
    color: var(--gold-light);
    transform: translateY(-1px);
}

/* ============================================
   CHARTS AREA
   ============================================ */
.chart-container {
    position: relative;
    height: 300px;
    padding: 20px;
}

/* ============================================
   PAGINATION
   ============================================ */
.pagination {
    display: flex;
    gap: 4px;
    justify-content: center;
    margin-top: 24px;
}

.pagination a, .pagination span {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    transition: var(--transition);
}

.pagination a:hover { border-color: var(--gold); color: var(--gold); }
.pagination .active {
    background: var(--gold);
    color: var(--bg-primary);
    border-color: var(--gold);
    font-weight: 600;
}

/* ============================================
   MATRIX REPORT TABLE
   ============================================ */
.matrix-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.matrix-table th {
    background: var(--bg-secondary);
    color: var(--gold);
    padding: 8px 10px;
    font-weight: 600;
    font-size: 11px;
    text-align: right;
    border-bottom: 2px solid var(--gold-dark);
}

.matrix-table th:first-child { text-align: left; }

.matrix-table td {
    padding: 6px 10px;
    text-align: right;
    border-bottom: 1px solid var(--border);
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-secondary);
}

.matrix-table td:first-child {
    text-align: left;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    color: var(--text-primary);
}

.matrix-table tr:hover td { background: var(--bg-card-hover); }
.matrix-table .total-row td {
    font-weight: 700;
    color: var(--gold);
    border-top: 2px solid var(--gold-dark);
    background: var(--gold-glow);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .sidebar { width: 200px; }
    .main-content { margin-left: 200px; padding: 20px; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        position: fixed;
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .kpi-grid { grid-template-columns: 1fr; }
    .ctrl-table { font-size: 11px; }
    .ctrl-compact { max-width: 100px; font-size: 11px !important; }
    .top-bar { padding: 0 8px; }
    .top-bar-center { display: none; }
    .top-bar-left .top-bar-app { display: none; }
    .top-bar-left .top-bar-sep { display: none; }
    .top-bar-right .tb-sep { display: none; }
    .top-bar-right .tb-btn { width: 28px; height: 28px; font-size: 14px; }
}
@media (max-width: 1100px) {
    .top-bar-center { font-size: 11px; gap: 4px; }
    .top-bar-left .top-bar-app { display: none; }
    .top-bar-left .top-bar-sep:last-of-type { display: none; }
    .module-tab { padding: 10px 12px; font-size: 13px; gap: 5px; }
    .module-icon { font-size: 15px; }
}
@media (max-width: 900px) {
    .module-tab { padding: 8px 8px; font-size: 12px; gap: 3px; }
    .module-label { display: none; }
    .module-icon { font-size: 18px; }
    .module-tab { padding: 10px 14px; }
}

/* ============================================
   UTILITIES
   ============================================ */
.text-gold { color: var(--gold); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-blue { color: var(--blue); }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-mono { font-family: 'JetBrains Mono', monospace; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 16px; }
.hidden { display: none; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dark); }

/* ============================================
   NO-SIDEBAR LAYOUT (Odoo-style home)
   ============================================ */
.app-body.no-sidebar .sidebar.hidden {
    display: none !important;
}
.app-body.no-sidebar .main-content {
    margin-left: 0 !important;
}

/* ============================================
   SIDEBAR TOGGLE (hamburger)
   ============================================ */
.sidebar-toggle-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.sidebar-toggle-btn:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-primary);
}

/* Sidebar collapsed state */
.sidebar.sidebar-hidden {
    transform: translateX(-100%);
    pointer-events: none;
}

/* When sidebar is shifted (hidden mode), main content takes full width */
.main-content.sidebar-shifted {
    margin-left: 0 !important;
}

/* ── Bouton replier sidebar ── */
.sidebar-collapse-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s;
    opacity: 0.5;
}
.sidebar-collapse-btn:hover {
    opacity: 1;
    background: var(--gold);
    color: #000;
    border-color: var(--gold);
}

/* ── Bouton réouvrir sidebar ── */
.sidebar-expand-btn {
    position: fixed;
    top: 96px;
    left: 0;
    width: 24px;
    height: 48px;
    border-radius: 0 8px 8px 0;
    border: 1px solid var(--border);
    border-left: none;
    background: var(--bg-sidebar);
    color: var(--text-muted);
    font-size: 10px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 101;
    transition: all 0.2s;
}
.sidebar-expand-btn:hover {
    background: var(--gold);
    color: #000;
    width: 32px;
}
.sidebar-expand-btn.visible {
    display: flex;
}

/* Smooth transitions */
.sidebar {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.main-content {
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Overlay when sidebar is open on top of content */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 40px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ============================================
   MODULE BAR — Horizontal top navigation
   ============================================ */
.module-bar {
    position: fixed;
    top: 40px;
    left: 0;
    right: 0;
    height: 48px;
    background: linear-gradient(180deg, #001a1e 0%, #002c30 100%);
    border-bottom: 1px solid rgba(0, 151, 175, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 0 16px;
    z-index: 102;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
}
.module-bar::-webkit-scrollbar { display: none; }

/* Bouton toggle bandeau — fixé, toujours visible */
.module-bar-toggle {
    position: fixed;
    left: 50%;
    top: 82px;
    transform: translateX(-50%);
    background: rgba(0,44,48,0.9);
    border: 1px solid rgba(0,151,175,0.2);
    color: var(--text-muted);
    font-size: 8px;
    width: 32px;
    height: 12px;
    border-radius: 0 0 6px 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 112;
    opacity: 0.4;
    padding: 0;
}
.module-bar-toggle:hover { opacity: 1; color: #00c8ff; background: rgba(0,44,48,1); }

/* État réduit du bandeau */
.module-bar-collapsed {
    height: 0 !important;
    min-height: 0;
    padding: 0 !important;
    border-bottom: none !important;
    overflow: hidden;
}
/* Quand réduit, le toggle remonte */
.module-bar-collapsed ~ .module-bar-toggle { top: 40px; }

/* Ajuster app-body quand bandeau réduit */
.app-body.has-module-bar.modulebar-collapsed { top: 40px !important; }

.module-tab {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    color: #b0bec5;
    text-decoration: none;
    white-space: nowrap;
    border-radius: 6px 6px 0 0;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
}
.module-tab:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.05);
}
.module-tab.active {
    color: #00c8ff;
    border-bottom-color: #00c8ff;
    background: rgba(0, 200, 255, 0.08);
}
.module-icon {
    font-size: 18px;
    line-height: 1;
}
.module-label {
    letter-spacing: 0.3px;
}

/* Adjust app-body to account for module-bar */
.app-body.has-module-bar {
    margin-top: 88px; /* 40px top-bar + 48px module-bar */
}

/* Context sidebar adjustments */
.context-sidebar {
    top: 88px !important;
    height: calc(100vh - 88px) !important;
    width: 220px;
}

/* Module panel in sidebar */
.module-panel {
    display: none;
    padding: 4px 0;
}
.module-panel-title {
    padding: 12px 16px 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    margin-bottom: 4px;
}

/* Make nav items slightly more compact in context sidebar */
.context-sidebar .nav-item {
    padding: 8px 16px;
    font-size: 13px;
    gap: 10px;
}

/* Main content when sidebar shows with module bar */
.app-body.has-module-bar .main-content {
    margin-left: 220px;
}
.app-body.has-module-bar .main-content.sidebar-shifted {
    margin-left: 0 !important;
}

/* Light theme adjustments for module bar */
[data-theme="light"] .module-bar {
    background: linear-gradient(180deg, #001a1e 0%, #002c30 100%);
    border-bottom-color: rgba(0, 151, 175, 0.2);
}
[data-theme="light"] .module-tab {
    color: #c8d6e0;
}
[data-theme="light"] .module-tab:hover {
    color: #f1f5f9;
}
[data-theme="light"] .module-tab.active {
    color: #00c8ff;
}

/* ============================================
   UTILITY CLASSES — TYPOGRAPHY
   ============================================ */
.text-xs   { font-size: var(--font-xs)  !important; }  /* 10px */
.text-sm   { font-size: var(--font-sm)  !important; }  /* 11px */
.text-base { font-size: var(--font-base) !important; }  /* 13px */
.text-md   { font-size: var(--font-md)  !important; }  /* 14px */
.text-lg   { font-size: var(--font-lg)  !important; }  /* 16px */
.text-xl   { font-size: var(--font-xl)  !important; }  /* 18px */
.text-2xl  { font-size: var(--font-2xl) !important; }  /* 24px */
.text-3xl  { font-size: var(--font-3xl) !important; }  /* 28px */
.text-4xl  { font-size: 32px !important; }
.text-5xl  { font-size: 48px !important; }

.text-muted     { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-primary   { color: var(--text-primary) !important; }
.text-gold      { color: var(--gold) !important; }
.text-green     { color: var(--green) !important; }
.text-red       { color: var(--red) !important; }
.text-orange    { color: var(--orange) !important; }
.text-blue      { color: var(--blue) !important; }
.text-purple    { color: var(--purple) !important; }

.fw-400 { font-weight: 400 !important; }
.fw-500 { font-weight: 500 !important; }
.fw-600 { font-weight: 600 !important; }
.fw-700 { font-weight: 700 !important; }
.fw-800 { font-weight: 800 !important; }

.text-upper { text-transform: uppercase !important; }
.text-center { text-align: center !important; }

/* ============================================
   UTILITY CLASSES — DASHBOARD CARDS
   ============================================ */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.stat-card:hover {
    border-color: var(--border-gold);
    box-shadow: var(--shadow-gold);
}
.stat-value {
    font-size: var(--font-2xl);
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}
.stat-label {
    font-size: var(--font-sm);
    color: var(--text-muted);
    text-transform: uppercase;
    margin-top: 4px;
}
.stat-trend {
    font-size: var(--font-sm);
    margin-top: 8px;
}
.stat-trend.up   { color: var(--green); }
.stat-trend.down { color: var(--red); }

/* Dashboard page title */
.page-title {
    font-size: var(--font-2xl);
    font-weight: 700;
    color: var(--text-primary);
}
.page-subtitle {
    font-size: var(--font-base);
    color: var(--text-muted);
}

/* Chart container */
.chart-container {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.chart-container:hover {
    border-color: var(--border-gold);
}
.chart-title {
    font-size: var(--font-md);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}
.chart-canvas-wrap {
    position: relative;
    height: 280px;
}
