/**
 * SARL AMAYRAF — Gestion des Achats (app.css)
 * Charte Graphique Exécutive : Bleu Nuit, Or Champagne & Bleu Roi
 */

:root {
    --navy-deep: #020b18;
    --navy-mid: #0a192f;
    --navy-surface: #0e2444;
    --navy-surface-hover: #132d56;
    --royal-blue: #0055D4;
    --royal-glow: rgba(0, 85, 212, 0.35);
    --gold-champagne: #D4AF37;
    --gold-light: #F3E5AB;
    --gold-glow: rgba(212, 175, 55, 0.3);
    --text-pure: #ffffff;
    --text-dim: #94a3b8;
    --text-muted: #64748b;
    --border-color: rgba(212, 175, 55, 0.2);
    --border-subtle: rgba(148, 163, 184, 0.15);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-heading: 'Cinzel', Georgia, serif;
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-main);
    background-color: var(--navy-deep);
    color: var(--text-pure);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
}

/* ======================================================== */
/* 1. HEADER & NAVIGATION                                   */
/* ======================================================== */
.app-header {
    background: rgba(10, 25, 47, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1440px;
    margin: 0 auto;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand-group {
    display: flex;
    align-items: center;
    gap: 14px;
}

.header-logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
}

.brand-title {
    display: block;
    font-family: var(--font-heading);
    font-size: 19px;
    font-weight: 700;
    letter-spacing: 2px;
    background: linear-gradient(135deg, #ffffff 30%, var(--gold-light) 70%, var(--gold-champagne) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-tag {
    display: block;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--gold-champagne);
}

.nav-tabs {
    display: flex;
    gap: 6px;
    background: rgba(2, 11, 24, 0.5);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
}

.nav-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-dim);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-tab:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
    background: linear-gradient(135deg, #012060 0%, #0045ba 100%);
    color: #ffffff;
    border: 1px solid rgba(212, 175, 55, 0.4);
    box-shadow: 0 4px 12px var(--royal-glow);
}

.badge-count {
    background: rgba(0, 85, 212, 0.35);
    color: #ffffff;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
}

.badge-year {
    background: rgba(212, 175, 55, 0.2);
    color: var(--gold-light);
    border: 1px solid rgba(212, 175, 55, 0.4);
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
}

.user-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(14, 36, 68, 0.6);
    border: 1px solid var(--border-subtle);
    padding: 6px 14px 6px 8px;
    border-radius: 20px;
}

.user-initials {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gold-champagne), #997819);
    color: #020b18;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 12px;
    letter-spacing: 0.5px;
}

.user-meta {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 12px;
    font-weight: 700;
    color: #ffffff;
}

.user-role {
    font-size: 10px;
    font-weight: 600;
    color: var(--gold-champagne);
    text-transform: uppercase;
}

.btn-logout {
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    width: 36px;
    height: 36px;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout:hover {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.1);
}

/* ======================================================== */
/* 2. MAIN LAYOUT & KPI STRIP                               */
/* ======================================================== */
.app-main {
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
    padding: 24px;
    flex: 1;
}

.kpi-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--navy-mid);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.kpi-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.kpi-value {
    font-size: 26px;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.2;
}

.kpi-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.highlight-gold {
    color: var(--gold-champagne) !important;
}

.highlight-blue {
    color: #60a5fa !important;
}

/* ======================================================== */
/* 3. TAB PANES & HEADERS                                   */
/* ======================================================== */
.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
    animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.pane-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 20px;
    gap: 16px;
    flex-wrap: wrap;
}

.pane-title {
    font-size: 22px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 4px;
}

.pane-desc {
    font-size: 13px;
    color: var(--text-dim);
}

.pane-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ======================================================== */
/* 4. BUTTONS & CONTROLS                                    */
/* ======================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, #012060 0%, #0045ba 50%, #0055D4 100%);
    border: 1px solid rgba(212, 175, 55, 0.6);
    color: #ffffff;
    box-shadow: 0 4px 12px var(--royal-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px var(--royal-glow), 0 0 10px var(--gold-glow);
    border-color: var(--gold-light);
}

.btn-secondary {
    background: var(--navy-surface);
    border: 1px solid var(--border-subtle);
    color: #ffffff;
}

.btn-secondary:hover {
    background: var(--navy-surface-hover);
    border-color: var(--border-color);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-dim);
}

.btn-outline:hover {
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.4);
}

.btn-warning {
    background: linear-gradient(135deg, #785700 0%, #a1770b 100%);
    border: 1px solid var(--gold-light);
    color: #ffffff;
}

.btn-warning:hover {
    background: linear-gradient(135deg, #916900 0%, #b8880c 100%);
}

.btn-danger {
    background: #dc2626;
    color: #ffffff;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 6px;
}

.w-full { width: 100%; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.ml-12 { margin-left: 12px; }
.font-mono { font-family: var(--font-mono); }
.font-bold { font-weight: 700; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-dim { color: var(--text-dim); }
.text-danger { color: #f87171; }
.text-xs { font-size: 11px; }
.text-sm { font-size: 12.5px; }

/* ======================================================== */
/* 5. FILTER PANEL                                          */
/* ======================================================== */
.filter-panel {
    background: var(--navy-mid);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.filter-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-field {
    flex: 1;
    min-width: 140px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-field.flex-2 {
    flex: 2;
    min-width: 220px;
}

.filter-field label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
}

.filter-field input,
.filter-field select,
.form-control {
    background: rgba(2, 11, 24, 0.7);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: #ffffff;
    font-family: inherit;
    font-size: 13px;
    padding: 8px 12px;
    height: 38px;
    outline: none;
    transition: all 0.2s ease;
}

.filter-field input:focus,
.filter-field select:focus,
.form-control:focus {
    border-color: var(--royal-blue);
    box-shadow: 0 0 10px var(--royal-glow);
}

.filter-actions {
    min-width: auto;
    flex: 0 0 auto;
}

/* ======================================================== */
/* 6. DATA TABLES                                           */
/* ======================================================== */
.table-card {
    background: var(--navy-mid);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}

.data-table th {
    background: rgba(14, 36, 68, 0.7);
    color: var(--text-dim);
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.08);
    color: #ffffff;
}

.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.data-table-sm th,
.data-table-sm td {
    padding: 8px 12px;
    font-size: 12px;
}

.table-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

/* Badges de Statut */
.status-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-brouillon { background: rgba(100, 116, 139, 0.2); color: #94a3b8; border: 1px solid #64748b; }
.status-valide { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid #10b981; }
.status-en_cours { background: rgba(0, 85, 212, 0.25); color: #60a5fa; border: 1px solid #0055D4; }
.status-receptionne { background: rgba(139, 92, 246, 0.2); color: #c084fc; border: 1px solid #8b5cf6; }
.status-cloture { background: rgba(212, 175, 55, 0.2); color: var(--gold-light); border: 1px solid var(--gold-champagne); }
.status-annule { background: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid #ef4444; }

.status-en_attente { background: rgba(245, 158, 11, 0.2); color: #fbbf24; border: 1px solid #f59e0b; }
.status-recu { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid #10b981; }
.status-converti { background: rgba(212, 175, 55, 0.25); color: var(--gold-light); border: 1px solid var(--gold-champagne); }

/* Actions en ligne */
.row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

.btn-action-icon {
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    width: 30px;
    height: 30px;
    color: var(--text-dim);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 13px;
}

.btn-action-icon:hover {
    color: #ffffff;
    background: var(--navy-surface-hover);
    border-color: var(--border-color);
}

.btn-action-icon.danger:hover {
    color: #ef4444;
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
}

/* ======================================================== */
/* 7. ARCHIVES SECTION                                      */
/* ======================================================== */
.archive-overview-grid {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
}

.archive-nav-card {
    background: var(--navy-mid);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px;
}

.archive-nav-card h3 {
    font-size: 13px;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 12px;
}

.year-selector-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.year-tab-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: rgba(2, 11, 24, 0.4);
    border: 1px solid transparent;
    color: var(--text-dim);
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.year-tab-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
}

.year-tab-item.active {
    background: linear-gradient(135deg, #012060, #0045ba);
    color: #ffffff;
    border-color: var(--gold-champagne);
}

.year-tab-item .tag-closed {
    font-size: 10px;
    padding: 2px 6px;
    background: rgba(212, 175, 55, 0.2);
    color: var(--gold-light);
    border-radius: 4px;
}

.year-tab-item .tag-active {
    font-size: 10px;
    padding: 2px 6px;
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border-radius: 4px;
}

.archive-detail-card {
    background: var(--navy-mid);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.archive-status-banner {
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 20px;
}

.archive-status-banner.banner-open {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid #10b981;
    color: #34d399;
}

.archive-status-banner.banner-locked {
    background: rgba(212, 175, 55, 0.15);
    border: 1px solid var(--gold-champagne);
    color: var(--gold-light);
}

.archive-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.metric-item {
    background: rgba(2, 11, 24, 0.5);
    padding: 14px;
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
}

.m-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; margin-bottom: 4px; }
.m-val { font-size: 20px; font-weight: 800; color: #ffffff; }

.card-header-clean {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
}

/* ======================================================== */
/* 8. CONFIG GRID                                           */
/* ======================================================== */
.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.config-card {
    background: var(--navy-mid);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.config-card.full-width {
    grid-column: 1 / -1;
}

.config-content {
    padding: 20px;
}

.grid-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.grid-form .full-width {
    grid-column: 1 / -1;
}

/* ======================================================== */
/* 9. MODALS                                                */
/* ======================================================== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(2, 11, 24, 0.85);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
}

.modal-backdrop.show,
.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.modal-dialog {
    width: 100%;
    max-width: 650px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: translateY(20px) scale(0.97);
    transition: transform 0.25s cubic-bezier(0.2, 0, 0.2, 1);
}

.modal-backdrop.show .modal-dialog,
.modal-backdrop.active .modal-dialog {
    transform: translateY(0) scale(1);
}

.modal-xl { max-width: 1080px; }
.modal-sm { max-width: 420px; }

.modal-content {
    background: var(--navy-mid);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 0 0 40px var(--royal-glow);
}

.modal-header {
    padding: 20px 28px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(14, 36, 68, 0.5);
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
}

.modal-subtitle {
    font-size: 11.5px;
    color: var(--text-dim);
    margin-top: 2px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 26px;
    color: var(--text-dim);
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover { color: #ffffff; }

.modal-body {
    padding: 24px 28px;
    overflow-y: auto;
    max-height: calc(90vh - 140px);
}

.modal-footer {
    padding: 16px 28px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    background: rgba(14, 36, 68, 0.3);
}

.form-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
}

/* Éditeur d'Articles / Items */
.items-editor-section {
    background: rgba(2, 11, 24, 0.5);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-top: 10px;
}

.section-header-inline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.section-header-inline h4 {
    font-size: 13px;
    text-transform: uppercase;
    color: var(--gold-light);
}

.table-items-editor {
    width: 100%;
    border-collapse: collapse;
}

.table-items-editor th {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-dim);
    padding: 8px;
    border-bottom: 1px solid var(--border-subtle);
    text-align: left;
}

.table-items-editor td {
    padding: 6px 4px;
}

.table-items-editor input {
    width: 100%;
    background: rgba(10, 25, 47, 0.8);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    color: #ffffff;
    font-family: inherit;
    font-size: 12.5px;
    padding: 6px 8px;
    height: 34px;
}

.table-items-editor input:focus {
    border-color: var(--royal-blue);
    outline: none;
}

.btn-remove-item {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
}

/* Totaux */
.totals-section {
    display: flex;
    justify-content: flex-end;
    margin-top: 14px;
}

.totals-grid {
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(14, 36, 68, 0.4);
    padding: 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.tva-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-control-sm {
    background: rgba(2, 11, 24, 0.8);
    border: 1px solid var(--border-subtle);
    color: #ffffff;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
}

.grand-total {
    border-top: 1px solid var(--border-color);
    padding-top: 8px;
    font-size: 15px;
    font-weight: 800;
}

/* ======================================================== */
/* 10. CANEVAS D'IMPRESSION OFFICIEL (EXCEL REPLICA)         */
/* ======================================================== */
.print-canvas-wrapper {
    background: #475569;
    padding: 30px;
    display: flex;
    justify-content: center;
}

.official-sheet {
    background: #ffffff;
    color: #000000;
    width: 210mm;
    max-width: 100%;
    min-height: 275mm;
    padding: 10mm 14mm;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    font-family: 'Aptos', Arial, Helvetica, sans-serif;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
    margin: 0 auto;
}

/* En-tête de la feuille */
.sheet-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    border-bottom: 2px solid #002060;
    padding-bottom: 12px;
}

.sheet-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sheet-logo {
    width: 60px;
    height: 60px;
    object-fit: contain;
}

.sheet-company-name {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 800;
    color: #002060;
    line-height: 1.1;
}

.sheet-company-sub {
    font-size: 9.5px;
    color: #64748b;
    font-weight: bold;
    text-transform: uppercase;
}

.sheet-meta-box {
    text-align: right;
}

.sheet-doc-badge {
    font-size: 16px;
    font-weight: 800;
    color: #002060;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.sheet-doc-num {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 800;
    color: #D4AF37;
    background: #002060;
    padding: 4px 10px;
    border-radius: 4px;
    display: inline-block;
}

.sheet-date {
    font-size: 11px;
    color: #334155;
    margin-top: 4px;
}

/* Bloc Fournisseur */
.sheet-supplier-box {
    border: 1.5px solid #002060;
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 20px;
    background: #f8fafc;
}

.sheet-supplier-title {
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
    color: #002060;
    margin-bottom: 2px;
}

.sheet-supplier-name {
    font-size: 14px;
    font-weight: bold;
    color: #0f172a;
}

.sheet-supplier-details {
    font-size: 10.5px;
    color: #475569;
}

.sheet-proforma-note {
    font-style: italic;
    font-size: 11px;
    color: #002060;
    font-weight: bold;
    margin-bottom: 12px;
}

/* Tableau officiel */
.sheet-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
}

.sheet-table th {
    background: #002060;
    color: #ffffff;
    font-size: 10.5px;
    font-weight: bold;
    text-transform: uppercase;
    padding: 7px 8px;
    border: 1px solid #002060;
    text-align: left;
}

.sheet-table td {
    padding: 7px 8px;
    border: 1px solid #cbd5e1;
    font-size: 11px;
    color: #0f172a;
}

.sheet-table tr:nth-child(even) td {
    background: #f8fafc;
}

.sheet-totals-box {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 20px;
}

.sheet-totals-table {
    width: 250px;
    border-collapse: collapse;
}

.sheet-totals-table td {
    padding: 5px 8px;
    font-size: 11px;
    border: 1px solid #cbd5e1;
}

.sheet-totals-table .td-label {
    background: #f1f5f9;
    font-weight: bold;
    text-align: right;
}

.sheet-totals-table .td-val {
    text-align: right;
    font-weight: bold;
}

.sheet-totals-table .total-ttc-row td {
    background: #002060;
    color: #ffffff;
    font-weight: 800;
    font-size: 12px;
}

/* Logistique & Observations */
.sheet-conditions-box {
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 25px;
    font-size: 10.5px;
    background: #fcfcfd;
}

.sheet-cond-row {
    margin-bottom: 4px;
}

.sheet-cond-label {
    font-weight: bold;
    color: #002060;
    display: inline-block;
    width: 130px;
}

/* Signatures */
.sheet-signatures {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    padding-top: 15px;
    border-top: 1px dashed #cbd5e1;
}

.sig-block {
    width: 220px;
    text-align: center;
}

.sig-title {
    font-size: 11px;
    font-weight: bold;
    color: #002060;
    text-transform: uppercase;
    margin-bottom: 45px;
}

.sig-name {
    font-size: 10.5px;
    font-weight: bold;
    border-top: 1px solid #000000;
    padding-top: 4px;
}

.sheet-footer-legal {
    text-align: center;
    font-size: 8.5px;
    color: #64748b;
    margin-top: 20px;
}

/* ======================================================== */
/* 11. PRINT MEDIA QUERY                                    */
/* ======================================================== */
@media print {
    @page {
        size: A4 portrait;
        margin: 6mm 8mm;
    }

    body, html {
        background: #ffffff !important;
        color: #000000 !important;
        margin: 0 !important;
        padding: 0 !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }

    .auth-gateway,
    #authGateway,
    .app-header,
    .kpi-strip,
    .tab-pane,
    .no-print,
    .modal-backdrop:not(#modalPrintPreview),
    .modal-header,
    .modal-close,
    .print-actions {
        display: none !important;
    }

    .modal-backdrop#modalPrintPreview {
        position: static !important;
        background: none !important;
        padding: 0 !important;
        margin: 0 !important;
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    .modal-dialog,
    .modal-content,
    .modal-body {
        max-width: 100% !important;
        max-height: none !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        box-shadow: none !important;
        background: none !important;
        overflow: visible !important;
    }

    .print-canvas-wrapper {
        background: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .official-sheet {
        width: 100% !important;
        max-width: 100% !important;
        min-height: 0 !important;
        height: auto !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        page-break-after: avoid !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    .sheet-doc-wrapper {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        min-height: 0 !important;
        height: auto !important;
        max-height: 100% !important;
    }

    .sheet-doc-wrapper * {
        page-break-inside: avoid;
    }
}


/* ========================================================================= */
/* 10. PASSERELLE D'AUTHENTIFICATION PLEIN ÉCRAN (AUTH GATEWAY)             */
/* ========================================================================= */
/* 10. PASSERELLE D'AUTHENTIFICATION OBLIGATOIRE (SARL AMAYRAF)              */
/* ========================================================================= */
.auth-gateway {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at 50% 25%, #0B254A 0%, #06152B 55%, #020914 100%);
    z-index: 99990;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    overflow-y: auto;
}

.auth-gateway::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: 
        radial-gradient(rgba(183, 151, 79, 0.12) 1px, transparent 1px),
        linear-gradient(to right, rgba(183, 151, 79, 0.035) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(183, 151, 79, 0.035) 1px, transparent 1px);
    background-size: 36px 36px, 72px 72px, 72px 72px;
    pointer-events: none;
}

.auth-gateway.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.auth-card {
    width: 100%;
    max-width: 460px;
    background: rgba(7, 21, 46, 0.94);
    border: 1px solid rgba(183, 151, 79, 0.38);
    box-shadow: 
        0 30px 65px -15px rgba(0, 0, 0, 0.8), 
        0 0 35px rgba(183, 151, 79, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    padding: 36px 32px 26px;
    backdrop-filter: blur(20px);
    text-align: center;
    position: relative;
    overflow: hidden;
    animation: authCardEnter 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1;
}

@keyframes authCardEnter {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #9E7D3B 0%, #F5D77F 50%, #B7974F 100%);
}

.auth-badge-box {
    margin-bottom: 16px;
    display: flex;
    justify-content: center;
}

.auth-security-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(183, 151, 79, 0.12);
    border: 1px solid rgba(183, 151, 79, 0.3);
    color: #E5C378;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 4px 12px;
    border-radius: 9999px;
    text-transform: uppercase;
}

.auth-logo-wrap {
    margin-bottom: 14px;
    display: inline-block;
    position: relative;
}

.auth-logo-wrap img {
    width: 92px;
    height: 92px;
    object-fit: contain;
    filter: drop-shadow(0 6px 18px rgba(183, 151, 79, 0.35));
    transition: transform 0.3s ease;
}

.auth-logo-wrap img:hover {
    transform: scale(1.04);
}

.auth-brand-title {
    font-family: var(--font-brand, 'Cinzel', 'Montserrat', serif);
    font-size: 1.65rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    color: #F5D77F;
    margin: 0 0 4px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.auth-company-title {
    font-family: var(--font-sans, 'Plus Jakarta Sans', sans-serif);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #ffffff;
    margin-bottom: 6px;
    text-transform: uppercase;
    opacity: 0.95;
}

.auth-company-sub {
    font-size: 0.78rem;
    color: var(--text-dim, #8FA0BC);
    margin-bottom: 22px;
    letter-spacing: 0.01em;
    line-height: 1.4;
}

.auth-form {
    text-align: left;
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 14px;
    color: #B7974F;
    opacity: 0.85;
    pointer-events: none;
}

.input-with-icon .form-control {
    padding-left: 42px;
}

.auth-submit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 18px;
    font-weight: 700;
    font-size: 0.92rem;
    letter-spacing: 0.02em;
    margin-top: 8px;
    border-radius: var(--radius-md, 8px);
    background: linear-gradient(135deg, #B7974F 0%, #8C6D2D 100%);
    border: 1px solid #E5C378;
    color: #06152B;
    box-shadow: 0 6px 18px rgba(183, 151, 79, 0.3);
    transition: all 0.25s ease;
    cursor: pointer;
}

.auth-submit-btn:hover {
    background: linear-gradient(135deg, #CFAF66 0%, #A08038 100%);
    box-shadow: 0 8px 24px rgba(183, 151, 79, 0.45);
    transform: translateY(-1px);
    color: #020914;
}

.auth-error-alert {
    background: rgba(220, 53, 69, 0.15);
    border: 1px solid rgba(220, 53, 69, 0.4);
    color: #ff858d;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.82rem;
    margin-bottom: 14px;
    text-align: center;
}

.auth-card-footer {
    margin-top: 22px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.45);
    letter-spacing: 0.02em;
}

/* ========================================================================= */
/* 11. ÉCRAN DE VERROUILLAGE / EXPIRATION DE LICENCE                        */
/* ========================================================================= */
.lockdown-gateway {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at 50% 30%, #30080c 0%, #100204 80%, #050001 100%);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    transition: all 0.3s ease;
}

.lockdown-gateway.hidden {
    display: none;
}

.lockdown-card {
    width: 100%;
    max-width: 500px;
    background: rgba(30, 8, 12, 0.95);
    border: 1px solid rgba(220, 38, 38, 0.5);
    box-shadow: 0 0 60px rgba(220, 38, 38, 0.3);
    border-radius: var(--radius-lg);
    padding: 44px 36px;
    text-align: center;
    backdrop-filter: blur(16px);
}

.lockdown-icon {
    font-size: 3.5rem;
    margin-bottom: 16px;
}

.lockdown-title {
    font-family: var(--font-brand);
    font-size: 1.5rem;
    color: #ef4444;
    margin-bottom: 12px;
}

.lockdown-msg {
    font-size: 0.95rem;
    color: #fca5a5;
    margin-bottom: 28px;
    line-height: 1.6;
}

/* ========================================================================= */
/* 12. LOGO CLIC & NAVIGATION SECRÈTE DE CONFIGURATION                       */
/* ========================================================================= */
.brand-group {
    cursor: pointer;
    user-select: none;
    transition: transform 0.2s ease, opacity 0.2s ease;
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    margin-left: -8px;
}

.brand-group:hover {
    background: rgba(212, 175, 55, 0.08);
    transform: translateY(-1px);
}

.brand-group:active {
    transform: scale(0.98);
}

/* ========================================================================= */
/* 13. SOUS-ONGLETS DU PANNEAU DE CONFIGURATION                              */
/* ========================================================================= */
.config-tabs-nav {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
    margin-bottom: 20px;
    overflow-x: auto;
}

.config-tab-btn {
    padding: 10px 16px;
    font-size: 0.88rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-dim);
    border: 1px solid transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.config-tab-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.05);
}

.config-tab-btn.active {
    color: #ffffff;
    background: var(--navy-light);
    border-color: rgba(212, 175, 55, 0.4);
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.15);
}

.config-subpane {
    display: none;
}

.config-subpane.active {
    display: block;
    animation: fadeIn 0.25s ease;
}

/* ========================================================================= */
/* 14. ÉDITEUR DE LOGO & GESTIONNAIRE DE MODÈLES D'ENTÊTE                     */
/* ========================================================================= */
.logo-uploader-box {
    display: flex;
    align-items: center;
    gap: 20px;
    background: var(--navy-dark);
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px dashed rgba(212, 175, 55, 0.3);
}

.logo-preview-img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-sm);
    padding: 4px;
    border: 1px solid var(--border-color);
}

.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    margin-top: 16px;
}

.template-card {
    background: var(--navy-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: all 0.2s ease;
    position: relative;
}

.template-card.active-template {
    border-color: var(--gold-primary);
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.2);
}

.template-badge {
    position: absolute;
    top: 14px;
    right: 14px;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 12px;
}

/* ========================================================================= */
/* 15. JOURNAL D'AUDIT IMMUABLE                                             */
/* ========================================================================= */
.audit-table-wrap {
    max-height: 480px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.audit-table th {
    position: sticky;
    top: 0;
    background: var(--navy-dark);
    z-index: 5;
}

.audit-time {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--gold-light);
    white-space: nowrap;
}

.badge-audit {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 7px;
    border-radius: 4px;
    text-transform: uppercase;
}

.badge-audit-po { background: rgba(0, 85, 212, 0.25); color: #60a5fa; border: 1px solid rgba(0, 85, 212, 0.4); }
.badge-audit-rfq { background: rgba(212, 175, 55, 0.25); color: #fde047; border: 1px solid rgba(212, 175, 55, 0.4); }
.badge-audit-sec { background: rgba(220, 38, 38, 0.25); color: #fca5a5; border: 1px solid rgba(220, 38, 38, 0.4); }
.badge-audit-sys { background: rgba(16, 185, 129, 0.25); color: #6ee7b7; border: 1px solid rgba(16, 185, 129, 0.4); }

/* Stacking des sous-modales de configuration */
#modalUser, #modalSupplier {
    z-index: 2100 !important;
}
#modalUser .modal-dialog, #modalSupplier .modal-dialog {
    z-index: 2110 !important;
}
