/**
 * Workflow CSS - Module Factures
 * Styles pour l'interface de rapprochement BL/Factures
 */

/* ===== Variables ===== */
:root {
    /* Primaire */
    --primary: #3498db;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    
    /* Neutres */
    --text-dark: #2c3e50;
    --text-light: #7f8c8d;
    --bg-light: #ecf0f1;
    --bg-white: #ffffff;
    
    /* États */
    --selected: #ebf5fb;
    --hover: #3498db;
    --ok-bg: #eafaf1;
    --diff-bg: #fadbd8;
    --missing-bg: #fff3cd;
}

/* ===== Workflow Steps ===== */
.workflow-steps {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.step {
    flex: 1;
    padding: 15px;
    border-radius: 8px;
    background: var(--bg-light);
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-light);
    position: relative;
    cursor: pointer;
    transition: all 0.3s;
}

.step.active {
    background: var(--primary);
    color: white;
}

.step.completed {
    background: var(--success);
    color: white;
}

.step::after {
    content: '→';
    position: absolute;
    right: -15px;
    top: 50%;
    transform: translateY(-50%);
    color: #bdc3c7;
}

.step:last-child::after {
    content: '';
}

/* ===== Main Content Layout ===== */
.main-content {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

/* ===== Sidebar ===== */
.sidebar {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    max-height: 800px;
    overflow-y: auto;
}

.sidebar h2 {
    font-size: 18px;
    margin-bottom: 15px;
    color: var(--text-dark);
}

.bl-filters {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.bl-filters input,
.bl-filters select {
    padding: 8px 12px;
    border: 1px solid #dfe6e9;
    border-radius: 6px;
    font-size: 13px;
}

.bl-filters input:focus,
.bl-filters select:focus {
    outline: none;
    border-color: var(--primary);
}

/* ===== BL List ===== */
.bl-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ===== BL Card ===== */
.bl-card {
    border: 2px solid #e0e6ed;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
}

.bl-card:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.2);
}

.bl-card.selected {
    border-color: var(--primary);
    background: var(--selected);
}

.bl-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.bl-number {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 14px;
}

.bl-amount {
    font-weight: 700;
    color: var(--success);
    font-size: 14px;
}

.bl-info {
    font-size: 12px;
    color: var(--text-light);
    line-height: 1.5;
}

.bl-info div {
    margin-bottom: 3px;
}

.bl-status {
    margin-top: 8px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    display: inline-block;
}

.bl-status.status-parsed {
    background: #d5f4e6;
    color: var(--success);
}

.bl-status.status-validated {
    background: #d4edda;
    color: #155724;
}

.bl-status.status-pending {
    background: var(--missing-bg);
    color: #856404;
}

/* ===== Main Panel ===== */
.main-panel {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--bg-light);
}

.panel-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-dark);
}

/* ===== Buttons ===== */
.search-btn,
.btn {
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.search-btn,
.btn-primary {
    background: var(--primary);
    color: white;
}

.search-btn:hover,
.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text-dark);
}

.btn-secondary:hover {
    background: #d5dbdb;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

/* ===== Facture Grid ===== */
.facture-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.facture-card {
    border: 2px solid #e0e6ed;
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.facture-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.facture-card.selected {
    border-color: var(--success);
    background: var(--ok-bg);
}

.match-score {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: white;
}

.score-excellent {
    background: var(--success);
}

.score-good {
    background: var(--warning);
}

.score-poor {
    background: var(--danger);
}

.facture-number {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 15px;
    margin-bottom: 8px;
    padding-right: 60px;
}

.facture-info {
    font-size: 12px;
    color: var(--text-light);
    line-height: 1.6;
}

/* ===== Action Buttons ===== */
.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* ===== Comparison Section ===== */
.comparison-section {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 2px solid var(--bg-light);
}

.comparison-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.comparison-stats {
    display: flex;
    gap: 20px;
}

.stat {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.stat-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
}

.stat-icon.ok {
    background: #d5f4e6;
    color: var(--success);
}

.stat-icon.diff {
    background: var(--diff-bg);
    color: var(--danger);
}

.comparison-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.comparison-column {
    border: 1px solid #e0e6ed;
    border-radius: 8px;
    padding: 15px;
}

.column-title {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 15px;
    font-size: 16px;
}

.line-item {
    display: grid;
    grid-template-columns: 3fr 1fr 1fr 1fr;
    gap: 10px;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 8px;
    font-size: 13px;
    align-items: center;
}

.line-item.header {
    font-weight: 600;
    color: var(--text-light);
    background: #f8f9fa;
}

.line-item.ok {
    background: var(--ok-bg);
}

.line-item.different {
    background: var(--diff-bg);
}

.line-item.missing {
    background: var(--missing-bg);
}

.highlight-diff {
    background: #ffeb3b;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 600;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        max-height: 400px;
    }
    
    .facture-grid {
        grid-template-columns: 1fr;
    }
    
    .comparison-grid {
        grid-template-columns: 1fr;
    }
    
    .workflow-steps {
        flex-direction: column;
        gap: 5px;
    }
    
    .step::after {
        content: '↓';
        right: auto;
        top: auto;
        bottom: -15px;
        left: 50%;
        transform: translateX(-50%);
    }
    
    .step:last-child::after {
        content: '';
    }
}

/* ===== Search Form (Étape 3) ===== */
.search-form {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 30px;
    max-width: 600px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #2c3e50;
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #dcdfe6;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* ===== Invoices Grid ===== */
.invoices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

/* ===== Invoice Card ===== */
.invoice-card {
    background: #ffffff;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.invoice-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.15);
    transform: translateY(-2px);
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
}

.invoice-number {
    font-weight: 700;
    font-size: 16px;
    color: #2c3e50;
}

.invoice-amount {
    font-weight: 700;
    font-size: 18px;
    color: var(--success);
}

.invoice-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.invoice-info div {
    font-size: 13px;
    color: #606266;
}

/* ===== Loading Indicator ===== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    font-size: 18px;
    color: var(--primary);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* ===== Utilities ===== */
.hidden {
    display: none !important;
}

.text-muted {
    color: var(--text-light);
}

/* ===== Invoice Selection Styles ===== */
.invoice-card {
    position: relative;
}

.invoice-card.selected {
    border-color: var(--primary) !important;
    background: #e8f4fd !important;
}

.invoice-checkbox {
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 10;
}

.invoice-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.invoice-header {
    margin-left: 30px;
}

.invoice-info {
    margin-left: 30px;
}

/* ===== Parsing Progress ===== */
.parsing-progress {
    text-align: center;
    padding: 40px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.progress-bar {
    width: 100%;
    height: 30px;
    background: #ecf0f1;
    border-radius: 15px;
    overflow: hidden;
    margin: 20px 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--success));
    transition: width 0.3s ease;
    width: 0%;
}

/* ===== Parsing Results ===== */
.parsing-complete {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.results-summary {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.result-card {
    padding: 20px;
    border-radius: 8px;
    border: 2px solid;
}

.result-card.success {
    border-color: var(--success);
    background: #e8f8f5;
}

.result-card.error {
    border-color: var(--danger);
    background: #fdf0f0;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.result-details {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    font-size: 14px;
    color: var(--text-dark);
}

.result-error {
    color: var(--danger);
    font-size: 13px;
    margin-top: 10px;
}

.validation-badge {
    padding: 6px 14px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: bold;
}

.validation-badge.passed {
    background: var(--success);
    color: white;
}

.validation-badge.warning {
    background: var(--warning);
    color: white;
}

/* ===== Details Button ===== */
.btn-details {
    position: absolute;
    bottom: 12px;
    right: 12px;
    padding: 8px 14px;
    background: #2E7D32;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    z-index: 5;
    outline: none;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-details:hover {
    background: #1B5E20;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.3);
}

.btn-details:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Adjust card padding for details button */
.bl-card {
    position: relative;
    padding-bottom: 50px;
}

.invoice-card {
    position: relative;
    padding-bottom: 50px;
}

/* ===== NOUVEAU LAYOUT 3 COLONNES ===== */

/* ===== SOUS-ONGLETS CONTRÔLE ===== */
.control-subtabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    padding: 4px;
    background: #f1f3f4;
    border-radius: 12px;
    width: fit-content;
}

.subtab-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    background: transparent;
    font-size: 14px;
    font-weight: 600;
    color: #7f8c8d;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.subtab-btn:hover {
    color: var(--text-dark);
    background: rgba(255, 255, 255, 0.5);
}

.subtab-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ===== SÉLECTEUR DE SOURCE (Grossiste) ===== */
.source-selector {
    padding: 8px;
    background: #f8f9fa;
    border-radius: 10px;
    margin-bottom: 10px;
}

.source-selector.hidden {
    display: none;
}

.source-tabs {
    display: flex;
    gap: 4px;
}

.source-tab {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    background: transparent;
    font-size: 12px;
    font-weight: 600;
    color: #7f8c8d;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.source-tab:hover {
    color: var(--text-dark);
    background: rgba(255, 255, 255, 0.5);
}

.source-tab.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.source-tab[data-source="ocp"].active {
    color: #27ae60;
}

.source-tab[data-source="digipharmacie"].active {
    color: #9b59b6;
}

/* ===== FACTURES OCP CARDS ===== */
.facture-card.ocp-source {
    border-left: 3px solid #27ae60;
}

.facture-card.ocp-source .source-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 2px 8px;
    background: #27ae60;
    color: white;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
}

.facture-card.digi-source {
    border-left: 3px solid #9b59b6;
}

.facture-card.digi-source .source-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 2px 8px;
    background: #9b59b6;
    color: white;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
}

/* Override container pour workflow full-width */
.workflow-section {
    max-width: none;
    padding: 0 15px;
}

.workflow-section .container,
.main:has(.workflow-section) .container {
    max-width: none;
    padding: 0;
}

/* Section Header */
.workflow-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--bg-light);
}

.workflow-section .section-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0;
}

.btn-upload-toggle {
    padding: 8px 16px;
    font-size: 13px;
}

/* Layout Principal */
.workflow-layout {
    display: flex;
    gap: 20px;
    height: calc(100vh - 200px);
    min-height: 500px;
}

/* Colonnes */
.column {
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    overflow: hidden;
    transition: flex 0.3s ease;
}

.column-bl,
.column-factures,
.column-matching {
    flex: 1;
    min-width: 280px;
}

.column-matching {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px 20px;
    justify-content: flex-start;
}

.column.collapsed {
    flex: 0 0 60px;
    min-width: 60px;
    max-width: 60px;
}

.column.collapsed .column-filters,
.column.collapsed .column-actions,
.column.collapsed .column-list,
.column.collapsed .column-title span:not(.column-icon) {
    display: none;
}

.column.collapsed .column-header {
    flex-direction: column;
    padding: 15px 10px;
}

.column.collapsed .btn-collapse {
    margin-top: 10px;
}

/* Column Header */
.column-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: var(--bg-light);
    border-bottom: 1px solid #dfe6e9;
}

.column-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 16px;
    color: var(--text-dark);
}

.column-icon {
    font-size: 20px;
}

.column-count {
    font-weight: 400;
    color: var(--text-light);
    font-size: 14px;
}

.btn-collapse {
    background: none;
    border: none;
    font-size: 14px;
    color: var(--text-light);
    cursor: pointer;
    padding: 5px;
    transition: color 0.2s;
}

.btn-collapse:hover {
    color: var(--primary);
}

/* Column Filters */
.column-filters {
    padding: 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.filter-input,
.filter-supplier-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    width: 100%;
}

.filter-supplier-row .filter-select,
.filter-supplier-row .choices {
    flex: 1;
    min-width: 0;
    width: 100% !important;
}

.filter-supplier-row .choices__inner {
    width: 100% !important;
    min-width: 100% !important;
}

.btn-refresh-suppliers {
    padding: 0;
    border: 1px solid #dfe6e9;
    border-radius: 8px;
    background-color: white;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    transition: all 0.3s ease;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 0;
    align-self: flex-start;
}

.btn-refresh-suppliers:hover {
    background-color: var(--primary);
    border-color: var(--primary);
    transform: rotate(180deg);
}

.filter-select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.85rem;
    background-color: white;
}

.filter-input:focus,
.filter-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* ===== FILTRE PÉRIODE (Style épuré minimaliste) ===== */
.filter-period {
    margin-top: 5px;
}

.period-label {
    display: block;
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 6px;
}

.period-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-date {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #dfe6e9;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: white;
    color: var(--text-dark);
    transition: border-color 0.2s ease;
}

.filter-date:focus {
    outline: none;
    border-color: var(--primary);
}

.filter-date:hover {
    border-color: #b2bec3;
}

.period-arrow {
    color: var(--text-light);
    font-size: 14px;
    flex-shrink: 0;
}

/* Bouton recherche Digi */
.btn-search-digi {
    width: 100%;
    padding: 10px;
    font-size: 13px;
    margin-top: 5px;
    border-radius: 8px;
}

/* ===== BARRE DE SÉLECTION CONTEXTUELLE ===== */
.selection-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 15px;
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    color: white;
    border-bottom: 1px solid rgba(0,0,0,0.1);
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.selection-bar.hidden {
    display: none;
}

.selection-count {
    font-size: 13px;
    font-weight: 600;
    flex: 1;
}

.btn-selection {
    padding: 5px 12px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 6px;
    background: rgba(255,255,255,0.15);
    color: white;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-selection:hover {
    background: rgba(255,255,255,0.25);
    border-color: rgba(255,255,255,0.5);
}

.btn-selection:active {
    transform: scale(0.95);
}

.btn-selection.btn-parser {
    background: rgba(52, 152, 219, 0.3);
    border-color: rgba(255,255,255,0.5);
    font-weight: 600;
}

.btn-selection.btn-parser:hover {
    background: rgba(52, 152, 219, 0.5);
    border-color: rgba(255,255,255,0.7);
}

/* Column Actions */
.column-actions {
    display: flex;
    gap: 8px;
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
}

.btn-select-all,
.btn-deselect-all {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #dfe6e9;
    border-radius: 4px;
    background: white;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-select-all:hover {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.btn-deselect-all:hover {
    background: var(--bg-light);
}

/* Column List */
.column-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.loading-placeholder {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
    font-size: 14px;
}

/* ===== INDICATEUR DE PROGRESSION ===== */
.progress-indicator {
    display: flex;
    gap: 12px;
    margin-bottom: 30px;
}

.progress-pill {
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.progress-pill.empty {
    background: #eee;
    color: #999;
}

.progress-pill.filled {
    background: var(--success);
    color: white;
}

.progress-pill.loading {
    background: var(--primary);
    color: white;
    animation: pulse 1s infinite;
}

/* ===== MATCHING ACTION ===== */
.matching-action {
    margin-bottom: 30px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.btn-launch-matching {
    padding: 15px 30px;
    font-size: 16px;
    border-radius: 8px;
}

.btn-launch-matching:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn-auto-match {
    padding: 12px 24px;
    font-size: 14px;
    border-radius: 8px;
    border: 2px solid #1565C0;
    background: #E3F2FD;
    color: #0D47A1;
    cursor: pointer;
    font-weight: 600;
    margin-left: 12px;
    transition: background 0.2s, color 0.2s;
}
.btn-auto-match:hover {
    background: #1565C0;
    color: #fff;
}
.btn-auto-match:active {
    background: #0D47A1;
    color: #fff;
}

/* ===== AUTO-MATCH MODAL ===== */
.auto-match-spinner {
    text-align: center;
    padding: 60px 30px;
}
.spinner-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.spinner-container .spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #E0E0E0;
    border-top-color: #1565C0;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.spinner-text {
    margin-top: 20px;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}
.spinner-sub {
    margin-top: 8px;
    font-size: 14px;
    color: #666;
}
.spinner-hint {
    margin-top: 12px;
    font-size: 12px;
    color: #999;
    font-style: italic;
}

.auto-match-error {
    text-align: center;
    padding: 40px;
    color: #c62828;
}
.auto-match-error .error-detail {
    margin-top: 12px;
    padding: 12px;
    background: #FFEBEE;
    border-radius: 6px;
    font-family: monospace;
    font-size: 13px;
}

.auto-match-summary {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 24px;
}
.summary-card {
    flex: 1 1 80px;
    min-width: 80px;
    text-align: center;
    padding: 16px 8px;
    border-radius: 8px;
    background: #F5F5F5;
    margin: 0 4px 8px 4px;
}
.summary-card.success {
    background: #E8F5E9;
}
.summary-card.warning {
    background: #FFF8E1;
}
.summary-card.error {
    background: #FFEBEE;
}
.summary-card .summary-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: #333;
}
.summary-card.success .summary-value { color: #2E7D32; }
.summary-card.warning .summary-value { color: #F57F17; }
.summary-card.error .summary-value { color: #C62828; }
.summary-card .summary-label {
    display: block;
    font-size: 11px;
    color: #666;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table-auto-match {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.table-auto-match th {
    background: #F5F5F5;
    padding: 10px 8px;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    color: #666;
    border-bottom: 2px solid #E0E0E0;
    text-align: left;
}
.table-auto-match th.th-center {
    text-align: center;
}
.table-auto-match td {
    padding: 10px 8px;
    border-bottom: 1px solid #EEEEEE;
}
.table-auto-match td.td-center {
    text-align: center;
}
.table-auto-match td.td-fournisseur {
    font-weight: 600;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.table-auto-match td.td-numero {
    color: #666;
    font-size: 12px;
}
.table-auto-match .status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}
.table-auto-match .status-ok {
    background: #E8F5E9;
    color: #2E7D32;
}
.table-auto-match .status-warning {
    background: #FFF8E1;
    color: #F57F17;
}
.table-auto-match .status-error {
    background: #FFEBEE;
    color: #C62828;
}

/* ===== MATCHING LOADING ===== */
.matching-loading {
    text-align: center;
    padding: 30px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #eee;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== JAUGES ===== */
.matching-gauges {
    display: flex;
    gap: 40px;
    margin: 20px 0 30px;
}

.gauge-container {
    width: 120px;
    height: 120px;
    position: relative;
}

.gauge-svg {
    width: 100%;
    height: 100%;
}

.gauge-bg {
    fill: none;
    stroke: #eee;
    stroke-width: 8;
}

.gauge-arc {
    fill: none;
    stroke: var(--success);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dasharray 0.5s ease;
}

.gauge-value {
    font-size: 20px;
    font-weight: 700;
    fill: var(--text-dark);
    text-anchor: middle;
    dominant-baseline: middle;
}

.gauge-label {
    font-size: 12px;
    fill: var(--text-light);
    text-anchor: middle;
}

/* ===== MATCHING SUMMARY ===== */
.matching-summary {
    display: flex;
    gap: 30px;
    margin-bottom: 30px;
}

.summary-stat {
    text-align: center;
}

.summary-value {
    display: block;
    font-size: 32px;
    font-weight: 700;
    color: var(--success);
}

.summary-stat.warning .summary-value {
    color: var(--warning);
}

.summary-label {
    display: block;
    font-size: 12px;
    color: var(--text-light);
    margin-top: 5px;
}

/* ===== ACTIONS POST-MATCHING ===== */
.matching-actions-post {
    margin-top: 20px;
}

.btn-voir-bilan {
    padding: 12px 25px;
    font-size: 15px;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #219a52;
}

/* ===== CARDS BL/FACTURES DANS COLONNES ===== */
.column-list .bl-card,
.column-list .facture-card {
    padding: 12px;
    padding-bottom: 12px;
    margin-bottom: 0;
}

.column-list .bl-card .btn-details,
.column-list .facture-card .btn-details {
    position: static;
    margin-top: 10px;
    width: 100%;
}

/* Card avec checkbox */
.column-list .bl-card,
.column-list .facture-card {
    display: flex;
    flex-direction: column;
    position: relative;
}

.column-list .bl-card.selected,
.column-list .facture-card.selected {
    border-color: var(--success);
    background: #f0fff4;
}

/* ===== RESPONSIVE 3 COLONNES ===== */
@media (max-width: 1200px) {
    .column-bl,
    .column-factures {
        min-width: 220px;
    }
    
    .column-matching {
        flex: 0 0 260px;
    }
}

@media (max-width: 992px) {
    .workflow-layout {
        flex-direction: column;
        height: auto;
    }
    
    .column-bl,
    .column-factures,
    .column-matching {
        max-width: none;
        min-width: auto;
        flex: none;
    }
    
    .column-bl,
    .column-factures {
        max-height: 400px;
    }
    
    .column-matching {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        padding: 20px;
    }
    
    .progress-indicator {
        width: 100%;
        justify-content: center;
        margin-bottom: 20px;
    }
    
    .matching-gauges {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .workflow-section .section-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .workflow-section .section-title {
        font-size: 20px;
    }
    
    .column-list {
        padding: 10px;
    }
    
    .progress-pill {
        padding: 8px 14px;
        font-size: 12px;
    }
}

/* ===== MODAL BILAN ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-content.modal-large {
    max-width: 900px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #eee;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    color: var(--text-dark);
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-light);
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.modal-close:hover {
    color: var(--danger);
}

.modal-body {
    padding: 25px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px 25px;
    border-top: 1px solid #eee;
    background: #f9f9f9;
}

/* Bilan Stats */
.bilan-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.bilan-stat {
    text-align: center;
    padding: 20px;
    background: var(--bg-light);
    border-radius: 12px;
}

.bilan-stat.warning {
    background: #fff3cd;
}

.bilan-stat-value {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: var(--success);
    margin-bottom: 8px;
}

.bilan-stat.warning .bilan-stat-value {
    color: var(--warning);
}

.bilan-stat-label {
    font-size: 12px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Bilan Matches */
.bilan-matches {
    margin-top: 20px;
}

.bilan-matches h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: var(--text-dark);
}

.match-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto auto;
    gap: 15px;
    padding: 15px;
    background: white;
    border: 2px solid #eee;
    border-radius: 8px;
    margin-bottom: 10px;
    align-items: center;
}

.match-row.success {
    border-color: var(--success);
    background: #f0fff4;
}

.match-row.warning {
    border-color: var(--warning);
    background: #fffbeb;
}

.match-row.danger {
    border-color: var(--danger);
    background: #fff5f5;
}

.match-label {
    font-size: 11px;
    color: var(--text-light);
    display: block;
    margin-bottom: 4px;
}

.match-value {
    font-weight: 600;
    color: var(--text-dark);
}

.match-percent {
    font-size: 18px;
    font-weight: 700;
    color: var(--success);
}

.match-row.warning .match-percent {
    color: var(--warning);
}

.match-row.danger .match-percent {
    color: var(--danger);
}

/* Empty state small */
.empty-state-small {
    text-align: center;
    padding: 30px 15px;
    color: var(--text-light);
}

.empty-state-small p {
    margin: 0;
    font-size: 14px;
}

/* ===== SECTIONS FACTURES (HYBRIDE) ===== */
.factures-section {
    margin-bottom: 20px;
}

.factures-section .section-header {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.factures-section .section-header.parsed {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.factures-section .section-header.new {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

/* ===== PARSING/PARSED BADGES ===== */
.parsing-badge {
    position: absolute;
    bottom: 12px;
    right: 12px;
    padding: 6px 12px;
    background: #3498db;
    color: white;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    animation: pulse 1.5s infinite;
}

.parsed-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 4px 8px;
    background: #27ae60;
    color: white;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

/* Facture card parsée - Style DISTINCT de selected */
.facture-card.parsed {
    border-color: #95a5a6;     /* Gris neutre, pas vert */
    background: #f8f9fa;       /* Gris très clair */
    cursor: pointer;           /* Cliquable pour sélectionner */
}

.facture-card.parsed:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-color: #7f8c8d;
}

/* Facture parsée ET sélectionnée */
.facture-card.parsed.selected {
    border-color: var(--success) !important;
    background: #e8f5e9 !important;  /* Vert plus visible */
}

/* Facture header/info adjustment quand pas de checkbox */
.facture-card.parsed .facture-header,
.facture-card.parsed .facture-info {
    margin-left: 0;
}

/* Responsive Modal */
@media (max-width: 768px) {
    .bilan-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .match-row {
        grid-template-columns: 1fr 1fr;
    }
    
    .modal-content.modal-large {
        max-width: 100%;
    }
}

/* ===== BOUTON IMPORT BL & MODAL ===== */
.column-header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-icon {
    background: var(--primary);
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: white;
    font-weight: 600;
}

.btn-icon-emoji {
    font-size: 1.2rem;
}

.btn-icon-text {
    font-size: 0.85rem;
    letter-spacing: 0.3px;
}

.btn-icon:hover {
    background: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
}

.btn-icon:active {
    transform: translateY(0);
}

.modal-import-bl {
    max-width: 500px;
}

.import-bl-upload-area {
    border: 2px dashed var(--border, #dfe6e9);
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
}

.import-bl-upload-area:hover {
    border-color: var(--primary);
    background: #f8f9fa;
}

.import-bl-upload-area.dragging {
    border-color: var(--primary);
    background: #ebf5fb;
}

.import-bl-progress {
    margin-top: 1.5rem;
}

/* ===== MODAL BILAN MATCHING - REFONTE ===== */

/* Modal plus large */
.modal-content.modal-xl {
    max-width: 1100px;
    width: 95vw;
}

/* Header compact BL ↔ Facture */
.matching-header-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr auto;
    gap: 20px;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    margin-bottom: 20px;
}

.header-card {
    padding: 15px 20px;
    border-radius: 10px;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.header-card.bl-card {
    border-left: 4px solid #3498db;
}

.header-card.fact-card {
    border-left: 4px solid #27ae60;
}

.header-card .card-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #95a5a6;
    margin-bottom: 4px;
}

.header-card .card-value {
    font-size: 18px;
    font-weight: 700;
    color: #2c3e50;
}

.header-card .card-sub {
    font-size: 12px;
    color: #7f8c8d;
    margin-top: 2px;
}

.header-arrow {
    font-size: 28px;
    color: #bdc3c7;
    font-weight: 300;
}

.header-stats {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.header-stats .stat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.header-stats .stat-label {
    font-size: 11px;
    color: #7f8c8d;
    text-transform: uppercase;
    font-weight: 600;
}

.header-stats .stat-value {
    font-size: 20px;
    font-weight: 800;
}

.header-stats .stat-value.text-success {
    color: #27ae60;
}

.header-stats .stat-value.text-warning {
    color: #f39c12;
}

.header-stats .stat-value.text-danger {
    color: #e74c3c;
}

/* ===== TOOLBAR FILTRES ===== */
.matching-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.filter-tabs {
    display: flex;
    gap: 8px;
}

.filter-tab {
    padding: 8px 16px;
    border: 1px solid #dfe6e9;
    border-radius: 20px;
    background: white;
    font-size: 13px;
    font-weight: 500;
    color: #7f8c8d;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-tab:hover {
    border-color: #3498db;
    color: #3498db;
}

.filter-tab.active {
    background: #3498db;
    border-color: #3498db;
    color: white;
}

.filter-tab .count {
    display: inline-block;
    min-width: 20px;
    padding: 2px 6px;
    margin-left: 6px;
    background: rgba(0,0,0,0.1);
    border-radius: 10px;
    font-size: 11px;
}

.filter-tab.active .count {
    background: rgba(255,255,255,0.3);
}

.matching-legend {
    display: flex;
    gap: 15px;
    font-size: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #7f8c8d;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.legend-dot.ok { background: #27ae60; }
.legend-dot.prix { background: #f39c12; }
.legend-dot.qte { background: #9b59b6; }
.legend-dot.manquant { background: #e74c3c; }

/* ===== TABLEAU REFONTE ===== */
.table-matching-v2 {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.table-matching-v2 thead th {
    background: #f8f9fa;
    padding: 12px 10px;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #7f8c8d;
    border-bottom: 2px solid #e9ecef;
    position: sticky;
    top: 0;
    z-index: 10;
}

.table-matching-v2 thead th.th-product {
    text-align: left;
    width: 35%;
}

.table-matching-v2 thead th.th-center {
    text-align: center;
}

.table-matching-v2 tbody tr {
    transition: background 0.15s;
}

.table-matching-v2 tbody tr:hover {
    background: #f8f9fa;
}

.table-matching-v2 tbody td {
    padding: 14px 10px;
    border-bottom: 1px solid #f1f3f4;
    vertical-align: middle;
}

/* Cellule Produit */
.table-matching-v2 .td-product {
    max-width: 280px;
}

.product-name {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 2px;
    line-height: 1.3;
}

.product-code {
    font-size: 11px;
    color: #95a5a6;
    font-family: 'Monaco', 'Consolas', monospace;
}

/* Cellules Quantité */
.td-qte {
    text-align: center;
    font-weight: 600;
    font-size: 14px;
}

/* Cellules Prix avec comparaison */
.td-prix-compare {
    min-width: 140px;
}

.prix-compare {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-end;
}

.prix-bl {
    font-weight: 600;
    color: #2c3e50;
}

.prix-arrow {
    color: #bdc3c7;
    font-size: 12px;
}

.prix-fact {
    font-weight: 700;
    color: #27ae60;
}

/* Quand il y a écart */
.prix-compare.has-ecart .prix-bl {
    color: #e74c3c;
    text-decoration: line-through;
    font-weight: 400;
    font-size: 12px;
}

.prix-compare.has-ecart .prix-fact {
    color: #27ae60;
    font-size: 15px;
}

/* Cellule Écart */
.td-ecart {
    text-align: center;
    font-weight: 700;
    font-size: 13px;
}

.ecart-value.positive {
    color: #e74c3c;
}

.ecart-value.negative {
    color: #27ae60;
}

.ecart-value.neutral {
    color: #95a5a6;
}

/* Cellule Statut */
.td-statut {
    text-align: center;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-badge.status-ok {
    background: #d4edda;
    color: #155724;
}

.status-badge.status-prix {
    background: #fff3cd;
    color: #856404;
}

.status-badge.status-qte {
    background: #e8daef;
    color: #6c3483;
}

.status-badge.status-manquant {
    background: #f8d7da;
    color: #721c24;
}

.status-badge .status-icon {
    font-size: 12px;
}

/* ===== LIGNES COLORÉES ===== */
.table-matching-v2 tbody tr.row-ok {
    background: #f0fff4;
}

.table-matching-v2 tbody tr.row-ok:hover {
    background: #e6f9ed;
}

.table-matching-v2 tbody tr.row-ecart {
    background: #fffbeb;
}

.table-matching-v2 tbody tr.row-ecart:hover {
    background: #fef3c7;
}

.table-matching-v2 tbody tr.row-manquant {
    background: #fff5f5;
}

.table-matching-v2 tbody tr.row-manquant:hover {
    background: #fee2e2;
}

/* Ligne manquante - colonnes facture grisées */
.table-matching-v2 tbody tr.row-manquant .td-fact-empty {
    color: #d5d8dc;
    font-style: italic;
}

/* ===== TABLE CONTAINER SCROLLABLE ===== */
.table-container {
    max-height: 450px;
    overflow-y: auto;
    border: 1px solid #e9ecef;
    border-radius: 10px;
}

.table-container::-webkit-scrollbar {
    width: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: #f1f3f4;
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb {
    background: #bdc3c7;
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #95a5a6;
}

/* ===== RÉSUMÉ BAS DE MODAL ===== */
.matching-footer-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border-radius: 10px;
    margin-top: 20px;
}

.footer-totals {
    display: flex;
    gap: 30px;
}

.footer-total-item {
    display: flex;
    flex-direction: column;
}

.footer-total-label {
    font-size: 11px;
    color: #7f8c8d;
    text-transform: uppercase;
    font-weight: 600;
}

.footer-total-value {
    font-size: 18px;
    font-weight: 700;
    color: #2c3e50;
}

.footer-total-value.text-danger {
    color: #e74c3c;
}

.footer-total-value.text-success {
    color: #27ae60;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 992px) {
    .matching-header-grid {
        grid-template-columns: 1fr 1fr;
        gap: 15px;
    }
    
    .header-arrow {
        display: none;
    }
    
    .header-stats {
        grid-column: 1 / -1;
        flex-direction: row;
        justify-content: center;
    }
    
    .matching-toolbar {
        flex-direction: column;
        gap: 15px;
    }
    
    .table-matching-v2 {
        font-size: 12px;
    }
    
    .product-name {
        font-size: 12px;
    }
}

@media (max-width: 768px) {
    .modal-content.modal-xl {
        width: 100%;
        max-width: 100%;
        border-radius: 12px 12px 0 0;
        max-height: 95vh;
    }
    
    .matching-header-grid {
        grid-template-columns: 1fr;
    }
    
    .filter-tabs {
        flex-wrap: wrap;
    }
    
    .table-container {
        max-height: 350px;
    }
}

/* ===== BADGE PDF NON PARSÉ (OCP) ===== */
.unparsed-badge {
    display: inline-block;
    padding: 6px 12px;
    margin-top: 8px;
    background: #fff3e0;
    color: #e65100;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
}

/* ===== AUTO-MATCH : BOUTON + CANDIDATS ===== */

.bl-card-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.bl-card-actions .btn-details,
.bl-card-actions .btn-auto-match {
    position: static;
    flex: 1;
    text-align: center;
    justify-content: center;
}

/* Actions facture (Détails + Supprimer) */
.facture-card-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.facture-card-actions .btn-details {
    position: static;
    flex: 1;
    text-align: center;
    justify-content: center;
}

.btn-delete {
    padding: 8px 10px;
    background: #c62828;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-delete:hover {
    background: #b71c1c;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(198, 40, 40, 0.3);
}

.btn-delete:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-auto-match {
    padding: 8px 14px;
    background: #1565C0;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    outline: none;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-auto-match:hover {
    background: #0D47A1;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(21, 101, 192, 0.3);
}

.btn-auto-match:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Auto-match header */
.auto-match-header {
    padding: 12px;
    background: #E3F2FD;
    border-bottom: 2px solid #1565C0;
    margin-bottom: 8px;
}

.auto-match-title {
    display: block;
    font-weight: 700;
    font-size: 14px;
    color: #0D47A1;
}

.auto-match-meta {
    display: block;
    font-size: 12px;
    color: #546E7A;
    margin-top: 4px;
}

/* Candidate card */
.candidate-card {
    padding: 10px 12px;
    margin: 4px 8px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.candidate-card:hover {
    border-color: #1565C0;
    background: #F5F9FF;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.candidate-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.candidate-score {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
    min-width: 32px;
    text-align: center;
}

.candidate-score.score-high {
    background: #C8E6C9;
    color: #2E7D32;
}

.candidate-score.score-medium {
    background: #FFF9C4;
    color: #F57F17;
}

.candidate-score.score-low {
    background: #FFCDD2;
    color: #C62828;
}

.candidate-source {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
}

.candidate-source.source-bdd {
    background: #E8F5E9;
    color: #2E7D32;
}

.candidate-source.source-digi {
    background: #F3E5F5;
    color: #7B1FA2;
}

.candidate-parsed {
    display: inline-block;
    padding: 2px 6px;
    background: #E0F7FA;
    color: #00695C;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
}

.candidate-parsing {
    display: inline-block;
    padding: 2px 6px;
    background: #FFF3E0;
    color: #E65100;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    animation: pulse-opacity 1.2s infinite;
}

@keyframes pulse-opacity {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.candidate-action {
    margin-top: 6px;
    padding: 4px 0;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: #1565C0;
    border-top: 1px solid #e0e0e0;
}

.candidate-card.parsed .candidate-action {
    color: #2E7D32;
}

.candidate-info {
    font-size: 12px;
    color: #546E7A;
    line-height: 1.4;
}

.candidate-number {
    font-weight: 600;
    color: #263238;
    font-size: 13px;
}

/* ===== MAPPING FOURNISSEURS MODAL ===== */

.mapping-info {
    background: #E3F2FD;
    border: 1px solid #90CAF9;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 13px;
    color: #1565C0;
    line-height: 1.5;
}

.mapping-hint {
    margin-top: 4px;
    font-size: 12px;
    color: #1976D2;
    opacity: 0.85;
}

.mapping-rows {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
    padding: 4px 0;
}

.mapping-row {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: #FAFAFA;
    border: 1px solid #E0E0E0;
    border-radius: 8px;
    transition: border-color 0.2s;
}

.mapping-row.mapping-error {
    border-color: #E53935;
    background: #FFF3F3;
}

.mapping-bl-name {
    flex: 0 0 240px;
    display: flex;
    flex-direction: column;
}

.mapping-bl-name strong {
    font-size: 14px;
    color: #263238;
    word-break: break-word;
}

.mapping-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #90A4AE;
    margin-bottom: 2px;
    font-weight: 600;
}

.mapping-count {
    font-size: 11px;
    color: #78909C;
    margin-top: 2px;
}

.mapping-arrow {
    flex: 0 0 40px;
    text-align: center;
    font-size: 20px;
    color: #90A4AE;
}

.mapping-digi-select {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.mapping-digi-select select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #CFD8DC;
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
}

.mapping-digi-select .choices {
    margin-bottom: 0;
}

.mapping-digi-select .choices__inner {
    min-height: 38px;
    border-color: #CFD8DC;
    border-radius: 6px;
    font-size: 13px;
    padding: 4px 8px;
}

/* Multi-select : hauteur auto + chips */
.mapping-digi-select .choices[data-type*="select-multiple"] .choices__inner {
    min-height: 42px;
    max-height: 120px;
    overflow-y: auto;
}

.mapping-digi-select .choices__item.choices__item--selectable {
    font-size: 13px;
}

.mapping-digi-select .choices__item--choice[data-value] {
    padding: 6px 10px;
}

.mapping-digi-select .choices__list--multiple .choices__item {
    background: #1565C0;
    border: none;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 12px;
    font-weight: 500;
    margin: 2px 4px 2px 0;
}

.mapping-digi-select .choices__list--multiple .choices__item .choices__button {
    border-left: 1px solid rgba(255,255,255,0.3);
    margin-left: 6px;
    padding-left: 6px;
}

.mapping-digi-select .choices__list--dropdown {
    max-height: 250px;
}

.mapping-digi-select .choices__list--dropdown .choices__item--selectable {
    padding: 8px 12px;
    font-size: 13px;
}

/* ===== BILAN SPLIT LAYOUT (tableau + PDF) ===== */

.bilan-split-layout {
    display: flex;
    gap: 16px;
    min-height: 400px;
}

.bilan-table-col {
    flex: 1;
    min-width: 0;
    transition: flex 0.3s ease;
}

.bilan-table-col.bilan-table-col-shrink {
    flex: 0 0 55%;
}

.bilan-pdf-col {
    flex: 0 0 42%;
    display: flex;
    flex-direction: column;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    background: #f8f9fa;
}

.bilan-pdf-col.hidden {
    display: none;
}

/* PDF viewer header */
.pdf-viewer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #2c3e50;
    color: white;
}

.pdf-viewer-title {
    font-size: 13px;
    font-weight: 600;
}

.pdf-viewer-close {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: 0.8;
}

.pdf-viewer-close:hover {
    opacity: 1;
}

/* PDF iframe */
.pdf-viewer-iframe {
    flex: 1;
    border: none;
    width: 100%;
    min-height: 500px;
    background: white;
}

/* ===== BILAN HEADER (BL -> Facture) ===== */

.bilan-header-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #f8f9fa 0%, #eef2f7 100%);
    border-radius: 10px;
    margin-bottom: 16px;
}

.bilan-bl-info,
.bilan-fact-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.bilan-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #95a5a6;
    font-weight: 700;
}

.bilan-value {
    font-size: 16px;
    font-weight: 700;
    color: #2c3e50;
}

.bilan-sub {
    font-size: 12px;
    color: #7f8c8d;
}

.bilan-arrow {
    font-size: 22px;
    color: #bdc3c7;
    font-weight: 300;
    flex-shrink: 0;
}

.bilan-rate {
    margin-left: auto;
    text-align: center;
    flex-shrink: 0;
}

.bilan-rate-value {
    display: block;
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
}

.bilan-rate-label {
    font-size: 10px;
    text-transform: uppercase;
    color: #95a5a6;
    letter-spacing: 0.5px;
}

/* ===== INVOICE CHIPS ===== */

.bilan-invoices {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.bilan-invoice-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: white;
    border: 1px solid #d5dbdb;
    border-radius: 20px;
    font-size: 12px;
}

.chip-label {
    font-weight: 600;
    color: #2c3e50;
}

.chip-date {
    color: #95a5a6;
    font-size: 11px;
}

.chip-amount {
    font-weight: 600;
    color: #27ae60;
    font-size: 11px;
}

.chip-pdf-btn {
    background: #3498db;
    color: white;
    border: none;
    border-radius: 12px;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.chip-pdf-btn:hover {
    background: #2980b9;
}

/* ===== INVOICE BADGE (multi-factures) ===== */

.invoice-badge {
    display: inline-block;
    padding: 2px 8px;
    background: #eaf2f8;
    color: #2c81ba;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

/* ===== EXTRA PRODUCTS SECTION ===== */

.bilan-extra-section {
    margin-top: 16px;
    border: 1px solid #ffc107;
    border-radius: 10px;
    overflow: hidden;
}

.bilan-section-title {
    font-size: 13px;
    font-weight: 700;
    color: #856404;
    padding: 10px 16px;
    background: #fff8e1;
    margin: 0;
    border-bottom: 1px solid #ffe082;
}

.table-matching-v2 tbody tr.row-extra {
    background: #fffbf0;
}

.table-matching-v2 tbody tr.row-extra:hover {
    background: #fff3d4;
}

/* ===== QTE & PRIX DIFF MARKERS ===== */

.qte-bl {
    font-weight: 600;
    color: #2c3e50;
}

.qte-arrow {
    color: #bdc3c7;
    font-size: 11px;
    margin: 0 2px;
}

.qte-fact {
    font-weight: 700;
    color: #2c3e50;
}

.qte-fact.qte-diff {
    color: #e74c3c;
    font-weight: 700;
}

.prix-diff {
    color: #e74c3c;
    font-weight: 700;
}

/* ===== FUZZY LOW STATUS ===== */

.status-badge.status-fuzzy-low {
    background: #fce4ec;
    color: #c62828;
}

/* ===== TEXT UTILITIES ===== */

.text-success { color: #27ae60; }
.text-warning { color: #f39c12; }
.text-danger { color: #e74c3c; }
.text-center { text-align: center; }
.text-muted { color: #95a5a6; }

/* ===== RESPONSIVE BILAN ===== */

@media (max-width: 992px) {
    .bilan-split-layout {
        flex-direction: column;
    }

    .bilan-table-col.bilan-table-col-shrink {
        flex: 1;
    }

    .bilan-pdf-col {
        flex: none;
        height: 400px;
    }

    .bilan-header-row {
        flex-wrap: wrap;
    }
}
