:root {
  color-scheme: light;
  --bg: #f6f5f2;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e2e0da;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #7a7974;
  --grid: #e8e6e1;
  --accent: #2a78d6;
  --up: #b42318;      /* price up = worse for a renter */
  --down: #067647;
  --warn-bg: #fff4e0;
  --warn-text: #7a4b00;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #4a3aa7; --series-8: #e34948;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #242422; --border: #33332f;
    --text: #ffffff; --text-2: #c3c2b7; --text-3: #8f8e86; --grid: #2c2c29;
    --accent: #3987e5; --up: #f97066; --down: #47cd89;
    --warn-bg: #3a2a0a; --warn-text: #f5c66b;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #242422; --border: #33332f;
  --text: #ffffff; --text-2: #c3c2b7; --text-3: #8f8e86; --grid: #2c2c29;
  --accent: #3987e5; --up: #f97066; --down: #47cd89;
  --warn-bg: #3a2a0a; --warn-text: #f5c66b;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }
/* Complex pages are wider so the floorplan table's fixed columns (below) fit beside Specials. */
body[data-page="complex"] .wrap { max-width: 1240px; }
header.top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
h1 { font-size: 24px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.stack > * + * { margin-top: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile .label { font-size: 13px; color: var(--text-2); }
.tile .value { font-size: 28px; font-weight: 650; letter-spacing: -0.02em; }
.tile .sub { font-size: 13px; color: var(--text-2); }

/* tables */
.table-scroll { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.04em; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th[aria-sort="ascending"]::after { content: " ↑"; }
th[aria-sort="descending"]::after { content: " ↓"; }
td.r, th.r { text-align: right; }
th.wrap-head { white-space: normal; }
tr:last-child td { border-bottom: 0; }
.name-cell a { font-weight: 600; }
.name-cell .addr { font-size: 12px; color: var(--text-3); white-space: normal; }

.delta { font-size: 12px; margin-left: 6px; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.delta.flat { color: var(--text-3); }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.badge.warn { background: var(--warn-bg); color: var(--warn-text); }
.badge.special { background: color-mix(in srgb, var(--series-3) 18%, transparent); color: var(--text); }
.banner { background: var(--warn-bg); color: var(--warn-text); border-radius: 8px; padding: 10px 12px; font-size: 14px; }

/* floorplan rows */
tr.fp-row { cursor: pointer; }
tr.fp-row:hover td { background: var(--surface-2); }
tr.fp-row.unavailable td { color: var(--text-3); }
tr.fp-row td:first-child::before { content: "▸"; display: inline-block; width: 14px; color: var(--text-3); transition: transform .15s; }
tr.fp-row.open td:first-child::before { transform: rotate(90deg); }
tr.fp-row.no-units td:first-child::before { visibility: hidden; }
tr.units-row td { background: var(--surface-2); padding: 8px 8px 12px 30px; }
tr.units-row table th, tr.units-row table td { padding: 6px 8px; border-color: var(--border); }
.fp-thumb { width: 42px; height: 32px; object-fit: contain; border-radius: 4px; background: #fff; vertical-align: middle; margin-right: 8px; }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }
label.toggle { font-size: 13px; color: var(--text-2); display: inline-flex; gap: 6px; align-items: center; margin-left: auto; }

/* charts */
.chart-box { position: relative; height: 260px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--text-2); margin-bottom: 8px; }
.legend span::before { content: ""; display: inline-block; width: 14px; height: 2px; border-radius: 1px; background: var(--c); vertical-align: middle; margin-right: 6px; }
.note { font-size: 13px; color: var(--text-3); margin-top: 8px; }
svg.spark { display: block; }

.back { font-size: 14px; display: inline-block; margin-bottom: 8px; }
footer { margin-top: 32px; font-size: 12px; color: var(--text-3); }

@media (max-width: 640px) {
  .tile .value { font-size: 22px; }
  .hide-sm { display: none; }
  label.toggle { margin-left: 0; }
}
.show-sm { display: none; }
@media (max-width: 640px) { .show-sm { display: inline; } div.show-sm { display: block; } }

/* specials & net rent */
.net { font-size: 12px; color: var(--down); font-weight: 600; }
.caveat { font-weight: 400; opacity: 0.85; }
.badge.new { background: color-mix(in srgb, var(--series-1) 20%, transparent); color: var(--text); }
.special-row + .special-row { border-top: 1px solid var(--border); padding-top: 12px; }
.special-row > div + div { margin-top: 2px; }
td.specials-cell { white-space: normal; min-width: 160px; max-width: 240px; }
td.specials-cell .badge { white-space: normal; line-height: 1.4; margin: 1px 0; }

/* overview small multiples */
.multiples { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.mini { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px 6px; background: var(--surface); min-width: 0; }
.mini-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; }
.mini-head a { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-value { font-weight: 650; white-space: nowrap; }
.mini-chart { position: relative; height: 120px; margin-top: 4px; }
.mini-empty { height: 120px; display: flex; align-items: center; justify-content: center; }

/* shortlist */
button.star { border: 0; background: none; padding: 0; width: 26px; height: 26px; font-size: 17px; line-height: 1; color: var(--text-3); cursor: pointer; border-radius: 6px; vertical-align: middle; margin-right: 4px; }
button.star:hover { background: var(--surface-2); color: var(--text); }
button.star[aria-pressed="true"] { color: var(--series-4); }
button.star:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
td.fp-name { white-space: nowrap; }
td.unit-cell { white-space: nowrap; }
.chip:disabled { opacity: 0.5; cursor: default; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
tr.dim td { color: var(--text-3); }
.share-url { width: 100%; font: inherit; font-size: 13px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); color: var(--text); }
.banner.info { background: var(--surface-2); color: var(--text); }
@media (max-width: 640px) {
  button.star { width: 32px; height: 32px; }
  /* floorplan table: let names and bed/bath wrap so price and $/sq ft fit on a phone */
  td.bed-cell { white-space: normal; }
  /* width: max-content makes the table reserve the name's width; shrink-to-fit alone ignored the ▸ and ☆ beside it, so a squeezed cell let the name spill into Bed / Bath */
  td.fp-name strong { display: inline-block; vertical-align: middle; white-space: normal; width: max-content; max-width: 92px; line-height: 1.3; }
  tr.fp-row td { padding-left: 5px; padding-right: 5px; }
}

/* tap-to-expand specials and net rent (hover tooltips don't work on phones) */
.expander { display: inline-block; vertical-align: top; max-width: 100%; }
.expand-btn { font: inherit; color: inherit; cursor: pointer; text-align: inherit; }
.expand-btn.badge { border: 0; }
.expand-btn.badge.special { color: var(--text); }
.expand-btn.net-btn { border: 0; background: none; padding: 0; border-bottom: 1px dotted var(--text-3); border-radius: 0; }
.expand-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.expand-detail { white-space: normal; font-size: 12px; line-height: 1.45; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; margin: 4px 0; max-width: 300px; text-align: left; font-weight: 400; }
.expand-detail > div + div { margin-top: 3px; }
.specials-sm { margin-bottom: 8px; flex-direction: column; align-items: flex-start; gap: 4px; white-space: normal; }
@media (max-width: 640px) { div.show-sm.specials-sm { display: flex; } }
/* The unit table under it is wider than a phone, so keep the specials in view and let long badges wrap. */
.specials-sm { position: sticky; left: 0; max-width: min(340px, calc(100vw - 96px)); }
.specials-sm .badge { white-space: normal; line-height: 1.4; }

/* page tabs (Viable units / All units) */
nav.tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
nav.tabs a { padding: 8px 12px; font-size: 14px; font-weight: 600; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
nav.tabs a:hover { color: var(--text); text-decoration: none; }
nav.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.badge.ok { background: color-mix(in srgb, var(--down) 18%, transparent); color: var(--text); }
td.wrap-cell { white-space: normal; min-width: 90px; }

/* Lease terms: the term under a price, and the per-term list in a unit's expanded details. */
.term.short { color: var(--warn-text); }
.term-head { margin-top: 6px; font-weight: 600; }
.term-line { font-variant-numeric: tabular-nums; }
.term-line.chosen { font-weight: 600; }
.term-line.off { color: var(--text-2); }

/* Viable units grouped by plan: ★ after a plan's count when one of its units is starred. */
.star-mark { color: var(--series-4); }
.name-cell .plan-line { color: var(--text-2); font-size: 13px; }
.plan-name { font-size: 14px; font-weight: 600; color: var(--text); }

/* A price's breakdown opens as its own row under the price, so it never squeezes the price column on phones. */
tr.breakdown-row td { text-align: right; white-space: normal; padding-top: 0; }
tr.breakdown-row .expand-detail { display: inline-block; max-width: 340px; margin: 0; }
tr:has(+ tr.breakdown-row) td { border-bottom: 0; }
/* Complex pages' unit tables are wider than a phone; left-aligned and sticky, the details stay on screen however far the table is scrolled. */
tr.breakdown-row.left td { text-align: left; }
tr.breakdown-row.left .expand-detail { position: sticky; left: 0; max-width: min(340px, calc(100vw - 96px)); }

/* Floorplan table: fixed column widths, sized for the widest value across the complexes, so
   toggling Viable only or a bed filter doesn't reflow every column (auto layout sizes columns
   from whichever rows are showing). Specials takes what's left. Only where it all fits; narrower
   screens keep auto layout. */
@media (min-width: 1232px) {
  table.fp-table { table-layout: fixed; }
  table.fp-table th.col-fp { width: 210px; }
  table.fp-table th.col-bed { width: 108px; }
  table.fp-table th.col-sqft { width: 62px; }
  table.fp-table th.col-from { width: 130px; }
  table.fp-table th.col-ppsf { width: 72px; }
  table.fp-table th.col-net { width: 74px; }
  table.fp-table th.col-units { width: 76px; }
  table.fp-table th.col-earliest { width: 114px; }
  table.fp-table th.col-range { width: 164px; }
  /* Long plan names ("Columbus (Phase 3 Pet Friendly)") wrap beside the ▸, star and thumbnail. */
  table.fp-table td.fp-name strong { display: inline-block; vertical-align: middle; white-space: normal; max-width: calc(100% - 100px); line-height: 1.3; }
}
