/* ===== COMPTABILIA - CHARTE GRAPHIQUE PROFESSIONNELLE ===== */

/* Variables CSS pour la cohérence - Palette Institutionnelle */
:root {
    /* Couleurs principales - Sobriété professionnelle */
    --primary-deep-blue: #1e3a8a;      /* Bleu profond principal */
    --primary-blue: #3b82f6;           /* Bleu standard */
    --secondary-slate: #475569;        /* Gris ardoise */
    --accent-slate: #64748b;           /* Gris ardoise clair */
    
    /* Couleurs fonctionnelles */
    --success-green: #059669;          /* Vert pour validations finales uniquement */
    --alert-red: #dc2626;             /* Rouge pour alertes critiques uniquement */
    --warning-amber: #d97706;          /* Ambre pour avertissements */
    
    /* Couleurs neutres - Blancs cassés et gris */
    --bg-primary: #fefefe;            /* Blanc cassé principal */
    --bg-secondary: #f8fafc;          /* Gris très clair */
    --bg-card: #ffffff;               /* Blanc pur pour cartes */
    --bg-subtle: #f1f5f9;             /* Gris subtil */
    
    /* Bordures et séparateurs */
    --border-light: #e2e8f0;          /* Bordure claire */
    --border-medium: #cbd5e1;         /* Bordure moyenne */
    --border-strong: #94a3b8;         /* Bordure forte */
    
    /* Textes - Hiérarchie claire */
    --text-primary: #0f172a;          /* Texte principal - très foncé */
    --text-secondary: #334155;        /* Texte secondaire */
    --text-muted: #64748b;            /* Texte atténué */
    --text-light: #94a3b8;           /* Texte clair */
    
    /* Ombres - Subtiles et professionnelles */
    --shadow-subtle: 0 1px 2px 0 rgb(0 0 0 / 0.03);
    --shadow-soft: 0 2px 4px 0 rgb(0 0 0 / 0.06);
    --shadow-medium: 0 4px 6px -1px rgb(0 0 0 / 0.08);
    --shadow-strong: 0 8px 25px -5px rgb(0 0 0 / 0.12);
    
    /* Rayons de bordure */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    
    /* Typographie - Hiérarchie claire */
    --font-family: Inter, 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: 'SF Mono', 'Monaco', 'Cascadia Code', monospace;
    
    /* Tailles de police - Hiérarchie nette */
    --text-xs: 0.75rem;      /* 12px */
    --text-sm: 0.875rem;     /* 14px */
    --text-base: 0.875rem;   /* 14px */
    --text-lg: 1.125rem;     /* 18px */
    --text-xl: 1.25rem;      /* 20px */
    --text-2xl: 1.5rem;      /* 24px */
    --text-3xl: 1.875rem;    /* 30px */
    --text-4xl: 2.25rem;     /* 36px */
    
    /* Espacements - Plus d'air */
    --space-xs: 0.25rem;     /* 4px */
    --space-sm: 0.5rem;      /* 8px */
    --space-md: 0.75rem;     /* 12px */
    --space-lg: 1rem;        /* 16px */
    --space-xl: 1.5rem;      /* 24px */
    --space-2xl: 2rem;       /* 32px */
    --space-3xl: 3rem;       /* 48px */
}

/* ===== RESET ET BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: var(--text-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== TYPOGRAPHIE - HIÉRARCHIE CLAIRE ===== */
h1 {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    margin-bottom: var(--space-lg);
}

h2 {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
    margin-bottom: var(--space-xl);
}

h3 {
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
    margin-bottom: var(--space-lg);
}

h4 {
    font-size: var(--text-lg);
    font-weight: 500;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: var(--space-md);
}

/* Chiffres en Ariary - Très lisibles */
.amount {
    font-family: var(--font-family);
    font-weight: 500;
    font-size: 1rem;
    color: var(--text-primary);
    text-align: right;
    letter-spacing: 0;
}

.amount-large {
    font-size: 1rem;
    font-weight: 500;
}

.amount-small {
    font-size: var(--text-base);
    font-weight: 500;
}

/* ===== HEADER - PROFESSIONNEL ===== */
.header {
    background: var(--bg-primary);
    border-bottom: 2px solid var(--border-light);
    box-shadow: var(--shadow-soft);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: var(--space-lg) 0;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--space-2xl);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.logo i {
    font-size: var(--text-3xl);
    color: var(--primary-deep-blue);
}

.logo h1 {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0;
}

.tagline {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-left: var(--space-sm);
}

.header-status {
    display: flex;
    align-items: center;
    gap: var(--space-2xl);
}

/* Barre d'état discrète */
.sync-status {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--text-sm);
    color: var(--text-muted);
    position: fixed;
    bottom: var(--space-lg);
    left: var(--space-lg);
    background: var(--bg-card);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-medium);
    z-index: 50;
}

.sync-status i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success-green);
    font-size: 0;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===== BOUTONS - HARMONISÉS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-xl);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    min-height: 44px; /* Taille harmonisée */
}

/* Bouton principal - Style plein */
.btn-primary {
    background: var(--primary-deep-blue);
    color: white;
    border-color: var(--primary-deep-blue);
}

.btn-primary:hover {
    background: var(--primary-blue);
    border-color: var(--primary-blue);
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

/* Boutons secondaires - Style outline */
.btn-secondary {
    background: transparent;
    color: var(--secondary-slate);
    border-color: var(--border-medium);
}

.btn-secondary:hover {
    background: var(--bg-subtle);
    border-color: var(--secondary-slate);
    color: var(--text-primary);
}

/* Bouton de succès - Vert pour validations finales */
.btn-success {
    background: var(--success-green);
    color: white;
    border-color: var(--success-green);
}

.btn-success:hover {
    background: #047857;
    border-color: #047857;
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

/* Bouton d'alerte - Rouge pour actions critiques */
.btn-danger {
    background: var(--alert-red);
    color: white;
    border-color: var(--alert-red);
}

.btn-danger:hover {
    background: #b91c1c;
    border-color: #b91c1c;
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

/* Tailles de boutons */
.btn-sm {
    padding: var(--space-sm) var(--space-lg);
    font-size: var(--text-xs);
    min-height: 36px;
}

.btn-lg {
    padding: var(--space-lg) var(--space-2xl);
    font-size: var(--text-base);
    min-height: 52px;
}

/* ===== CARTES - PLUS D'AIR ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    box-shadow: var(--shadow-subtle);
    transition: all 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-medium);
    transform: translateY(-2px);
    border-color: var(--border-medium);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-xl);
    padding-bottom: var(--space-lg);
    border-bottom: 1px solid var(--border-light);
}

.card-title {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.card-title i {
    font-size: var(--text-lg);
    color: var(--primary-deep-blue);
}

.card-body {
    padding: 0;
}

/* ===== TABLEAUX - ESPACEMENT AMÉLIORÉ ===== */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: var(--space-2xl);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-subtle);
}

.table th {
    background: var(--bg-subtle);
    padding: var(--space-lg) var(--space-xl);
    text-align: left;
    font-weight: 700;
    font-size: var(--text-xs);
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-family: var(--font-family);
}

.table td {
    padding: var(--space-lg) var(--space-xl);
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    vertical-align: middle;
    font-family: var(--font-family);
    font-size: var(--text-base);
}

.table tbody tr:hover {
    background: var(--bg-subtle);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* Alignement des montants */
.table th.amount,
.table td.amount {
    text-align: right;
}

.table tfoot {
    background: var(--bg-subtle);
    font-weight: 600;
}

.table tfoot td {
    border-top: 2px solid var(--border-medium);
    border-bottom: none;
    padding: var(--space-xl);
}

/* ===== ONGLETS - STYLE PROFESSIONNEL ===== */
.tabs {
    display: flex;
    background: var(--bg-card);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: var(--shadow-subtle);
    border-bottom: 2px solid var(--border-light);
}

.tab-btn {
    flex: 1;
    padding: var(--space-xl) var(--space-2xl);
    border: none;
    background: transparent;
    cursor: pointer;
    font-weight: 500;
    font-size: var(--text-base);
    color: var(--text-muted);
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
}

.tab-btn:hover {
    background: var(--bg-subtle);
    color: var(--text-secondary);
}

.tab-btn.active {
    background: var(--bg-card);
    color: var(--primary-deep-blue);
    border-bottom-color: var(--primary-deep-blue);
    font-weight: 600;
}

.tab-content {
    background: var(--bg-card);
    padding: var(--space-3xl);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    box-shadow: var(--shadow-subtle);
    min-height: 600px;
}

/* ===== GRILLES - RESPONSIVE ===== */
.grid {
    display: grid;
    gap: var(--space-xl);
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

/* ===== MÉTRIQUES - CARTES AMÉLIORÉES ===== */
.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    box-shadow: var(--shadow-subtle);
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary-deep-blue);
}

.metric-card:hover {
    box-shadow: var(--shadow-medium);
    transform: translateY(-2px);
}

.metric-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.metric-header i {
    font-size: var(--text-xl);
    color: var(--primary-deep-blue);
}

.metric-header h3 {
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0;
    flex: 1;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.metric-value {
    display: flex;
    align-items: baseline;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.metric-trend {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--text-sm);
    font-weight: 500;
}

.metric-trend.positive {
    color: var(--success-green);
}

.metric-trend.negative {
    color: var(--alert-red);
}

.metric-info {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-top: var(--space-md);
}

.page-shell {
    max-width: 1440px;
    margin: 0 auto;
    padding: var(--space-2xl);
}

.toolbar {
    margin-bottom: var(--space-xl);
}

.toolbar-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-xl);
    flex-wrap: wrap;
}

.toolbar-actions {
    display: flex;
    align-items: flex-end;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.section-title {
    margin-bottom: var(--space-sm);
}

.page-subtitle {
    color: var(--text-muted);
    font-size: var(--text-base);
}

.field-stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-md);
}

.field-label,
.card-eyebrow {
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.table-input {
    width: 100%;
    min-width: 80px;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    padding: var(--space-sm) var(--space-md);
    font-family: var(--font-family);
    font-size: var(--text-base);
    color: var(--text-primary);
    background: var(--bg-card);
}

.table-scroll {
    overflow: auto;
    max-height: 62vh;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
}

.responsive-table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
    border-radius: var(--radius-lg);
}

.table-scroll > .table,
.responsive-table-wrap > .table {
    min-width: 760px;
    margin-bottom: 0;
}

#reconciliationWorkspace .table-scroll > .table {
    min-width: 1080px;
}

.table-scroll:focus,
.responsive-table-wrap:focus {
    outline: 2px solid rgba(37, 99, 235, 0.45);
    outline-offset: 2px;
}

.entry-line {
    display: grid;
    grid-template-columns: minmax(110px, 0.8fr) minmax(170px, 1.25fr) minmax(190px, 1.5fr) minmax(110px, 0.8fr) minmax(110px, 0.8fr) auto;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
    align-items: start;
}

.entry-line.account-title-hidden {
    grid-template-columns: minmax(120px, 0.9fr) minmax(220px, 1.7fr) minmax(110px, 0.8fr) minmax(110px, 0.8fr) auto;
}

.entry-line.account-title-hidden .account-title-input {
    display: none;
}

.entry-mode-toolbar,
.guided-suggestion-heading,
.guided-suggestion-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.entry-mode-toolbar {
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-light);
}

.entry-mode-switch,
.entry-line-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.guided-entry-panel {
    display: grid;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    padding: var(--space-lg);
    border: 1px solid rgba(37, 99, 235, 0.24);
    border-radius: var(--radius-md);
    background: rgba(239, 246, 255, 0.72);
}

.guided-entry-panel[hidden] {
    display: none;
}

.guided-entry-panel h4 {
    margin: 0 0 var(--space-xs);
    color: var(--text-primary);
}

.guided-entry-input-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-md);
    align-items: end;
}

.guided-suggestion-result {
    display: grid;
    gap: var(--space-md);
    padding: var(--space-md);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
}

.guided-suggestion-result[hidden] {
    display: none;
}

.guided-lines-preview {
    max-height: 18rem;
}

.guided-suggestion-notes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-sm);
}

.guided-suggestion-notes > div {
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    background: var(--bg-subtle);
}

.guided-suggestion-notes ul {
    margin: var(--space-xs) 0 0 1rem;
}

.guided-warning {
    border-left: 3px solid var(--warning-amber);
}

.guided-required {
    border-left: 3px solid var(--primary-blue);
}

.journal-entry-modal.is-expert .modal-body {
    padding-top: var(--space-md);
}

.journal-entry-modal.is-expert .entry-help-panel {
    margin-top: var(--space-sm);
}

.editable-suggestion {
    background-image: linear-gradient(90deg, rgba(37, 99, 235, 0.08), transparent 65%);
}

.vat-breakdown {
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-top: var(--space-sm);
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--bg-subtle);
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

.vat-breakdown span,
.doc-badge,
.journal-alert {
    display: inline-flex;
    align-items: center;
    width: max-content;
    max-width: 100%;
    padding: 0.18rem 0.45rem;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.08);
    color: var(--text-secondary);
    font-size: var(--text-xs);
    white-space: nowrap;
}

.doc-badge.has-document {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success-green);
}

.journal-alert {
    background: rgba(245, 158, 11, 0.12);
    color: #92400e;
}

.document-list-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.6rem;
    align-items: center;
    flex-wrap: wrap;
}

.document-list-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.field-help {
    color: var(--text-muted);
    font-size: var(--text-xs);
    line-height: 1.35;
}

.hint-dot {
    display: inline-flex;
    width: 1rem;
    height: 1rem;
    align-items: center;
    justify-content: center;
    margin-left: 0.25rem;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-deep-blue);
    font-size: 0.7rem;
    cursor: help;
    text-transform: none;
    letter-spacing: 0;
}

.hint-popover {
    position: absolute;
    z-index: 30;
    max-width: 280px;
    margin-left: 0.35rem;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    box-shadow: var(--shadow-soft);
    color: var(--text-secondary);
    font-size: var(--text-xs);
    line-height: 1.35;
    text-transform: none;
    letter-spacing: 0;
}

.hint-popover button {
    margin-left: 0.4rem;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}

.document-preview {
    margin: var(--space-md) 0;
    padding: var(--space-md);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--bg-subtle);
    min-height: 220px;
}

.document-preview img,
.document-preview iframe {
    display: block;
    width: 100%;
    max-height: 560px;
    margin-top: var(--space-sm);
    border: 0;
    border-radius: var(--radius-sm);
    object-fit: contain;
    background: white;
}

.document-preview iframe {
    height: 520px;
}

.document-preview-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.field-expense-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
    gap: var(--space-lg);
    align-items: start;
}

.entry-help-panel {
    display: grid;
    gap: 0.35rem;
    margin-top: var(--space-md);
    padding: var(--space-md);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--bg-subtle);
    color: var(--text-secondary);
    font-size: var(--text-xs);
}

.document-preview-panel {
    gap: 0.6rem;
    margin-top: var(--space-md);
    padding: var(--space-md);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--bg-subtle);
}

.document-preview-header {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    justify-content: space-between;
    flex-wrap: wrap;
}

.document-preview-panel iframe,
.document-preview-panel img {
    width: 100%;
    min-height: 320px;
    max-height: 48vh;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    object-fit: contain;
}

.page-shell {
    padding: var(--space-xl);
}

.card,
.metric-card {
    padding: var(--space-xl);
}

.card-header {
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
}

.table th,
.table td {
    padding: var(--space-md) var(--space-lg);
}

.muted-text {
    color: var(--text-muted);
    font-size: var(--text-xs);
}

.info-line {
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
    font-size: var(--text-base);
}

.amount-emphasis {
    font-size: 1rem;
    font-weight: 500;
}

.declaration-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-lg);
    padding: var(--space-lg) 0;
    border-bottom: 1px solid var(--border-light);
}

.declaration-row:last-child {
    border-bottom: none;
}

/* ===== INDICATEURS DE STATUT ===== */
.status-indicator {
    display: inline-flex;
    align-items: center;
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-ok {
    background: #d1fae5;
    color: #065f46;
}

.status-warning {
    background: #fef3c7;
    color: #92400e;
}

.status-error {
    background: #fee2e2;
    color: #991b1b;
}

/* ===== MODALES - STYLE PROFESSIONNEL ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-strong);
    position: relative;
}

.modal-header {
    padding: var(--space-2xl);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: var(--text-xl);
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-subtle);
}

.modal-body {
    padding: var(--space-2xl);
}

.modal-footer {
    padding: var(--space-2xl);
    border-top: 1px solid var(--border-light);
    display: flex;
    gap: var(--space-md);
    justify-content: flex-end;
}

/* ===== NOTIFICATIONS ÉLÉGANTES ===== */
.notification {
    position: fixed;
    top: var(--space-2xl);
    right: var(--space-2xl);
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow-strong);
    z-index: 1100;
    max-width: 400px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.notification-info {
    border-left: 4px solid var(--primary-blue);
}

.notification-success {
    border-left: 4px solid var(--success-green);
}

.notification-warning {
    border-left: 4px solid var(--warning-amber);
}

.notification-error {
    border-left: 4px solid var(--alert-red);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .page-shell {
        padding: var(--space-md);
        max-width: 100vw;
        overflow-x: clip;
    }

    .toolbar-row,
    .toolbar-actions {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .toolbar-actions > *,
    .header-status > .btn,
    [data-auth-actions] .btn {
        width: 100%;
        min-height: 44px;
        justify-content: center;
    }

    .card-header {
        align-items: stretch;
        flex-direction: column;
        gap: var(--space-md);
    }

    .card-header .toolbar-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .table-scroll,
    .responsive-table-wrap {
        max-width: 100%;
        margin-inline: calc(var(--space-md) * -1);
        padding-inline: var(--space-md);
        border-radius: 0;
    }

    .table-scroll > .table,
    .responsive-table-wrap > .table {
        min-width: 680px;
    }

    #reconciliationWorkspace .table-scroll > .table {
        min-width: 980px;
    }

    .table-scroll::after,
    .responsive-table-wrap::after {
        content: 'Faites glisser horizontalement pour voir toutes les colonnes';
        display: block;
        padding: 0.45rem 0.15rem 0;
        color: var(--text-muted);
        font-size: var(--text-xs);
    }

    .header-content {
        padding: 0 var(--space-lg);
        flex-direction: column;
        gap: var(--space-lg);
        text-align: center;
    }
    
    .tabs {
        flex-direction: column;
    }
    
    .tab-btn {
        border-bottom: 1px solid var(--border-light);
        border-right: none;
    }
    
    .tab-btn.active {
        border-bottom-color: var(--border-light);
        border-left: 3px solid var(--primary-deep-blue);
    }
    
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }
    
    .table {
        font-size: var(--text-sm);
    }
    
    .table th,
    .table td {
        padding: var(--space-sm) var(--space-md);
    }

    .entry-line {
        grid-template-columns: 1fr;
    }

    .guided-entry-input-row {
        grid-template-columns: 1fr;
    }

    .guided-entry-input-row .btn,
    .entry-line-actions .btn {
        width: 100%;
    }
    
    .sync-status {
        position: relative;
        bottom: auto;
        left: auto;
        margin-top: var(--space-lg);
    }
}

/* ===== ANIMATIONS SUBTILES ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card,
.metric-card {
    animation: fadeIn 0.4s ease forwards;
}

.card:nth-child(1) { animation-delay: 0.1s; }
.card:nth-child(2) { animation-delay: 0.2s; }
.card:nth-child(3) { animation-delay: 0.3s; }
.card:nth-child(4) { animation-delay: 0.4s; }

/* ===== UTILITAIRES ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.mb-0 { margin-bottom: 0; }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }
.mb-2xl { margin-bottom: var(--space-2xl); }

.mt-0 { margin-top: 0; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mt-2xl { margin-top: var(--space-2xl); }

.p-0 { padding: 0; }
.p-sm { padding: var(--space-sm); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }
.p-xl { padding: var(--space-xl); }
.p-2xl { padding: var(--space-2xl); }

.hidden { display: none; }
.block { display: block; }
.flex { display: flex; }
.grid { display: grid; }

.w-full { width: 100%; }
.h-full { height: 100%; }

.cursor-pointer { cursor: pointer; }
.cursor-not-allowed { cursor: not-allowed; }

.user-pill {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 0.65rem 0.9rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
}

.quick-role-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-lg);
}

.auth-card {
    height: 100%;
}

.auth-meta {
    display: flex;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: 0.55rem;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.permission-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: var(--space-lg);
}

.permission-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.08);
    color: var(--primary-deep-blue);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.auth-hidden {
    display: none !important;
}

.module-disabled,
.is-disabled {
    opacity: 0.45;
    pointer-events: none;
}

/* ===== DENSITE PILOTE ===== */
.header {
    padding: var(--space-sm) 0;
}

.header-content {
    padding: 0 var(--space-xl);
}

.logo {
    gap: var(--space-md);
}

.logo i {
    font-size: var(--text-2xl);
}

.logo h1 {
    font-size: var(--text-xl);
}

.header-status {
    gap: var(--space-lg);
}

.page-shell {
    padding: var(--space-lg) var(--space-xl);
}

.toolbar {
    margin-bottom: var(--space-lg);
}

.toolbar.card,
.page-shell > .card {
    padding: var(--space-lg);
}

.grid {
    gap: var(--space-lg);
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.metric-card {
    padding: var(--space-lg);
    min-height: 120px;
}

.metric-header,
.metric-value,
.metric-info {
    margin-bottom: var(--space-sm);
    margin-top: 0;
}

.card[data-module] {
    padding: var(--space-lg);
    min-height: 160px;
}

.card[data-module] .card-header {
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-md);
    align-items: flex-start;
}

.card[data-module] .card-title {
    font-size: 1rem;
    line-height: 1.25;
}

.card[data-module] .card-body p {
    line-height: 1.45;
}

.quick-role-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-md);
}

.auth-card {
    padding: var(--space-lg);
}

.auth-card .card-header {
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
}

.auth-card .permission-chips {
    margin-top: var(--space-md);
}

.page-guard {
    margin-bottom: var(--space-lg);
    padding: 0.9rem 1rem;
    border-radius: var(--radius-lg);
    border: 1px solid transparent;
    font-size: var(--text-sm);
}

.page-guard-warning {
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.25);
    color: #8a5a00;
}

.page-guard-error {
    background: rgba(220, 38, 38, 0.08);
    border-color: rgba(220, 38, 38, 0.25);
    color: #9a1f1f;
}

@media (max-width: 720px) {
    .header-content,
    .toolbar-row,
    .header-status {
        align-items: stretch;
        flex-direction: column;
        gap: var(--space-md);
    }

}

/* ===== DASHBOARD DENSE - V1.1 UX ===== */
body {
    line-height: 1.42;
}

.header {
    padding: 0.45rem 0;
}

.header-content {
    max-width: 1500px;
    padding: 0 1.1rem;
    min-height: 58px;
}

.logo {
    gap: 0.55rem;
}

.logo h1 {
    font-size: 1.35rem;
}

.tagline {
    margin-left: 0.35rem;
}

.header-status {
    gap: 0.75rem;
}

.user-pill {
    padding: 0.45rem 0.7rem;
    gap: 0.55rem;
}

.page-shell {
    max-width: 1500px;
    padding: 0.9rem 1.15rem 1.25rem;
}

.page-shell > .card,
.toolbar.card {
    padding: 0.85rem 1rem;
    margin-bottom: 0.75rem;
}

.toolbar-row {
    align-items: center;
    gap: 0.75rem;
}

.toolbar-actions {
    gap: 0.5rem;
}

.section-title,
.card-title,
h2,
h3 {
    margin-bottom: 0.35rem;
}

.page-subtitle,
.muted-text,
.metric-info {
    line-height: 1.35;
}

.btn {
    min-height: 36px;
    padding: 0.45rem 0.85rem;
}

.btn-sm {
    min-height: 30px;
    padding: 0.3rem 0.55rem;
}

.grid {
    gap: 0.75rem;
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.metric-card {
    min-height: 92px;
    padding: 0.75rem 0.9rem;
}

.metric-card::before {
    height: 3px;
}

.metric-header {
    margin-bottom: 0.35rem;
}

.metric-value {
    margin-bottom: 0.3rem;
}

.metric-info {
    margin-top: 0.2rem;
}

.quick-role-grid {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 0.45rem;
}

.card-header {
    margin-bottom: 0.55rem;
    padding-bottom: 0.45rem;
}

.card[data-module] {
    min-height: 112px;
    padding: 0.65rem 0.75rem;
}

.card[data-module] .card-header {
    margin-bottom: 0.45rem;
    padding-bottom: 0.45rem;
    gap: 0.45rem;
}

.card[data-module] .card-title {
    gap: 0.45rem;
    font-size: 0.98rem;
    line-height: 1.18;
}

.card[data-module] .card-title i {
    font-size: 0.95rem;
}

.card[data-module] .status-indicator {
    padding: 0.2rem 0.45rem;
    line-height: 1.15;
}

.card[data-module] .card-body p {
    line-height: 1.25;
}

.module-hidden {
    display: none !important;
}

.hinted-text {
    border-bottom: 1px dotted var(--text-muted);
    cursor: help;
}

.modal-content {
    max-height: 92vh;
}

.modal-body {
    padding: 0.9rem 1.1rem;
}

.modal-header,
.modal-footer {
    padding: 0.8rem 1.1rem;
}

.entry-line {
    gap: 0.45rem;
    margin-bottom: 0.45rem;
}

.entry-help-panel {
    margin: 0.55rem 0;
    padding: 0.55rem 0.7rem;
    gap: 0.25rem;
}

.help-panel {
    padding: 0.85rem 1rem;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius-md);
    background: #eff6ff;
    color: #1e3a8a;
    line-height: 1.5;
}

.help-panel ul {
    margin: 0.5rem 0 0;
    padding-left: 1.2rem;
}

.help-panel li + li {
    margin-top: 0.35rem;
}

.muted-row {
    opacity: 0.58;
}

.dcom-cell-input {
    min-width: 9.5rem;
}

.sync-status {
    bottom: 0.75rem;
    left: 0.75rem;
    padding: 0.4rem 0.55rem;
}

/* ===== ACCUEIL DENSE - V1.1 UX ===== */
.home-dashboard .header-content {
    min-height: 52px;
}

.home-dashboard .page-shell {
    padding-top: 0.55rem;
    padding-bottom: 0.8rem;
}

.home-dashboard .toolbar.card {
    padding: 0.6rem 0.8rem;
    margin-bottom: 0.5rem;
}

.home-dashboard .toolbar-row {
    gap: 0.55rem;
}

.home-dashboard .section-title {
    margin-bottom: 0.15rem;
    font-size: 1.05rem;
}

.home-dashboard .page-subtitle,
.home-dashboard .muted-text {
    font-size: 0.84rem;
    line-height: 1.25;
}

.home-dashboard .grid {
    gap: 0.5rem;
}

.home-dashboard .metric-card {
    min-height: 76px;
    padding: 0.5rem 0.65rem;
}

.home-dashboard .metric-header {
    margin-bottom: 0.15rem;
}

.home-dashboard .metric-value {
    margin-bottom: 0.12rem;
    font-size: 1.03rem;
}

.home-dashboard .metric-info {
    font-size: 0.78rem;
    line-height: 1.2;
}

.home-dashboard main > section.card {
    padding: 0.55rem 0.7rem;
    margin-bottom: 0.5rem;
}

.home-dashboard main > section.card > .card-header {
    margin-bottom: 0.35rem;
    padding-bottom: 0.28rem;
}

.home-dashboard .quick-role-grid {
    grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
    gap: 0.32rem;
}

.home-dashboard .grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.home-dashboard .card[data-module] {
    min-height: 92px;
    padding: 0.5rem 0.58rem;
}

.home-dashboard .card[data-module] .card-header {
    border-bottom: 0;
    margin-bottom: 0.22rem;
    padding-bottom: 0;
    gap: 0.32rem;
}

.home-dashboard .card[data-module] .card-title {
    font-size: 0.88rem;
    line-height: 1.1;
    gap: 0.32rem;
}

.home-dashboard .card[data-module] .card-title i {
    font-size: 0.86rem;
}

.home-dashboard .card[data-module] .status-indicator {
    padding: 0.15rem 0.34rem;
    font-size: 0.68rem;
    line-height: 1.1;
}

.home-dashboard .card[data-module] .card-body p {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.79rem;
    line-height: 1.2;
}

.home-dashboard .sync-status {
    padding: 0.32rem 0.48rem;
    font-size: 0.78rem;
}

/* ===== FOCUS ET ACCESSIBILITÉ ===== */
/* ===== ACCUEIL DENSE - V1.2 FINITION 1365x768 ===== */
@media (min-width: 1024px) {
    .home-dashboard .header {
        padding: 0.28rem 0;
    }

    .home-dashboard .header-content {
        min-height: 44px;
        padding: 0 0.9rem;
    }

    .home-dashboard .logo {
        gap: 0.42rem;
    }

    .home-dashboard .logo i {
        font-size: 1.35rem;
    }

    .home-dashboard .logo h1 {
        font-size: 1.24rem;
    }

    .home-dashboard .tagline {
        font-size: 0.84rem;
        margin-left: 0.2rem;
    }

    .home-dashboard .header-status {
        gap: 0.45rem;
    }

    .home-dashboard .user-pill {
        padding: 0.28rem 0.5rem;
        gap: 0.38rem;
        border-radius: var(--radius-md);
    }

    .home-dashboard .user-pill i {
        font-size: 0.95rem;
    }

    .home-dashboard .page-shell {
        padding: 0.38rem 0.8rem 0.55rem;
    }

    .home-dashboard .toolbar.card {
        padding: 0.42rem 0.65rem;
        margin-bottom: 0.34rem;
    }

    .home-dashboard .toolbar-row {
        gap: 0.45rem;
    }

    .home-dashboard .toolbar-actions {
        gap: 0.35rem;
    }

    .home-dashboard .btn {
        min-height: 31px;
        padding: 0.34rem 0.62rem;
    }

    .home-dashboard .btn-sm {
        min-height: 27px;
        padding: 0.24rem 0.45rem;
    }

    .home-dashboard .section-title {
        font-size: 0.98rem;
        margin-bottom: 0.08rem;
    }

    .home-dashboard .page-subtitle {
        max-width: 760px;
    }

    .home-dashboard .page-subtitle,
    .home-dashboard .muted-text {
        font-size: 0.79rem;
        line-height: 1.18;
    }

    .home-dashboard .grid {
        gap: 0.36rem;
    }

    .home-dashboard .grid-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .home-dashboard .metric-card {
        min-height: 61px;
        padding: 0.38rem 0.55rem;
    }

    .home-dashboard .metric-header {
        margin-bottom: 0.06rem;
    }

    .home-dashboard .metric-value {
        margin-bottom: 0.02rem;
        font-size: 0.94rem;
    }

    .home-dashboard .metric-info {
        font-size: 0.72rem;
        line-height: 1.12;
    }

    .home-dashboard main > section.card {
        padding: 0.4rem 0.55rem;
        margin-bottom: 0.34rem;
        border-radius: var(--radius-md);
    }

    .home-dashboard main > section.card > .card-header {
        margin-bottom: 0.18rem;
        padding-bottom: 0.16rem;
        gap: 0.35rem;
    }

    .home-dashboard main > section.card > .card-header .card-title {
        font-size: 0.94rem;
        margin-bottom: 0.04rem;
    }

    .home-dashboard .quick-role-grid {
        grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
        gap: 0.24rem;
    }

    .home-dashboard .grid-3 {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }

    .home-dashboard .card[data-module] {
        min-height: 72px;
        padding: 0.38rem 0.46rem;
        border-radius: var(--radius-md);
    }

    .home-dashboard .card[data-module] .card-header {
        margin-bottom: 0.12rem;
        gap: 0.24rem;
    }

    .home-dashboard .card[data-module] .card-title {
        font-size: 0.79rem;
        line-height: 1.05;
        gap: 0.22rem;
    }

    .home-dashboard .card[data-module] .card-title i {
        font-size: 0.77rem;
    }

    .home-dashboard .card[data-module] .status-indicator {
        padding: 0.11rem 0.26rem;
        font-size: 0.6rem;
        line-height: 1.05;
    }

    .home-dashboard .card[data-module] .card-body p {
        -webkit-line-clamp: 1;
        font-size: 0.72rem;
        line-height: 1.12;
    }

    .home-dashboard .sync-status {
        bottom: 0.45rem;
        left: 0.45rem;
        padding: 0.24rem 0.36rem;
        font-size: 0.7rem;
    }
}

@media (max-width: 768px) {
    .home-dashboard {
        overflow-x: hidden;
    }

    .home-dashboard .header-content,
    .home-dashboard .toolbar-row,
    .home-dashboard main > section.card > .card-header {
        align-items: flex-start;
        gap: 0.55rem;
    }

    .home-dashboard .header-status,
    .home-dashboard .toolbar-actions {
        width: 100%;
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .home-dashboard .user-pill {
        max-width: 100%;
    }

    .home-dashboard .grid,
    .home-dashboard .quick-role-grid {
        min-width: 0;
    }

    .home-dashboard .card,
    .home-dashboard .metric-card {
        min-width: 0;
    }

    .home-dashboard .sync-status {
        max-width: calc(100vw - 1rem);
    }
}

@media (max-width: 960px) {
    .field-expense-layout {
        grid-template-columns: 1fr;
    }
}

/* ===== ESPACE UTILE ET RESPONSIVE PRODUIT ===== */
.page-shell,
.header-content {
    width: min(1760px, calc(100vw - 24px));
    max-width: 1760px;
}

.page-shell {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

.toolbar.card,
.page-shell > .card,
.tab-content,
.tabs {
    margin-bottom: 0.65rem;
}

.tab-content {
    padding: 0.8rem;
}

.card {
    border-radius: var(--radius-md);
}

.card-body {
    min-width: 0;
}

.home-dashboard .page-shell,
.home-dashboard .header-content {
    width: min(1760px, calc(100vw - 20px));
    max-width: 1760px;
}

.home-dashboard .modules-grid {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.module-groups {
    display: grid;
    gap: var(--space-lg);
}

.module-group {
    min-width: 0;
}

.module-group-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: var(--space-sm);
    padding-bottom: var(--space-xs);
    border-bottom: 1px solid var(--color-border);
}

.module-group-heading h4 {
    margin: 0;
    color: var(--color-text);
    font-size: 0.95rem;
}

.module-group-heading p {
    margin: 0.2rem 0 0;
    color: var(--color-text-muted);
    font-size: 0.78rem;
}

.module-group-heading > span {
    flex: 0 0 auto;
    color: var(--color-text-muted);
    font-size: 0.72rem;
}

.progress-track {
    height: 0.55rem;
    overflow: hidden;
    border-radius: 999px;
    background: var(--color-surface-muted, #e2e8f0);
}

.module-sidebar {
    position: fixed;
    z-index: 900;
    top: 50%;
    right: 0;
    width: min(17rem, calc(100vw - 2rem));
    max-height: min(78vh, 44rem);
    overflow: hidden;
    transform: translateY(-50%);
    border: 1px solid var(--color-border);
    border-right: 0;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    background: var(--color-surface, #fff);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.16);
}

.module-sidebar nav {
    display: grid;
    max-height: calc(78vh - 3rem);
    overflow-y: auto;
    padding: 0.35rem;
}

.module-sidebar-toggle,
.module-sidebar-link {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 0.65rem;
    border: 0;
    background: transparent;
    color: var(--color-text);
    text-align: left;
    cursor: pointer;
}

.module-sidebar-toggle {
    min-height: 2.7rem;
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-primary, #1e3a8a);
    font-weight: 700;
}

.module-sidebar-link {
    min-height: 2.45rem;
    padding: 0.5rem 0.65rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
}

.module-sidebar-link:hover,
.module-sidebar-link.is-active {
    background: var(--color-surface-muted, #eef2ff);
    color: var(--color-primary, #1e3a8a);
}

.module-sidebar-link i,
.module-sidebar-toggle i {
    width: 1.1rem;
    text-align: center;
}

.module-sidebar.is-collapsed {
    width: 7rem;
}

.module-sidebar.is-collapsed nav {
    display: none;
}

.module-sidebar.is-collapsed .module-sidebar-toggle {
    justify-content: flex-start;
    border-bottom: 0;
}

.module-sidebar.is-collapsed .module-sidebar-toggle i {
    transform: rotate(180deg);
}

.dashboard-widget {
    width: 100%;
    border: 1px solid var(--color-border);
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.dashboard-widget:hover,
.dashboard-widget:focus-visible {
    border-color: var(--color-primary, #1e3a8a);
    box-shadow: 0 6px 18px rgba(30, 58, 138, 0.12);
}

.dashboard-widget .metric-header {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
}

.dashboard-widget .metric-header i {
    color: var(--color-primary, #1e3a8a);
}

.dashboard-detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(16rem, 1fr);
    gap: var(--space-lg);
    margin-top: var(--space-lg);
}

.dashboard-detail-grid h4 {
    margin: 0 0 0.35rem;
}

.dashboard-trend {
    display: grid;
    grid-template-columns: repeat(6, minmax(3rem, 1fr));
    gap: 0.5rem;
    min-height: 11rem;
    margin-top: 0.75rem;
}

.dashboard-trend-month {
    display: grid;
    grid-template-rows: 8rem auto;
    gap: 0.35rem;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 0.7rem;
}

.dashboard-trend-month:hover {
    background: var(--color-surface-muted, #f8fafc);
}

.dashboard-bars {
    display: flex;
    align-items: end;
    justify-content: center;
    gap: 0.2rem;
    height: 8rem;
    padding: 0.25rem;
    border-bottom: 1px solid var(--color-border);
}

.dashboard-bars i,
.dashboard-bars b {
    display: block;
    width: 35%;
    min-height: 3px;
    border-radius: 0.2rem 0.2rem 0 0;
}

.dashboard-bars i {
    background: #15803d;
}

.dashboard-bars b {
    background: #dc2626;
}

.dashboard-priorities {
    display: grid;
    gap: 0.45rem;
}

.dashboard-priority {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid #f59e0b;
    border-radius: var(--radius-sm);
    background: #fffbeb;
    color: #92400e;
    text-align: left;
    cursor: pointer;
}

.dashboard-priority.is-critical {
    border-color: #ef4444;
    background: #fef2f2;
    color: #991b1b;
}

.dashboard-state {
    margin-bottom: 0.9rem;
    color: var(--color-text-muted);
    font-size: 0.88rem;
}

.dashboard-widget {
    min-height: 160px;
}

.dashboard-widget-status {
    font-size: 0.72rem;
    font-weight: 800;
    border-radius: 999px;
    padding: 0.22rem 0.5rem;
    background: #eef2ff;
    color: #1e3a8a;
    white-space: nowrap;
}

.dashboard-widget-attention .dashboard-widget-status,
.dashboard-widget-insufficient_data .dashboard-widget-status {
    background: #fff7ed;
    color: #9a3412;
}

.dashboard-widget-critique .dashboard-widget-status {
    background: #fef2f2;
    color: #991b1b;
}

.dashboard-gauge {
    margin-top: 0.9rem;
    height: 0.45rem;
    border-radius: 999px;
    background: #e5e7eb;
    overflow: hidden;
}

.dashboard-gauge span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #dc2626, #f59e0b, #16a34a);
}

.dashboard-ops-grid,
.dashboard-tables {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-lg);
    margin-top: var(--space-lg);
}

.dashboard-tables {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dashboard-ops-grid > section,
.dashboard-table-card {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: var(--space-md);
    background: #fff;
}

.dashboard-ops-grid h4,
.dashboard-table-heading h4 {
    margin: 0 0 0.75rem;
    font-size: 0.98rem;
}

.dashboard-cashflow,
.dashboard-recommendations {
    display: grid;
    gap: 0.6rem;
}

.dashboard-cashflow-card {
    display: grid;
    gap: 0.22rem;
    text-align: left;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: #f8fafc;
    padding: 0.75rem;
    cursor: pointer;
}

.dashboard-cashflow-card strong {
    color: var(--color-text);
    font-size: 1.05rem;
}

.dashboard-cashflow-card small {
    color: var(--color-text-muted);
}

.dashboard-cashflow-card.is-warning,
.dashboard-priority.is-warning {
    border-color: #f59e0b;
    background: #fffbeb;
    color: #92400e;
}

.dashboard-cashflow-card.is-critical {
    border-color: #ef4444;
    background: #fef2f2;
    color: #991b1b;
}

.dashboard-recommendation {
    border-left: 4px solid #2563eb;
    background: #eff6ff;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
}

.dashboard-recommendation p {
    margin: 0.25rem 0 0;
    color: var(--color-text-muted);
    line-height: 1.4;
}

.dashboard-recommendation.is-warning {
    border-color: #f59e0b;
    background: #fffbeb;
}

.dashboard-recommendation.is-critical {
    border-color: #ef4444;
    background: #fef2f2;
}

.dashboard-table-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.dashboard-empty-states {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: var(--space-md);
}

.dashboard-empty-states span {
    border: 1px solid var(--color-border);
    border-radius: 999px;
    padding: 0.35rem 0.65rem;
    background: #f8fafc;
    color: var(--color-text-muted);
    font-size: 0.82rem;
}

@media (max-width: 700px) {
    .module-sidebar {
        top: auto;
        right: 0.6rem;
        bottom: 0.75rem;
        width: calc(100vw - 1.2rem);
        max-height: 70vh;
        transform: none;
        border-right: 1px solid var(--color-border);
        border-radius: var(--radius-md);
    }

    .module-sidebar.is-collapsed {
        width: 7rem;
    }

    .dashboard-detail-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-ops-grid,
    .dashboard-tables {
        grid-template-columns: 1fr;
    }

    .dashboard-trend {
        grid-template-columns: repeat(3, minmax(3rem, 1fr));
    }
}

.progress-track > span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--color-primary, #1e3a8a);
    transition: width 180ms ease;
}

.business-plan-auto-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

.business-plan-auto-summary > div {
    display: grid;
    gap: 0.2rem;
    padding: 0.7rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface-muted, #f8fafc);
}

.business-plan-auto-summary span,
.field-help {
    color: var(--color-text-muted);
    font-size: 0.75rem;
}

@media (max-width: 700px) {
    .business-plan-auto-summary {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .module-group-heading {
        align-items: stretch;
        flex-direction: column;
    }
}

@media (min-width: 1280px) {
    .home-dashboard .modules-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    body:not(.home-dashboard) .page-shell {
        padding-top: 0.65rem;
    }

    body:not(.home-dashboard) .toolbar.card {
        padding: 0.65rem 0.85rem;
    }

    body:not(.home-dashboard) .card {
        padding: 1rem;
    }

    body:not(.home-dashboard) .card-header {
        margin-bottom: 0.65rem;
        padding-bottom: 0.55rem;
    }

    body:not(.home-dashboard) .metric-card {
        min-height: 78px;
        padding: 0.65rem 0.8rem;
    }
}

body:not(.home-dashboard) {
    font-size: 0.94rem;
}

body:not(.home-dashboard) .table {
    font-size: 0.86rem;
}

body:not(.home-dashboard) .table th,
body:not(.home-dashboard) .table td {
    padding: 0.7rem 0.75rem;
    line-height: 1.4;
    vertical-align: middle;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}

.field-expense-table {
    min-width: 850px;
}

.field-expense-table td:nth-child(2) {
    min-width: 220px;
}

.field-expense-table td:nth-child(3),
.field-expense-table td:nth-child(4),
.field-expense-table td:nth-child(5) {
    white-space: nowrap;
}

.workflow-page .card-body > p,
.workflow-page .card-header > p,
.workflow-page .manual-section,
.setup-security-list > li {
    line-height: 1.55;
}

.workflow-page .card-body > p + p,
.setup-security-list > li + li {
    margin-top: 0.75rem;
}

.workflow-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.setup-profile-grid {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.setup-profile-card {
    display: flex;
    flex-direction: column;
    min-height: 230px;
}

.setup-profile-card .card-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.75rem;
}

.setup-profile-card .card-body p {
    margin: 0;
    line-height: 1.55;
}

.setup-profile-card .btn {
    align-self: flex-start;
    margin-top: auto;
}

.setup-security-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.setup-security-list > li {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.7rem;
    align-items: start;
}

@media (max-width: 700px) {
    .setup-security-list > li {
        grid-template-columns: 1fr;
        gap: 0.35rem;
    }
}

body:not(.home-dashboard) .table-input {
    min-height: 34px;
    padding: 0.38rem 0.55rem;
}

#payrollPage .table-scroll {
    overflow-x: auto;
    scrollbar-gutter: stable;
}

#payrollPage .table {
    min-width: 0;
}

#payrollPage #employees .table th,
#payrollPage #employees .table td {
    padding: 0.48rem 0.42rem;
}

#payrollPage #employees .table-input {
    width: 5.25rem;
    min-width: 4.75rem;
}

#payrollPage #employees th:first-child,
#payrollPage #employees td:first-child {
    min-width: 10rem;
}

#payrollPage .payroll-filter-bar {
    display: grid;
    grid-template-columns: minmax(240px, 1.5fr) repeat(2, minmax(170px, 0.7fr)) auto;
    gap: 0.6rem;
    align-items: end;
    margin-bottom: 0.8rem;
}

#payrollPage .payroll-variable-table {
    min-width: 1380px;
}

#payrollPage .payroll-variable-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg-subtle);
}

#payrollPage .payroll-variable-table tr[data-dirty="true"] {
    background: #fffbeb;
    box-shadow: inset 3px 0 #d97706;
}

#payrollPage .payroll-variable-table .table-input {
    min-width: 5.5rem;
}

#payrollPage .timesheet-summary-grid {
    margin: 0.85rem 0;
}

#payrollPage .timesheet-validation-actions {
    justify-content: flex-end;
    margin-bottom: 0.65rem;
}

#payrollPage .timesheet-table {
    min-width: 1480px;
}

#payrollPage .timesheet-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg-subtle);
}

#payrollPage .timesheet-anomaly-list {
    display: grid;
    gap: 0.55rem;
}

#payrollPage .timesheet-anomaly-item {
    padding: 0.65rem 0.75rem;
    border: 1px solid #f59e0b;
    border-radius: var(--radius-sm);
    background: #fffbeb;
    line-height: 1.45;
}

.timesheet-preview-table .table-input {
    min-width: 7rem;
}

@media (max-width: 900px) {
    #payrollPage .payroll-filter-bar {
        grid-template-columns: 1fr;
    }

    #payrollPage .timesheet-validation-actions {
        justify-content: stretch;
    }

    #payrollPage .timesheet-validation-actions .btn {
        flex: 1 1 100%;
    }
}

.compact-header {
    margin-bottom: 0.5rem;
    padding-bottom: 0.45rem;
}

.invoice-lines-editor {
    display: grid;
    gap: 0.45rem;
}

.invoice-line-row {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(78px, 0.25fr) minmax(110px, 0.34fr) minmax(78px, 0.24fr) minmax(78px, 0.26fr) minmax(78px, 0.26fr) minmax(78px, 0.26fr) auto;
    gap: 0.45rem;
    align-items: center;
}

.invoice-line-total {
    display: inline-flex;
    gap: 0.25rem;
    align-items: center;
    min-height: 2.35rem;
    padding: 0.3rem 0.45rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--bg-subtle);
    color: var(--text-secondary);
    font-size: var(--text-xs);
    white-space: nowrap;
}

.invoice-preview {
    background: #fff;
    color: #172033;
    border: 1px solid #d8dee9;
    padding: 2rem;
    max-width: 900px;
    margin: 0 auto;
}

.invoice-preview-header {
    display: flex;
    justify-content: space-between;
    gap: 2rem;
    border-bottom: 3px solid var(--primary-blue);
    padding-bottom: 1.25rem;
}

.invoice-preview-title { text-align: right; }
.invoice-preview-title h2 { margin: 0 0 .5rem; letter-spacing: .08em; }
.invoice-party-name { font-size: 1.1rem; font-weight: 700; }
.invoice-customer-box { margin: 1.5rem 0; padding: 1rem; border: 1px solid #d8dee9; max-width: 50%; }
.invoice-totals { width: min(360px, 100%); margin: 1.25rem 0 0 auto; }
.invoice-totals > div { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem .75rem; }
.invoice-total-ttc { background: var(--primary-blue); color: #fff; font-size: 1.05rem; }
.invoice-status-line { margin-top: 1.5rem; border-top: 1px solid #d8dee9; padding-top: .75rem; }

@media (max-width: 700px) {
    .invoice-preview { padding: 1rem; }
    .invoice-preview-header { flex-direction: column; }
    .invoice-preview-title { text-align: left; }
    .invoice-customer-box { max-width: none; }
}

@media (max-width: 900px) {
    .page-shell,
    .header-content,
    .home-dashboard .page-shell,
    .home-dashboard .header-content {
        width: calc(100% - 12px);
        padding-left: 0.45rem;
        padding-right: 0.45rem;
    }

    .invoice-line-row {
        grid-template-columns: 1fr;
    }

    .invoice-line-row .btn {
        width: max-content;
    }
}

*:focus {
    outline: 2px solid var(--primary-blue);
    outline-offset: 2px;
}

.btn:focus,
.tab-btn:focus {
    outline: 2px solid var(--primary-blue);
    outline-offset: 2px;
}

.network-status-banner {
    position: fixed;
    z-index: 10020;
    right: 1rem;
    bottom: 1rem;
    width: min(32rem, calc(100vw - 2rem));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
    padding: 0.75rem 0.9rem;
    border: 1px solid #9fb4cf;
    border-radius: var(--radius-md);
    background: #eef5ff;
    color: #123766;
    box-shadow: 0 12px 36px rgba(15, 23, 42, 0.18);
    font-size: var(--text-sm);
    font-weight: 650;
}

.network-status-banner[hidden] {
    display: none;
}

.network-status-banner.is-offline {
    border-color: #e0a43a;
    background: #fff8e7;
    color: #714600;
}

.network-status-banner button {
    flex: 0 0 auto;
    min-height: 2.25rem;
    padding: 0.4rem 0.7rem;
    border: 0;
    border-radius: var(--radius-sm);
    background: #123766;
    color: white;
    font: inherit;
    cursor: pointer;
}

@media (max-width: 600px) {
    .network-status-banner {
        right: 0.5rem;
        bottom: 0.5rem;
        width: calc(100% - 1rem);
        align-items: stretch;
        flex-direction: column;
    }
}

/* ===== IMPRESSION ===== */
@media print {
    .header,
    .sync-status,
    .btn,
    .modal-overlay,
    .toolbar,
    .tabs,
    .pagination,
    [data-auth-actions] {
        display: none !important;
    }

    .network-status-banner {
        display: none !important;
    }

    @page {
        margin: 12mm;
    }
    
    .card,
    .table {
        box-shadow: none;
        border: 1px solid #cbd5e1;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .page-shell {
        max-width: none;
        padding: 0;
    }

    .tab-content {
        display: block !important;
        min-height: auto;
        padding: 0;
        box-shadow: none;
    }

    body.print-selected-reports .tab-content {
        display: none !important;
    }

    body.print-selected-reports .tab-content[data-print-include="true"] {
        display: block !important;
        page-break-after: always;
    }

    body.journal-print-hide-date #journalTableBody td:nth-child(1),
    body.journal-print-hide-date table.table th:nth-child(1),
    body.journal-print-hide-piece #journalTableBody td:nth-child(2),
    body.journal-print-hide-piece table.table th:nth-child(2),
    body.journal-print-hide-description #journalTableBody td:nth-child(3),
    body.journal-print-hide-description table.table th:nth-child(3),
    body.journal-print-hide-account #journalTableBody td:nth-child(4),
    body.journal-print-hide-account table.table th:nth-child(4),
    body.journal-print-hide-account-name #journalTableBody td:nth-child(5),
    body.journal-print-hide-account-name table.table th:nth-child(5),
    body.journal-print-hide-counterparties #journalTableBody td:nth-child(6),
    body.journal-print-hide-counterparties table.table th:nth-child(6),
    body.journal-print-hide-documents #journalTableBody td:nth-child(7),
    body.journal-print-hide-documents table.table th:nth-child(7),
    body.journal-print-hide-alerts #journalTableBody td:nth-child(8),
    body.journal-print-hide-alerts table.table th:nth-child(8),
    body.journal-print-hide-ht #journalTableBody td:nth-child(9),
    body.journal-print-hide-ht table.table th:nth-child(9),
    body.journal-print-hide-vat #journalTableBody td:nth-child(10),
    body.journal-print-hide-vat table.table th:nth-child(10),
    body.journal-print-hide-ttc #journalTableBody td:nth-child(11),
    body.journal-print-hide-ttc table.table th:nth-child(11),
    body.journal-print-hide-debit #journalTableBody td:nth-child(12),
    body.journal-print-hide-debit table.table th:nth-child(12),
    body.journal-print-hide-credit #journalTableBody td:nth-child(13),
    body.journal-print-hide-credit table.table th:nth-child(13),
    body.journal-print-hide-status #journalTableBody td:nth-child(14),
    body.journal-print-hide-status table.table th:nth-child(14),
    body.journal-print-hide-actions #journalTableBody td:nth-child(15),
    body.journal-print-hide-actions table.table th:nth-child(15) {
        display: none !important;
    }

    .table-scroll {
        max-height: none;
        overflow: visible;
    }

    .table {
        font-size: 10px;
        margin-bottom: 12px;
    }

    .table th,
    .table td {
        padding: 5px 6px;
    }
    
    body {
        background: white;
        color: black;
    }
}
