/* ===================================================================
   Vivacompta — Charte graphique « Aurora »
   Design premium : dégradés, glassmorphism, micro-animations
   =================================================================== */

:root {
    --sidebar-width: 268px;
    --primary: #6366f1;
    --primary-deep: #4f46e5;
    --primary-light: #a5b4fc;
    --accent: #8b5cf6;
    --accent-2: #06b6d4;
    --success: #10b981;
    --danger: #f43f5e;
    --warning: #f59e0b;
    --info: #3b82f6;

    --gradient-brand: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
    --gradient-cyan: linear-gradient(135deg, #06b6d4, #3b82f6);
    --gradient-green: linear-gradient(135deg, #10b981, #34d399);

    --bg-body: #eef1f8;
    --bg-card: #ffffff;
    --bg-card-glass: rgba(255, 255, 255, .72);
    --bg-sidebar: #11101d;
    --text-primary: #101225;
    --text-secondary: #6b7280;
    --border-color: #e4e7f0;

    --shadow: 0 2px 8px rgba(20, 22, 50, .06), 0 1px 2px rgba(20, 22, 50, .04);
    --shadow-lg: 0 18px 40px -12px rgba(20, 22, 50, .18);
    --shadow-glow: 0 8px 30px -6px rgba(99, 102, 241, .45);
    --radius: 18px;
    --radius-sm: 12px;
}

[data-theme="dark"] {
    --bg-body: #0b0e1a;
    --bg-card: #151929;
    --bg-card-glass: rgba(21, 25, 41, .72);
    --bg-sidebar: #0b0e1a;
    --text-primary: #eef0fa;
    --text-secondary: #93a0b8;
    --border-color: #252b40;
    --shadow: 0 2px 8px rgba(0, 0, 0, .35);
    --shadow-lg: 0 18px 40px -12px rgba(0, 0, 0, .6);
    --shadow-glow: 0 8px 30px -6px rgba(99, 102, 241, .35);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: 'Plus Jakarta Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    transition: background .4s ease, color .4s ease;
}

/* Fond « aurora » animé derrière tout le contenu */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(40% 35% at 12% 8%, rgba(99, 102, 241, .14), transparent 70%),
        radial-gradient(35% 30% at 88% 12%, rgba(217, 70, 239, .10), transparent 70%),
        radial-gradient(45% 40% at 75% 90%, rgba(6, 182, 212, .12), transparent 70%);
    animation: auroraDrift 18s ease-in-out infinite alternate;
    pointer-events: none;
}

[data-theme="dark"] body::before {
    background:
        radial-gradient(40% 35% at 12% 8%, rgba(99, 102, 241, .18), transparent 70%),
        radial-gradient(35% 30% at 88% 12%, rgba(217, 70, 239, .12), transparent 70%),
        radial-gradient(45% 40% at 75% 90%, rgba(6, 182, 212, .12), transparent 70%);
}

@keyframes auroraDrift {
    0%   { transform: translate3d(0, 0, 0) scale(1); }
    50%  { transform: translate3d(-2%, 2%, 0) scale(1.05); }
    100% { transform: translate3d(2%, -2%, 0) scale(1.02); }
}

/* Scrollbar personnalisée */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: linear-gradient(180deg, #6366f1, #8b5cf6); border-radius: 8px; border: 2px solid var(--bg-body); }
::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, #4f46e5, #7c3aed); }

::selection { background: rgba(99, 102, 241, .25); }

/* ===================== LOGIN ===================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(-45deg, #11101d, #312e81, #6d28d9, #1e1b4b);
    background-size: 400% 400%;
    animation: gradientShift 14s ease infinite;
    position: relative;
    overflow: hidden;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Blobs flottants */
.login-page::before,
.login-page::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(70px);
    opacity: .55;
    animation: blobFloat 12s ease-in-out infinite alternate;
}
.login-page::before { width: 380px; height: 380px; background: radial-gradient(circle, #8b5cf6, transparent 70%); top: -90px; left: -90px; }
.login-page::after { width: 460px; height: 460px; background: radial-gradient(circle, #06b6d4, transparent 70%); bottom: -130px; right: -110px; animation-delay: -6s; }

@keyframes blobFloat {
    0%   { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 35px) scale(1.18); }
}

.login-container { width: 100%; max-width: 440px; padding: 1rem; position: relative; z-index: 2; }

.login-card {
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: 24px;
    padding: 2.75rem;
    box-shadow: 0 30px 60px -15px rgba(0, 0, 0, .45);
    animation: cardEntrance .7s cubic-bezier(.22, 1, .36, 1) both;
}

[data-theme="dark"] .login-card { background: rgba(21, 25, 41, .9); border-color: rgba(255, 255, 255, .08); }

@keyframes cardEntrance {
    from { opacity: 0; transform: translateY(28px) scale(.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-logo {
    font-size: 3rem;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
    animation: logoPulse 3s ease-in-out infinite;
}

.login-logo-img {
    width: 230px;
    max-width: 80%;
    height: auto;
    object-fit: contain;
    animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(139, 92, 246, 0)); }
    50% { transform: scale(1.06); filter: drop-shadow(0 0 14px rgba(139, 92, 246, .5)); }
}

.login-card h1 { font-size: 1.6rem; font-weight: 800; margin: .5rem 0 0; letter-spacing: -.02em; }

/* ===================== LAYOUT ===================== */
.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #14122b 0%, #11101d 45%, #0d1326 100%);
    color: #e2e8f0;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: transform .35s cubic-bezier(.22, 1, .36, 1);
    border-right: 1px solid rgba(255, 255, 255, .06);
}

/* Liseré lumineux à droite de la sidebar */
.sidebar::after {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 1px;
    background: linear-gradient(180deg, transparent, rgba(139, 92, 246, .5), rgba(6, 182, 212, .4), transparent);
}

.sidebar-brand {
    padding: 1.4rem 1.5rem;
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: -.02em;
    display: flex;
    align-items: center;
    gap: .75rem;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}

.sidebar-brand i {
    font-size: 1.5rem;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: logoPulse 4s ease-in-out infinite;
}

.brand-logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
    filter: drop-shadow(0 0 10px rgba(139, 92, 246, .45));
    animation: logoPulse 4s ease-in-out infinite;
}

.sidebar-brand .brand-name {
    color: #fff;
    font-weight: 600;
}

.sidebar-brand .brand-name strong {
    font-weight: 800;
    background: linear-gradient(90deg, #8b5cf6, #06b6d4);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

.nav-section {
    padding: 1rem 1.5rem .35rem;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .14em;
    color: #595e78;
    font-weight: 700;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .8rem;
    margin: .15rem .75rem;
    padding: .62rem .9rem;
    color: #aab2cf;
    text-decoration: none;
    font-size: .9rem;
    font-weight: 500;
    border-radius: 10px;
    position: relative;
    transition: color .25s, background .25s, transform .25s, box-shadow .25s;
}

.nav-item i { width: 20px; text-align: center; transition: transform .25s; }

.nav-item:hover {
    background: rgba(255, 255, 255, .06);
    color: #fff;
    transform: translateX(4px);
}

.nav-item:hover i { transform: scale(1.2); }

.nav-item.active {
    background: linear-gradient(90deg, rgba(99, 102, 241, .28), rgba(139, 92, 246, .12));
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(139, 92, 246, .35), 0 4px 16px -4px rgba(99, 102, 241, .4);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: -0.75rem;
    top: 20%;
    bottom: 20%;
    width: 3px;
    border-radius: 3px;
    background: var(--gradient-brand);
    box-shadow: 0 0 10px rgba(139, 92, 246, .8);
}

.nav-item.active i {
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.main-content { flex: 1; margin-left: var(--sidebar-width); min-height: 100vh; }

/* Topbar glassmorphism */
/* Barre d'actions compacte et transparente (le titre de page est déjà dans le menu) */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .6rem 1.5rem 0;
    gap: 1rem;
}

.topbar-actions { display: flex; align-items: center; gap: .5rem; margin-left: auto; }

/* Sélecteur de période dans la topbar */
.topbar .topbar-period { gap: .35rem; min-width: 0; overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; }
.topbar .topbar-period::-webkit-scrollbar { display: none; }
.topbar .topbar-period .year-pill { padding: .25rem .85rem; font-size: .8rem; white-space: nowrap; }
.topbar .topbar-period .year-pill:hover { transform: none; }

.content-area { padding: .75rem 1.75rem 1.75rem; animation: pageIn .5s cubic-bezier(.22, 1, .36, 1) both; }

@keyframes pageIn {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===================== BOUTONS ===================== */
.btn { border-radius: 10px; font-weight: 600; transition: all .25s cubic-bezier(.22, 1, .36, 1); }

.btn-primary {
    background: var(--gradient-brand);
    border: none;
    box-shadow: 0 4px 14px -4px rgba(99, 102, 241, .5);
}
.btn-primary:hover, .btn-primary:focus {
    background: linear-gradient(135deg, #4f46e5, #7c3aed, #c026d3);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}
.btn-primary:active { transform: translateY(0); }

.btn-success { background: var(--gradient-green); border: none; }
.btn-success:hover { transform: translateY(-2px); box-shadow: 0 8px 24px -6px rgba(16, 185, 129, .5); }

.btn-outline-secondary, .btn-outline-primary, .btn-outline-success, .btn-outline-danger { border-width: 1.5px; }
.btn-outline-primary:hover, .btn-outline-success:hover, .btn-outline-danger:hover, .btn-outline-secondary:hover { transform: translateY(-2px); }

/* ===================== KPI CARDS ===================== */
.kpi-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.3rem;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
    transition: transform .3s cubic-bezier(.22, 1, .36, 1), box-shadow .3s, border-color .3s;
    animation: pageIn .55s cubic-bezier(.22, 1, .36, 1) both;
}

/* Stagger d'apparition */
.row > div:nth-child(1) .kpi-card { animation-delay: .02s; }
.row > div:nth-child(2) .kpi-card { animation-delay: .07s; }
.row > div:nth-child(3) .kpi-card { animation-delay: .12s; }
.row > div:nth-child(4) .kpi-card { animation-delay: .17s; }
.row > div:nth-child(5) .kpi-card { animation-delay: .22s; }
.row > div:nth-child(6) .kpi-card { animation-delay: .27s; }
.row > div:nth-child(7) .kpi-card { animation-delay: .32s; }
.row > div:nth-child(8) .kpi-card { animation-delay: .37s; }
.row > div:nth-child(9) .kpi-card { animation-delay: .42s; }
.row > div:nth-child(10) .kpi-card { animation-delay: .47s; }
.row > div:nth-child(11) .kpi-card { animation-delay: .52s; }
.row > div:nth-child(12) .kpi-card { animation-delay: .57s; }

/* Barre dégradée en haut, révélée au survol */
.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--gradient-brand);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform .35s cubic-bezier(.22, 1, .36, 1);
}

/* Reflet balayant au survol */
.kpi-card::after {
    content: '';
    position: absolute;
    top: 0; left: -80%;
    width: 50%; height: 100%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .25), transparent);
    transform: skewX(-20deg);
    transition: left .6s ease;
    pointer-events: none;
}

[data-theme="dark"] .kpi-card::after { background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .07), transparent); }

.kpi-card:hover {
    transform: translateY(-6px) scale(1.015);
    box-shadow: var(--shadow-lg);
    border-color: rgba(99, 102, 241, .35);
}
.kpi-card:hover::before { transform: scaleX(1); }
.kpi-card:hover::after { left: 130%; }

.kpi-icon {
    width: 50px; height: 50px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
    transition: transform .35s cubic-bezier(.34, 1.56, .64, 1);
}

.kpi-card:hover .kpi-icon { transform: scale(1.12) rotate(-6deg); }

.kpi-primary .kpi-icon { background: linear-gradient(135deg, rgba(99,102,241,.18), rgba(139,92,246,.18)); color: var(--primary); }
.kpi-success .kpi-icon { background: linear-gradient(135deg, rgba(16,185,129,.16), rgba(52,211,153,.16)); color: var(--success); }
.kpi-danger .kpi-icon { background: linear-gradient(135deg, rgba(244,63,94,.14), rgba(251,113,133,.14)); color: var(--danger); }
.kpi-warning .kpi-icon { background: linear-gradient(135deg, rgba(245,158,11,.16), rgba(252,211,77,.16)); color: var(--warning); }
.kpi-info .kpi-icon { background: linear-gradient(135deg, rgba(59,130,246,.16), rgba(6,182,212,.16)); color: var(--info); }
.kpi-secondary .kpi-icon { background: rgba(100,116,139,.14); color: #64748b; }
.kpi-dark .kpi-icon { background: rgba(30,41,59,.14); color: #475569; }
[data-theme="dark"] .kpi-dark .kpi-icon { background: rgba(148,163,184,.14); color: #94a3b8; }

.kpi-label { font-size: .78rem; color: var(--text-secondary); margin-bottom: .3rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 1.45rem; font-weight: 800; line-height: 1.15; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-evo { font-size: .7rem; margin-top: .4rem; }

/* ===================== CARDS & CHARTS ===================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: transform .3s cubic-bezier(.22, 1, .36, 1), box-shadow .3s, border-color .3s;
    animation: pageIn .55s cubic-bezier(.22, 1, .36, 1) both;
    overflow: hidden;
}

.card:hover { box-shadow: var(--shadow-lg); border-color: rgba(99, 102, 241, .25); }

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    font-weight: 700;
    padding: 1rem 1.35rem;
    letter-spacing: -.01em;
}

.card-header i { color: var(--primary); margin-right: .35rem; }

.chart-card .card-body { padding: 1.35rem; }

/* ===================== MATRIX CELLS ===================== */
.cell-green { background: rgba(16,185,129,.14) !important; color: #047857; }
.cell-orange { background: rgba(245,158,11,.14) !important; color: #b45309; }
.cell-red { background: rgba(244,63,94,.12) !important; color: #be123c; }
[data-theme="dark"] .cell-green { color: #6ee7b7; }
[data-theme="dark"] .cell-orange { color: #fcd34d; }
[data-theme="dark"] .cell-red { color: #fda4af; }

/* ===================== TABLES ===================== */
.table { color: var(--text-primary); margin-bottom: 0; }
.table thead th {
    background: linear-gradient(180deg, var(--bg-body), transparent);
    font-weight: 700;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-secondary);
    border-color: var(--border-color);
    white-space: nowrap;
}
.table td, .table th { border-color: var(--border-color); vertical-align: middle; }
.table tbody tr { transition: background .2s, transform .2s; }
.table-hover tbody tr:hover,
.table tbody tr:hover { background: rgba(99, 102, 241, .06); }
[data-theme="dark"] .table thead th { background: linear-gradient(180deg, #0b0e1a, transparent); }
[data-theme="dark"] .table tbody tr:hover { background: rgba(99, 102, 241, .1); }

.table a { color: var(--primary); font-weight: 600; text-decoration: none; }
.table a:hover { text-decoration: underline; }

.badge { border-radius: 999px; padding: .4em .75em; font-weight: 600; letter-spacing: .02em; }

/* ===================== IMPORT WIZARD ===================== */
.import-steps { display: flex; gap: 0; margin-bottom: 2rem; position: relative; }

.import-step { flex: 1; text-align: center; padding: 1rem; position: relative; }

/* Ligne de connexion entre étapes */
.import-step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: calc(1rem + 19px);
    left: calc(50% + 28px);
    right: calc(-50% + 28px);
    height: 2px;
    background: var(--border-color);
    z-index: 0;
}
.import-step.done:not(:last-child)::after { background: linear-gradient(90deg, #10b981, #34d399); }

.import-step .step-num {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    margin-bottom: .5rem;
    position: relative;
    z-index: 1;
    transition: all .35s cubic-bezier(.34, 1.56, .64, 1);
}

.import-step.active .step-num {
    background: var(--gradient-brand);
    border-color: transparent;
    color: #fff;
    transform: scale(1.15);
    box-shadow: 0 0 0 6px rgba(99, 102, 241, .15), var(--shadow-glow);
    animation: stepPulse 2s ease-in-out infinite;
}

@keyframes stepPulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(99, 102, 241, .15), var(--shadow-glow); }
    50% { box-shadow: 0 0 0 9px rgba(99, 102, 241, .08), var(--shadow-glow); }
}

.import-step.done .step-num { background: var(--gradient-green); border-color: transparent; color: #fff; }

.import-step .step-label { font-size: .85rem; color: var(--text-secondary); font-weight: 600; }
.import-step.active .step-label {
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
}

.upload-zone {
    border: 2px dashed rgba(99, 102, 241, .35);
    border-radius: var(--radius);
    padding: 3.5rem 3rem;
    text-align: center;
    cursor: pointer;
    transition: all .3s cubic-bezier(.22, 1, .36, 1);
    background: var(--bg-card);
    position: relative;
    overflow: hidden;
}

.upload-zone::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 0%, rgba(99, 102, 241, .08), transparent 60%);
    opacity: 0;
    transition: opacity .3s;
    pointer-events: none;
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary);
    transform: scale(1.01);
    box-shadow: var(--shadow-glow);
}
.upload-zone:hover::before, .upload-zone.dragover::before { opacity: 1; }

.upload-zone i {
    font-size: 3.2rem;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
    animation: floatY 3s ease-in-out infinite;
}

@keyframes floatY {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* ===================== ANALYSE IA ===================== */
.ai-hero {
    background: linear-gradient(-45deg, #4f46e5, #7c3aed, #c026d3, #6366f1);
    background-size: 300% 300%;
    animation: gradientShift 10s ease infinite;
    color: #fff;
    border-radius: var(--radius);
    padding: 2.25rem;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-glow);
}

.ai-hero::after {
    content: '';
    position: absolute;
    top: -60%; right: -10%;
    width: 320px; height: 320px;
    background: radial-gradient(circle, rgba(255, 255, 255, .18), transparent 70%);
    border-radius: 50%;
    animation: blobFloat 9s ease-in-out infinite alternate;
}

.ai-score {
    font-size: 4.2rem;
    font-weight: 800;
    line-height: 1;
    text-shadow: 0 0 30px rgba(255, 255, 255, .4);
    animation: scoreGlow 2.6s ease-in-out infinite;
}

@keyframes scoreGlow {
    0%, 100% { text-shadow: 0 0 24px rgba(255, 255, 255, .35); }
    50% { text-shadow: 0 0 44px rgba(255, 255, 255, .75); }
}

.ai-score-label { font-size: .9rem; opacity: .85; }

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

.swot-card {
    border-radius: var(--radius-sm);
    padding: 1.35rem;
    transition: transform .3s cubic-bezier(.22, 1, .36, 1), box-shadow .3s;
    animation: pageIn .55s both;
}
.swot-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.swot-grid .swot-card:nth-child(2) { animation-delay: .08s; }
.swot-grid .swot-card:nth-child(3) { animation-delay: .16s; }
.swot-grid .swot-card:nth-child(4) { animation-delay: .24s; }

.swot-forces { background: rgba(16,185,129,.1); border-left: 4px solid var(--success); }
.swot-faiblesses { background: rgba(244,63,94,.1); border-left: 4px solid var(--danger); }
.swot-opportunites { background: rgba(59,130,246,.1); border-left: 4px solid var(--info); }
.swot-risques { background: rgba(245,158,11,.1); border-left: 4px solid var(--warning); }

.anomaly-item {
    padding: .95rem 1.1rem;
    border-radius: var(--radius-sm);
    margin-bottom: .6rem;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    transition: transform .25s, box-shadow .25s, border-color .25s;
}
.anomaly-item:hover { transform: translateX(6px); border-color: rgba(99, 102, 241, .4); box-shadow: var(--shadow); }

/* ===================== GRAND LIVRE ===================== */
.account-tree { list-style: none; padding-left: 0; }
.account-tree .class-header {
    font-weight: 700;
    padding: .55rem .5rem;
    color: var(--primary);
    cursor: pointer;
    border-radius: 8px;
    transition: background .2s;
}
.account-tree .class-header:hover { background: rgba(99, 102, 241, .08); }
.account-tree .account-link {
    display: block;
    padding: .38rem .75rem;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 8px;
    font-size: .875rem;
    transition: all .2s;
    border-left: 2px solid transparent;
}
.account-tree .account-link:hover {
    background: rgba(99, 102, 241, .08);
    color: var(--primary);
    transform: translateX(4px);
    border-left-color: var(--primary-light);
}
.account-tree .account-link.active {
    background: linear-gradient(90deg, rgba(99, 102, 241, .16), transparent);
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 600;
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); box-shadow: none; }
    .sidebar.open { transform: translateX(0); box-shadow: 30px 0 60px rgba(0, 0, 0, .4); }
    .main-content { margin-left: 0; }
}

/* ===================== DATATABLES ===================== */
.dataTables_wrapper { padding: 1rem 1.25rem; }
.dataTables_wrapper .dataTables_filter { margin: 0; }
.dataTables_wrapper .dataTables_filter label { display: flex; align-items: center; gap: .5rem; margin: 0; font-weight: 600; color: var(--text-secondary); }
.dataTables_wrapper .dataTables_filter input {
    min-width: 230px;
    padding: .45rem .9rem;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-card);
    color: var(--text-primary);
    transition: border-color .25s, box-shadow .25s;
}
.dataTables_wrapper .dataTables_filter input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, .14);
}
.dataTables_wrapper .dataTables_length select {
    padding: .4rem .55rem;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-card);
    color: var(--text-primary);
}
.dataTables_wrapper .dataTables_info { color: var(--text-secondary); font-size: .875rem; }
.dataTables_wrapper table.dataTable thead th { cursor: pointer; position: relative; padding-right: 1.5rem; user-select: none; }
.dataTables_wrapper table.dataTable thead th.no-sort { cursor: default; padding-right: .75rem; }
.dataTables_wrapper table.dataTable thead .sorting:after,
.dataTables_wrapper table.dataTable thead .sorting_asc:after,
.dataTables_wrapper table.dataTable thead .sorting_desc:after {
    position: absolute;
    right: .5rem;
    top: 50%;
    transform: translateY(-50%);
    opacity: .4;
    font-size: .75rem;
    transition: opacity .2s;
}
.dataTables_wrapper table.dataTable thead .sorting:after { content: '⇅'; }
.dataTables_wrapper table.dataTable thead .sorting_asc:after { content: '↑'; opacity: 1; color: var(--primary); }
.dataTables_wrapper table.dataTable thead .sorting_desc:after { content: '↓'; opacity: 1; color: var(--primary); }
.dataTables_wrapper .dataTables_paginate .paginate_button { border-radius: 8px !important; transition: all .2s; }
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--gradient-brand) !important;
    border-color: transparent !important;
    color: #fff !important;
    box-shadow: 0 4px 12px -4px rgba(99, 102, 241, .5);
}
[data-theme="dark"] .dataTables_wrapper .dataTables_filter input,
[data-theme="dark"] .dataTables_wrapper .dataTables_length select { background: #151929; border-color: #252b40; color: #eef0fa; }
[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button { color: #93a0b8 !important; }

/* ===================== PROGRESS ===================== */
.progress { height: 10px; border-radius: 6px; background: var(--border-color); overflow: hidden; }
.progress-bar {
    background: var(--gradient-brand);
    background-size: 200% 100%;
    animation: progressFlow 2s linear infinite;
}

@keyframes progressFlow {
    0% { background-position: 0% 0; }
    100% { background-position: 200% 0; }
}

/* ===================== BADGES JOURNAUX ===================== */
.journal-achats { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #92400e; }
.journal-ventes { background: linear-gradient(135deg, #d1fae5, #a7f3d0); color: #065f46; }
.journal-banque { background: linear-gradient(135deg, #dbeafe, #bfdbfe); color: #1e40af; }
.journal-caisse { background: linear-gradient(135deg, #fce7f3, #fbcfe8); color: #9d174d; }
.journal-od { background: linear-gradient(135deg, #f3e8ff, #e9d5ff); color: #6b21a8; }

/* ===================== FORMULAIRES ===================== */
.form-control, .form-select {
    border-radius: 10px;
    border: 1.5px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    transition: border-color .25s, box-shadow .25s;
}
.form-control:focus, .form-select:focus {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, .14);
}

/* ===================== TOOLTIP DÉTAIL CELLULES ===================== */
.cell-detail { cursor: help; position: relative; }
.cell-detail:hover { outline: 2px solid var(--primary); outline-offset: -2px; border-radius: 4px; }

.cell-tooltip {
    position: fixed;
    z-index: 2000;
    min-width: 300px;
    max-width: 460px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(99, 102, 241, .15);
    overflow: hidden;
    pointer-events: none;
    animation: tooltipIn .18s cubic-bezier(.22, 1, .36, 1) both;
}

@keyframes tooltipIn {
    from { opacity: 0; transform: translateY(6px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.cell-tooltip-header {
    background: var(--gradient-brand);
    color: #fff;
    font-weight: 700;
    font-size: .82rem;
    padding: .55rem .85rem;
}

.cell-tooltip-table { width: 100%; font-size: .78rem; border-collapse: collapse; }
.cell-tooltip-table th, .cell-tooltip-table td { padding: .35rem .65rem; text-align: left; border-bottom: 1px solid var(--border-color); color: var(--text-primary); }
.cell-tooltip-table thead th { font-weight: 700; color: var(--text-secondary); text-transform: uppercase; font-size: .68rem; letter-spacing: .04em; }
.cell-tooltip-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell-tooltip-table tfoot th { border-bottom: none; font-weight: 800; color: var(--primary); }

/* ===================== IMPERSONATION ===================== */
.impersonation-banner {
    background: linear-gradient(90deg, #f59e0b, #f97316);
    color: #fff;
    font-weight: 600;
    font-size: .9rem;
    padding: .55rem 1.5rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    position: sticky;
    top: 0;
    z-index: 101;
    box-shadow: 0 4px 16px -4px rgba(245, 158, 11, .5);
}
.impersonation-banner i { font-size: 1.1rem; }

/* ===================== ALERTES ===================== */
.alert { border-radius: var(--radius-sm); border: none; box-shadow: var(--shadow); animation: pageIn .5s both; }

/* ===================== SAISIE D'ÉCRITURES ===================== */
.entry-grid td { vertical-align: top; }
.entry-grid .form-control-sm { font-size: .85rem; }
.entry-grid .inp-account-label { background: transparent; border-color: transparent; color: var(--text-muted); }

.entry-totals td {
    border-top: 2px solid var(--border-color);
    font-size: .95rem;
}

.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1500;
    max-height: 260px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    margin-top: 2px;
}

.autocomplete-item {
    padding: .45rem .7rem;
    font-size: .85rem;
    cursor: pointer;
    display: flex;
    gap: .5rem;
    align-items: baseline;
    border-bottom: 1px solid var(--border-color);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover, .autocomplete-item.active {
    background: rgba(99, 102, 241, .1);
    color: var(--primary);
}

.entry-lines-detail table { font-size: .8rem; background: rgba(99, 102, 241, .04); border-radius: 8px; }

/* ===================== ASSISTANT IA ===================== */
.ai-chat-toggle {
    border: none;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .9rem;
    flex-shrink: 0;
    transition: transform .15s, box-shadow .15s;
}
.ai-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 0 12px rgba(168, 85, 247, .5);
    color: #fff;
}
/* Neutralise l'effet « texte dégradé transparent » hérité de .sidebar-brand i */
.sidebar-brand .ai-chat-toggle i {
    background: none;
    -webkit-background-clip: initial;
    background-clip: initial;
    -webkit-text-fill-color: #fff;
    font-size: .95rem;
    animation: none;
}

.ai-chat-panel { width: 460px; max-width: 95vw; }
.ai-chat-messages {
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: .75rem;
}
.ai-msg {
    max-width: 92%;
    padding: .6rem .85rem;
    border-radius: 14px;
    font-size: .9rem;
    line-height: 1.45;
    word-wrap: break-word;
}
.ai-msg-user {
    align-self: flex-end;
    background: linear-gradient(135deg, #6366f1, #818cf8);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.ai-msg-model {
    align-self: flex-start;
    background: rgba(99, 102, 241, .08);
    border: 1px solid rgba(99, 102, 241, .15);
    border-bottom-left-radius: 4px;
}
.ai-msg-model ul { margin: .3rem 0; padding-left: 1.2rem; }
.ai-msg-model pre {
    background: rgba(0, 0, 0, .06);
    padding: .5rem;
    border-radius: 8px;
    font-size: .8rem;
    margin: .3rem 0;
    white-space: pre-wrap;
}
.ai-chat-input textarea { resize: none; }

/* Cartes des journaux (page unique liste + détail) */
.journal-cards-row {
    display: flex;
    flex-wrap: wrap;
    gap: .85rem;
}
.journal-cards-item {
    flex: 1 1 0;
    min-width: 165px; /* en dessous, les cartes passent à la ligne (mobile) */
}
.journal-card { transition: transform .12s, box-shadow .12s; }
.journal-card:hover { transform: translateY(-2px); }
.journal-card-active {
    border: 2px solid var(--primary, #6366f1);
    box-shadow: 0 4px 14px rgba(99, 102, 241, .2);
}

/* Numéros de compte cliquables (modal de détail) */
.acc-pop { text-decoration: none; }
.acc-pop code {
    cursor: pointer;
    border-bottom: 1px dashed currentColor;
    transition: opacity .15s;
}
.acc-pop:hover code { opacity: .75; }

/* Poignée de déplacement des lignes de saisie */
.entry-line .drag-handle {
    cursor: grab;
    color: var(--text-muted, #94a3b8);
    user-select: none;
    vertical-align: middle;
}
.entry-line .drag-handle:hover { color: var(--primary, #6366f1); }
.entry-line .drag-handle:active { cursor: grabbing; }
.entry-line.dragging {
    opacity: .55;
    background: rgba(99, 102, 241, .08);
}

/* ===================== SÉLECTEUR D'ANNÉE ===================== */
.year-selector {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
}

.year-selector-label {
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    margin-right: .25rem;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}

.year-pill {
    padding: .4rem 1.1rem;
    border-radius: 999px;
    font-size: .85rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--text-muted);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    transition: all .25s cubic-bezier(.22, 1, .36, 1);
}

.year-pill:hover {
    color: var(--primary);
    border-color: rgba(99, 102, 241, .45);
    transform: translateY(-2px);
    box-shadow: 0 4px 14px -4px rgba(99, 102, 241, .35);
}

.year-pill.active {
    color: #fff;
    background: var(--gradient-brand);
    border-color: transparent;
    box-shadow: 0 4px 16px -4px rgba(99, 102, 241, .55);
}

/* ===================== ACCESSIBILITÉ ===================== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001s !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001s !important;
    }
}
