/* ============================================================
   Système de design Chanv — répliqué de GestionnaireCOA
   pour assurer l'uniformité visuelle entre les apps internes.
   ============================================================ */

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

:root {
    /* Palette de marque */
    --chanv-blanc: #FFFFFF;
    --chanv-beige: #DDCBA4;
    --chanv-fibre: #F1EADA;
    --chanv-terre: #282828;

    /* Échelle brand étendue */
    --brand-50:  #FBF8F0;
    --brand-100: #F1EADA;
    --brand-200: #E8DDC2;
    --brand-300: #DDCBA4;
    --brand-400: #C9B585;
    --brand-500: #B89E66;
    --brand-600: #8A7648;
    --brand-700: #5E5031;
    --brand-900: #282828;

    /* Slate */
    --slate-50:  #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;

    /* États */
    --success-bg: #d1fae5;
    --success-fg: #065f46;
    --danger-bg: #fed7d7;
    --danger-fg: #9b2c2c;
    --danger:    #e53e3e;
    --warning-bg: #fef3c7;
    --warning-fg: #92400e;

    /* Tokens */
    --radius-chanv: 20px;
    --shadow-soft:  0 4px 20px rgba(40, 40, 40, 0.05);
    --shadow-bold:  0 12px 40px rgba(40, 40, 40, 0.10);
    --transition-chanv: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
    font-family: 'Inter', system-ui, sans-serif;
    color: var(--chanv-terre);
    background: var(--chanv-blanc);
    background-image: radial-gradient(var(--chanv-fibre) 1px, transparent 1px);
    background-size: 40px 40px;
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

h1, h2, h3, h4, h5 {
    font-family: 'Outfit', 'Inter', system-ui, sans-serif;
    letter-spacing: -0.5px;
    margin: 0;
}

a { color: var(--brand-700); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- LOGIN OVERLAY --- */
#login-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: var(--chanv-fibre);
    z-index: 5000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 20px;
    backdrop-filter: blur(10px);
}
.login-card {
    background: var(--chanv-blanc);
    padding: 50px;
    border-radius: 20px;
    box-shadow: var(--shadow-bold);
    border: 1px solid var(--chanv-fibre);
    width: 100%;
    max-width: 420px;
    text-align: center;
}
.login-card .main-logo-login { height: 60px; margin-bottom: 24px; }
.login-card h2 { margin-bottom: 8px; color: var(--chanv-terre); font-size: 24px; }
.login-card p { color: #666; margin-bottom: 30px; font-size: 14px; }
.login-card .btn-google {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    border: 1px solid var(--chanv-fibre);
    border-radius: 12px;
    background: var(--chanv-blanc);
    color: var(--chanv-terre);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition-chanv);
    box-shadow: var(--shadow-soft);
}
.login-card .btn-google:hover {
    background: var(--chanv-beige);
    border-color: var(--chanv-beige);
    box-shadow: var(--shadow-bold);
    transform: translateY(-2px);
}
#loginError {
    color: var(--danger);
    display: none;
    margin-top: 12px;
    font-size: 13px;
}

/* --- HEADER STANDARD CHANV --- */
.main-header {
    background: var(--chanv-terre);
    color: var(--chanv-blanc);
    padding: 40px 20px 90px;
    position: relative;
    overflow: hidden;
}
.main-header::after {
    content: "";
    position: absolute;
    bottom: -50px;
    left: 0;
    width: 100%;
    height: 100px;
    background: var(--chanv-blanc);
    transform: skewY(-2deg);
}
.header-container {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 24px;
    position: relative;
    z-index: 10;
}
.logo-wrapper {
    text-decoration: none;
    display: flex;
    align-items: center;
    background: var(--chanv-fibre);
    padding: 12px 18px;
    border-radius: 20px;
    box-shadow: var(--shadow-soft);
    transition: var(--transition-chanv);
    flex-shrink: 0;
}
.logo-wrapper:hover { filter: brightness(0.97); box-shadow: var(--shadow-bold); text-decoration: none; }
.main-logo { height: 40px; display: block; }
.header-titles { display: flex; flex-direction: column; gap: 4px; }
.header-titles h1 { font-size: 20px; font-weight: 700; color: #fff; margin: 0; line-height: 1.2; }
.header-titles p { font-size: 11px; text-transform: uppercase; letter-spacing: 3px; margin: 4px 0 0; opacity: 0.7; }

/* Navigation interne */
.chanv-nav { display: flex; gap: 6px; flex-wrap: wrap; margin-left: 8px; }
.chanv-nav-link {
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.75);
    transition: var(--transition-chanv);
    text-decoration: none;
}
.chanv-nav-link:hover { background: rgba(255,255,255,0.1); color: #fff; text-decoration: none; }
.chanv-nav-link.active { background: var(--chanv-beige); color: var(--chanv-terre); }

/* --- HEADER USER SECTION --- */
.header-user-section {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}
.user-details { text-align: right; white-space: nowrap; }
.header-user-section .user-name {
    display: block; font-size: 14px; font-weight: 600; color: #ffffff;
}
.header-user-section .user-role {
    display: block; font-size: 11px; text-transform: uppercase;
    letter-spacing: 1.5px; color: rgba(255, 255, 255, 0.6);
}

/* --- AVATAR-BURGER BUTTON --- */
.avatar-burger-btn {
    position: relative; background: none; border: none;
    cursor: pointer; padding: 0; outline: none;
    -webkit-tap-highlight-color: transparent;
}
.avatar-burger-inner {
    position: relative; display: flex; align-items: center;
    gap: 10px; padding: 5px 14px 5px 5px;
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    transition: var(--transition-chanv);
}
.avatar-burger-btn:hover .avatar-burger-inner {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}
.avatar-burger-photo {
    width: 34px; height: 34px; border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    object-fit: cover; transition: var(--transition-chanv);
}
.avatar-burger-icon {
    display: flex; flex-direction: column; gap: 4px; width: 16px;
}
.avatar-burger-icon span {
    display: block; height: 2px; width: 100%;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 2px; transition: var(--transition-chanv);
}
.avatar-burger-icon span:nth-child(2) { width: 70%; }
.avatar-burger-btn:hover .avatar-burger-icon span { background: white; }
.avatar-burger-btn:hover .avatar-burger-icon span:nth-child(2) { width: 100%; }

/* --- Conteneur principal ----------------------------------- */
.chanv-main { max-width: 1280px; margin: 24px auto 0; padding: 0 24px 60px; position: relative; z-index: 2; }

/* --- Cartes ------------------------------------------------ */
.card {
    background: var(--chanv-blanc);
    border: 1px solid var(--chanv-fibre);
    border-radius: var(--radius-chanv);
    box-shadow: var(--shadow-soft);
    padding: 20px;
    animation: chanvFadeIn 0.5s ease-out both;
}
.section-card {
    background: var(--chanv-blanc);
    border: 1px solid var(--chanv-fibre);
    border-radius: var(--radius-chanv);
    padding: 32px;
    box-shadow: var(--shadow-soft);
    animation: chanvFadeIn 0.5s ease-out both;
}
.card-highlight {
    background: var(--chanv-beige);
    color: var(--chanv-terre);
    border-radius: var(--radius-chanv);
    box-shadow: var(--shadow-bold);
    padding: 20px;
}
.card h2, .section-card h2 {
    font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
    color: var(--slate-500); margin-bottom: 14px;
}

/* --- Boutons ----------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border-radius: 12px; padding: 10px 18px;
    font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
    border: 1px solid transparent; cursor: pointer; font-family: inherit;
    transition: var(--transition-chanv);
}
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn-primary { background: var(--chanv-beige); color: var(--chanv-terre); box-shadow: var(--shadow-soft); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.05); transform: translateY(-2px); box-shadow: var(--shadow-bold); }
.btn-secondary { background: #edf2f7; color: #4a5568; }
.btn-secondary:hover:not(:disabled) { background: #e2e8f0; }
.btn-danger { background: var(--danger); color: #fff; box-shadow: 0 4px 15px rgba(229,62,62,0.25); }
.btn-danger:hover:not(:disabled) { background: #c53030; transform: translateY(-2px); }
.btn-ghost {
    background: transparent; color: var(--slate-700); padding: 8px 14px;
    text-transform: none; letter-spacing: normal; font-weight: 500;
}
.btn-ghost:hover:not(:disabled) { background: var(--chanv-fibre); }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* --- Inputs / labels --------------------------------------- */
.input, input[type="text"]:not(.bare), input[type="number"]:not(.bare), select:not(.bare) {
    width: 100%; padding: 10px 14px;
    border: 2px solid var(--chanv-fibre); border-radius: 12px;
    background: var(--chanv-blanc); color: var(--chanv-terre);
    font-size: 14px; font-family: inherit;
    transition: var(--transition-chanv);
}
.input::placeholder, input::placeholder { color: var(--slate-400); }
.input:focus, input:focus, select:focus {
    outline: none; border-color: var(--chanv-beige);
    box-shadow: 0 0 0 4px rgba(221, 203, 164, 0.25);
}
.label {
    display: block; font-size: 11px; font-weight: 700; color: var(--chanv-terre);
    margin-bottom: 6px; text-transform: uppercase; letter-spacing: 1px;
}

/* --- Badges ------------------------------------------------ */
.badge {
    display: inline-flex; align-items: center;
    border-radius: 9999px; padding: 2px 10px;
    font-size: 11px; font-weight: 600; line-height: 18px;
}
.badge-success { background: var(--success-bg); color: var(--success-fg); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger-fg); }
.badge-neutral { background: var(--chanv-fibre); color: var(--chanv-terre); }
.badge-accent  { background: var(--chanv-terre); color: var(--chanv-beige); }
.badge-warning { background: var(--warning-bg); color: var(--warning-fg); }

/* --- Tableaux ---------------------------------------------- */
.table-wrap { background: var(--chanv-blanc); border: 1px solid var(--chanv-fibre); border-radius: var(--radius-chanv); overflow: hidden; box-shadow: var(--shadow-soft); }
table.chanv { width: 100%; border-collapse: collapse; font-size: 14px; }
table.chanv thead { background: var(--slate-50); }
table.chanv th { text-align: left; padding: 12px 16px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--slate-500); font-weight: 600; }
table.chanv td { padding: 12px 16px; border-top: 1px solid var(--slate-100); vertical-align: top; }
table.chanv tbody tr:hover { background: var(--slate-50); }
table.chanv td.num, table.chanv th.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--slate-500); }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; }

/* --- Utilitaires ------------------------------------------- */
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.small { font-size: 12px; }
.err { color: var(--danger); }
.ok { color: var(--success-fg); font-weight: 600; }
.warn { color: var(--warning-fg); }

/* --- Animation --------------------------------------------- */
@keyframes chanvFadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* --- RESPONSIVE MOBILE --- */
@media (max-width: 768px) {
    .main-header { padding: 20px 16px 50px; }
    .main-header::after { height: 60px; bottom: -30px; }
    .header-container {
        flex-direction: column;
        text-align: center;
        position: relative;
    }
    .header-user-section {
        position: absolute;
        top: 0;
        right: 0;
        margin: 0;
    }
    .header-titles p { font-size: 10px; }
    /* Nav inter-pages sur mobile : barre défilable horizontalement (au lieu d'être masquée),
       pour que toutes les pages — dont le Tableau de bord — restent accessibles. */
    .chanv-nav {
        display: flex;
        flex-wrap: nowrap;
        width: 100%;
        margin: 6px 0 0;
        gap: 6px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 2px;
    }
    .chanv-nav::-webkit-scrollbar { display: none; }
    .chanv-nav-link {
        flex: 0 0 auto;
        white-space: nowrap;
        font-size: 12px;
        padding: 7px 13px;
        background: rgba(255, 255, 255, 0.08);
    }
    .user-details { display: none !important; }
    .avatar-burger-inner { padding: 3px 10px 3px 3px; }
    .avatar-burger-photo { width: 30px; height: 30px; }
    .avatar-burger-icon { width: 14px; gap: 3px; }
    .chanv-main { padding: 0 12px 40px; }
}

/* ============================================================
   NAV D'EMBED GANDALF — #gandalf-embed-nav (pastilles, style GPI)
   Construite par auth-client.js quand html.gandalf-embed est posé
   par /gandalf/embed-client.js (le header complet est masqué en embed).
   ============================================================ */
#gandalf-embed-nav { display: none; }

html.gandalf-embed #gandalf-embed-nav {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    position: sticky;
    top: 0;
    z-index: 60;
    background: #F4EFE3; /* parchemin */
    padding: 10px 14px;
    margin: -8px -8px 14px;
    border-bottom: 1px solid rgba(168, 134, 63, 0.25);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
html.gandalf-embed #gandalf-embed-nav::-webkit-scrollbar { display: none; }

#gandalf-embed-nav .gen-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    background: #fff;
    color: var(--chanv-terre, #3f3527);
    border: 1px solid rgba(168, 134, 63, 0.3);
    border-radius: 999px;
    padding: 7px 15px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}
#gandalf-embed-nav .gen-tab:hover { border-color: #A8863F; text-decoration: none; }
#gandalf-embed-nav .gen-tab.active { background: #A8863F; border-color: #A8863F; color: #fff; }

/* ============================================================
   MODE SOMBRE GANDALF — html.gandalf-dark
   Classe posée sur <html> par le SDK Gandalf (pilotée par le hub).
   Palette : fond #201d19 / surfaces #2b2823 /
   texte rgba(255,255,255,.92) / lignes rgba(221,203,164,.14) /
   accent or #DDCBA4. Bloc append-only : aucune règle claire modifiée.
   ============================================================ */

/* --- Variables : la majorité des composants suivent d'elles-mêmes --- */
html.gandalf-dark {
    color-scheme: dark;
    /* --chanv-blanc devient la couleur de SURFACE (cartes, modals, seg…) ;
       le fond de page est re-noirci sur body plus bas. */
    --chanv-blanc: #2b2823;
    --chanv-fibre: rgba(221, 203, 164, 0.14);
    --chanv-terre: rgba(255, 255, 255, 0.92);
    /* --chanv-beige reste #DDCBA4 : accent (focus, bordures actives).
       Les FONDS beiges sont re-assombris individuellement plus bas. */

    --brand-50:  #26231e;
    --brand-100: rgba(221, 203, 164, 0.18);
    --brand-200: rgba(221, 203, 164, 0.22);
    --brand-600: #A8863F;
    --brand-700: #DDCBA4;   /* liens & accents texte -> or */

    --slate-50:  #26231e;   /* thead, hover de lignes */
    --slate-100: rgba(221, 203, 164, 0.12);
    --slate-300: rgba(255, 255, 255, 0.30);
    --slate-400: rgba(255, 255, 255, 0.45);
    --slate-500: rgba(255, 255, 255, 0.60);  /* texte secondaire */
    --slate-600: rgba(255, 255, 255, 0.75);
    --slate-700: rgba(255, 255, 255, 0.85);

    --success-bg: rgba(34, 163, 90, 0.18);
    --success-fg: #7ee2a8;
    --danger-bg:  rgba(220, 38, 38, 0.20);
    --danger-fg:  #f1948a;
    --danger:     #f07070;
    --warning-bg: rgba(217, 119, 6, 0.20);
    --warning-fg: #fbbf24;

    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.25);
    --shadow-bold: 0 12px 40px rgba(0, 0, 0, 0.45);
}

/* --- Structure : fond de page, header, nav --- */
html.gandalf-dark body {
    background: #201d19;
    background-image: radial-gradient(rgba(221, 203, 164, 0.07) 1px, transparent 1px);
    background-size: 40px 40px;
    background-attachment: fixed;
    color: rgba(255, 255, 255, 0.92);
}
html.gandalf-dark .main-header { background: #2b2823; }
html.gandalf-dark .main-header::after { background: #201d19; }
html.gandalf-dark .logo-wrapper { background: #F1EADA; } /* logo sombre : fond clair conservé */
html.gandalf-dark .chanv-nav-link.active { background: #DDCBA4; color: #201d19; }

/* --- Login overlay --- */
html.gandalf-dark #login-overlay { background: #201d19; }
html.gandalf-dark .login-card { background: #2b2823; border-color: rgba(221, 203, 164, 0.14); }
html.gandalf-dark .login-card p { color: rgba(255, 255, 255, 0.6); }
html.gandalf-dark .login-card .btn-google { background: #201d19; border-color: rgba(221, 203, 164, 0.25); color: rgba(255, 255, 255, 0.92); }
html.gandalf-dark .login-card .btn-google:hover { background: #DDCBA4; border-color: #DDCBA4; color: #201d19; }

/* --- Cartes / sections (suivent --chanv-blanc) + compléments --- */
html.gandalf-dark .card-highlight { background: rgba(221, 203, 164, 0.16); color: rgba(255, 255, 255, 0.92); }

/* --- Boutons --- */
html.gandalf-dark .btn-primary { background: #DDCBA4; color: #201d19; }
html.gandalf-dark .btn-secondary { background: rgba(221, 203, 164, 0.14); color: rgba(255, 255, 255, 0.85); }
html.gandalf-dark .btn-secondary:hover:not(:disabled) { background: rgba(221, 203, 164, 0.25); }
html.gandalf-dark .btn-ghost:hover:not(:disabled) { background: rgba(221, 203, 164, 0.14); }

/* --- Formulaires --- */
html.gandalf-dark .input,
html.gandalf-dark input[type="text"]:not(.bare),
html.gandalf-dark input[type="number"]:not(.bare),
html.gandalf-dark input[type="search"],
html.gandalf-dark input[type="date"],
html.gandalf-dark select:not(.bare),
html.gandalf-dark textarea {
    background: #201d19;
    color: rgba(255, 255, 255, 0.92);
    border-color: rgba(221, 203, 164, 0.20);
}
html.gandalf-dark .input::placeholder,
html.gandalf-dark input::placeholder,
html.gandalf-dark textarea::placeholder { color: rgba(255, 255, 255, 0.35); }
html.gandalf-dark .input:focus,
html.gandalf-dark input:focus,
html.gandalf-dark select:focus,
html.gandalf-dark textarea:focus {
    border-color: #DDCBA4;
    box-shadow: 0 0 0 4px rgba(221, 203, 164, 0.15);
}
html.gandalf-dark .toolbar input[type=search] { background: #201d19; color: rgba(255, 255, 255, 0.92); border-color: rgba(221, 203, 164, 0.20); }

/* --- Badges génériques --- */
html.gandalf-dark .badge-accent { background: #DDCBA4; color: #201d19; }

/* --- Tableaux : bordures internes hardcodées (#f1ede4) --- */
html.gandalf-dark table.db td,
html.gandalf-dark .wrow,
html.gandalf-dark .alert-row,
html.gandalf-dark .combo-item,
html.gandalf-dark .m-sec { border-bottom-color: rgba(221, 203, 164, 0.14); }
html.gandalf-dark .m-sec:last-child { border-bottom-color: transparent; }

/* --- Modals / overlays / loaders / toast --- */
html.gandalf-dark .modal-back { background: rgba(0, 0, 0, 0.60); }
html.gandalf-dark .modal,
html.gandalf-dark .modal-head { background: #2b2823; }
html.gandalf-dark #toast { background: #DDCBA4; color: #201d19; }

/* ================= INDEX (accueil / widgets) ================= */
html.gandalf-dark .hw-skel { background: rgba(255, 255, 255, 0.10); }
html.gandalf-dark .hw-sub.warn { color: #fbbf24; }
html.gandalf-dark .hw-sub.up { color: #7ee2a8; }
html.gandalf-dark .hw-sub.down { color: #f1948a; }
html.gandalf-dark .hw-link { color: #DDCBA4; }
html.gandalf-dark .wrow .mv { background: #201d19; color: rgba(255, 255, 255, 0.75); border-color: rgba(221, 203, 164, 0.20); }
html.gandalf-dark .wrow .mv:hover { background: rgba(221, 203, 164, 0.18); }

/* ================= DASHBOARD ================= */
html.gandalf-dark .seg { border-color: rgba(221, 203, 164, 0.20); }
html.gandalf-dark .seg button { background: #2b2823; color: rgba(255, 255, 255, 0.65); }
html.gandalf-dark .seg button.active { background: #DDCBA4; color: #201d19; }
html.gandalf-dark .health { background: rgba(221, 203, 164, 0.15); }
html.gandalf-dark .bar,
html.gandalf-dark .comp-bar { background: rgba(255, 255, 255, 0.12); }
html.gandalf-dark .sev-CRITIQUE  { background: rgba(220, 38, 38, 0.22);  color: #fca5a5; }
html.gandalf-dark .sev-IMPORTANT { background: rgba(217, 119, 6, 0.22);  color: #fcd34d; }
html.gandalf-dark .sev-NOUVEAU   { background: rgba(34, 163, 90, 0.20);  color: #86efac; }
html.gandalf-dark .sev-MANUEL    { background: rgba(59, 130, 246, 0.22); color: #93c5fd; }
html.gandalf-dark .chip-CRITIQUE  { background: rgba(220, 38, 38, 0.22);  color: #fca5a5; }
html.gandalf-dark .chip-IMPORTANT { background: rgba(217, 119, 6, 0.22);  color: #fcd34d; }
html.gandalf-dark .chip-NOUVEAU   { background: rgba(34, 163, 90, 0.20);  color: #86efac; }
html.gandalf-dark .h-badge.green  { background: rgba(34, 163, 90, 0.20);  color: #86efac; }
html.gandalf-dark .h-badge.yellow { background: rgba(217, 119, 6, 0.22);  color: #fcd34d; }
html.gandalf-dark .h-badge.red    { background: rgba(220, 38, 38, 0.22);  color: #fca5a5; }
html.gandalf-dark tr.row-red td { background: rgba(220, 38, 38, 0.10); }
html.gandalf-dark tr.row-red:hover td { background: rgba(220, 38, 38, 0.18); }
html.gandalf-dark .m-sec .formula { background: #201d19; color: #DDCBA4; }
html.gandalf-dark .combo-item:hover,
html.gandalf-dark .combo-item.hl { background: rgba(221, 203, 164, 0.14); }

/* ================= BLEND ================= */
html.gandalf-dark .cost-edit .ok-btn { background: #DDCBA4; color: #201d19; }
html.gandalf-dark .cost-row .edit:hover { background: rgba(221, 203, 164, 0.16); }

/* ================= PRODUCTION ================= */
html.gandalf-dark .route-preroll { background: rgba(56, 139, 253, 0.20); color: #7fb3f5; }
html.gandalf-dark .act-btn:hover { background: rgba(221, 203, 164, 0.18); border-color: #DDCBA4; }
html.gandalf-dark .split-badge { background: rgba(221, 203, 164, 0.16); color: rgba(255, 255, 255, 0.85); }
html.gandalf-dark .act-hint { background: rgba(217, 119, 6, 0.14); color: #fcd34d; border-color: rgba(217, 119, 6, 0.35); }
html.gandalf-dark .dest-faconnage { color: #7fb3f5; }
html.gandalf-dark .dest-interne { color: #fbbf24; }
html.gandalf-dark .dest-achat { color: #7ee2a8; }
html.gandalf-dark .subtab.active .cnt { background: #DDCBA4; color: #201d19; }

/* ================= ATELIER ================= */
html.gandalf-dark .iconbtn:hover { background: rgba(221, 203, 164, 0.16); }
html.gandalf-dark .need .calc { color: #a3b88c; }
html.gandalf-dark .cell { background: #26231e; }
html.gandalf-dark .cell.over { background: rgba(34, 165, 90, 0.14); }
html.gandalf-dark .cell.nodrop { border-color: rgba(220, 38, 38, 0.55); }
html.gandalf-dark .r-205 { background: rgba(217, 119, 6, 0.22);  color: #fcd34d; }
html.gandalf-dark .r-206 { background: rgba(99, 102, 241, 0.25); color: #a5b4fc; }
html.gandalf-dark .k-fini { background: rgba(34, 163, 90, 0.20); color: #86efac; }
html.gandalf-dark .k-sf { background: rgba(255, 255, 255, 0.10); color: rgba(255, 255, 255, 0.60); }
html.gandalf-dark .st-planned   { background: rgba(255, 255, 255, 0.12); color: rgba(255, 255, 255, 0.75); }
html.gandalf-dark .st-confirmed { background: rgba(59, 130, 246, 0.25); color: #93c5fd; }
html.gandalf-dark .st-sent      { background: rgba(34, 163, 90, 0.20);  color: #86efac; }
html.gandalf-dark .capbar { background: rgba(255, 255, 255, 0.12); }
html.gandalf-dark .lotopt:hover { background: rgba(221, 203, 164, 0.14); }
html.gandalf-dark .lotopt.sel { background: rgba(34, 165, 90, 0.14); }

/* ================= FORECAST ================= */
html.gandalf-dark tr.row-shortage { background: rgba(245, 158, 11, 0.10); }
html.gandalf-dark tr.row-shortage:hover { background: rgba(245, 158, 11, 0.18); }

/* ================= PURCHASING ================= */
html.gandalf-dark .pill-achat   { background: rgba(217, 119, 6, 0.22);  color: #fcd34d; }
html.gandalf-dark .pill-transfo { background: rgba(99, 102, 241, 0.25); color: #a5b4fc; }
html.gandalf-dark .why-btn { color: #DDCBA4; }
html.gandalf-dark .peg { background: rgba(221, 203, 164, 0.12); }

/* ================= COMPATIBILITY ================= */
html.gandalf-dark .chip.active { background: #DDCBA4; color: #201d19; border-color: #DDCBA4; }
html.gandalf-dark .chip.active .n { color: rgba(32, 29, 25, 0.7); }
html.gandalf-dark .assigned-pill.yes { background: rgba(221, 203, 164, 0.20); color: #DDCBA4; }
html.gandalf-dark .save-bar { background: linear-gradient(180deg, rgba(43, 40, 35, 0) 0%, #2b2823 30%); }

/* ================= AGING ================= */
/* Buckets pastel -> équivalents sombres (même teinte, luminosité basse,
   texte clair hérité). Doublés en [style*=…] pour battre le background
   inline posé en JS sur .agebadge (BUCKET_BG). */
html.gandalf-dark .b-0 { background: #3d381c; }  /* jaune  */
html.gandalf-dark .b-1 { background: #1e3527; }  /* vert   */
html.gandalf-dark .b-2 { background: #38243a; }  /* fuchsia*/
html.gandalf-dark .b-3 { background: #3d2b18; }  /* orange */
html.gandalf-dark .b-4 { background: #1d2c42; }  /* bleu   */
html.gandalf-dark .b-5 { background: #2c2547; }  /* violet */
html.gandalf-dark .b-6 { background: #402222; }  /* rouge  */
html.gandalf-dark .b-7 { background: #2e3136; }  /* slate  */
html.gandalf-dark .agebadge[style*="#fef9c3"] { background: #3d381c !important; }
html.gandalf-dark .agebadge[style*="#dcfce7"] { background: #1e3527 !important; }
html.gandalf-dark .agebadge[style*="#fae8ff"] { background: #38243a !important; }
html.gandalf-dark .agebadge[style*="#ffedd5"] { background: #3d2b18 !important; }
html.gandalf-dark .agebadge[style*="#dbeafe"] { background: #1d2c42 !important; }
html.gandalf-dark .agebadge[style*="#ede9fe"] { background: #2c2547 !important; }
html.gandalf-dark .agebadge[style*="#fee2e2"] { background: #402222 !important; }
html.gandalf-dark .agebadge[style*="#f1f5f9"] { background: #2e3136 !important; }
html.gandalf-dark .bucket.active { outline-color: #DDCBA4; }
html.gandalf-dark .chips .chip.active { background: #DDCBA4; color: #201d19; border-color: #DDCBA4; }

/* ================= WEB ================= */
html.gandalf-dark .charttip { background: #201d19; border: 1px solid rgba(221, 203, 164, 0.25); color: rgba(255, 255, 255, 0.92); }
html.gandalf-dark .ai-card { background: #2b2823; border-color: rgba(221, 203, 164, 0.20); border-left-color: #DDCBA4; }
html.gandalf-dark .ai-btn { background: #201d19; color: #DDCBA4; border-color: rgba(221, 203, 164, 0.30); }
html.gandalf-dark .ai-btn:hover { background: rgba(221, 203, 164, 0.14); }
html.gandalf-dark .seg button.active { background: #DDCBA4; color: #201d19; }

/* ================= NAV D'EMBED GANDALF ================= */
html.gandalf-dark.gandalf-embed #gandalf-embed-nav {
    background: #2b2823;
    border-bottom-color: rgba(221, 203, 164, 0.14);
}
html.gandalf-dark #gandalf-embed-nav .gen-tab {
    background: #201d19;
    color: rgba(255, 255, 255, 0.75);
    border-color: rgba(221, 203, 164, 0.25);
}
html.gandalf-dark #gandalf-embed-nav .gen-tab:hover { border-color: #A8863F; color: rgba(255, 255, 255, 0.95); }
html.gandalf-dark #gandalf-embed-nav .gen-tab.active { background: #A8863F; border-color: #A8863F; color: #fff; }


/* Fenêtres redimensionnées (desktop) : les pastilles d'embed passent à la
   ligne — scrollbar masquée + molette = derniers onglets inaccessibles. */
@media (hover: hover) and (pointer: fine) {
    html.gandalf-embed #gandalf-embed-nav,
    #gandalf-embed-nav { flex-wrap: wrap; overflow-x: visible; }
}
