/* ===================================================================
   COST HISTORY · PROJECT HISTORY · ALL PROJECTS — cost-projects.css
   Design-system pass 2026-10-18 (DESIGN-SYSTEM.md). K tokens only.
   Page layout for #panel-cost, #panel-history and #panel-allprojects:
   the toolbars, the card grids, the Cost History › Projects table and the
   All Projects portfolio strip. The page-header row is the shared
   .page-head / .page-head-actions (styles.css). The shared pieces live in
   styles.css (cost search card, $/SF tiles, search field, project card,
   outcome pills); the unit-cost results + drill-down in cost-library.css;
   the Lead Times tab in lead-times.css.

   Color jobs (red + grayscale only):
   - brand red — primary actions, the active tab, the selected $/SF tile,
     active filters (red wash), Hard Bid, the source / "Current" pill icons
   - stage colors (§2.4) — Pursuit gray-400 → Preconstruction gray-650 →
     Hard Bid red; completed (awarded) work ink, lost work light gray
   - ink / gray — structure and every figure
   Team avatars use the shared avatar palette (project-team.css), exactly
   as on the Company Dashboard and the project hero.
   Class names avoid "empty", "-label" and "-value" (styles.css restyles
   any class containing them).
   =================================================================== */

/* ----- toolbar row (Project History, All Projects): search + filters ----- */
:is(#panel-history,#panel-allprojects) .cp-toolbar{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin:0 0 16px}
:is(#panel-history,#panel-allprojects) .cp-toolbar .cost-search-input{flex:1 1 280px;max-width:520px}
:is(#panel-history,#panel-allprojects) .cp-toolbar .form-select{flex:0 0 auto;width:160px;font-size:12.5px}
:is(#panel-history,#panel-allprojects) .cp-toolbar .form-select:has(option:checked:not([value=""])){border-color:var(--k-accent-line);background-color:var(--k-accent-wash);color:var(--k-accent-ink);font-weight:600}
:is(#panel-history,#panel-allprojects) .cp-toolbar-end{margin-left:auto}

/* ----- card grids: never more than 4 across — the pre-redesign card width
   (.grid-4), so a wide screen gets wider cards, not a 5th or 6th column.
   A card never drops under 280px (its footer buttons stay on one line): a
   narrower window goes 3 / 2 across, a phone stacks them. 25% - 13px = a
   quarter of the row less its share of the three 16px gaps (+1px slack). ----- */
#projCardGrid,#histCardGrid{grid-template-columns:repeat(auto-fill,minmax(min(100%,max(280px,calc(25% - 13px))),1fr));gap:16px}

/* ----- empty states: the product empty state (.k-blank). One that stands
   alone on the canvas (Project History, All Projects search) gets the
   dashed frame; one inside a card (Cost History lists) stays plain. ----- */
#projCardGrid > .k-blank{grid-column:1/-1}
:is(#panel-history,#panel-allprojects) .k-blank{border:1px dashed var(--k-line-strong);border-radius:var(--k-r-lg);background:var(--k-surface-2)}
:is(#panel-cost,#panel-history,#panel-allprojects) .k-blank .btn{margin-top:8px}

/* ===== COST HISTORY ===== */
/* Clear = a quiet ghost button at the end of each toolbar. */
#panel-cost .cost-search-controls .btn-ghost{flex:0 0 auto}

/* Projects sub-tab: the product table inside its wrapper (1px line, radius 12;
   boxed because the disclaimer follows it). Figures = the shared .k-num. */
#panel-cost .cp-tbl-wrap{overflow-x:auto;border:1px solid var(--k-line);border-radius:var(--k-r-lg)}
#panel-cost .cp-tbl-wrap .tbl{margin:0}
/* K CORE left-aligns every .tbl header (body .tbl thead th): figure columns keep theirs right, in the UI font. */
#panel-cost .cp-tbl-wrap .tbl th.k-num{text-align:right;font-family:var(--k-font)}
#panel-cost .cp-tbl-wrap .tbl td.cp-mono{font-family:var(--k-mono);font-variant-numeric:tabular-nums;white-space:nowrap}
#panel-cost .cp-tbl-wrap .tbl td.cp-strong{font-weight:700;color:var(--k-ink)}
#panel-cost .cp-tbl-wrap .tbl td.cp-name{font-weight:700;color:var(--k-ink);min-width:180px}
#panel-cost .cp-tbl-wrap .tbl :is(th,td).cp-act{text-align:right;white-space:nowrap}
#panel-cost .cp-tbl-wrap .cp-dim{margin-left:2px;font-size:10.5px;color:var(--k-text-3)}
#panel-cost .cp-tbl-wrap .cp-muted{color:var(--k-text-3)}

/* ===== ALL PROJECTS ===== */
/* Portfolio strip: one slim card — two figures + the stage-split bar. */
#panel-allprojects .cp-port{display:flex;align-items:center;gap:24px;flex-wrap:wrap;padding:12px 16px;margin:0 0 16px}
#panel-allprojects .cp-port-fig{flex-shrink:0;min-width:0}
#panel-allprojects .cp-port-k{font-size:var(--k-fs-micro);font-weight:700;line-height:1.3;letter-spacing:var(--k-ls-micro);text-transform:uppercase;color:var(--k-text-2)}
#panel-allprojects .cp-port-n{margin-top:4px;font-family:var(--k-mono);font-size:var(--k-fs-xl);font-weight:700;line-height:1.1;letter-spacing:-0.02em;color:var(--k-ink);white-space:nowrap;font-variant-numeric:tabular-nums}
#panel-allprojects .cp-port-n small{margin-left:6px;font-family:var(--k-font);font-size:var(--k-fs-xs);font-weight:500;letter-spacing:0;color:var(--k-text-3)}
#panel-allprojects .cp-port-mix{flex:1 1 300px;min-width:0}
#panel-allprojects .cp-port-bar{display:flex;gap:2px;height:10px;border-radius:var(--k-r-pill);overflow:hidden;background:var(--k-fill-2)}
#panel-allprojects .cp-port-bar > span{display:block;height:100%;min-width:2px}
#panel-allprojects .cp-port-legend{display:flex;flex-wrap:wrap;gap:4px 16px;margin-top:8px}
#panel-allprojects .cp-port-lg{display:inline-flex;align-items:center;gap:6px;font-size:var(--k-fs-xs);color:var(--k-text-2);white-space:nowrap}
#panel-allprojects .cp-port-lg b{font-family:var(--k-mono);font-weight:600;color:var(--k-ink);font-variant-numeric:tabular-nums}
#panel-allprojects .cp-port-sw{width:10px;height:10px;border-radius:2px;flex-shrink:0}
/* stage colors (DESIGN-SYSTEM §2.4) */
#panel-allprojects .cp-st-pursuit{background:var(--k-stage-pursuit)}
#panel-allprojects .cp-st-active{background:var(--k-stage-active)}
#panel-allprojects .cp-st-hard_bid{background:var(--k-stage-hard)}
#panel-allprojects .cp-st-completed{background:var(--k-stage-won)}

/* ----- phones ----- */
@media (max-width:768px){
  :is(#panel-history,#panel-allprojects) .cp-toolbar .cost-search-input{flex-basis:100%;max-width:none}
  :is(#panel-history,#panel-allprojects) .cp-toolbar .form-select{flex:1 1 140px;width:auto}
  :is(#panel-history,#panel-allprojects) .cp-toolbar-end{margin-left:0}
  /* The phone layer grows .btn-sm to 32px: the card footer's icon button matches it. */
  #histCardGrid .proj-card-foot-actions .k-icon-btn.is-sm{width:var(--k-control-h);height:var(--k-control-h)}
  #panel-cost .cost-search-card{padding:14px}
  #panel-cost .cost-kpi-strip{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
  #panel-cost .cost-search-controls .cost-search-input{flex-basis:100%}
  #panel-cost .cost-search-controls .cost-filter-select{flex:1 1 140px;min-width:0;width:auto !important}
  #panel-cost .cost-region-help{flex-basis:100%;margin-left:0}
  #panel-allprojects .cp-port{gap:12px 20px}
  #panel-allprojects .cp-port-mix{flex-basis:100%}
}
