/* CONTRACTOR-BALANCE-1 (Kamal 23-11-2026, «نفذه» on the approved design ~/Downloads/HOMEi-Contractor-Balance-Design):
   what HOMEi owes each construction company — the companies tab of «متابعة الدفعات الصادرة» and
   «كشف حساب <شركة>». Built on the finance sheet (.fn-*); this file only adds what it lacks (prefix cb-).
   House tokens only, text never below 12px. */

/* ── the companies strip: the hero card first, wider ── */
.fn-strip.cb-strip { grid-template-columns: minmax(0, 1.7fr) repeat(3, minmax(0, 1fr)); }
.cb-strip .cb-hero { background: var(--lm-d-accent-soft); border-radius: 0 16px 16px 0; }
.cb-strip .cb-hero:dir(ltr) { border-radius: 16px 0 0 16px; }
.cb-strip .cb-hero .fn-k-l { color: var(--lm-d-ink); font-weight: 700; font-size: 14px; }
.cb-strip .cb-hero .fn-k-v { font-size: 30px; line-height: 1.2; }
.cb-hero-split { font-size: 13px; color: var(--lm-d-muted); line-height: 1.6; }
.cb-hero-split b { color: var(--lm-d-ink); font-weight: 700; }
.fn .fn-k-cur { font-size: 14px; font-weight: 600; color: var(--lm-d-muted); }

/* ── the companies list ── */
.cb-table td.cb-co > b { display: block; }
.cb-table .cb-phone-line { display: none; }
.cb-table td.cb-net { font-weight: 700; font-size: 15px; }
.fn .cb-due { color: var(--lm-d-accent); font-weight: 700; }
.fn .cb-adv { color: var(--lm-d-warn); }
.fn .cb-zero { color: var(--lm-d-muted); }
.fn .is-neg { color: var(--lm-d-danger); }
.fn .cb-age { font-size: 13px; font-weight: 600; }
.fn .cb-late { color: var(--lm-d-danger); font-weight: 700; white-space: nowrap; }
.fn-split.has-open .cb-hide-open { display: none; }

/* ── the company panel: the sum written as an equation ── */
.cb-eq { display: flex; flex-direction: column; }
.cb-eq > div { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 7px 0; border-block-end: 1px solid var(--lm-d-divider); font-size: 13.5px; }
.cb-eq > div > span { color: var(--lm-d-muted); }
.cb-eq i { display: inline-block; inline-size: 16px; font-style: normal; font-weight: 700; color: var(--lm-d-subtle); }
.cb-eq b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cb-eq .cb-eq-tot { border-block-end: 0; border-block-start: 2px solid var(--lm-d-ink); padding-block-start: 9px; font-size: 15px; }
.cb-eq .cb-eq-tot > span { color: var(--lm-d-ink); font-weight: 700; }
.cb-eq .cb-eq-tot small { font-size: 12.5px; font-weight: 500; color: var(--lm-d-muted); }
.cb-mini th, .cb-mini td { padding: 7px 6px; font-size: 13px; }
.cb-mini tbody tr { cursor: default; }
.cb-pend { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; background: var(--lm-d-quiet-bg); font-size: 13px; }
.cb-pend > span { color: var(--lm-d-muted); }

/* ── «كشف حساب»: facts, pickers, the equation strip ── */
.cb-facts { display: flex; flex-wrap: wrap; gap: 4px 18px; color: var(--lm-d-muted); font-size: 13.5px; }
.cb-facts b { color: var(--lm-d-ink); font-weight: 600; }
.cb-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.cb-range { display: inline-flex; align-items: center; gap: 6px; block-size: 40px; padding: 0 10px; border: 1px solid var(--lm-d-control-edge); border-radius: 12px; background: var(--lm-d-surface); font-size: 13px; color: var(--lm-d-muted); }
.cb-range.is-on { border-color: var(--lm-d-ink); box-shadow: 0 0 0 1px var(--lm-d-ink); }
.cb-range input { font: inherit; font-size: 13px; color: var(--lm-d-ink); border: 0; background: none; inline-size: 132px; }

.cb-eqstrip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 1.3fr); background: var(--lm-d-surface); border: 1px solid var(--lm-d-border); border-radius: 16px; box-shadow: 0 1px 2px var(--lm-d-shadow); }
.cb-eqc { position: relative; padding: 12px 18px; border-inline-start: 1px solid var(--lm-d-divider); min-inline-size: 0; }
.cb-eqc:first-child { border-inline-start: 0; }
.cb-eqc.cb-res { background: var(--lm-d-accent-soft); border-start-end-radius: 16px; border-end-end-radius: 16px; }
.cb-eqc.cb-res .fn-k-l { color: var(--lm-d-ink); font-weight: 700; }
.cb-op { position: absolute; inset-block-start: 50%; inset-inline-start: -11px; transform: translateY(-50%); inline-size: 22px; block-size: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--lm-d-surface); border: 1px solid var(--lm-d-border); font-style: normal; font-weight: 700; font-size: 13px; color: var(--lm-d-muted); z-index: 1; }

.cb-two { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 14px; align-items: start; }
.cb-side { display: flex; flex-direction: column; gap: 14px; }
.fn-card.cb-plain { border-block-start-width: 1px; }
.cb-led tbody tr { cursor: default; }
.cb-led td.cb-date { white-space: nowrap; }
.cb-led td.cb-bal { font-weight: 700; }
.cb-led tr.cb-opening td { background: var(--lm-d-quiet-bg); font-weight: 600; }
.cb-led tr.cb-pending-row td { color: var(--lm-d-muted); }
.cb-kind { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--lm-d-info-soft); color: var(--lm-d-info); }
.cb-kind.is-payment, .cb-kind.is-retention_release { background: var(--lm-d-ok-soft); color: var(--lm-d-ok); }
.cb-kind.is-advance { background: var(--lm-d-warn-soft); color: var(--lm-d-warn); }
.cb-kind.is-advance_refund, .cb-kind.is-advance_write_off { background: var(--lm-d-quiet-bg); color: var(--lm-d-muted); }
.cb-note { padding: 10px 18px; border-block-start: 1px solid var(--lm-d-divider); font-size: 13px; color: var(--lm-d-muted); line-height: 1.6; }

.cb-legend { display: inline-flex; gap: 12px; font-size: 12.5px; color: var(--lm-d-muted); }
.cb-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cb-legend i { display: inline-block; inline-size: 10px; block-size: 10px; border-radius: 3px; }
.cb-legend i.is-paid { background: var(--lm-d-ok); }
.cb-legend i.is-due { background: var(--lm-d-accent); }
.cb-ctrs { display: flex; flex-direction: column; gap: 10px; padding: 12px 16px; }
.cb-ctr { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border: 1px solid var(--lm-d-border); border-radius: 12px; }
.cb-ctr.is-on { border-color: var(--lm-d-info); }
.cb-ctr-h { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.cb-ctr-h span { color: var(--lm-d-muted); font-size: 12.5px; white-space: nowrap; }
.cb-bar { block-size: 8px; border-radius: 6px; background: var(--lm-d-accent); overflow: hidden; }
.cb-bar s { display: block; block-size: 100%; inline-size: var(--cb-pct, 0%); background: var(--lm-d-ok); }
.cb-row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.cb-row span { color: var(--lm-d-muted); }
.cb-row b { font-variant-numeric: tabular-nums; }
.cb-row.is-tot span { color: var(--lm-d-ink); font-weight: 700; }

@media (max-width: 1100px) {
    .fn-strip.cb-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cb-strip .cb-hero { grid-column: 1 / -1; border-radius: 16px 16px 0 0; }
    .cb-strip .fn-strip-c:last-child { grid-column: 1 / -1; }
    .cb-two { grid-template-columns: minmax(0, 1fr); }
    .cb-eqstrip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cb-eqc.cb-res { grid-column: 1 / -1; border-radius: 0 0 16px 16px; }
    .cb-eqc:nth-child(n + 3) { border-block-start: 1px solid var(--lm-d-divider); }
    .cb-eqc:nth-child(odd) { border-inline-start: 0; }
    .cb-op { display: none; }
}
@media (max-width: 640px) {
    .cb-strip .cb-hero .fn-k-v { font-size: 26px; }
    .cb-table td.cb-hide-phone { display: none; }
    .cb-table tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; }
    .cb-table .cb-phone-line { display: block; grid-column: 1 / -1; font-size: 13px; color: var(--lm-d-muted); }
    .cb-table tfoot { display: none; }
    .cb-range { inline-size: 100%; }
    .cb-range input { flex: 1; inline-size: auto; }
    .cb-led td.cb-date { color: var(--lm-d-muted); font-size: 12.5px; }
    .cb-led td.cb-nil { display: none; }
    .cb-led td.fn-end-cell { text-align: start; }
    .cb-led tfoot td[colspan] { display: none; }
    /* the header's words stay (the finance sheet shrinks them to icons, and these buttons carry none) */
    .fn-page.cb-page .fi-header-actions-ctn .fi-btn:not(.fi-color-primary):not(.fi-color-success) { font-size: 14px; gap: 6px; padding-inline: 14px; }
}

/* ── «طباعة»: the statement alone on the paper ── */
@media print {
    .cb-page .fi-sidebar, .cb-page .fi-topbar, .cb-page .fi-header-actions-ctn, .cb-noprint { display: none !important; }
    .cb-page .fi-main { padding: 0 !important; }
    .cb-two { grid-template-columns: minmax(0, 1fr); }
    .cb-eqstrip, .fn-card { box-shadow: none; break-inside: avoid; }
}
