/* ===== DESIGN SYSTEM CSF EXPERT ===== */
:root {
    /* Transitions & Shared */
    --transition-fast: 0.15s ease;
    --transition-base: 0.25s ease;
    --transition-slow: 0.4s ease;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Default Dark Theme */
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a2235;
    --bg-hover: #252f45;
    --border-color: #2d3a52;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-primary: #3b82f6;
    --accent-secondary: #6366f1;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    --gradient-primary: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    --gradient-card: linear-gradient(145deg, rgba(26, 34, 53, 0.9) 0%, rgba(17, 24, 39, 0.95) 100%);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(59, 130, 246, 0.2);
}

body[data-theme='light'] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --accent-primary: #2563eb;
    --accent-secondary: #4f46e5;
    --gradient-primary: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
    --gradient-card: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 30px rgba(37, 99, 235, 0.1);
}

/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 80px;
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg) 0;
    z-index: 200;
    transition: transform var(--transition-base);
}

.sidebar-logo {
    width: 60px;
    height: 60px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    box-shadow: var(--shadow-sm);
}

.sidebar-logo svg {
    width: 24px;
    height: 24px;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.sidebar-item {
    width: 50px;
    height: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-base);
    gap: 4px;
}

.sidebar-item svg {
    width: 24px;
    height: 24px;
}

.sidebar-item span {
    font-size: 0.65rem;
    font-weight: 500;
}

.sidebar-item:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.sidebar-item.active {
    background: var(--bg-card);
    color: var(--accent-primary);
    box-shadow: var(--shadow-sm);
}

.main-wrapper {
    margin-left: 80px;
    min-height: 100vh;
    transition: margin-left var(--transition-base);
}

body.hide-sidebar .sidebar {
    transform: translateX(-100%);
}

body.hide-sidebar .main-wrapper {
    margin-left: 0;
}

body.hide-sidebar .app-header,
body.hide-sidebar .modules-nav {
    left: 0;
}

.app-view {
    display: none;
}

.app-view.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ===== HEADER ===== */
.app-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: var(--space-md) var(--space-xl);
    position: fixed;
    top: 0;
    left: 80px;
    right: 0;
    z-index: 110;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    opacity: 0.98;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-xl);
    flex-wrap: wrap;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: var(--gradient-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
}

.logo-icon svg {
    width: 28px;
    height: 28px;
    color: white;
}

.logo-text h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-text .subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Import Zones */
.import-zones {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.import-zone {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    transition: all var(--transition-base);
}

.import-zone:hover,
.import-zone.has-file {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.import-zone.has-file {
    border-color: var(--accent-success);
}

.import-icon {
    width: 36px;
    height: 36px;
    background: var(--bg-hover);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.import-icon svg {
    width: 20px;
    height: 20px;
    color: var(--accent-primary);
}

.import-content {
    display: flex;
    flex-direction: column;
}

.import-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.import-status {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.import-status.loaded {
    color: var(--accent-success);
}

.import-btn {
    width: 36px;
    height: 36px;
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.import-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

.import-btn svg {
    width: 18px;
    height: 18px;
    color: white;
}

/* ===== NAVIGATION ===== */
.modules-nav {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 0 var(--space-xl);
    position: fixed;
    top: 108px;
    left: 80px;
    right: 0;
    height: 70px;
    /* Réduit pour un look plus compact et mieux centrer visuellement */
    display: flex;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    opacity: 0.98;
}

.nav-content {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    overflow-x: auto;
    position: relative;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE interface */
    width: 100%;
    height: 40px;
    /* Zone de contenu fixe pour centrage parfait */
}

.nav-content::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Edge */
}

/* Magic Indicator */
.nav-indicator {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    /* Prend toute la hauteur de .nav-content (40px) */
    background: var(--gradient-primary);
    border-radius: var(--radius-md);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: -1;
    box-shadow: var(--shadow-glow);
    pointer-events: none;
    opacity: 0;
}

.nav-indicator.active {
    opacity: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 0 var(--space-md);
    height: 40px;
    /* Hauteur fixe pour contrôle total */
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-secondary);
    transition: all var(--transition-base);
    white-space: nowrap;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.nav-item.active {
    background: transparent;
    /* L'indicateur passera derrière */
    color: white;
    border-color: transparent;
}

.nav-letter {
    width: 24px;
    height: 24px;
    background: var(--bg-hover);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
}

.nav-item:not(.active) .nav-letter {
    background: var(--bg-hover);
}

.nav-label {
    font-size: 0.85rem;
    font-weight: 500;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-xl);
    padding-top: calc(178px + var(--space-xl));
    /* 108px header + 70px nav */
}

/* ===== MODULES ===== */
.module {
    margin-bottom: var(--space-2xl);
    animation: fadeInUp 0.5s ease;
    scroll-margin-top: 195px;
    /* Ajusté pour éviter que le titre soit coupé */
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.module-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}

/* Zone d'import dans les modules */
.module-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.module-import-zone {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    transition: all var(--transition-base);
}

.module-import-zone:hover,
.module-import-zone.has-file {
    border-color: var(--accent-primary);
}

.module-import-zone.has-file {
    border-color: var(--accent-success);
}

.module-import-content {
    display: flex;
    flex-direction: column;
}

.module-import-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.module-import-status {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.module-import-status.loaded {
    color: var(--accent-success);
}

.module-import-btn {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.module-import-btn:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-glow);
}

.module-import-btn svg {
    width: 16px;
    height: 16px;
}

.generate-all-btn {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.generate-all-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}

.generate-all-btn svg {
    width: 16px;
    height: 16px;
}

.generate-all-btn.loading {
    opacity: 0.8;
    cursor: wait;
    animation: pulse 1.5s infinite;
}

.generate-all-btn.loading svg {
    animation: spin 1s linear infinite;
}

/* Indicateur documents pour B/C */
.module-docs-info {
    margin-left: auto;
    padding: var(--space-sm) var(--space-md);
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: var(--radius-md);
}

.docs-label {
    font-size: 0.8rem;
    color: var(--accent-primary);
    font-weight: 500;
}

.module-badge {
    width: 48px;
    height: 48px;
    background: var(--gradient-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    box-shadow: var(--shadow-glow);
}

.module-info h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: var(--space-xs);
}

.module-mode {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.questions-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

/* ===== MODULE PROGRESS RING ===== */
.module-progress {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 0 var(--space-sm);
    flex-shrink: 0;
}

.module-progress .progress-ring-container {
    position: relative;
    width: 44px;
    height: 44px;
}

.module-progress .progress-ring-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.08);
    stroke-width: 3.5;
}

.module-progress .progress-ring-fill {
    fill: none;
    stroke: var(--accent-primary);
    stroke-width: 3.5;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.6s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.4s ease;
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
}

.module-progress .progress-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    transition: color 0.4s ease;
    white-space: nowrap;
}

.module-progress .progress-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    transition: color 0.4s ease;
    white-space: nowrap;
}

.module-progress.complete .progress-ring-fill {
    stroke: #10b981;
}

.module-progress.complete .progress-label,
.module-progress.complete .progress-text {
    color: #10b981;
}

.module-progress.complete .progress-ring-container {
    animation: progressPulse 2s ease-in-out infinite;
}

@keyframes progressPulse {

    0%,
    100% {
        filter: drop-shadow(0 0 0px rgba(16, 185, 129, 0));
    }

    50% {
        filter: drop-shadow(0 0 6px rgba(16, 185, 129, 0.5));
    }
}

/* ===== GLOBAL PROGRESS FOOTER ===== */
.global-progress-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-lg);
    padding: var(--space-xl) var(--space-lg);
    margin-top: var(--space-xl);
    background: var(--gradient-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.global-progress-footer .progress-ring-container {
    position: relative;
    width: 72px;
    height: 72px;
}

.global-progress-footer .progress-ring-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.08);
    stroke-width: 4;
}

.global-progress-footer .progress-ring-fill {
    fill: none;
    stroke: var(--accent-primary);
    stroke-width: 4;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.6s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.4s ease;
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
}

.global-progress-footer .progress-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    transition: color 0.4s ease;
    white-space: nowrap;
}

.global-progress-footer .global-progress-info {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.global-progress-footer .global-progress-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.global-progress-footer .global-progress-detail {
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: color 0.4s ease;
}

.global-progress-footer.complete .progress-ring-fill {
    stroke: #10b981;
}

.global-progress-footer.complete .progress-label,
.global-progress-footer.complete .global-progress-detail {
    color: #10b981;
}

.global-progress-footer.complete .progress-ring-container {
    animation: progressPulse 2s ease-in-out infinite;
}

/* ===== QUESTION CARDS ===== */
.question-card {
    background: var(--gradient-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    transition: all var(--transition-base);
}

.question-card:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-md);
}

.question-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.question-number {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.15);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
}


.editor-content:empty::before {
    content: attr(placeholder);
    color: var(--text-muted);
    font-style: italic;
    /* Added italic for consistency */
    pointer-events: none;
    display: block;
    /* For Firefox */
    white-space: pre-wrap;
    /* Allow wrapping */
}

/* Priorité au data-default-text s'il existe et n'est pas vide */
.editor-content:not([data-default-text=""]):empty::before {
    content: attr(data-default-text);
    font-style: italic;
    color: var(--text-muted);
}

.question-mode-badge {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
}

.question-mode-badge.hybride {
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
}

.question-mode-badge.standard {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}

.question-mode-badge.analytique {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
}

.question-mode-badge.libre {
    background: rgba(148, 163, 184, 0.2);
    color: #cbd5e1;
}

.question-mode-badge.extraction {
    background: rgba(236, 72, 153, 0.2);
    color: #f472b6;
}

.question-mode-badge.redactionnel {
    background: rgba(34, 197, 94, 0.2);
    /* Green-500 equivalent with opacity */
    color: #4ade80;
    /* Green-400 */
}

.question-text {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
    line-height: 1.5;
}

/* Prompt Placeholder */
.prompt-placeholder {
    background: var(--bg-hover);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-sm);
    padding: var(--space-sm) var(--space-md);
    margin-bottom: var(--space-md);
}

.prompt-placeholder code {
    font-family: 'Fira Code', monospace;
    font-size: 0.8rem;
    color: var(--accent-warning);
}

/* ===== TABS ===== */
.tabs-container {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
}

.tab-btn {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tab-btn:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--gradient-primary);
    border-color: transparent;
    color: white;
}

/* ===== GPT BUTTON ===== */
.gpt-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    background: linear-gradient(135deg, #10a37f 0%, #1a7f64 100%);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: 0 4px 15px rgba(16, 163, 127, 0.3);
}

.gpt-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(16, 163, 127, 0.4);
}

.gpt-btn:active {
    transform: translateY(0);
}

.gpt-btn svg {
    width: 18px;
    height: 18px;
}

.gpt-btn.loading {
    opacity: 0.8;
    cursor: wait;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.8;
    }

    50% {
        opacity: 0.5;
    }
}

.gpt-btn.loading svg {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* ===== BUTTONS ROW ===== */
.buttons-row {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
    margin-bottom: var(--space-md);
}

.buttons-row:empty {
    display: none;
}

/* ===== AI BUTTON ===== */
.ai-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.ai-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(99, 102, 241, 0.4);
}

.ai-btn:active:not(:disabled) {
    transform: translateY(0);
}

.ai-btn svg {
    width: 18px;
    height: 18px;
}

.ai-btn:disabled,
.ai-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: linear-gradient(135deg, #6b7280 0%, #9ca3af 100%) !important;
    box-shadow: none;
    position: relative;
    /* Pour le tooltip */
}

/* Tooltip CSS pour boutons désactivés */
.ai-btn.disabled:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #1f2937;
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 100;
    pointer-events: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.ai-btn.disabled:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 5px;
    border-style: solid;
    border-color: #1f2937 transparent transparent transparent;
    z-index: 100;
}

.ai-btn.loading {
    opacity: 0.8;
    cursor: wait;
    animation: pulse 1.5s infinite;
}

.ai-btn.loading svg {
    animation: spin 1s linear infinite;
}

/* ===== QUESTION ANNEXE ZONE (Module C) ===== */
.question-annexe-zone {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    transition: all 0.2s;
}

.question-annexe-zone.drag-over {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--accent-primary);
    border-style: solid;
}

.question-annexe-zone.has-file {
    background: rgba(34, 197, 94, 0.1);
    border-color: var(--success);
    border-style: solid;
}

.question-annexe-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.85rem;
    color: var(--text-secondary);
    flex: 1;
}

.question-annexe-label svg {
    color: var(--accent-primary);
}

.question-annexe-status {
    font-weight: 600;
    color: var(--text-muted);
}

.question-annexe-status.loaded {
    color: var(--accent-success);
}

/* File Chips for Question Annexes */
.file-chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
}

.file-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    max-width: 180px;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
}

.file-chip:hover {
    border-color: var(--accent-primary);
    background: var(--bg-secondary);
}

.file-chip .file-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
    color: var(--text-primary);
    font-weight: 500;
}

.btn-remove-file {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    display: flex;
    align-items: center;
    padding: 0;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    justify-content: center;
}

.btn-remove-file:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.question-annexe-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
}

.question-annexe-btn:hover {
    background: var(--accent-secondary);
    transform: translateY(-1px);
}

.question-annexe-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== RESPONSE ZONE ===== */
.response-zone {
    position: relative;
}

.response-zone textarea {
    width: 100%;
    min-height: 120px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    padding-right: 80px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.6;
    resize: vertical;
    transition: all var(--transition-base);
}

.response-zone textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.response-zone textarea::placeholder {
    color: var(--text-muted);
}

/* Response Actions Container */
.response-actions {
    position: absolute;
    right: var(--space-sm);
    top: var(--space-sm);
    display: flex;
    gap: var(--space-xs);
}

.copy-btn,
.clear-btn {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.copy-btn:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.clear-btn:hover {
    background: var(--accent-error);
    border-color: var(--accent-error);
    color: white;
}

.copy-btn svg,
.clear-btn svg {
    width: 14px;
    height: 14px;
}

.copy-btn.copied {
    background: var(--accent-success);
    border-color: var(--accent-success);
    color: white;
}

.clear-btn.cleared {
    background: var(--accent-error);
    border-color: var(--accent-error);
    color: white;
    transform: scale(0.95);
}

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: var(--space-xl);
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    background: var(--accent-success);
    border-radius: var(--radius-md);
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all var(--transition-base);
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast svg {
    width: 20px;
    height: 20px;
}

/* ===== FOOTER ===== */
.app-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: var(--space-xl);
    text-align: center;
}

.footer-content p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.footer-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

/* ===== RESPONSIVE ===== */
/* Multi-module select badges */
.es-multi-module-select {
    display: flex;
    gap: 4px;
    background: var(--bg-primary);
    padding: 2px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.m-badge {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
    background: transparent;
}

.m-badge:hover {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.m-badge.active {
    color: white;
}

.m-badge.active[data-mod="a"] { background: #3b82f6; } /* Blue */
.m-badge.active[data-mod="b"] { background: #10b981; } /* Green */
.m-badge.active[data-mod="d"] { background: #f59e0b; } /* Orange */
.m-badge.active[data-mod="e"] { background: #10b981; } /* Emerald - same as B for consistency in rea/dep? or #8b5cf6 Violet? Let's use Violet for E */
.m-badge.active[data-mod="e"] { background: #8b5cf6; } 
.m-badge.active[data-mod="f"] { background: #6366f1; } /* Indigo */

/* MÉMO : Groupement par catégories */
.memo-section {
    margin-bottom: 2rem;
}

.memo-section-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.memo-section-title::before {
    content: "";
    width: 4px;
    height: 18px;
    background: var(--accent-primary);
    border-radius: 2px;
}

/* DÉPENSES : Sélection des catégories et Sections */
.expense-category-selector {
    display: flex;
    gap: 1.5rem;
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    align-items: center;
    flex-wrap: wrap;
}

.expense-cat-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}

.expense-cat-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-primary);
    cursor: pointer;
}

.expense-cat-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 100px;
    font-size: 0.85rem;
    font-weight: 500;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.expense-cat-label:hover .expense-cat-badge {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.expense-cat-label input:checked + .expense-cat-badge.personnel { background: rgba(59, 130, 246, 0.2); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.3); }
.expense-cat-label input:checked + .expense-cat-badge.fonctionnement { background: rgba(139, 92, 246, 0.2); color: #a78bfa; border: 1px solid rgba(139, 92, 246, 0.3); }
.expense-cat-label input:checked + .expense-cat-badge.prestations { background: rgba(236, 72, 153, 0.2); color: #f472b6; border: 1px solid rgba(236, 72, 153, 0.3); }

.expense-cat-label input:disabled + .expense-cat-badge {
    opacity: 0.8;
    cursor: default;
}

.expense-section-divider {
    margin: 2.5rem 0 1.5rem 0;
    padding-top: 1.5rem;
    border-top: 2px dashed var(--border-color);
    position: relative;
}

.expense-section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}


@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: stretch;
    }

    .import-zones {
        flex-direction: column;
    }

    .modules-nav {
        top: auto;
        position: relative;
    }

    .main-content {
        padding: var(--space-md);
    }

    .module-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .response-zone textarea {
        padding-right: var(--space-md);
        padding-bottom: 60px;
    }

    .copy-btn {
        top: auto;
        bottom: var(--space-sm);
        right: var(--space-sm);
    }
}

/* ===== VUE MÃ‰MO ===== */
.view-header {
    padding: var(--space-2xl) var(--space-xl);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.view-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
}

.search-bar {
    position: relative;
    width: 400px;
}

.search-bar input {
    width: 100%;
    padding: var(--space-sm) var(--space-xl);
    padding-right: var(--space-2xl);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all var(--transition-base);
}

.search-bar input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-bar svg {
    position: absolute;
    right: var(--space-md);
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

.memo-content {
    padding: var(--space-xl);
    max-width: 1200px;
    margin: 0 auto;
}

.memo-placeholder {
    text-align: center;
    padding: var(--space-2xl);
    color: var(--text-muted);
    background: var(--bg-card);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    margin-top: var(--space-2xl);
}

.memo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: var(--space-lg);
    margin-top: var(--space-xl);
}

.memo-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    transition: all var(--transition-base);
    cursor: pointer;
    overflow: hidden;
    /* EmpÃªche tout dÃ©bordement de contenu */
    position: relative;
    display: flex;
    flex-direction: column;
}

.memo-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-md);
}

.memo-card-category {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--accent-primary);
    margin-bottom: var(--space-sm);
}

.memo-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: var(--space-sm);
}

.memo-card-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    position: relative;
    max-height: 6.8em;
    /* Environ 4 lignes */
    overflow-wrap: break-word;
    /* Casse les mots longs */
    word-break: break-word;
}

/* Boutons et Groupes dans le MÃ©mo */
.header-title-group {
    display: flex;
    align-items: center;
    gap: var(--space-xl);
}

.add-memo-btn {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    background: var(--accent-success);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
}

.add-memo-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.3);
}

.add-memo-btn svg {
    width: 18px;
    height: 18px;
}

/* Modale */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    width: 90%;
    max-width: 600px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-modal {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.close-modal:hover {
    color: var(--text-primary);
}

#memo-form {
    padding: var(--space-lg);
}

.form-group {
    margin-bottom: var(--space-lg);
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: var(--space-xs);
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-md);
    margin-top: var(--space-xl);
}

.btn-secondary {
    padding: var(--space-sm) var(--space-xl);
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
}

.btn-primary {
    padding: var(--space-sm) var(--space-xl);
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-weight: 600;
    cursor: pointer;
}

/* Actions sur carte MÃ©mo */
.memo-card-actions {
    position: absolute;
    top: var(--space-sm);
    right: var(--space-sm);
    display: flex;
    gap: var(--space-xs);
    opacity: 0.7;
    transition: opacity var(--transition-base);
}

.memo-card:hover .memo-card-actions {
    opacity: 1;
}

.memo-action-btn {
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
}

.memo-action-btn svg {
    width: 14px;
    height: 14px;
}

.memo-action-btn.edit:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.memo-action-btn.delete:hover {
    background: var(--accent-danger);
    border-color: var(--accent-danger);
    color: white;
}

/* On retire l'ancien bouton de suppression unique */
.delete-memo-btn {
    display: none;
}

/* Modale de lecture (Quick View) */
.modal-content.view {
    max-width: 650px;
    padding: var(--space-lg);
}

.memo-view-title {
    font-size: 1.4rem;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: var(--space-xs);
}

.memo-view-text {
    font-size: 1.1rem;
    line-height: 1.7;
    color: var(--text-secondary);
    white-space: pre-wrap;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: var(--space-sm);
}

.memo-view-text::-webkit-scrollbar {
    width: 6px;
}

.memo-view-text::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

/* ===== VUE OUTILS ===== */
.tools-content {
    padding: var(--space-xl);
    max-width: 1200px;
    margin: 0 auto;
}

.tool-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow-md);
}

.tool-row {
    display: flex;
    gap: var(--space-xl);
    margin-bottom: var(--space-xl);
}

.tool-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.tool-column label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent-primary);
}

.tool-column textarea {
    height: 300px;
    padding: var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.95rem;
    line-height: 1.5;
    resize: none;
    transition: border-color var(--transition-base);
}

.tool-column textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.tool-column textarea[readonly] {
    background: var(--bg-hover);
    cursor: default;
}

.tool-actions {
    display: flex;
    justify-content: center;
    gap: var(--space-lg);
    border-top: 1px solid var(--border-color);
    padding-top: var(--space-xl);
}

.tool-actions .btn-primary,
.tool-actions .btn-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: var(--space-sm) var(--space-xl);
}

/* Scrollbars pour les outils */
.tool-column textarea::-webkit-scrollbar {
    width: 6px;
}

.tool-column textarea::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 3px;
}

.tool-column textarea::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.tool-column textarea::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

@media (max-width: 900px) {
    .tool-row {
        flex-direction: column;
    }

    .tool-column textarea {
        height: 200px;
    }
}

/* ===== VUE CONTRÃ”LE QUALITÃ‰ ===== */
.qc-content {
    padding: var(--space-xl);
    padding-top: 110px;
    /* Ã‰vite le chevauchement avec le header fixe */
    max-width: 1400px;
    margin: 0 auto;
}

.qc-layout {
    display: flex;
    gap: var(--space-xl);
    align-items: flex-start;
}

.qc-table-container {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.qc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.qc-table th {
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-weight: 600;
    text-align: left;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 2px solid var(--border-color);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
}

.qc-table td {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.qc-category-label {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.85rem;
    color: #333;
    /* Texte sombre sur fonds pastels */
    white-space: nowrap;
}

.qc-point-text {
    line-height: 1.4;
    color: var(--text-primary);
}

.qc-status-toggle {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    padding: 3px;
    border-radius: 8px;
    width: fit-content;
}

.status-btn {
    padding: 4px 12px;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    background: transparent;
    color: var(--text-muted);
    transition: all 0.2s;
}

.status-btn:hover {
    color: var(--text-primary);
}

.status-btn.oui.active {
    background: var(--accent-success);
    color: white;
}

.status-btn.non.active {
    background: var(--accent-danger);
    color: white;
}

.qc-missing-input {
    width: 100%;
    min-height: 36px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.85rem;
    line-height: 1.4;
    font-family: inherit;
    resize: vertical;
    transition: all 0.2s;
}

.qc-missing-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: var(--bg-card);
}

/* SynthÃ¨se QC */
.qc-summary-sidebar {
    width: 350px;
    position: sticky;
    top: 120px;
    /* Header (80px) + space (40px) */
}

.qc-summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow-lg);
}

.qc-summary-card h3 {
    margin-bottom: var(--space-lg);
    color: var(--accent-primary);
    font-size: 1.1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: var(--space-md);
}

/* Number selector for demande de pièces */
.demande-num-btn {
    width: 22px;
    height: 22px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-hover);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.demande-num-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.demande-num-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
}

.demande-header-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: var(--space-sm);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border-color);
}

.demande-header-row h3 {
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    flex-shrink: 0;
}

.btn-expand-demande {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 8px;
    margin-top: var(--space-sm);
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: var(--radius-md);
    color: var(--accent-primary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-expand-demande:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--accent-primary);
}

.qc-metrics {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.qc-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.metric-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.metric-value {
    font-weight: 700;
    font-size: 1.1rem;
}

.metric-value.success {
    color: var(--success);
}

.metric-value.danger {
    color: var(--danger);
}

.qc-metric-total {
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-color);
}

/* Progress Bar Refactoring */
.metric-progress-layout {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.metric-progress-track {
    flex: 1;
    height: 12px;
    background: var(--bg-hover);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border-color);
}

.metric-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    transition: width 0.5s ease;
}

.metric-percentage {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 40px;
    text-align: right;
}

/* ===== DOSSIER MANAGER MODAL ===== */
.dossier-modal-content {
    max-width: 550px;
    width: 90%;
}

.dossier-modal-content .modal-body {
    padding: var(--space-xl);
}

.dossier-creation {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
    padding-bottom: var(--space-xl);
    border-bottom: 1px solid var(--border-color);
}

.dossier-creation input {
    flex: 1;
    min-width: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    color: white;
    font-family: inherit;
    font-size: 0.9rem;
}

.dossier-creation input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.dossier-creation .btn-primary {
    flex-shrink: 0;
    padding: 12px 24px;
}

.dossier-list-wrapper h3 {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--space-md);
}

.dossier-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    max-height: 280px;
    overflow-y: auto;
    margin-right: -8px;
    padding-right: 8px;
}

/* Scrollbar stylÃ©e pour le gestionnaire de dossiers */
.dossier-grid::-webkit-scrollbar {
    width: 8px;
}

.dossier-grid::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

.dossier-grid::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.dossier-grid::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.dossier-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.dossier-card:hover {
    border-color: var(--accent-primary);
    background: var(--bg-hover);
}

.dossier-card.active {
    border-color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.08);
}

.dossier-card-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 8px;
    color: var(--accent-primary);
    flex-shrink: 0;
}

.dossier-card-icon svg {
    width: 20px;
    height: 20px;
}

.dossier-card-info {
    flex: 1;
    min-width: 0;
}

.dossier-card-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dossier-active-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent-success);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

.btn-delete-dossier {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-delete-dossier:hover {
    color: var(--accent-danger);
    background: rgba(239, 68, 68, 0.1);
}

.dossier-empty-state {
    text-align: center;
    padding: var(--space-2xl) var(--space-lg);
    color: var(--text-muted);
}

.dossier-empty-state svg {
    color: var(--text-muted);
    opacity: 0.5;
    margin-bottom: var(--space-md);
}

.dossier-empty-state p {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.dossier-empty-state span {
    font-size: 0.85rem;
}

/* HEADER DOSSIER PILL */
.header-dossier-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 20px;
    padding: 6px 14px;
    margin-top: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.header-dossier-pill:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--accent-primary);
}

.header-dossier-pill span {
    color: var(--accent-primary);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.header-dossier-pill span.no-dossier {
    color: var(--text-muted);
    font-style: italic;
    text-transform: none;
    font-weight: 500;
}

@media (max-width: 1200px) {
    .qc-layout {
        flex-direction: column;
    }

    .qc-summary-sidebar {
        width: 100%;
        position: static;
    }
}

/* ===== MODALE PIECES MANQUANTES ===== */
/* Bouton Détail pour pièces manquantes */
.qc-btn-detail {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 4px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.qc-btn-detail:hover:not([disabled]) {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--text-primary);
}

.qc-btn-detail.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.qc-btn-detail:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--bg-secondary);
}

/* Modale */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 90%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    animation: modalSlideUp 0.3s ease-out;
}

@keyframes modalSlideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
}

.modal-body {
    padding: var(--space-lg);
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: var(--bg-secondary);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.btn-add-line {
    display: block;
    width: 100%;
    padding: 8px;
    margin-top: 10px;
    background: var(--bg-hover);
    border: 1px dashed var(--border-color);
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-add-line:hover {
    background: var(--bg-secondary);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.missing-item-input {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.2s;
}

.missing-item-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Common buttons for modal */
.btn-primary,
.btn-secondary {
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    font-size: 0.9rem;
    border: none;
    transition: background 0.2s;
}

/* Modale de Preview en plein écran */
.modal.fullscreen-mode .modal-content.preview-modal-content {
    max-width: 100% !important;
    width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0;
    border: none;
}

.modal.fullscreen-mode .preview-modal-body {
    height: calc(100vh - 130px);
}

.preview-toolbar .btn-icon {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    cursor: pointer;
    transition: background var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-toolbar .btn-icon:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ===== DOCUMENTATION VIEW ===== */
.docs-container {
    padding-top: 180px;
    max-width: 1400px;
    margin: 0 auto;
}

.docs-actions {
    margin-bottom: var(--space-xl);
}

.upload-zone-docs {
    background: var(--bg-card);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
}

.upload-zone-docs:hover {
    border-color: var(--accent-primary);
    background: var(--bg-hover);
}

.upload-zone-docs.drag-over {
    border-color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.1);
    transform: translateY(-2px);
}

.upload-icon {
    width: 64px;
    height: 64px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
    margin-bottom: var(--space-sm);
    flex-shrink: 0;
}

.upload-icon svg {
    width: 32px !important;
    height: 32px !important;
    display: block;
}

.upload-text h3 {
    font-size: 1.25rem;
    margin-bottom: 4px;
}

.upload-text p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.upload-text span {
    font-size: 0.8rem;
    color: var(--accent-primary);
    font-weight: 500;
}

.docs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
    gap: var(--space-md);
}

.docs-search {
    flex: 1;
    max-width: 400px;
}

.docs-search input {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all 0.2s;
}

.docs-search input:focus {
    border-color: var(--accent-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.docs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-lg);
}

.doc-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.doc-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-lg);
}

.doc-card-main {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.doc-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.doc-icon.pdf {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.doc-icon.excel {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.doc-icon.image {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.doc-icon.other {
    background: rgba(107, 114, 128, 0.1);
    color: #6b7280;
}

.doc-info {
    flex: 1;
    min-width: 0;
}

.doc-name {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.doc-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    gap: 8px;
}

.doc-card-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--border-color);
}

.btn-doc-action {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-doc-action:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-doc-action.delete:hover {
    color: #ef4444;
    border-color: #ef4444;
}

.doc-empty-state {
    grid-column: 1 / -1;
    padding: var(--space-2xl);
    text-align: center;
    color: var(--text-muted);
}

/* ===== DOCUMENTATION PREVIEW MODAL ===== */
.preview-modal-content {
    width: 90%;
    max-width: 1200px;
    height: 85vh;
    display: flex;
    flex-direction: column;
}

.preview-modal-body {
    flex: 1;
    overflow: hidden;
    padding: 0;
    background: #111;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.preview-container embed,
.preview-container iframe {
    width: 100%;
    height: 100%;
    background: white;
}

/* ===== DASHBOARD (HOME) ===== */
#view-home {
    padding: 0;
    padding-bottom: var(--space-2xl);
    background: var(--bg-primary);
}

.dashboard-hero {
    padding: var(--space-2xl) var(--space-lg);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    text-align: center;
    margin-bottom: var(--space-2xl);
}

.hero-content {
    max-width: 800px;
    margin: 0 auto;
}

.hero-logo {
    width: 120px;
    height: auto;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-xl);
    padding: 15px;
    margin-bottom: var(--space-lg);
    box-shadow: var(--shadow-md);
}

.dashboard-hero h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: var(--space-sm);
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.dashboard-hero p {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: var(--space-xl);
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-xl);
}

.dashboard-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    display: flex;
    align-items: flex-start;
    gap: var(--space-lg);
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.dashboard-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: transparent;
    transition: background var(--transition-base);
}

.dashboard-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-lg);
    background: var(--bg-hover);
}

.dashboard-card:hover::before {
    background: var(--accent-primary);
}

.card-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.card-icon svg {
    width: 28px;
    height: 28px;
    color: white;
}

.card-icon.assistant {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.card-icon.qc {
    background: linear-gradient(135deg, #10b981, #059669);
}

.card-icon.docs {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
}

.card-icon.memo {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.card-icon.tools {
    background: linear-gradient(135deg, #6b7280, #4b5563);
}

.card-info h3 {
    font-size: 1.25rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.card-info p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
    line-height: 1.5;
}

.card-action {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent-primary);
    display: flex;
    align-items: center;
}

/* ===== ACTIONS BAR (EXPORT/IMPORT) ===== */
.actions-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--space-xl);
    margin-top: var(--space-xl);
}

.actions-bar {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-md) var(--space-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
    gap: var(--space-md);
}

.actions-group {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.actions-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 16px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.action-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.action-btn svg {
    width: 18px;
    height: 18px;
    color: var(--accent-primary);
}

.action-btn.secondary {
    border-color: var(--accent-secondary);
    color: var(--text-secondary);
}

.action-btn.secondary:hover {
    color: var(--text-primary);
    background: rgba(79, 70, 229, 0.1);
}

/* ===== MEMO SEARCH BAR CORRECTION ===== */
.search-bar {
    position: relative;
    max-width: 400px;
    width: 100%;
}

.search-bar input {
    width: 100%;
    padding: 10px 16px;
    padding-right: 40px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all var(--transition-base);
}

.search-bar input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
    outline: none;
}

.search-bar svg {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
    pointer-events: none;
}

/* ===== DOSSIER MANAGER INPUT CORRECTION ===== */
#new-dossier-input {
    width: 100%;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all var(--transition-base);
}

#new-dossier-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
    outline: none;
}

/* ===== MISSING ITEMS REQUEST ZONE ===== */
.mt-4 {
    margin-top: 1.5rem;
}

.missing-items-textarea {
    width: 100%;
    min-height: 120px;
    height: 150px;
    padding: 10px;
    margin-bottom: 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
    font-family: inherit;
}

/* Full-screen overlay for textarea */
.textarea-fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
    animation: fadeIn 0.2s ease;
}

.textarea-fullscreen-overlay .fullscreen-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 900px;
    margin-bottom: var(--space-md);
}

.textarea-fullscreen-overlay .fullscreen-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.textarea-fullscreen-overlay .fullscreen-close {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    padding: 6px 14px;
    font-size: 0.85rem;
    transition: all var(--transition-fast);
}

.textarea-fullscreen-overlay .fullscreen-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.textarea-fullscreen-overlay textarea {
    width: 100%;
    max-width: 900px;
    flex: 1;
    padding: var(--space-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.7;
    resize: none;
    font-family: inherit;
}

.textarea-fullscreen-overlay .fullscreen-editor-wrapper {
    width: 100%;
    max-width: 900px;
    flex: 1;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-card);
}

.textarea-fullscreen-overlay .fullscreen-editor-wrapper .editor-toolbar {
    border-radius: 0;
    background: var(--bg-secondary);
}

.fullscreen-editor-content {
    flex: 1 !important;
    max-height: none !important;
    min-height: 300px !important;
    padding: var(--space-lg) !important;
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.7;
    overflow-y: auto;
    outline: none;
}

.fullscreen-editor-content:focus {
    box-shadow: inset 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.textarea-fullscreen-overlay .fullscreen-actions {
    display: flex;
    gap: 10px;
    width: 100%;
    max-width: 900px;
    margin-top: var(--space-md);
}

.btn-gpt-request {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
}

/* Disabled Editor Styling */
.editor-content[contenteditable="false"],
.editor-content.disabled {
    background-color: var(--bg-hover);
    /* Darker background */
    color: var(--text-muted);
    /* Muted text */
    cursor: not-allowed;
    opacity: 0.7;
    /* pointer-events: none; Default tooltip requires pointer events */
    border-color: transparent;
}

/* Copied Animation State */
.btn-secondary.copied,
.copy-btn.copied {
    background-color: var(--accent-success) !important;
    border-color: var(--accent-success) !important;
    color: white !important;
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.5);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-gpt-request:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-gpt-request svg {
    width: 18px;
    height: 18px;
}

/* ===== CUSTOM SCROLLBAR FOR MISSING ITEMS TEXTAREA ===== */
.missing-items-textarea::-webkit-scrollbar {
    width: 6px;
}

.missing-items-textarea::-webkit-scrollbar-track {
    background: transparent;
}

.missing-items-textarea::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 4px;
}

.missing-items-textarea::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-muted);
}

/* ===== GLOBAL CUSTOM SCROLLBAR ===== */
/* Applique le style fin Ã  tous les Ã©lÃ©ments dÃ©filables */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-muted);
}

/* ===== DISABLED STATES (SAFE MODE) ===== */
button:disabled,
textarea:disabled,
input:disabled {
    cursor: not-allowed !important;
    opacity: 0.6;
    filter: grayscale(100%);
    pointer-events: auto;
    /* Permet le hover pour le tooltip */
}

/* Specific overrides for buttons to look clearly disabled */
.gpt-btn:disabled,
.ai-btn:disabled,
.tab-btn:disabled,
.status-btn:disabled,
.copy-btn:disabled {
    background: var(--bg-hover) !important;
    color: var(--text-muted) !important;
    box-shadow: none !important;
    border-color: var(--border-color) !important;
}

textarea:disabled,
input[type="text"]:disabled {
    background-color: var(--bg-secondary) !important;
    color: var(--text-muted) !important;
}

/* ===== FIX DISABLED STATE FOR IMPORT BUTTONS ===== */
.import-btn:disabled,
.module-import-btn:disabled {
    background: var(--bg-hover) !important;
    color: var(--text-muted) !important;
    box-shadow: none !important;
    border: 1px solid var(--border-color) !important;
    cursor: not-allowed !important;
    transform: none !important;
}

/* Confirmation Modal */
.confirm-modal-content {
    max-width: 400px !important;
    border-radius: 16px;
}

/* Mini Modal Mode */
.modal.mini-mode {
    background-color: transparent !important;
    backdrop-filter: none !important;
}

.modal.mini-mode .modal-content {
    width: 300px !important;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3) !important;
}


/* Refinement for Mini Confirmation Modal */
.modal.mini-mode .modal-header {
    display: none;
}

.modal.mini-mode .modal-body {
    text-align: center;
    padding: var(--space-md);
}

.modal.mini-mode .modal-actions {
    justify-content: center !important;
    margin-top: var(--space-md);
}

.modal.mini-mode .modal-content {
    border-radius: var(--radius-md);
    border: 1px solid var(--accent-danger);
    padding: 5px;
}

#btn-confirm-ok {
    background-color: var(--accent-danger);
}

#btn-confirm-ok:hover {
    background-color: #b91c1c;
}



/* Refined Documentation View Styles */
.docs-hero {
    padding: var(--space-2xl) var(--space-lg);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    text-align: center;
    margin-bottom: var(--space-xl);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
}

.docs-hero h1 {
    font-size: 2.2rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.docs-hero p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto;
}

.docs-container {
    padding-top: 0 !important;
}

.docs-header-centered {
    display: flex;
    justify-content: center;
    margin-bottom: var(--space-xl);
}

.docs-search {
    position: relative;
    width: 100%;
    max-width: 500px;
}

.docs-search .search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    pointer-events: none;
}

.docs-search input {
    padding-right: 40px !important;
}

.upload-zone-docs {
    max-width: 800px;
    width: 100%;
    margin-top: var(--space-md);
}


/* Redesign refinements */
.docs-hero {
    padding: var(--space-xl) var(--space-lg) !important;
}

.docs-grid {
    justify-content: flex-start;
    justify-items: start;
}

.doc-card {
    width: 100%;
    max-width: 250px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    transition: all var(--transition-base);
}

.doc-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-primary);
}

.doc-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-xs);
}

.doc-icon svg {
    width: 20px;
    height: 20px;
}

.doc-icon.pdf {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.doc-icon.excel {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.doc-icon.image {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-primary);
}

.doc-icon.other {
    background: rgba(156, 163, 175, 0.1);
    color: var(--text-secondary);
}

.doc-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.doc-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doc-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    gap: 8px;
}

.doc-actions {
    display: flex;
    gap: 6px;
    margin-top: auto;
    padding-top: var(--space-sm);
    border-top: 1px solid var(--border-color);
}

.doc-action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.doc-action-btn svg {
    width: 16px;
    height: 16px;
}

.doc-action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.doc-action-btn.delete:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-color: var(--danger);
}


/* CSS Refinement for Documentation */
.docs-grid {
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)) !important;
    justify-content: start !important;
    justify-items: start !important;
}

.docs-hero {
    padding: var(--space-lg) var(--space-md) !important;
    gap: 10px !important;
}

.docs-hero h1 {
    font-size: 1.8rem !important;
    margin-bottom: 0 !important;
}

.upload-zone-docs {
    padding: var(--space-lg) !important;
}



/* ===== AUDIT QUALITÉ VIEW ===== */
.audit-container {
    padding: var(--space-xl);
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
}

.audit-grid-layout {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: var(--space-xl);
}

@media (max-width: 1200px) {
    .audit-grid-layout {
        grid-template-columns: 1fr;
    }
}

.audit-status-badge {
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 700;
    color: white;
    background: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.audit-status-badge.ok {
    background: var(--success);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.4);
}

.audit-status-badge.warning {
    background: var(--warning);
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.4);
}

.audit-status-badge.danger {
    background: var(--danger);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
}

.audit-summary-grid {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: var(--space-md);
}

.audit-module-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.2s;
}

.audit-module-card.status-ok {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.05);
}

.audit-module-card.status-warning {
    border-color: var(--warning);
    background: rgba(245, 158, 11, 0.05);
}

.audit-module-card.status-danger {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.05);
}

.audit-module-card .module-letter {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.audit-module-card .module-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 600;
}

.audit-findings-card,
.audit-financial-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow-sm);
}

.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
}

.findings-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.finding-item {
    display: flex;
    gap: var(--space-md);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    border-left: 4px solid transparent;
    background: var(--bg-secondary);
}

.finding-item.bloquant {
    border-left-color: var(--danger);
}

.finding-item.majeur {
    border-left-color: var(--warning);
}

.finding-item.mineur {
    border-left-color: var(--accent-primary);
}

.finding-content h4 {
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.finding-content p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.finding-action {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-primary);
    text-transform: uppercase;
    cursor: pointer;
}

.financial-drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-xl);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.financial-drop-zone:hover {
    border-color: var(--accent-primary);
    background: var(--bg-hover);
}

.financial-drop-zone svg {
    width: 40px;
    height: 40px;
    color: var(--text-muted);
}

.audit-footer-actions {
    border-top: 1px solid var(--border-color);
    padding-top: var(--space-xl);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
}


.card-icon.audit {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
}



/* ===== REFINEMENTS AUDIT LAYOUT ===== */
.audit-header {
    padding: 10px var(--space-xl);
    min-height: 70px;
}

.audit-header .logo-text h1 {
    font-size: 1.2rem;
}

.audit-container {
    padding-top: calc(70px + var(--space-xl));
}

.audit-status-badge {
    font-size: 0.75rem;
    padding: 6px 12px;
}


/* Enchancement de la luminosité pour le statut OK dans l'audit */
.audit-module-card.status-ok {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.1);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.1);
}

.audit-module-card.status-ok .module-letter {
    color: #10b981;
    text-shadow: 0 0 8px rgba(16, 185, 129, 0.3);
}

.audit-module-card.status-ok .module-title {
    color: #059669;
}


/* Styles pour le compteur de caractères */
.char-counter {
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
    transition: color 0.2s ease;
}

.char-counter.limit-exceeded {
    color: #ef4444;
    /* Rouge erreur */
    font-weight: 500;
}

textarea.limit-exceeded {
    border-color: #ef4444 !important;
    background-color: rgba(239, 68, 68, 0.05);
}

textarea.limit-exceeded:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

/* ===== MODAL DOSSIERS ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 24px;
    max-width: 480px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid var(--border-color);
}

.modal-content h2 {
    margin: 0 0 20px;
    color: var(--text-primary);
}

.new-dossier-form {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.new-dossier-form input {
    flex: 1;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
}

.new-dossier-form button {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    background: var(--accent-primary);
    color: white;
    cursor: pointer;
    font-weight: 600;
}

.dossiers-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.dossier-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
}

.dossier-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
}

.dossier-item.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.delete-dossier-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 0, 0, 0.2);
    color: #ff6b6b;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

.delete-dossier-btn:hover {
    background: #ff6b6b;
    color: white;
}

.close-modal-btn {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    margin-top: 16px;
}

.no-dossiers {
    text-align: center;
    color: var(--text-muted);
    padding: 20px;
}

/* ===== RICH TEXT EDITOR ===== */
.rich-editor-container {
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all var(--transition-base);
}

.rich-editor-container:focus-within {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-sm);
}

.editor-toolbar {
    display: flex;
    gap: 4px;
    padding: 8px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.editor-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.editor-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.editor-btn.active {
    background: var(--accent-primary);
    color: white;
}

.editor-btn svg {
    width: 16px;
    height: 16px;
}

.editor-separator {
    width: 1px;
    height: 20px;
    background: var(--border-color);
    margin: 4px;
}

.editor-content {
    min-height: 150px;
    max-height: 400px;
    overflow-y: auto;
    padding: 12px;
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.6;
    outline: none;
    white-space: pre-wrap;
}

/* Placeholder simulation for contenteditable */
.editor-content:empty:before {
    content: attr(placeholder);
    color: var(--text-muted);
    opacity: 0.7;
    pointer-events: none;
    display: block;
}

/* Editor content styling */
.editor-content ul,
.editor-content ol {
    padding-left: 20px;
    margin: 8px 0;
}

.editor-content b,
.editor-content strong {
    font-weight: 700;
    color: var(--text-primary);
}

.editor-content i,
.editor-content em {
    font-style: italic;
}

/* Override response-zone styles for the container */
.response-zone .rich-editor-container {
    margin-bottom: 5px;
}

/* ===== EXCEL SPLITTER ===== */
.excel-split-content {
    max-width: 900px;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-lg);
    padding-top: 80px;
}

.view-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.card-icon.excel-split {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

/* Upload Zone */
.es-upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl) var(--space-xl);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-base);
    background: var(--bg-card);
    position: relative;
}

.es-upload-zone:hover,
.es-upload-zone.dragover {
    border-color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.05);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.es-upload-zone.dragover {
    border-color: var(--accent-success);
    background: rgba(16, 185, 129, 0.05);
}

.es-upload-zone.has-file {
    border-color: var(--accent-success);
    background: rgba(16, 185, 129, 0.05);
}

.es-upload-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto var(--space-lg);
    background: rgba(59, 130, 246, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.es-upload-icon svg {
    width: 36px;
    height: 36px;
    color: var(--accent-primary);
}

.es-upload-text h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.es-upload-text p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: var(--space-lg);
}

.es-browse-btn {
    display: inline-flex;
    align-items: center;
    padding: var(--space-sm) var(--space-lg);
    font-size: 0.9rem;
}

/* File Info */
.es-file-info {
    margin-top: var(--space-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    animation: fadeInUp 0.3s ease;
}

.es-file-details {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.es-file-name {
    font-weight: 600;
    color: var(--text-primary);
    display: block;
}

.es-file-size {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Progress Bar */
.es-progress-container {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.es-progress-track {
    flex: 1;
    height: 6px;
    background: var(--bg-hover);
    border-radius: 3px;
    overflow: hidden;
}

.es-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--gradient-primary);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.es-progress-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Error */
.es-error {
    margin-top: var(--space-lg);
    padding: var(--space-md) var(--space-lg);
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-md);
    color: var(--accent-danger);
    font-size: 0.9rem;
    font-weight: 500;
    animation: fadeIn 0.3s ease;
}

/* Toolbar */
.es-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
}

.es-toolbar-left {
    display: flex;
    gap: var(--space-sm);
}

.es-toolbar-right {
    display: flex;
    gap: var(--space-sm);
}

.es-search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.es-search-icon {
    position: absolute;
    left: 10px;
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

.es-search-box input {
    padding: 8px 12px 8px 32px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
    transition: border-color var(--transition-fast);
    width: 220px;
}

.es-search-box input:focus {
    border-color: var(--accent-primary);
}

/* Counter */
.es-counter {
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: var(--space-sm) 0;
    font-weight: 500;
}

/* Sheets List */
.es-sheets-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    max-height: 400px;
    overflow-y: auto;
}

.es-sheet-item {
    display: flex;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    transition: background var(--transition-fast);
    gap: var(--space-md);
}

.es-sheet-item:hover {
    background: var(--bg-hover);
}

.es-sheet-item.hidden {
    display: none;
}

.es-sheet-item label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex: 1;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 500;
}

.es-sheet-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-primary);
    cursor: pointer;
    flex-shrink: 0;
}

.es-sheet-index {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-hover);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    min-width: 28px;
    text-align: center;
}

.es-sheet-download-btn {
    padding: 4px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.es-sheet-download-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.05);
}

.es-sheet-download-btn svg {
    width: 14px;
    height: 14px;
}

/* Actions */
.es-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    margin-top: var(--space-xl);
    flex-wrap: wrap;
}

.es-action-btn {
    padding: var(--space-sm) var(--space-lg);
    font-size: 0.9rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.es-action-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.es-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Dispatch Section */
.es-dispatch-divider {
    height: 1px;
    background: var(--border-color);
    margin: var(--space-lg) 0;
}

.es-dispatch-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-lg);
    flex-wrap: wrap;
}

.es-dispatch-info {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
    flex: 1;
    min-width: 200px;
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
}

.btn-success:hover {
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
    transform: translateY(-1px);
}

.es-dispatch-btn {
    white-space: nowrap;
}

/* Module dropdown per sheet */
.es-sheet-module {
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.75rem;
    cursor: pointer;
    outline: none;
    transition: border-color var(--transition-fast);
    min-width: 90px;
}

.es-sheet-module:focus {
    border-color: var(--accent-primary);
}

.es-sheet-module option {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* Generating Spinner */
.es-generating {
    text-align: center;
    padding: var(--space-2xl);
}

.es-spinner {
    width: 56px;
    height: 56px;
    border: 4px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    margin: 0 auto var(--space-lg);
    animation: esSpin 0.8s linear infinite;
}

@keyframes esSpin {
    to {
        transform: rotate(360deg);
    }
}

.es-generating h3 {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.es-generating-sub {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Done */
.es-done {
    text-align: center;
    padding: var(--space-2xl);
}

.es-done-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--space-lg);
    background: rgba(16, 185, 129, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeInUp 0.5s ease;
}

.es-done-icon svg {
    width: 40px;
    height: 40px;
    color: var(--accent-success);
}

.es-done h3 {
    font-size: 1.3rem;
    color: var(--accent-success);
    margin-bottom: var(--space-sm);
}

.es-done p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Step visibility */
.es-step {
    animation: fadeIn 0.3s ease;
}

/* ===== LOGIN MODAL ===== */
.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: loginFadeIn 0.4s ease;
}

.login-overlay.hidden {
    display: none;
}

@keyframes loginFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.login-modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl) var(--space-xl);
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg), 0 0 60px rgba(59, 130, 246, 0.1);
    text-align: center;
    animation: loginSlideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes loginSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.login-modal-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--space-lg);
    background: var(--gradient-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
}

.login-modal-icon svg {
    width: 32px;
    height: 32px;
    color: white;
}

.login-modal-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: var(--space-xl);
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    text-align: left;
}

.login-field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.login-field input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
}

.login-field input::placeholder {
    color: var(--text-muted);
}

.login-field input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.login-error {
    color: var(--accent-danger);
    font-size: 0.85rem;
    min-height: 1.2em;
    margin: 0;
    text-align: center;
    font-weight: 500;
}

.login-submit-btn {
    width: 100%;
    padding: 14px;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    margin-top: var(--space-sm);
}

.login-submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow), 0 4px 15px rgba(59, 130, 246, 0.3);
}

.login-submit-btn:active {
    transform: translateY(0);
}

.login-footer {
    margin-top: var(--space-lg);
    font-size: 0.75rem;
    color: var(--text-muted);
}

@keyframes loginFadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

@keyframes loginShake {

    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-10px);
    }

    40% {
        transform: translateX(10px);
    }

    60% {
        transform: translateX(-6px);
    }

    80% {
        transform: translateX(6px);
    }
}

/* ===== SAVE WORKSPACE BUTTON ===== */
.save-workspace-btn {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 8px 16px;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    white-space: nowrap;
    margin-left: var(--space-md);
}

.save-workspace-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow), 0 4px 15px rgba(59, 130, 246, 0.3);
}

.save-workspace-btn:active {
    transform: translateY(0);
}

/* ===== SAVE WORKSPACE MODAL ===== */
.save-workspace-modal-content {
    max-width: 460px;
}

.save-workspace-field {
    margin-bottom: var(--space-md);
}

.save-workspace-field label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.save-workspace-field input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.save-workspace-field input[type="text"]::placeholder {
    color: var(--text-muted);
}

.save-workspace-field input[type="text"]:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.save-workspace-checkbox {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.save-workspace-checkbox:hover {
    border-color: var(--accent-primary);
}

.save-workspace-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-primary);
    cursor: pointer;
}

.save-workspace-checkbox label {
    font-size: 0.9rem;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
}

/* ===== LOAD WORKSPACE MODAL ===== */
.load-workspace-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.load-workspace-btn:hover {
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.2), 0 4px 15px rgba(16, 185, 129, 0.3);
}

.load-workspace-modal-content {
    max-width: 720px;
    width: 90vw;
}

.workspace-sections {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
}

@media (max-width: 640px) {
    .workspace-sections {
        grid-template-columns: 1fr;
    }
}

.workspace-section-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border-color);
}

.workspaces-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    max-height: 360px;
    overflow-y: auto;
    padding-right: var(--space-xs);
}

.workspace-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.workspace-card:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.workspace-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
}

.workspace-card-meta {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    font-size: 0.78rem;
    color: var(--text-muted);
}

.workspace-card-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.workspace-open-btn {
    padding: 4px 12px;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform var(--transition-fast);
    white-space: nowrap;
    flex-shrink: 0;
}

.workspace-open-btn:hover {
    transform: scale(1.05);
}

.workspace-empty {
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-muted);
    font-size: 0.88rem;
    font-style: italic;
}

.close-workspace-btn {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.close-workspace-btn:hover {
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.2), 0 4px 15px rgba(239, 68, 68, 0.3);
}

.workspace-actions {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.workspace-delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.workspace-delete-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* ===== SAVE STATUS INDICATOR ===== */
.save-status {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-left: var(--space-sm);
    white-space: nowrap;
    transition: color var(--transition-fast);
}

.save-status.saving {
    color: var(--accent-warning);
    font-style: italic;
}

.save-status.saved {
    color: var(--accent-success);
}