/* app.css — shared chrome for / (Zillow) and /me (MLS Matrix).
 *
 * Both pages render the identical form and report; only the import card
 * differs. Keeping one stylesheet means a layout change cannot land on one
 * page and miss the other, which is how the two drifted apart before.
 *
 * Chart tokens (--s1/--s2/--grid/--axis) are separate from the UI accent on
 * purpose: series colour identifies data, the accent identifies the product.
 * Reusing the brand green for a series would make "green" mean two things.
 */
:root {
  --bg: #fbfbfa; --card: #fff; --line: #e4e2dd; --ink: #1c1b19;
  --muted: #6f6b64; --accent: #2f5d50; --accent-soft: #eef4f2;
  --warn: #8a5a12; --warn-bg: #fdf6e7;
  --err: #9b2c2c; --err-bg: #fdf0ef; --sel: #eef4f2;
  --shadow: 0 1px 2px rgba(28, 27, 25, .04), 0 8px 24px -16px rgba(28, 27, 25, .18);
  /* chart */
  --s1: #2a78d6; --s2: #eb6834;
  --grid: #e1e0d9; --axis: #c3c2b7;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17171a; --card: #1f1f23; --line: #35353b; --ink: #eceae6;
    --muted: #9d988f; --accent: #7fb6a3; --accent-soft: #21302c;
    --warn: #d9a441; --warn-bg: #2b2519;
    --err: #e08a84; --err-bg: #2c1c1c; --sel: #21302c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -16px rgba(0, 0, 0, .8);
    --s1: #3987e5; --s2: #d95926;
    --grid: #2c2c2a; --axis: #383835;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.6 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
a { color: var(--accent); }
.wrap { max-width: 900px; margin: 0 auto; padding: 0 20px 96px; }

/* ---------- hero ---------- */
.hero {
  padding: 44px 0 28px; margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.eyebrow {
  font-size: 11.5px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--accent); font-weight: 600; margin-bottom: 10px;
}
h1 { font-size: 32px; line-height: 1.25; margin: 0 0 10px; letter-spacing: -.02em; font-weight: 650; }
.lede { font-size: 16px; color: var(--muted); margin: 0 0 22px; max-width: 54ch; }
.stats { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-top: 14px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px;
}
.stat .lab { font-size: 11.5px; color: var(--muted); display: block; margin-bottom: 3px; }
.stat .val { font-size: 21px; font-weight: 600; letter-spacing: -.01em; }
.stat .val small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 3px; }
/* Deltas stay in muted ink rather than red/green: over a buyer's horizon a
   rising index is not "good" or "bad", and colouring it would assert one. */
.stat .deltas {
  display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 5px;
  font-size: 11.5px; color: var(--muted);
}
.stat .deltas b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
code {
  font: 11.5px/1.5 ui-monospace, Consolas, monospace;
  background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px;
}
.trust {
  font-size: 16px; font-weight: 600; color: var(--accent); margin: 12px 0 0;
  letter-spacing: -.01em;
}
.trust b { font-size: 19px; }
.trust:empty { display: none; }
.hero .meta {
  font-size: 12.5px; color: var(--muted); margin-top: 16px;
  display: flex; flex-wrap: wrap; gap: 4px 14px;
}
/* A flex item defaults to min-width:auto and will not shrink below its own
   content width. Both of these hold text that grows with the data — the served
   ZIP list, and region display names from config — so they opt out before one
   long run pushes the page sideways. */
.hero .meta > span, .legend > span { min-width: 0; }

/* ---------- cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 22px; margin-bottom: 14px; box-shadow: var(--shadow);
}
h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin: 0 0 16px; font-weight: 600;
}
h2 .note { text-transform: none; letter-spacing: 0; font-weight: 400; }
.fieldset { border: 0; padding: 0; margin: 22px 0 0; }
.fieldset > legend {
  padding: 0; font-size: 13px; font-weight: 600; color: var(--ink);
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
/* Key inputs get an accent rail, not a full yellow panel: the old block shouted
   loudly enough that the eye started skipping it. */
.keyed { border-left: 3px solid var(--accent); padding-left: 14px; }
.keyed.hot { border-left-color: var(--warn); }
.tag {
  font-size: 10.5px; font-weight: 600; letter-spacing: .04em; padding: 2px 7px;
  border-radius: 20px; background: var(--accent-soft); color: var(--accent);
  text-transform: none;
}
.tag.hot { background: var(--warn-bg); color: var(--warn); }

/* 165px lands on 4 columns at full width, so the 7-field 房源 block fills 4+3
   instead of leaving a 5+2 half-row, and the inputs are wide enough to read. */
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }
.span-all { grid-column: 1 / -1; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; padding: 9px 10px; font-size: 14px; font-family: inherit;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: 7px;
}
select { cursor: pointer; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}
.hint { font-size: 12.5px; color: var(--muted); margin: 8px 0 0; }
.hint b { color: var(--ink); }

/* The bookmarklet is the whole point of this card, so it sits above the fold,
   styled as the draggable chip it is rather than as a link in a paragraph. */
.drag { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 14px 0 0;
        font-size: 13.5px; color: var(--muted); }
.drag b { color: var(--ink); }
a.bmlink {
  display: inline-block; padding: 8px 14px; border-radius: 8px;
  background: var(--accent); color: #fff; text-decoration: none;
  font-size: 13.5px; font-weight: 600; cursor: grab;
  box-shadow: var(--shadow);
}
a.bmlink:active { cursor: grabbing; }
a.bmlink:hover { filter: brightness(1.08); }
button {
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: 12px 26px; font-size: 15px; font-weight: 600; font-family: inherit;
  cursor: pointer;
}
button:hover:not(:disabled) { filter: brightness(1.08); }
button:disabled { opacity: .55; cursor: default; }
.actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 18px; }

/* ---------- market section ---------- */
/* Collapsed by default: this page prices one house, and the market chart is
   context for that, not the reason anyone opened it. */
.market-summary {
  font-size: 15px; font-weight: 600; color: var(--ink); padding: 2px 0;
}
.market-summary:hover { color: var(--accent); }
.market-summary .note { font-weight: 400; }
#mdetails[open] > .market-summary { margin-bottom: 14px; }
.ctrl-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px 16px; flex-wrap: wrap;
}
.range { display: flex; gap: 4px; }
.range button {
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  padding: 4px 11px; font-size: 12px; font-weight: 500; border-radius: 6px;
}
.range button[aria-pressed="true"] {
  background: var(--accent-soft); color: var(--accent);
  border-color: var(--accent); font-weight: 600;
}
/* Measure switches. The swatch repeats the stroke pattern the line will use, so
   the control shows what it turns on rather than only naming it. */
.toggles { display: flex; gap: 6px; flex-wrap: wrap; }
.toggles button {
  display: inline-flex; align-items: center; gap: 7px;
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  padding: 5px 11px; font-size: 12px; font-weight: 500; border-radius: 6px;
}
.toggles button[aria-pressed="true"] {
  background: var(--accent-soft); color: var(--accent);
  border-color: var(--accent); font-weight: 600;
}
.toggles button svg { flex: none; }
.toggles button em { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.toggles .sep { width: 1px; background: var(--line); margin: 2px 6px; align-self: stretch; }
.stat.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.stat[role="button"] { cursor: pointer; transition: border-color .12s, background .12s; }
.stat[role="button"]:hover { border-color: var(--accent); background: var(--accent-soft); }
.stat[role="button"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.legend { display: flex; gap: 8px 16px; flex-wrap: wrap; margin: 12px 0 6px; font-size: 12.5px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); }
.legend i { width: 16px; height: 2px; border-radius: 2px; background: currentColor; }

.tbl-head {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  font-size: 13px; font-weight: 600; margin: 18px 0 6px;
}
.tbl-head i { width: 14px; height: 2px; border-radius: 2px; align-self: center; flex: none; }
.tbl-head small { font-weight: 400; font-size: 11.5px; color: var(--muted); }
.chart-box { position: relative; }
.chart-box svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.tip {
  position: absolute; pointer-events: none; z-index: 5; opacity: 0;
  transition: opacity .1s; background: var(--card); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font-size: 12.5px; min-width: 132px;
  box-shadow: 0 4px 16px -4px rgba(0, 0, 0, .25);
}
.tip.on { opacity: 1; }
.tip .tym { color: var(--muted); font-size: 11.5px; margin-bottom: 5px; }
.tip .trow { display: flex; align-items: center; gap: 7px; margin-top: 3px; }
.tip .trow i { width: 12px; height: 2px; border-radius: 2px; flex: none; }
.tip .trow b { font-variant-numeric: tabular-nums; }
.tip .trow small { color: var(--muted); }

/* ---------- report / shared ---------- */
.note { font-size: 12.5px; color: var(--muted); }
.big { font-size: 34px; font-weight: 650; letter-spacing: -.02em; }
.band { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.band div { border: 1px solid var(--line); border-radius: 8px; padding: 10px; text-align: center; }
.band .mid { border-color: var(--accent); background: var(--sel); }
.band small { display: block; color: var(--muted); font-size: 11.5px; }
.band b { font-size: 16px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 500; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.msg { border-radius: 8px; padding: 12px 14px; font-size: 13.5px; margin-bottom: 10px; }
.msg.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid currentColor; }
.msg.err { background: var(--err-bg); color: var(--err); border: 1px solid currentColor; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 4px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.pill {
  display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 20px;
  border: 1px solid currentColor; margin-left: 6px;
}
.hide { display: none; }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
details { margin-top: 10px; }
details summary {
  cursor: pointer; font-size: 13px; color: var(--muted);
  padding: 3px 0; list-style-position: outside;
}
details summary:hover { color: var(--accent); }
details[open] summary { margin-bottom: 8px; }

@media (max-width: 560px) {
  .wrap { padding: 0 16px 72px; }
  h1 { font-size: 26px; }
  .hero { padding: 32px 0 22px; }
  .card { padding: 18px 16px; }
  .actions button { width: 100%; }
}
