/* Billing analysis (#analysis) and APP.invoices. Kit tokens only; classes prefixed bl-.
   Tables follow the house table standard in app.css; nothing here overrides it. */
.bl { min-width: 0; }
.bl .page-head { margin-bottom: 0; } /* the .stack-24 wrapper gives the 24 px below the header */
.bl-nowrap { white-space: nowrap; }
.bl-bad { color: var(--destructive); }
.bl-invalid { border-color: var(--destructive) !important; }

/* Header: period select (P1), view tabs, facts */
.bl-filters { gap: 12px; min-height: 32px; }
.bl-period { width: auto; min-width: 200px; flex: 0 0 auto; }

/* Summary table (B2): totals row, header "How" buttons */
.bl-th { display: inline-flex; align-items: center; gap: 4px; }
.table tfoot td { border-top: 1px solid var(--border); border-bottom: 0; background: var(--muted); font-weight: 600; }
.table tfoot .cell-sub { font-weight: 400; }
.bl-how { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: var(--radius-sm, 6px); background: transparent; color: var(--muted-foreground); cursor: pointer; }
.bl-how:hover, .bl-how:focus-visible { background: var(--accent); color: var(--foreground); }
.bl-how svg { width: 14px; height: 14px; }
.bl-pop { position: fixed; z-index: 60; width: 280px; max-width: calc(100vw - 16px); padding: 12px; display: flex; flex-direction: column; gap: 4px; background: var(--popover); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); white-space: normal; text-align: left; font-weight: 400; }

/* One contract (B3): sections 24 px apart, KPI tiles balanced at 5 */
.bl-section { min-width: 0; }
.bl-sec-head { min-height: 32px; }
.bl-kpis { grid-template-columns: repeat(var(--bl-n, 5), minmax(0, 1fr)); }
@media (max-width: 1199px) { .bl-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.bl-kpis .ra-kpi .t-meta { font-size: 12px; line-height: 16px; }
.bl-wf-why { display: block; font-size: 12px; line-height: 16px; font-weight: 400; color: var(--muted-foreground); }
.bl-card { padding: 16px; }

/* Side panel content */
.bl-panel { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.bl-sec { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.bl-total { padding-top: 8px; border-top: 1px solid var(--border); }
.bl-panel .kv { grid-template-columns: minmax(120px, 36%) minmax(0, 1fr); }

/* Dialogs */
.bl-dialog .bl-dlg-body { margin-top: 16px; }

/* Invoice insights (APP.invoices.insights) */
.bl-k6 .ra-kpis { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.bl-causes { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; }
/* Billing analysis summary: fixed widths (950 px) so it fits the content width at 1280 px (about 960 px) */
.bl-sum .table { table-layout: fixed; width: 100%; }
.bl-sum th:nth-child(1) { width: 136px; } .bl-sum th:nth-child(2) { width: 120px; } .bl-sum th:nth-child(3) { width: 120px; }
.bl-sum th:nth-child(4) { width: 136px; } .bl-sum th:nth-child(5) { width: 124px; } .bl-sum th:nth-child(6) { width: 124px; }
.bl-sum th:nth-child(7) { width: 150px; } .bl-sum th:nth-child(8) { width: 40px; }
.bl-sum th { height: auto; min-height: 40px; padding-top: 8px; padding-bottom: 8px; vertical-align: middle; }
.bl-sum th .bl-th-sub { white-space: normal; font-weight: 400; }
.bl-sum td .cell-sub { white-space: normal; }
/* Round 8: Delivery tables fit at 1280 px (content about 960 px); wide notes wrap in two lines */
.bl-rec .table, .bl-fc .table { width: 100%; }
.bl-rec th:first-child { width: 200px; }
.bl-fc td:nth-last-child(2) { min-width: 240px; white-space: normal; }
/* Delivery tiles: the unit sits beside the number in a smaller muted size so long units fit */
.bl-unit { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--muted-foreground); }
/* Round 9: Balance to go (P3) and credit notes (V3) fit the content width at 1280 px (about 960 px) */
.bl-btg .table, .bl-btgm .table, .bl-btgc .table, .bl-cn .table { width: 100%; }
.bl-btg .table { table-layout: fixed; }
.bl-btg th:nth-child(1) { width: 128px; } .bl-btg th:nth-child(2), .bl-btg th:nth-child(3), .bl-btg th:nth-child(4) { width: 108px; }
.bl-btg th:nth-child(5) { width: 72px; } .bl-btg th:nth-child(6), .bl-btg th:nth-child(7) { width: 108px; }
.bl-btg th:nth-child(8) { width: 180px; } .bl-btg th:nth-child(9) { width: 40px; }
.bl-btg th { white-space: normal; height: auto; min-height: 40px; padding-top: 8px; padding-bottom: 8px; }
.bl-btg td .cell-sub { white-space: normal; }
.bl-cn td:nth-child(3) { min-width: 180px; }
.bl-cn td:nth-child(6) { min-width: 150px; }
