/* Barclay Project Manager — Consultant section. Ported from Barclay Consultant Response (style.css);
   everything is scoped under .cr and uses the shared palette variables from app.css. */

.cr .lede { margin: 0 0 14px; color: var(--muted); }
.cr .hint { color: var(--muted); font-size: 12.5px; margin: 10px 0 0; }
.cr .req { color: var(--red); font-style: normal; }
.cr .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.cr .head-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.cr .check { min-height: 30px; }

/* ── list ────────────────────────────────── */
.cr-list .cr-listcard { overflow: hidden; transition: border-color .12s, background .12s; }
.cr-list.over .cr-listcard { border: 2px dashed var(--blue); background: var(--sel); }
.cr-list .cr-table tbody tr:focus td { background: var(--sel); }
.cr-list .cr-table tbody tr:focus td:first-child { box-shadow: inset 3px 0 0 var(--blue); }
.cr-list .cr-empty { padding: 34px 24px 14px; text-align: center; max-width: 620px; margin: 0 auto; }
.cr-list .cr-empty p { margin: 0 0 8px; }
.cr-list .cr-dropnote { display: flex; gap: 6px; align-items: center; justify-content: center; padding: 12px; border-top: 1px dashed var(--line); }

/* ── editor frame ────────────────────────── */
.cr-ed { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.cr-head { background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px 20px 0; }
.cr-head-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.cr-back { display: inline-flex; align-items: center; gap: 4px; color: var(--blue); text-decoration: none; font-size: 12.5px; white-space: nowrap; padding: 3px 6px 3px 0; border-radius: 4px; }
.cr-back:hover { text-decoration: underline; }
.cr-title { flex: 1; min-width: 200px; display: flex; align-items: baseline; gap: 10px; overflow: hidden; }
.cr-title h1 { font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-title .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-acts { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.cr-steps { display: flex; gap: 2px; margin-top: 6px; overflow-x: auto; }
.cr-step { display: flex; gap: 9px; align-items: flex-start; padding: 7px 14px 8px 8px; border: 0; background: transparent; cursor: pointer; text-align: left; border-bottom: 3px solid transparent; border-radius: 6px 6px 0 0; }
.cr-step:hover { background: var(--hover); }
.cr-step[aria-current=step] { border-bottom-color: var(--blue); background: var(--sel); }
.cr-step b { display: block; font-weight: 600; font-size: 13px; }
.cr-step small { display: block; color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.cr-step .step-n { flex: none; width: 21px; height: 21px; border-radius: 50%; display: grid; place-items: center; font-size: 11.5px; font-weight: 700; background: var(--line-2); color: var(--muted); margin-top: 1px; }
.cr-step[aria-current=step] .step-n { background: var(--blue); color: #fff; }
.cr-step.done .step-n { background: var(--green); color: #fff; }
.cr-body { flex: 1; overflow: auto; padding: 16px 20px 30px; }
.cr-view { max-width: 1680px; margin: 0 auto; }
.cr-viewhead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 4px; }
.cr-viewhead .lede { margin-bottom: 8px; }
.cr-foot { display: flex; justify-content: space-between; margin-top: 20px; gap: 10px; }
.cr-foot .btn.primary:only-child { margin-left: auto; }

/* ── cards & fields ──────────────────────── */
.cr .cr-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 14px; margin-bottom: 14px; }
.cr .cr-card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px 16px; margin: 0; min-width: 0; }
.cr .cr-card.accent { border-top: 3px solid var(--blue); }
.cr .cr-card legend, .cr .cr-card .legend { float: left; width: 100%; padding: 0; margin: 0 0 12px; font: 600 15px var(--font-d); color: var(--navy-text); }
:root[data-theme="dark"] .cr .cr-card legend, :root[data-theme="dark"] .cr .cr-card .legend { color: #cfe0ee; }
.cr .cr-card legend + *, .cr .cr-card .legend + * { clear: both; }
.cr .cr-readout { display: flex; align-items: center; justify-content: flex-end; min-height: 32px; padding: 0 9px; border-radius: 5px; background: var(--surface-2); font-variant-numeric: tabular-nums; font-weight: 600; }
.cr .field .num { text-align: right; }
.cr .field.has-sfx .num { padding-right: 26px; }

/* inputs outside .field (line items, section titles) */
.cr .item input:not([type=radio]), .cr .item textarea, .cr .sec-title {
  width: 100%; min-height: 30px; padding: 4px 7px; font-size: 13.5px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); outline: none; }
.cr .item input:focus, .cr .item textarea:focus, .cr .sec-title:focus { border-color: var(--focus); box-shadow: inset 0 -2px 0 var(--focus); }
.cr .item input::placeholder, .cr .item textarea::placeholder { color: var(--faint); }
.cr .item input.num { text-align: right; font-variant-numeric: tabular-nums; }

/* segmented radio buttons */
.cr .seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); align-self: flex-start; }
.cr .seg label { position: relative; cursor: pointer; }
.cr .seg input { position: absolute; opacity: 0; inset: 0; margin: 0; width: 100%; height: 100%; min-height: 0; padding: 0; border: 0; cursor: pointer; }
.cr .seg span { display: block; padding: 5px 12px; font-size: 13px; color: var(--muted); border-left: 1px solid var(--line); white-space: nowrap; font-weight: 400; }
.cr .seg label:first-child span { border-left: 0; }
.cr .seg input:checked + span { background: var(--blue); color: #fff; font-weight: 600; }
.cr .seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: -2px; }
.cr .seg label:hover span { background: var(--line-2); }
.cr .seg input:checked:hover + span { background: var(--blue); filter: brightness(1.05); }
.cr .seg.resp .yes input:checked + span { background: var(--green); }
.cr .seg.resp .partial input:checked + span { background: var(--amber); }
.cr .seg.resp .no input:checked + span { background: var(--red); }
.cr .seg.small span { padding: 3px 10px; font-size: 12.5px; }

/* ── line items ──────────────────────────── */
.cr .items-wrap { container-type: inline-size; }
.cr .items-colhead, .cr .item { display: grid; grid-template-columns: 74px minmax(190px, 1.25fr) 108px 108px 100px 196px 108px 76px minmax(200px, 1.6fr) 34px; gap: 6px; align-items: start; }
.cr .items-colhead { position: sticky; top: -16px; z-index: 3; background: var(--bg); padding: 8px 10px 6px; font-size: 11.5px; font-weight: 600; letter-spacing: .3px; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); }
.cr .items-colhead .r { text-align: right; }
.cr .items-colhead .c { text-align: center; }
.cr .sec { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; margin: 12px 0; overflow: hidden; }
.cr .sec-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.cr .sec-head .sec-title { font: 600 14.5px var(--font-d); color: var(--navy-text); border-color: transparent; background: transparent; max-width: 340px; }
:root[data-theme="dark"] .cr .sec-head .sec-title { color: #cfe0ee; }
.cr .sec-head .sec-title:hover { border-color: var(--line); background: var(--surface); }
.cr .sec-meta { margin-left: auto; display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cr .sec-meta b { color: var(--ink); }
.cr .sec-foot { padding: 6px 10px 10px 90px; }
.cr .sec-foot .btn { color: var(--blue); border: 1px dashed var(--line); }
.cr .item { padding: 8px 10px; border-bottom: 1px solid var(--line-2); position: relative; }
.cr .item:last-of-type { border-bottom: 0; }
.cr .item.is-No { background: var(--bad-bg); }
.cr .item.is-Partial { background: var(--wait-bg); }
.cr .item.flash { animation: cr-flash 1.2s ease-out; }
@keyframes cr-flash { from { background: #fff3c4; } }
.cr .item .desc { display: flex; flex-direction: column; gap: 4px; }
.cr .item .desc .title { font-weight: 600; }
.cr .item .desc .detail { color: var(--muted); }
.cr .item textarea { resize: none; overflow: hidden; line-height: 1.4; display: block; }
.cr .item .calc { min-height: 30px; display: flex; align-items: center; justify-content: flex-end; padding: 0 6px; font-variant-numeric: tabular-nums; border-radius: 5px; background: var(--surface-2); color: var(--muted); }
.cr .item .calc.neg { color: var(--ink); }
.cr .item .calc.strong { font-weight: 600; color: var(--ink); }
.cr .item .seg { width: 100%; display: flex; }
.cr .item .seg label { flex: 1; }
.cr .item .seg span { text-align: center; padding: 4px; font-size: 12.5px; }
.cr .item .comment { display: flex; gap: 2px; align-items: flex-start; }
.cr .item .comment .icon-btn, .cr .item .menu-cell .icon-btn { width: 30px; height: 30px; }
.cr .item .ref input { font-weight: 700; color: var(--navy-text); }
:root[data-theme="dark"] .cr .item .ref input { color: #cfe0ee; }
.cr .item .warn { grid-column: 2 / -1; font-size: 12px; color: var(--amber); display: flex; gap: 6px; align-items: center; }
.cr .item .warn::before { content: "!"; display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; background: var(--amber); color: #fff; font-weight: 700; font-size: 10px; flex: none; }
.cr .add-section { margin-top: 4px; }
.cr .empty-sec { padding: 14px 90px; color: var(--muted); font-size: 13px; }

@container (max-width: 1320px) {
  .cr .items-colhead, .cr .item { grid-template-columns: 64px minmax(170px, 1fr) 100px 100px 92px 186px 100px 66px 34px; }
  .cr .items-colhead > span:nth-child(9) { display: none; }
  .cr .item > :nth-child(1) { grid-column: 1; grid-row: 1; }
  .cr .item > :nth-child(2) { grid-column: 2; grid-row: 1 / span 2; }
  .cr .item > :nth-child(3) { grid-column: 3; grid-row: 1; }
  .cr .item > :nth-child(4) { grid-column: 4; grid-row: 1; }
  .cr .item > :nth-child(5) { grid-column: 5; grid-row: 1; }
  .cr .item > :nth-child(6) { grid-column: 6; grid-row: 1; }
  .cr .item > :nth-child(7) { grid-column: 7; grid-row: 1; }
  .cr .item > :nth-child(8) { grid-column: 8; grid-row: 1; }
  .cr .item > .comment { grid-column: 3 / 10; grid-row: 2; }
  .cr .item > .menu-cell { grid-column: 9; grid-row: 1; }
  .cr .item > .warn { grid-column: 2 / 10; grid-row: 3; }
}
@container (max-width: 980px) {
  .cr .items-colhead { display: none; }
  .cr .item { grid-template-columns: 1fr 1fr 1fr; }
  .cr .item > * { grid-column: auto !important; grid-row: auto !important; }
  .cr .item .desc, .cr .item .comment, .cr .item .resp-cell { grid-column: 1 / -1 !important; }
  .cr .item .menu-cell { position: absolute; right: 6px; top: 6px; }
  .cr .item [data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; text-align: left; }
  .cr .sec-foot, .cr .empty-sec { padding-left: 10px; }
  .cr .sec-meta { display: none; }
}

/* ── summary tables & checks ─────────────── */
.cr .sum-table table, .cr .mini-table table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.cr .sum-table td, .cr .sum-table th, .cr .mini-table td, .cr .mini-table th { padding: 6px 8px; border-bottom: 1px solid var(--line-2); text-align: left; }
.cr .sum-table th, .cr .mini-table th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); font-weight: 600; }
.cr .sum-table .r, .cr .mini-table .r { text-align: right; }
.cr .sum-table tr.sub td { font-weight: 600; }
.cr .sum-table tr.total td { font-weight: 700; color: var(--navy-text); background: var(--surface-2); border-top: 2px solid var(--line); }
:root[data-theme="dark"] .cr .sum-table tr.total td { color: #cfe0ee; }
.cr .sum-table .rate { color: var(--muted); text-align: right; width: 60px; }
.cr .mini-table { margin-top: 14px; }
.cr .checks-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.cr .checks-list li button { all: unset; cursor: pointer; display: flex; gap: 8px; align-items: baseline; padding: 4px 6px; border-radius: 4px; width: 100%; box-sizing: border-box; }
.cr .checks-list li button:hover { background: var(--line-2); }
.cr .checks-list li button:focus-visible { outline: 2px solid var(--focus); }
.cr .checks-list .ref { font-weight: 700; color: var(--navy-text); min-width: 56px; }
:root[data-theme="dark"] .cr .checks-list .ref { color: #cfe0ee; }
.cr .cr-ok { color: var(--green); font-weight: 600; margin: 0; }

/* ── report ──────────────────────────────── */
.cr .preview { position: relative; height: calc(100vh - 290px); min-height: 420px; background: #525659; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.cr .preview iframe { width: 100%; height: 100%; border: 0; }
.cr .preview-msg { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 14px; pointer-events: none; }
.cr .cr-notice { margin-bottom: 12px; align-items: center; }
.cr .cr-notice .btn { margin-left: auto; }

/* ── totals bar ──────────────────────────── */
.cr-totals { display: flex; align-items: center; gap: 24px; padding: 6px 20px; background: var(--surface); border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); overflow-x: auto; }
.cr-totals .stat { display: flex; gap: 6px; align-items: baseline; white-space: nowrap; }
.cr-totals .stat b { color: var(--ink); font-variant-numeric: tabular-nums; font-size: 13.5px; }
.cr-totals .stat b.neg { color: var(--red); }
.cr-totals .cr-chips { gap: 4px; }
.cr-totals .cchip { display: inline-grid; place-items: center; min-width: 26px; height: 20px; padding: 0 6px; border-radius: 10px; font-size: 11.5px; font-weight: 700; color: #fff; }
.cr-totals .cchip.yes { background: var(--green); } .cr-totals .cchip.partial { background: var(--amber); }
.cr-totals .cchip.no { background: var(--red); } .cr-totals .cchip.open { background: var(--faint); }
.cr-totals .checks-link { margin-left: auto; color: var(--amber); font-weight: 600; border: 0; background: transparent; cursor: pointer; padding: 2px 4px; border-radius: 4px; white-space: nowrap; }
.cr-totals .checks-link:hover { text-decoration: underline; }
.cr-totals .checks-link.clear { color: var(--green); }

@media (max-width: 900px) {
  .cr .cr-cards { grid-template-columns: 1fr; }
  .cr .grid2 { grid-template-columns: 1fr; }
  .cr .span2 { grid-column: auto; }
  .cr-acts .btn span { display: none; }
}
