/* Compare products (js/views/compare.js; owner, 21 October 2026). Colours are the app's tokens (css/app.css),
   so light and dark follow; the phone rules there keep every control 44px and every box 16px. On a wide screen
   each product is one line under a heading row; narrower, each is a card with its own labels; the results are
   a table, and cards on a phone. */

.cp-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .cp-grid { grid-template-columns: minmax(0, 1fr); } }
.cp-grid .panel + .panel { margin-top: 0; }
.cp-options { display: flex; flex-direction: column; gap: 14px; }
.cp-options .seg { display: flex; width: 100%; }
.cp-options .seg button { flex: 1 1 0; min-width: 0; white-space: normal; line-height: 1.25; }
.cp-adders { gap: 8px; margin-bottom: 12px; }
.cp-adders .cp-saved-pick { flex: 1 1 260px; width: auto; min-width: 0; max-width: 520px; }
/* Calculate and compare with nothing to compare: what to add, beside the button (round 19 audit). */
.cp-go-said { margin: 0; font-weight: 600; min-width: 0; }

/* The product lines: one grid for the heading row and each product. */
.cp-rows-head, .cp-row {
  display: grid; gap: 8px; align-items: start;
  /* Lender, product, Type (round 9: it decides the stress rate), rate, fee, flat fee, stress, max LTV (round 21), ERC, notes, buttons. */
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.4fr) 128px 76px 76px 100px 116px 76px minmax(0, 1fr) minmax(0, 1.3fr) auto;
}
.cp-rows-head { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 0 0 6px; }
.cp-row { padding: 8px 0; border-top: 1px solid var(--line-2); }
.cp-row [name=lender_name] { margin-top: 6px; }
.cp-l { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.cp-f { min-width: 0; }
.cp-acts { display: flex; flex-direction: column; gap: 4px; align-items: stretch; }
#cp-rows .empty { padding: 14px 0; }

/* Narrower (a laptop too): each product a card, its boxes labelled. */
@media (max-width: 1440px) {
  .cp-rows-head { display: none; }
  .cp-row { grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; margin-top: 10px; background: var(--surface); }
  .cp-f-lender, .cp-f-product, .cp-f-erc, .cp-f-notes { grid-column: span 2; }
  .cp-acts { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; justify-content: flex-end; }
}
@media (max-width: 1440px) {
  .cp-l { position: static; width: auto; height: auto; clip: auto; display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
}
@media (max-width: 640px) {
  .cp-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cp-f-lender, .cp-f-product, .cp-f-erc, .cp-f-notes { grid-column: 1 / -1; }
  .cp-acts .btn { flex: 1 1 auto; }
}
/* The summary tiles: five across, then three, then two. */
.tiles.cp-tiles { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1200px) { .tiles.cp-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .tiles.cp-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.cp-tiles .v { font-size: 24px; overflow-wrap: anywhere; }
.cp-tiles .s { overflow-wrap: anywhere; }

/* The results. */
.cp-cols { display: flex; flex-wrap: wrap; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.cp-cols legend { padding: 0; margin-bottom: 6px; }
.cp-col input { margin: 0; accent-color: var(--accent); }
.cp-table th, .cp-table td { padding: 9px 9px; }
.cp-table th { white-space: nowrap; }
.cp-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cp-table td.num .t-sub { white-space: nowrap; }
.cp-hint { overflow-wrap: anywhere; }
.cp-table td { vertical-align: top; }
.cp-need { color: var(--warn); font-size: 12px; font-weight: 600; white-space: normal; }
.cp-error { color: var(--bad); font-weight: 600; padding: 14px 16px; margin: 0; }
.cp-cards { display: grid; gap: 10px; padding: 10px; }
.cp-card { cursor: default; }
.cp-card:hover { border-color: var(--line); }
.cp-card-top { margin-bottom: 8px; overflow-wrap: anywhere; }
.cp-card .t-main { font-weight: 600; }
.cp-card .t-sub { font-size: 12px; color: var(--muted); }
.cp-kv { grid-template-columns: minmax(0, auto) minmax(0, 1fr); }
.cp-kv dd { overflow-wrap: anywhere; }
.cp-card-acts { margin-top: 10px; }
.cp-card-acts .btn { flex: 1 1 auto; }

/* Round 18 (owner, 5 November 2026: "save the rates in easy way and edit easy when rate changes"): Compare products' three tabs,
   a product's internal note under its line, Both's second figure, Choose several, the Rates tab (js/views/rates.js) and the Rate
   comparison. Wide tables scroll inside their own box (.tbl-wrap); the page itself never scrolls sideways. */
.cp-tabs { margin: 0 0 14px; border-bottom: 1px solid var(--line); }
.cp-tabs .ptab-list { overflow-x: auto; scrollbar-width: none; }
.cp-internal { grid-column: 1 / -1; overflow-wrap: anywhere; padding: 6px 10px; border-radius: 8px; background: var(--sunk); }
.cp-both { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); }
.cp-adders .cp-to-rates { align-self: center; margin-left: auto; }
.cp-pick { display: flex; flex-direction: column; gap: 12px; max-height: 60vh; overflow-y: auto; }
.cp-pick-g { border: 1px solid var(--line); border-radius: var(--r); padding: 8px 12px; margin: 0; min-width: 0; }
.cp-pick-g legend { padding: 0 4px; }
.cp-pick-l { display: flex; align-items: center; gap: 8px; min-height: 36px; overflow-wrap: anywhere; cursor: pointer; }
.cp-pick-l input { margin: 0; flex: none; accent-color: var(--accent); width: 18px; height: 18px; }
.cp-pick-tiers { display: flex; flex-wrap: wrap; gap: 0 16px; padding-bottom: 4px; border-bottom: 1px solid var(--line-2); margin-bottom: 4px; }
.cp-pick-p { padding-left: 4px; }
@media (pointer: coarse) { .cp-pick-l { min-height: 44px; } }

/* Rates: a panel for each lender, its products a table changed in place. */
.rs-intro { margin: 0 0 12px; }
.rs-tools { margin-bottom: 12px; max-width: 420px; }
.rs-group + .rs-group { margin-top: 16px; }
.rs-group .panel-h { flex-wrap: wrap; gap: 6px 12px; }
.rs-table th, .rs-table td { padding: 6px 6px; vertical-align: top; }
.rs-table th { white-space: nowrap; }
.rs-table input, .rs-table select { min-width: 0; width: 100%; padding-top: 6px; padding-bottom: 6px; }
.rs-table td[data-col="tier"] { min-width: 100px; }
.rs-table td[data-col="product"] { min-width: 180px; }
/* The product stays in view while the table scrolls sideways (wider than a phone: there it would take half the screen). */
@media (min-width: 641px) {
  .rs-table th[data-col="product"], .rs-table td[data-col="product"] { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--line); }
  .rs-table thead th[data-col="product"] { z-index: 2; background: var(--sunk); }
  .rs-table tr.rs-new td[data-col="product"] { background: var(--accent-soft); }
}
.rs-table td[data-col="type"] { min-width: 140px; }
.rs-table td[data-col="rate"], .rs-table td[data-col="fee"], .rs-table td[data-col="stress"], .rs-table td[data-col="max_ltv"] { min-width: 86px; }
.rs-table td[data-col="flat"] { min-width: 110px; }
.rs-table td[data-col="erc"] { min-width: 130px; }
.rs-table td[data-col="notes"], .rs-table td[data-col="internal"] { min-width: 200px; }
.rs-table td.rs-when { min-width: 150px; max-width: 220px; white-space: normal; }
.rs-table .rs-internal { background: var(--warn-soft, var(--sunk)); }
.rs-state { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
.rs-state.good { color: var(--good); }
.rs-state.bad { color: var(--bad); }
.rs-acts .btn + .btn { margin-left: 4px; }
.rs-table tr.rs-new td { background: var(--accent-soft); }
.rs-reprice p { margin-top: 0; }
.rs-tick { display: flex; align-items: center; gap: 8px; margin: 12px 0; min-height: 36px; cursor: pointer; }
.rs-tick input { margin: 0; width: 18px; height: 18px; accent-color: var(--accent); }
.rs-preview { margin-top: 8px; max-height: 40vh; overflow-y: auto; }
@media (pointer: coarse) { .rs-tick { min-height: 44px; } }

/* The Rate comparison. */
.rc-side .panel-h h2 { margin: 0; }
.rc-current { border-left: 3px solid var(--bad); }
.rc-next { border-left: 3px solid var(--good); }
.rc-sides { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 900px) { .rc-sides { grid-template-columns: minmax(0, 1fr); } }
.rc-loan .rc-l { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.rc-loan .seg { display: flex; width: 100%; }
.rc-loan .seg button { flex: 1 1 0; min-width: 0; white-space: normal; line-height: 1.25; }
.rc-table tbody th[scope=row] { text-align: left; text-transform: none; letter-spacing: 0; font-size: 13.5px; font-weight: 600; color: var(--ink-2);
  background: transparent; white-space: normal; position: static; border-bottom: 1px solid var(--line-2); }
.rc-table tbody th .t-sub { font-weight: 400; color: var(--muted); font-size: 12px; }
@media (max-width: 640px) { .rc-table th, .rc-table td { padding: 8px 6px; } }
.rc-table td.num, .rc-table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rc-say { margin: 12px 16px; padding: 12px 14px; border-radius: var(--r); background: var(--good-soft); color: var(--ink); font-weight: 600; }
.rc-needs, .rc-how { margin: 8px 16px 12px; }
