/* Onglet « Balance âgée » de l'écran Balance (views/comptageneral/etatFinancier/balanceAgee.html), préfixe bag- */

.bag-zone { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.bag-root { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding: 8px 10px 10px; overflow: auto;
    font-size: 13px; color: var(--ax-text, #1f2937); }

/* ── Critères ── */
.bag-criteres { background: #fff; border: 1px solid var(--ax-border, #e5e7eb); border-radius: 12px; padding: 10px 12px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .05); }
.bag-ligne, .bag-options { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; }
.bag-options { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--ax-border, #e5e7eb); }
.bag-champ { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.bag-label { font-size: 11px; font-weight: 600; color: var(--ax-text-sec, #64748b); text-transform: uppercase; letter-spacing: .3px; }
.bag-root .form-control { height: 34px; border-radius: 8px; border-color: #d7dce5; box-shadow: none; font-size: 13px; }
.bag-root .form-control:focus { border-color: var(--ax-primary, #3f51b5); box-shadow: 0 0 0 3px rgba(63, 81, 181, .12); }
.bag-select { min-width: 200px; }
.bag-champ-date .bag-date { display: flex; }
.bag-champ-date input { width: 118px; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.bag-icone { width: 36px; border: 1px solid #d7dce5; border-left: 0; border-radius: 0 8px 8px 0; background: #f8fafc; color: var(--ax-primary, #3f51b5); }
.bag-icone:hover { background: #eef2ff; }
.bag-suffixe { display: flex; align-items: center; gap: 6px; }
.bag-suffixe input { width: 74px; }
.bag-suffixe span { color: var(--ax-text-sec, #64748b); font-size: 12px; }

.bag-segment { display: inline-flex; background: #f1f5f9; border-radius: 9px; padding: 3px; gap: 2px; }
.bag-segment button { border: 0; background: transparent; padding: 5px 12px; border-radius: 7px; font-size: 13px; font-weight: 600;
    color: #475569; white-space: nowrap; transition: background .15s ease, color .15s ease, box-shadow .15s ease; }
.bag-segment button:hover { color: var(--ax-primary, #3f51b5); }
.bag-segment button.actif { background: #fff; color: var(--ax-primary, #3f51b5); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }
.bag-segment-petit button { padding: 4px 10px; font-size: 12px; }
.bag-root button:focus-visible, .bag-panneau button:focus-visible, .bag-tiers:focus-visible { outline: 2px solid var(--ax-primary, #3f51b5); outline-offset: 2px; }

.bag-tranches { display: flex; align-items: center; gap: 8px; }
.bag-tranches input { width: 190px; }
.bag-lien { border: 0; background: none; color: var(--ax-primary, #3f51b5); font-size: 12px; font-weight: 600; padding: 0; white-space: nowrap; }
.bag-lien:hover { text-decoration: underline; }
.bag-lien[disabled] { color: #cbd5e1; text-decoration: none; }
.bag-champ-collectifs { min-width: 240px; }
.bag-champ-compte input { width: 120px; }
.bag-interrupteurs { display: flex; flex-wrap: wrap; gap: 0 18px; align-items: center; }
.bag-interrupteurs md-switch { margin: 4px 0; font-size: 13px; }

.bag-actions { display: flex; gap: 8px; margin-left: auto; align-items: center; flex-wrap: wrap; }
.bag-btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 8px; font-size: 13px; font-weight: 600;
    border: 1px solid transparent; background: #fff; cursor: pointer; transition: background .15s ease, border-color .15s ease; white-space: nowrap; }
.bag-btn[disabled] { opacity: .55; cursor: not-allowed; }
.bag-btn-primaire { background: var(--ax-primary, #3f51b5); color: #fff; }
.bag-btn-primaire:hover:not([disabled]) { background: #34449b; }
.bag-btn-ghost { border-color: #d7dce5; color: #334155; }
.bag-btn-ghost:hover:not([disabled]) { background: #f8fafc; }
.bag-btn-excel { border-color: #bbf7d0; color: #15803d; background: #f0fdf4; }
.bag-btn-excel:hover:not([disabled]) { background: #dcfce7; }
.bag-btn-pdf { border-color: #fecaca; color: #b91c1c; background: #fef2f2; }
.bag-btn-pdf:hover:not([disabled]) { background: #fee2e2; }

/* ── Bandeaux ── */
.bag-bandeau { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; background: #fffbeb;
    border: 1px solid #fde68a; color: #92400e; font-size: 12.5px; }
.bag-bandeau-erreur { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.bag-bandeau .bag-btn { margin-left: auto; height: 28px; }

/* ── Chargement ── */
.bag-squelette { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.bag-squelette-kpi { height: 74px; border-radius: 12px; }
.bag-squelette-ligne { grid-column: 1 / -1; height: 22px; border-radius: 6px; }
.bag-squelette-kpi, .bag-squelette-ligne { background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%); background-size: 200% 100%;
    animation: bagReflet 1.2s linear infinite; }
@keyframes bagReflet { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.bag-contenu { display: flex; flex-direction: column; gap: 10px; min-height: 0; transition: opacity .15s ease; }
.bag-recalcul { opacity: .55; pointer-events: none; }

/* ── Indicateurs ── */
.bag-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.bag-kpi { background: #fff; border: 1px solid var(--ax-border, #e5e7eb); border-radius: 12px; padding: 10px 14px; display: flex; flex-direction: column;
    gap: 2px; position: relative; overflow: hidden; }
.bag-kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--ax-primary, #3f51b5); }
.bag-kpi-retard::before { background: #ef4444; }
.bag-kpi-echu::before { background: #3b82f6; }
.bag-kpi-inverse::before { background: #f59e0b; }
.bag-kpi-controle::before { background: #22c55e; }
.bag-kpi-ko::before { background: #ef4444; }
.bag-kpi-titre { font-size: 11px; font-weight: 600; color: var(--ax-text-sec, #64748b); text-transform: uppercase; letter-spacing: .3px; }
.bag-kpi-valeur { font-size: 19px; font-weight: 700; color: var(--ax-text-strong, #0f172a); font-variant-numeric: tabular-nums; }
.bag-kpi-sous { font-size: 12px; color: var(--ax-text-sec, #64748b); }
.bag-kpi-controle .fa-check-circle { color: #16a34a; }
.bag-kpi-ko .bag-kpi-sous { color: #b91c1c; }

/* ── « Les deux » : synthèse et sections ── */
.bag-kpi-dettes::before { background: #f97316; }
.bag-kpi-position::before { background: #0ea5e9; }
.bag-kpi-negative .bag-kpi-valeur { color: #b91c1c; }
.bag-kpi-double { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; color: var(--ax-text-strong, #0f172a);
    font-variant-numeric: tabular-nums; }
.bag-kpi-double .fa { width: 16px; font-size: 12px; color: #94a3b8; }
.bag-kpi-controle .bag-kpi-valeur .fa-check-circle { color: #16a34a; }
.bag-kpi-ko .bag-kpi-valeur .fa-times-circle { color: #dc2626; }
.bag-section { display: flex; flex-direction: column; gap: 10px; }
.bag-section + .bag-section { margin-top: 8px; padding-top: 14px; border-top: 1px dashed #cbd5e1; }
.bag-section-entete { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; background: #fff;
    border: 1px solid var(--ax-border, #e5e7eb); border-left: 4px solid var(--ax-primary, #3f51b5); }
.bag-section-FOURNISSEURS .bag-section-entete { border-left-color: #f97316; }
.bag-section-entete h3 { margin: 0; font-size: 15px; font-weight: 700; color: var(--ax-text-strong, #0f172a); }
.bag-section-entete > .fa { color: var(--ax-primary, #3f51b5); }
.bag-section-FOURNISSEURS .bag-section-entete > .fa { color: #f97316; }
.bag-section-total { margin-left: auto; font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bag-section .bag-table-zone { flex: none; max-height: 70vh; }

/* ── Répartition ── */
.bag-repartition { background: #fff; border: 1px solid var(--ax-border, #e5e7eb); border-radius: 12px; padding: 10px 14px; }
.bag-barre { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: #f1f5f9; }
.bag-barre-segment { height: 100%; min-width: 2px; }
.bag-barre-segment + .bag-barre-segment { border-left: 2px solid #fff; }
.bag-legende { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; font-size: 12px; color: #475569; }
.bag-legende i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; }
.bag-legende b { color: var(--ax-text-strong, #0f172a); margin-left: 3px; }

/* ── Tableau ── */
.bag-table-barre { display: flex; align-items: center; gap: 14px; }
.bag-recherche { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid #d7dce5; border-radius: 9px; padding: 0 10px;
    height: 34px; width: 320px; max-width: 100%; }
.bag-recherche:focus-within { border-color: var(--ax-primary, #3f51b5); box-shadow: 0 0 0 3px rgba(63, 81, 181, .12); }
.bag-recherche i { color: #94a3b8; }
.bag-recherche input { border: 0; outline: 0; flex: 1; font-size: 13px; background: transparent; }
.bag-aide { font-size: 12px; color: var(--ax-text-light, #94a3b8); }
.bag-table-zone { background: #fff; border: 1px solid var(--ax-border, #e5e7eb); border-radius: 12px; overflow: auto; min-height: 220px; flex: 1; }
.bag-table { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
.bag-table th { position: sticky; top: 0; z-index: 2; background: #f8fafc; color: #475569; font-size: 11.5px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .2px; padding: 9px 10px; border-bottom: 1px solid var(--ax-border, #e5e7eb); white-space: nowrap; text-align: left; }
.bag-table td { padding: 6px 10px; border-bottom: 1px solid #f1f5f9; white-space: nowrap; }
.bag-num { text-align: right !important; }
.bag-col-compte { width: 96px; color: #475569; }
.bag-col-tiers { min-width: 220px; white-space: normal !important; }
.bag-pastille { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.bag-groupe td { background: #f8fafc; font-weight: 700; color: #334155; cursor: pointer; border-bottom: 1px solid #e2e8f0; }
.bag-groupe:hover td { background: #eef2ff; }
.bag-groupe .fa { width: 14px; color: #94a3b8; }
.bag-groupe-libelle { font-weight: 500; color: #64748b; margin-left: 6px; }
.bag-nb { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 6px; border-radius: 999px; background: #e0e7ff; color: #3730a3;
    font-size: 11px; font-weight: 700; text-align: center; }
.bag-tiers { cursor: pointer; transition: background .1s ease; }
.bag-tiers:hover td { background: #f5f7ff; }
.bag-tiers.bag-actif td { background: #eef2ff; }
.bag-solde { font-weight: 600; }
.bag-retard { color: #b91c1c; }
.bag-negatif, .bag-negatif td { color: #b45309; }
.bag-an { color: #94a3b8; margin-left: 6px; }
.bag-ecart { color: #dc2626; margin-left: 6px; }
.bag-jauge { display: inline-block; width: 42px; height: 6px; border-radius: 999px; background: #fee2e2; margin-right: 8px; vertical-align: middle; overflow: hidden; }
.bag-jauge span { display: block; height: 100%; background: #ef4444; max-width: 100%; }
.bag-table tfoot td { position: sticky; z-index: 1; background: #fff; font-weight: 700; }
.bag-total td { bottom: 26px; border-top: 2px solid #cbd5e1; color: var(--ax-text-strong, #0f172a); }
.bag-pct td { bottom: 0; color: #475569; font-size: 12px; }
.bag-vide { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 28px; color: #64748b; }
.bag-vide .fa { color: #22c55e; font-size: 18px; }

/* ── Soldes inverses ── */
.bag-inverses { border-top: 8px solid #f8fafc; }
.bag-inverses-titre { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: #fffbeb; padding: 10px 12px; font-weight: 700;
    color: #92400e; text-align: left; }
.bag-inverses-titre .bag-nb { background: #fde68a; color: #92400e; }
.bag-inverses-total { margin-left: 10px; font-variant-numeric: tabular-nums; }
.bag-inverses-titre .bag-aide { margin-left: auto; font-weight: 500; color: #b45309; }

/* ── Panneau latéral du tiers ── */
.bag-voile { position: fixed; inset: 0; background: rgba(15, 23, 42, .18); z-index: 1040; }
.bag-panneau { position: fixed; top: 0; right: 0; bottom: 0; width: min(1000px, 96vw); background: #fff; z-index: 1041; font-size: 13px; color: var(--ax-text, #1f2937); display: flex; flex-direction: column;
    box-shadow: -12px 0 32px rgba(15, 23, 42, .18); animation: bagEntree .2s ease-out; }
@keyframes bagEntree { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.bag-panneau-entete { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 20px;
    background: var(--ax-primary, #3f51b5); color: #fff; }
.bag-panneau-entete h3 { margin: 2px 0 0; font-size: 18px; font-weight: 700; }
.bag-panneau-compte { font-size: 12px; opacity: .85; }
.bag-fermer { width: 32px; height: 32px; border: 0; border-radius: 8px; background: rgba(255, 255, 255, .15); color: #fff; }
.bag-fermer:hover { background: rgba(255, 255, 255, .28); }
.bag-panneau-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--ax-border, #e5e7eb); border-bottom: 1px solid var(--ax-border, #e5e7eb); }
.bag-panneau-kpis div { background: #fff; padding: 10px 16px; display: flex; flex-direction: column; gap: 2px; }
.bag-panneau-kpis span { font-size: 11px; color: #64748b; text-transform: uppercase; font-weight: 600; letter-spacing: .3px; }
.bag-panneau-kpis b { font-size: 15px; font-variant-numeric: tabular-nums; }
.bag-panneau-repartition { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px; border-bottom: 1px solid #f1f5f9; }
.bag-puce { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border: 1px solid #e2e8f0; border-radius: 999px; font-size: 12px; background: #fff; }
.bag-puce i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.bag-puce b { font-variant-numeric: tabular-nums; }
.bag-puce-petite { padding: 1px 8px; font-size: 11.5px; }
.bag-panneau-corps { flex: 1; overflow: auto; padding: 12px 16px 20px; }
.bag-panneau-corps h4 { margin: 0 0 8px; font-size: 13px; font-weight: 700; color: #334155; }
.bag-table-pieces td { font-size: 12.5px; }
.bag-libelle { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.bag-origine { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 6px; background: #f1f5f9; color: #475569; font-size: 11px; font-weight: 600; }

@media (max-width: 900px) {
    .bag-actions { margin-left: 0; }
    .bag-panneau-kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
    .bag-panneau, .bag-squelette-kpi, .bag-squelette-ligne { animation: none; }
    .bag-contenu, .bag-segment button, .bag-btn { transition: none; }
}
