:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #10151c;
  --ink-2: #55606e;
  --ink-3: #8b95a3;
  --line: #e2e6ec;
  --line-2: #eef1f5;
  --accent: #0b5cd5;
  --accent-soft: #e8f0fd;
  --up: #b42318;
  --up-soft: #fef3f2;
  --down: #067647;
  --down-soft: #ecfdf3;
  --new: #6941c6;
  --new-soft: #f4f3ff;
  --warn: #b54708;
  --warn-soft: #fffaeb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 16px rgba(16,24,40,.06);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- header */
header {
  position: sticky; top: 0; z-index: 60;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 9px 16px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 15px; letter-spacing: -.01em; white-space: nowrap; }
.brand span { color: var(--ink-3); font-weight: 500; }
.tabs { display: flex; gap: 2px; background: var(--line-2); padding: 3px; border-radius: 8px; }
.tabs button {
  border: 0; background: transparent; padding: 6px 14px; border-radius: 6px;
  cursor: pointer; color: var(--ink-2); font-weight: 500;
}
.tabs button.on { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.spacer { flex: 1; }
/* Six tabs plus the counts plus the week select is a tight fit at 1280px; the
   counts are the one part that can shrink without becoming unreadable. */
.stat { color: var(--ink-2); font-size: 12.5px; white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.stat b { color: var(--ink); font-variant-numeric: tabular-nums; }
.release-note {
  flex: 1 1 100%;
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 12px;
  line-height: 1.4;
}
.release-note b { color: #7c2d12; }

/* --------------------------------------------------------------- filters */
.filters {
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 10px 20px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  position: sticky; top: 57px; z-index: 55;
}
.filters input, .filters select {
  border: 1px solid var(--line); background: var(--panel); border-radius: 7px;
  padding: 6px 9px; min-width: 0;
}
.filters input:focus, .filters select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.filters input[type=search] { flex: 1 1 240px; }
.filters input.num { width: 92px; }
.chip {
  display: inline-block;               /* anchors styled as chips need a real box */
  border: 1px solid var(--line); background: var(--panel); border-radius: 7px;
  padding: 6px 11px; cursor: pointer; color: var(--ink-2);
  text-decoration: none; line-height: 1.3;
}
a.chip:hover { text-decoration: none; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ----------------------------------------------------------------- table */
main { padding: 16px 20px 60px; }
.tablewrap {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto;
}
table { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 1100px; }
th {
  position: sticky; top: 0; z-index: 10;
  background: var(--panel); border-bottom: 1px solid var(--line);
  text-align: left; padding: 10px 12px; font-size: 12px; font-weight: 600;
  color: var(--ink-2); white-space: nowrap; cursor: pointer; user-select: none;
}
th:hover { color: var(--accent); }
th .dir { color: var(--accent); font-size: 10px; }
th.no-sort { cursor: default; }
th.no-sort:hover { color: var(--ink-2); }
td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #fafbfd; }
tbody tr.open { background: var(--accent-soft); }
.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 13px; }
.muted { color: var(--ink-3); }
.title-cell { max-width: 320px; }
.title-cell .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title-cell .s { color: var(--ink-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.thumb {
  width: 62px; height: 46px; border-radius: 6px; object-fit: cover;
  background: var(--line-2); display: block; border: 1px solid var(--line);
}
.thumb.ph { display: grid; place-items: center; color: var(--ink-3); font-size: 10px; }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
  background: var(--line-2); color: var(--ink-2);
}
.tag.ccr { background: var(--new-soft); color: var(--new); }
.tag.rcr { background: var(--accent-soft); color: var(--accent); }
.tag.ocr { background: var(--down-soft); color: var(--down); }
.tag.NEW { background: var(--new-soft); color: var(--new); }
.tag.PRICE_UP { background: var(--up-soft); color: var(--up); }
.tag.PRICE_DOWN { background: var(--down-soft); color: var(--down); }
.tag.REMOVED { background: var(--line-2); color: var(--ink-2); }
.tag.SOLD { background: #fee4e2; color: #b42318; }
.tag.RELISTED { background: var(--warn-soft); color: var(--warn); }
.tag.AGENT_CHANGE, .tag.AREA_CHANGE { background: var(--warn-soft); color: var(--warn); }
.tag.removed { background: var(--line-2); color: var(--ink-3); }
.retired-intro {
  margin: 0 0 12px; padding: 10px 12px; border: 1px solid #fecdca;
  background: #fff6f5; color: #7a271a; border-radius: 8px; font-size: 12px;
}
.retired-row { background: #fffdfc; }
.retired-row:hover { background: #fff6f5; }
.evidence-note {
  margin-top: 4px; max-width: 190px; color: var(--ink-2); font-size: 11px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.pager { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 14px; color: var(--ink-2); }

/* ---------------------------------------------------------------- drawer */
.drawer-back {
  position: fixed; inset: 0; background: rgba(16,24,40,.35);
  z-index: 100; opacity: 0; pointer-events: none; transition: opacity .18s;
}
.drawer-back.on { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 96vw);
  background: var(--panel); z-index: 101; overflow-y: auto;
  transform: translateX(100%); transition: transform .22s cubic-bezier(.4,0,.2,1);
  box-shadow: -8px 0 40px rgba(16,24,40,.14);
}
.drawer.on { transform: none; }
.drawer header {
  position: sticky; top: 0; display: flex; align-items: flex-start; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.drawer h2 { margin: 0 0 4px; font-size: 17px; letter-spacing: -.01em; }
.drawer .close {
  border: 1px solid var(--line); background: var(--panel); width: 30px; height: 30px;
  border-radius: 7px; cursor: pointer; font-size: 17px; line-height: 1; color: var(--ink-2);
}
.drawer .close:hover { border-color: var(--accent); color: var(--accent); }
.dsec { padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.dsec h3 {
  margin: 0 0 10px; font-size: 11px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-3);
}
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px 18px; }
.kv div { min-width: 0; }
.kv dt { color: var(--ink-3); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.kv dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.desc { white-space: pre-wrap; color: var(--ink-2); max-height: 260px; overflow-y: auto; }

/* --------------------------------------------------- mini photo grid */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 8px; }
.photos button {
  padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  cursor: zoom-in; background: var(--line-2); aspect-ratio: 4/3; position: relative;
}
.photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photos button:hover { border-color: var(--accent); }
.photos button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------- lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 200; background: rgba(8,12,18,.94);
  display: none;
  /* minmax(0,1fr): without the 0 minimum the image row refuses to shrink below
     its intrinsic size and the picture overflows the screen on phones. */
  grid-template-rows: auto minmax(0, 1fr) auto;
  /* dvh tracks the shrinking URL bar on iOS; vh does not. */
  height: 100dvh;
  max-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
  box-sizing: border-box;
}
.lightbox.on { display: grid; }
.lb-top { display: flex; align-items: center; gap: 14px; padding: 14px 18px; color: #e6eaf0; }
.lb-top .cap { flex: 1; font-size: 13px; color: #aab4c2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-top button, .lb-nav button {
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18);
  color: #fff; border-radius: 8px; cursor: pointer; padding: 7px 12px;
}
.lb-top button:hover, .lb-nav button:hover { background: rgba(255,255,255,.2); }
.lb-stage {
  /* flex, not grid: a percentage max-height on a grid item resolves against an
     auto-sized row, so the image kept its natural height and overflowed in
     landscape. In flex it resolves against the container's definite height. */
  position: relative; display: flex; align-items: center; justify-content: center;
  padding: 0 18px; min-height: 0; min-width: 0; overflow: hidden;
}
.lb-stage img {
  max-width: 100%; max-height: 100%;
  width: auto; height: auto;            /* never upscale past the frame */
  object-fit: contain; border-radius: 8px;
}
.lb-nav { position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; pointer-events: none; }
.lb-nav button { pointer-events: auto; width: 44px; height: 60px; font-size: 20px; }
.lb-film { display: flex; gap: 8px; padding: 12px 18px; overflow-x: auto; }
.lb-film img {
  height: 58px; width: 78px; object-fit: cover; border-radius: 6px; cursor: pointer;
  opacity: .45; border: 2px solid transparent; flex: 0 0 auto;
}
.lb-film img.on { opacity: 1; border-color: #fff; }

.empty { padding: 60px 20px; text-align: center; color: var(--ink-3); }
.spin { padding: 40px; text-align: center; color: var(--ink-3); }

/* ------------------------------------------------------ WhatsApp co-broke */
a.wa {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 14px;
  background: #25d366; color: #08361b; border: 1px solid #1eb85a;
  padding: 9px 14px; border-radius: 8px; font-weight: 600; text-decoration: none;
}
a.wa:hover { background: #1eb85a; color: #fff; text-decoration: none; }
a.wa:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------ link button */
a.btn-link {
  display: inline-block; padding: 4px 10px; border-radius: 6px;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid #cfe0fb; font-size: 11px; font-weight: 700;
  letter-spacing: .03em; text-decoration: none; white-space: nowrap;
}
a.btn-link:hover { background: var(--accent); color: #fff; border-color: var(--accent); text-decoration: none; }
a.btn-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a.btn-link.big { padding: 9px 14px; font-size: 13px; letter-spacing: 0; }

/* --------------------------------------------------------- row action pair */
.acts { display: inline-flex; align-items: center; gap: 6px; }
.btn-wa {
  display: inline-grid; place-items: center; width: 26px; height: 24px;
  border-radius: 6px; background: #25d366; color: #08361b;
  border: 1px solid #1eb85a; text-decoration: none;
}
.btn-wa:hover { background: #1eb85a; color: #fff; }
.btn-wa:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-wa.off { background: var(--line-2); color: var(--ink-3); border-color: var(--line); cursor: not-allowed; }

/* Keep the WhatsApp / LINK controls reachable on a wide table. */
table.pin-actions th:last-child,
table.pin-actions td:last-child {
  position: sticky; right: 0; z-index: 5;
  background: var(--panel);
  box-shadow: -8px 0 10px -8px rgba(16,24,40,.18);
}
table.pin-actions th:last-child { z-index: 12; }
table.pin-actions tbody tr:hover td:last-child { background: #fafbfd; }
table.pin-actions tbody tr.open td:last-child { background: var(--accent-soft); }

/* --------------------------------------------------------- duplicate badge */
.tag.dup { background: var(--warn-soft); color: var(--warn); }
.tag.dup.medium { background: var(--line-2); color: var(--ink-2); }

/* ------------------------------------------- multi-agent rows (co-broking) */
.agents { display: flex; flex-direction: column; gap: 4px; }
.agents .ag {
  height: 24px; display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 190px;
}
.agents .ag.acts { max-width: none; }

/* ------------------------------------------------------------- disclaimer */
footer.disclaimer {
  margin: 28px 20px 32px;
  background: var(--warn-soft);
  border: 1px solid #fde68a;
  color: #7c4a03;
  border-radius: 8px;
  padding: 11px 14px;
  font-size: 11.5px;
  line-height: 1.55;
}
footer.disclaimer b { color: #6b3f02; }
.tag.agency { background: var(--line-2); color: var(--ink-2); font-size: 10.5px; font-weight: 700; letter-spacing: .02em; }

/* ------------------------------------------------- market summary by district */
.district {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden;
}
.district .dhead { padding: 14px 18px; border-bottom: 1px solid var(--line-2); background: #fbfcfe; }
.district .dtitle { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.district .dcode { font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
.district .dstats { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px 16px; }
.district .sub { padding: 12px 18px 16px; }
.district .sub h4 {
  margin: 0 0 8px; font-size: 11px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-3);
}
.district .sub h4 .muted { text-transform: none; letter-spacing: 0; font-weight: 500; }
.filters select.needs-enrich { border-color: #fde68a; background: var(--warn-soft); }
.pager .chip:disabled { opacity: .4; cursor: default; }
.pager .chip:disabled:hover { border-color: var(--line); color: var(--ink-2); }

/* ------------------------------------------------- phones and small tablets */
@media (max-width: 820px) {
  .lb-top { padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
  .lb-top .cap { order: 3; flex-basis: 100%; font-size: 11.5px; white-space: normal;
                 max-height: 2.6em; overflow: hidden; }
  .lb-top button { padding: 6px 10px; font-size: 12px; }
  .lb-stage { padding: 0 8px; }
  .lb-nav { padding: 0 4px; }
  .lb-nav button { width: 38px; height: 52px; font-size: 18px; }
  .lb-film { padding: 8px 10px; gap: 6px; }
  .lb-film img { height: 44px; width: 58px; }

  /* the detail panel should be full-width on a phone, not a narrow column */
  .drawer { width: 100%; }
  .drawer header { padding: 14px 16px; }
  .dsec { padding: 14px 16px; }
  .photos { grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 6px; }
  footer.disclaimer { font-size: 11px; margin: 20px 14px 24px; }
}

/* Landscape phones are short: give the image every pixel of height. */
@media (max-height: 500px) and (orientation: landscape) {
  .lb-top { padding: 6px 10px; }
  .lb-top .cap { display: none; }
  .lb-film { display: none; }
  .lb-stage { padding: 0 6px; }
}

/* ============================================================ viewing list */
.pickbox { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }
th.pick, td.pick { width: 34px; text-align: center; }
.chip.build { background: #067647; border-color: #067647; color: #fff; font-weight: 700; }
.chip.build:hover { background: #05603a; color: #fff; }

.vbar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  flex-wrap: wrap; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 16px; margin-bottom: 14px;
}
.vactions { display: flex; gap: 8px; flex-wrap: wrap; }
.vactions a.chip { text-decoration: none; }

.vsheet { display: grid; gap: 14px; }
.vcard {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px;
}
.vcard header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.vnum {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 7px; background: var(--ink);
  color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 700;
}
.vhead { flex: 1; min-width: 0; }
.vcard h3 { margin: 0; font-size: 16px; letter-spacing: -.01em; }
.vaddr { color: var(--ink-3); font-size: 12.5px; margin-top: 2px; }
.vprice { font-size: 17px; font-weight: 800; white-space: nowrap; }

.vshots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px; }
.vshots img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 7px; border: 1px solid var(--line); }

.vstats { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 9px 14px; margin-bottom: 12px; }
.vagents { display: flex; flex-direction: column; gap: 5px; border-top: 1px solid var(--line-2); padding-top: 10px; }
.vagent { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.vfoot { display: flex; gap: 8px; margin-top: 12px; }

.only-print { display: none; }

/* --------------------------------------------------------------- A4 print */
@media print {
  @page { size: A4 portrait; margin: 12mm; }

  header, .filters, .vbar, .no-print, .drawer, .drawer-back, .lightbox { display: none !important; }
  body { background: #fff; }
  main { padding: 0; }

  .only-print { display: block; }
  .vsheet-head { font-size: 12pt; margin-bottom: 6mm; padding-bottom: 2mm; border-bottom: 1px solid #999; }
  .vsheet-foot { margin-top: 6mm; font-size: 8pt; color: #666; }

  .vsheet { gap: 0; }
  .vcard {
    box-shadow: none; border: 1px solid #ccc; border-radius: 6px;
    padding: 5mm; margin-bottom: 5mm;
    /* two cards per A4 page, never split across a page break */
    break-inside: avoid; page-break-inside: avoid;
  }
  .vcard h3 { font-size: 12pt; }
  .vprice { font-size: 12pt; }
  .vaddr, .vagent { font-size: 9pt; }
  .vstats { font-size: 9pt; grid-template-columns: repeat(4, 1fr); }
  .vshots { grid-template-columns: repeat(4, 1fr); }
  .vshots img { aspect-ratio: 4/3; }
  .tag { border: 1px solid #ddd; }
}
.zoneblock { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 10px; }
.zonehead { background: #fbfcfe; border-bottom: 1px solid var(--line-2); padding: 9px 14px; font-weight: 700; font-size: 13.5px; }
.zoneblock .slice { border: 0; border-bottom: 1px solid var(--line-2); border-radius: 0; box-shadow: none; }
.zoneblock .slice:last-child { border-bottom: 0; }

/* --------------------------------------------------- open listings ------
 * Several agents marketing one property at different asking prices. The
 * lowest is what a buyer's agent acts on, so it leads and the rest is context.
 */
.pricespread { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; line-height: 1.25; }
.pricespread .hi { font-size: 11px; color: var(--ink-3, #6b7280); font-variant-numeric: tabular-nums; }
.tag.spread {
  font-size: 10px; padding: 0 4px; border-radius: 3px; margin-top: 1px;
  background: #FDF0E4; color: #A2521C; border: 1px solid #E8CDB4; white-space: nowrap;
}
.ag .anm { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ag .askp {
  margin-left: 6px; font-size: 10.5px; padding: 0 4px; border-radius: 3px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
  background: var(--surface-2, #eef1f4); color: var(--ink-2, #3a4753);
}
.ag .askp.best { background: #E4F0EE; color: #12504C; font-weight: 600; }
@media (prefers-color-scheme: dark) {
  .tag.spread { background: #2C2118; color: #D9955C; border-color: #4A3626; }
  .ag .askp.best { background: #16302E; color: #7FCFC8; }
}

/* ------------------------------------------------------ deals analysis ---
 * Scenario chooser: tenure group x property type, cheapest first. Counts and
 * entry prices sit on the card so it is obvious which are worth opening.
 */
#dealsbar { padding: 12px 16px 4px; }
.dealshead { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.dealslede { font-weight: 600; font-size: 14px; }
.dealscards { display: grid; grid-template-columns: repeat(auto-fill, minmax(198px, 1fr)); gap: 8px; }
.dealcard {
  text-align: left; cursor: pointer; font: inherit;
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  background: var(--card, #fff); display: grid; gap: 3px;
}
.dealcard:hover { border-color: var(--accent, #16a34a); }
.dealcard.on { border-color: var(--accent, #16a34a); box-shadow: inset 0 0 0 1px var(--accent, #16a34a); }
.dealcard .dc-t { font-weight: 600; font-size: 13.5px; line-height: 1.25; }
.dealcard .dc-m { font-size: 11.5px; color: var(--ink-3, #6b7280); font-variant-numeric: tabular-nums; }
.dealcard .dc-p { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.dealcard .tag.fh { background: #E4F0EE; color: #12504C; }
.dealcard .tag.lh { background: #EEF1F4; color: #3A4753; }
@media (prefers-color-scheme: dark) {
  .dealcard .tag.fh { background: #16302E; color: #7FCFC8; }
  .dealcard .tag.lh { background: #1D2830; color: #BCC7D0; }
}

/* ------------------------------------------------------ cross-over -------
 * Two columns: what this money buys in the tier you asked for, and what the
 * same money (plus the buffer) buys one tier up.
 */
.dealsmodes { display: inline-flex; gap: 6px; }
#xocontrols { padding: 0 0 10px; border: 0; }
.xoband { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 12px; overflow: hidden; }
.xoband > h4 {
  margin: 0; padding: 8px 12px; font-size: 13px; background: var(--line-2, #eef1f4);
  display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap;
}
.xoband > h4 .muted { font-weight: 400; font-size: 12px; }
.xocols { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.xocol { padding: 10px; min-width: 0; }
.xocol + .xocol { border-left: 1px solid var(--line); }
.xocol > .xohead {
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-3, #6b7280); margin-bottom: 8px;
}
.xocard { display: grid; grid-template-columns: 46px 1fr auto; gap: 9px; align-items: center;
  padding: 7px 0; border-top: 1px solid var(--line-2, #eef1f4); min-width: 0; }
.xocard:first-of-type { border-top: 0; }
.xocard img { width: 46px; height: 36px; object-fit: cover; border-radius: 4px; }
.xocard .ph { width: 46px; height: 36px; border-radius: 4px; background: var(--line-2, #eef1f4); }
.xocard .xt { min-width: 0; }
.xocard .xt b { display: block; font-size: 13px; font-weight: 600; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.xocard .xt span { font-size: 11.5px; color: var(--ink-3, #6b7280); }
.xocard .xa { display: flex; gap: 4px; align-items: center; }
.xomore { font-size: 12px; color: var(--ink-3, #6b7280); padding-top: 8px; }
@media (max-width: 820px) {
  .xocols { grid-template-columns: 1fr; }
  .xocol + .xocol { border-left: 0; border-top: 1px solid var(--line); }
}

/* ------------------------------------------------------- top listers ----
 * Ranked by stock held in the current search. Each opens to the listings
 * themselves, so a consultant can go straight to the agent holding the patch.
 */
.lister { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; overflow: hidden; }
.lister > summary {
  display: grid; grid-template-columns: 34px 1fr auto auto; gap: 12px; align-items: center;
  padding: 10px 13px; cursor: pointer; list-style: none;
}
.lister > summary::-webkit-details-marker { display: none; }
.lister > summary:hover { background: var(--line-2); }
.lister .rank {
  font-weight: 700; font-size: 14px; color: var(--ink-3);
  font-variant-numeric: tabular-nums; text-align: right;
}
.lister .who b { display: block; font-size: 14px; }
.lister .who span { font-size: 11.5px; color: var(--ink-3); }
.lister .cnt { text-align: right; font-variant-numeric: tabular-nums; }
.lister .cnt b { font-size: 15px; display: block; }
.lister .cnt span { font-size: 11px; color: var(--ink-3); }
.lister .acts { display: flex; gap: 5px; }
.lister .stock { border-top: 1px solid var(--line); padding: 8px 13px 12px; }

/* --------------------------------------------------------- CAT status ---
 * Read from the agent's copy, so confidence is shown as well as the value:
 * a faded badge means the wording was weak and the photos should be checked.
 */
.tag.cat { font-weight: 600; letter-spacing: .01em; }
.tag.cat.c1 { background: #FBE9E4; color: #9A3412; }   /* rebuild   */
.tag.cat.c2 { background: #FDF0E4; color: #A2521C; }   /* major A&A */
.tag.cat.c3 { background: #E7EEF7; color: #1E4B7A; }   /* renovate  */
.tag.cat.c4 { background: #E4F0EE; color: #12504C; }   /* new build */
.tag.cat.low { opacity: .62; }
@media (prefers-color-scheme: dark) {
  .tag.cat.c1 { background: #37211B; color: #E9A184; }
  .tag.cat.c2 { background: #2C2118; color: #D9955C; }
  .tag.cat.c3 { background: #182636; color: #8FB6DD; }
  .tag.cat.c4 { background: #16302E; color: #7FCFC8; }
}

/* CAT override: a person's call, sitting where the inferred value is shown. */
.catset { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.catset select { font: inherit; padding: 3px 6px; border: 1px solid var(--line); border-radius: 6px; }
.catset .muted { font-size: 11.5px; }

/* Explainers: what a control is for, said once, near the control. */
.modewhy { margin: 2px 0 12px; font-size: 12.5px; max-width: 92ch; }
.chip.help {
  width: 24px; padding: 0; font-weight: 700; color: var(--ink-3);
  border-radius: 50%; line-height: 1;
}
.chip.help:hover { color: var(--accent); border-color: var(--accent); }
.catlegend {
  margin: 0 0 10px; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--panel); font-size: 13px; max-width: 92ch;
}
.catlegend dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 8px 0 0; }
.catlegend dt { font-weight: 600; white-space: nowrap; }
.catlegend dd { margin: 0; color: var(--ink-2); }
.catlegend .note { margin-top: 10px; font-size: 12px; color: var(--ink-3); }

/* Submitting a CAT change is deliberate: the button only wakes when the value
   actually differs, and confirms in place rather than flashing a toast. */
.catset { flex-wrap: wrap; }
.chip.catsubmit { font-weight: 600; }
.chip.catsubmit:disabled { opacity: .45; cursor: default; }
.chip.catsubmit:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.chip.catsubmit.done { border-color: var(--accent); background: var(--ok-soft, #E4F0EE); color: #12504C; }
@media (prefers-color-scheme: dark) {
  .chip.catsubmit.done { background: #16302E; color: #7FCFC8; }
}

/* The CAT log: a change is only interesting next to what the rules said. */
.cathist { display: grid; gap: 1px; margin: 10px 0 0; max-height: 340px; overflow-y: auto; }
.chrow {
  display: grid; grid-template-columns: 74px 118px 1fr 180px 150px; gap: 10px;
  padding: 6px 8px; border-radius: 5px; cursor: pointer; font-size: 12.5px; align-items: baseline;
}
.chrow:hover { background: var(--line-2); }
.chrow.differs { background: var(--warn-soft); }
.chrow.differs:hover { filter: brightness(.97); }
.chrow .ch-what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chrow .ch-when { font-variant-numeric: tabular-nums; color: var(--ink-3); }
@media (max-width: 900px) {
  .chrow { grid-template-columns: 1fr; gap: 2px; padding: 8px; border-bottom: 1px solid var(--line-2); }
}

/* A gap between the scenario modes and the movement modes: they answer
   different kinds of question and shouldn't read as one long row. */
.modesep { display: inline-block; width: 1px; height: 20px; background: var(--line); margin: 0 4px; }

/* ----------------------------------------------------------- trends ----
 * Charts are hand-drawn: a strict CSP blocks external libraries, and these
 * shapes are simple enough that a dependency would cost more than it saves.
 */
#trendsbar { padding: 12px 16px 4px; }
.chart { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 16px 18px; margin-bottom: 14px; }
.chart h4 { margin: 0 0 3px; font-size: 15px; }
.chart .sub { font-size: 12.5px; color: var(--ink-3); margin: 0 0 14px; }

/* bar chart: rows, because category names need room to be readable */
.bars { display: grid; gap: 7px; }
.barrow { display: grid; grid-template-columns: 150px 1fr 96px; gap: 12px; align-items: center; font-size: 13px; }
.barrow .bl { text-align: right; color: var(--ink-2); }
/* Both are spans inside a grid row, so they need an explicit box: height on an
   inline element does nothing, which left every bar looking empty. */
.bartrack { display: block; background: var(--line-2); border-radius: 4px; height: 22px; overflow: hidden; }
.barfill  { display: block; height: 100%; background: var(--accent); border-radius: 4px; min-width: 2px; }
.barrow .bv { font-variant-numeric: tabular-nums; font-weight: 600; }
.barrow .bn { color: var(--ink-3); font-weight: 400; font-size: 11.5px; }

/* bubbles and treemap share a colour ramp, so the two views read the same */
.heatwrap { overflow-x: auto; }
.heatlegend { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 11.5px; color: var(--ink-3); }
.heatlegend .swatches { display: flex; }
.heatlegend i { width: 26px; height: 10px; display: block; }
.bub text, .tm text { pointer-events: none; }
.bub circle, .tm rect { cursor: pointer; }
.bub circle:hover, .tm rect:hover { stroke: var(--ink); stroke-width: 2; }

/* --------------------------------------------------- chart revamp ------
 * Marks are thin, chrome is recessive, and a hover layer ships by default -
 * an HTML chart is interactive whether or not you plan for it.
 */
.chart { box-shadow: none; }

/* Bar: 4px rounded data-end anchored to the baseline, so the rounding reads as
   the end of the value rather than a floating pill. */
.bartrack { background: var(--line-2); border-radius: 3px; height: 20px; }
.barfill  { background: var(--series-1, #2a78d6); border-radius: 0 4px 4px 0; }
.barrow.mk { padding: 1px 0; border-radius: 5px; outline-offset: 2px; }
.barrow.mk:hover .barfill, .barrow.mk:focus-visible .barfill { filter: brightness(1.08); }
.barrow .bv { font-variant-numeric: tabular-nums; }

/* Marks get a visible focus state so the keyboard reaches the same numbers. */
.mk:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.bub .mk circle, .tm .mk rect { transition: opacity .12s ease; }
.bub:hover .mk:not(:hover) circle, .tm:hover .mk:not(:hover) rect { opacity: .55; }

.viztip {
  position: fixed; z-index: 90; display: none; pointer-events: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 7px;
  padding: 7px 10px; box-shadow: 0 6px 22px -10px rgba(0,0,0,.4);
  font-size: 12.5px; line-height: 1.45; max-width: 260px;
}
.viztip b { display: block; font-size: 13px; }
.viztip span { display: block; font-variant-numeric: tabular-nums; }

.tabletoggle { margin-top: 12px; }
.charttable { margin-top: 10px; }
.charttable table { font-size: 13px; }
.charttable td.num, .charttable th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Numbers that stack in columns line up; hero figures never do. */
table td.num, table th.num { font-variant-numeric: tabular-nums; }

:root { --series-1: #2a78d6; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --series-1: #3987e5; }
}
:root[data-theme="dark"] { --series-1: #3987e5; }

/* ------------------------------------------------------- dashboard -----
 * The landing view. Read top to bottom: what the market is, what it is made
 * of, where it is, what to act on, and how complete the picture is.
 */
.dash { display: grid; gap: 14px; }
.dashgrid { display: grid; gap: 14px; grid-template-columns: repeat(12, 1fr); }
.card {
  grid-column: span 12; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); padding: 16px 18px; min-width: 0;
}
.card > h4 { margin: 0 0 2px; font-size: 14px; }
.card > .sub { margin: 0 0 14px; font-size: 12.5px; color: var(--ink-3); }
.c4 { grid-column: span 4; } .c6 { grid-column: span 6; } .c8 { grid-column: span 8; }
@media (max-width: 900px) { .c4, .c6, .c8 { grid-column: span 12; } }

/* Hero: the one number the dashboard leads with. Proportional figures - equal
   width digits make a display number look loose. */
.hero { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.hero .big { font-size: 52px; font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.hero .cap { font-size: 13.5px; color: var(--ink-2); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 10px; margin-top: 16px; }
.kpi { border-top: 2px solid var(--line); padding-top: 9px; }
.kpi b { display: block; font-size: 21px; font-weight: 650; letter-spacing: -.01em; }
.kpi span { font-size: 11.5px; color: var(--ink-3); }

/* A composition bar: one row, ordered segments, 2px surface gaps. */
.mix { display: flex; height: 26px; border-radius: 5px; overflow: hidden; gap: 2px; background: var(--panel); }
.mix > i { display: block; height: 100%; }
.mixkey { display: grid; gap: 5px; margin-top: 11px; font-size: 12.5px; }
.mixkey > div { display: grid; grid-template-columns: 11px 1fr auto auto; gap: 9px; align-items: center; }
.mixkey i { width: 11px; height: 11px; border-radius: 3px; }
.mixkey .n { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.mixkey .p { font-variant-numeric: tabular-nums; color: var(--ink-3); min-width: 42px; text-align: right; }

/* Meters for data health: a ratio against a limit, same-ramp track. */
.meters { display: grid; gap: 11px; }
.meter b { display: block; font-size: 12.5px; margin-bottom: 5px; font-weight: 500; }
.meter .track { display: block; height: 8px; background: var(--line-2); border-radius: 4px; }
.meter .fill { display: block; height: 100%; border-radius: 4px; background: var(--series-1, #2a78d6); }
.meter .v { float: right; font-variant-numeric: tabular-nums; color: var(--ink-3); font-weight: 400; }

.ranklist { display: grid; gap: 8px; }
.rankrow { display: grid; grid-template-columns: 20px 1fr auto; gap: 10px; align-items: baseline; font-size: 13px; }
.rankrow .rk { color: var(--ink-3); font-variant-numeric: tabular-nums; text-align: right; }
.rankrow .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rankrow .nm small { display: block; color: var(--ink-3); font-size: 11px; }
.rankrow .ct { font-variant-numeric: tabular-nums; font-weight: 600; }

.dashlink { font-size: 12.5px; color: var(--accent); cursor: pointer; background: none; border: 0; padding: 0; }
.dashlink:hover { text-decoration: underline; }
