/* ──────────────────────────────────────────────────────────────────
   Editions (Compte de Résultat, Bilan, Analytique)
   ────────────────────────────────────────────────────────────────── */

.edition-wrap {
    font-family: 'Segoe UI', Arial, sans-serif;
    font-size: 14px;
    color: #1f2937;
    max-width: 1100px;
}

/* ── Filtre période ───────────────────────────────────────────────── */
.edition-filter {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
}
.edition-filter label { font-weight: 500; }
.edition-filter input[type="date"] {
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 5px 8px;
    margin-left: 6px;
}
.btn-filter {
    background: #065f46;
    color: #fff;
    border: none;
    padding: 7px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}
.btn-filter:hover { background: #047857; }
.edition-exercise {
    color: #6b7280;
    font-style: italic;
    font-size: 13px;
}

/* ── Sous-onglets (même style que .configuration .tab) ─────────────── */
.edition-tabs {
    margin: 20px 0 0 0;
    border-bottom: 2px solid var(--border-color, #e5e7eb);
    display: flex;
    gap: 5px;
    position: relative;
    z-index: 1;
    background: transparent;
    overflow-x: auto;
    margin-bottom: 24px;
}
.edition-tab {
    padding: 12px 24px;
    background: var(--gray-100, #f3f4f6);
    border: none;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-size: 17px;
    font-weight: 600;
    color: var(--primary-color, #065f46);
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-bottom: 3px solid transparent;
    min-width: fit-content;
}
.edition-tab:hover {
    background: var(--gray-200, #e5e7eb);
    color: var(--gray-700, #374151);
    text-decoration: none;
}
.edition-tab.active {
    background: #fff;
    color: var(--primary-color, #065f46);
    border-bottom-color: var(--primary-color, #065f46);
    margin-bottom: -2px;
    position: relative;
    z-index: 2;
}
.edition-tab i { font-size: 1.2em; }

/* ── En-tête impression ───────────────────────────────────────────── */
.cr-header {
    text-align: center;
    margin-bottom: 20px;
}
.cr-header h2 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin: 0 0 4px;
}

/* ── Table Compte de Résultat ─────────────────────────────────────── */
.cr-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 24px;
    font-size: 13px;
}
.cr-table thead tr {
    background: #064e3b;
    color: #fff;
}
.cr-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
}
.cr-col-label { width: 64%; }
.cr-col-n     { width: 18%; text-align: right; }
.cr-col-n1    { width: 18%; text-align: right; color: #9ca3af; }

.cr-table td {
    padding: 7px 12px;
    border-bottom: 1px solid #f1f5f9;
}
.cr-val { text-align: right; font-variant-numeric: tabular-nums; }
.cr-n1  { color: #9ca3af; }

/* Niveaux hiérarchiques */
.cr-section td {
    background: #f0fdf4;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #065f46;
    border-top: 2px solid #d1fae5;
    border-bottom: 1px solid #d1fae5;
}
.cr-level-1 .cr-label { padding-left: 16px; }
.cr-level-2 .cr-label { padding-left: 32px; color: #374151; }
.cr-level-3 .cr-label { padding-left: 48px; color: #6b7280; font-style: italic; font-size: 12px; }

/* Totaux */
.cr-total td {
    background: #ecfdf5;
    font-weight: 700;
    border-top: 2px solid #6ee7b7;
    border-bottom: 2px solid #6ee7b7;
}

/* Résultats */
.cr-result td {
    background: #fef9c3;
    font-weight: 700;
    font-size: 13px;
    border-top: 2px solid #fde68a;
    border-bottom: 2px solid #fde68a;
    color: #1f2937;
}

/* Valeurs zéro */
.cr-zero { color: #d1d5db; }

/* Montants positifs/négatifs */
.cr-pos { color: #065f46; font-weight: 600; }
.cr-neg { color: #dc2626; font-weight: 600; }

/* ── Bilan ────────────────────────────────────────────────────────── */
.bilan-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}
.bilan-colhead {
    padding: 12px 16px;
    margin: 0 0 12px;
    font-size: 15px;
    font-weight: 700;
    border-radius: 6px 6px 0 0;
    letter-spacing: 1px;
}
.bilan-colhead.actif  { background: #dbeafe; color: #1e40af; }
.bilan-colhead.passif { background: #fce7f3; color: #9d174d; }
.bilan-warn {
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: 4px;
    padding: 8px 12px;
    margin-top: 8px;
    font-size: 12px;
    color: #92400e;
}

/* ── Analytique ───────────────────────────────────────────────────── */
.analytique-summary {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.ana-card {
    flex: 1 1 180px;
    border-radius: 8px;
    padding: 16px 20px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}
.ana-card.produit { border-top: 4px solid #10b981; }
.ana-card.charge  { border-top: 4px solid #ef4444; }
.ana-card.result.pos { border-top: 4px solid #3b82f6; }
.ana-card.result.neg { border-top: 4px solid #f97316; }
.ana-card-label { font-size: 12px; color: #6b7280; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.ana-card-val   { font-size: 22px; font-weight: 700; margin-top: 4px; color: #1f2937; }

.ana-section { margin-bottom: 28px; }
.ana-section-title {
    font-size: 15px;
    font-weight: 700;
    padding: 8px 14px;
    border-left: 4px solid #065f46;
    background: #f8fafc;
    margin: 0 0 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.ana-section-total {
    font-size: 16px;
    font-weight: 700;
    color: #065f46;
}

.ana-table code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
    color: #475569;
}
.ana-col-cat { width: 50%; }

/* Ligne catégorie expandable */
.ana-expandable { cursor: pointer; }
.ana-expandable:hover td { background: #f0fdf4; }
.ana-cat-label { padding-left: 12px !important; }
.ana-cat-compte {
    background: #e0f2fe;
    color: #0369a1;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 11px;
    margin-left: 8px;
    vertical-align: middle;
}
/* Badge sous-classe (706xxx) */
.ana-sc-badge {
    background: #1e3a5f;
    color: #bfdbfe;
    padding: 1px 7px;
    border-radius: 3px;
    font-size: 11px;
    margin-right: 8px;
    vertical-align: middle;
    letter-spacing: 0.3px;
}
/* Mention catégorie (en gris sous le label) */
.ana-cat-hint {
    color: #9ca3af;
    font-size: 11px;
    margin-left: 8px;
    font-style: italic;
}
.ana-toggle {
    display: inline-block;
    width: 16px;
    font-size: 10px;
    color: #6b7280;
    transition: transform 0.15s;
    user-select: none;
}
/* Ligne détail compte */
.ana-compte-row td { background: #f8fafc; }
.ana-compte-label {
    padding-left: 40px !important;
    color: #6b7280;
    font-size: 12px;
}

/* Barre de pourcentage */
.pct-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 140px;
}
.pct-fill {
    height: 8px;
    border-radius: 4px;
    min-width: 2px;
    flex-shrink: 0;
}
.pct-bar span { font-size: 12px; color: #4b5563; white-space: nowrap; }

/* ── Impression ───────────────────────────────────────────────────── */
@media print {
    .no-print, .edition-filter, .edition-tabs { display: none !important; }
    .print-only { display: block !important; }
    .edition-wrap { max-width: 100%; font-size: 11px; }
    .cr-table { page-break-inside: avoid; }
    .bilan-grid { grid-template-columns: 1fr 1fr; }
    .edition-content { padding: 0; }
    body { background: white; }

    @page {
        size: A4;
        margin: 15mm 10mm;
    }
}
.print-only { display: none; }
