/* NSW Property Explorer — mobile-first */
:root {
  color-scheme: light;
  --surface: #fcfcfb;
  --plane: #f9f9f7;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --s1: #2a78d6;          /* house / primary series */
  --s2: #eb6834;          /* unit / secondary series */
  --up: #006300;
  --down: #d03b3b;
  --accent: #2a78d6;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --surface: #1a1a19;
    --plane: #0d0d0d;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --s1: #3987e5;
    --s2: #d95926;
    --up: #0ca30c;
    --accent: #3987e5;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--plane);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  padding-bottom: 64px; /* bottom nav */
}
a { color: var(--accent); text-decoration: none; }
button { font: inherit; }

#app { max-width: 760px; margin: 0 auto; padding: 12px 12px 24px; }

/* ---- header / nav ---- */
.topbar {
  position: sticky; top: 0; z-index: 500;
  background: var(--plane);
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  display: flex; align-items: center; gap: 8px;
}
.topbar .brand { font-weight: 700; font-size: 16px; color: var(--ink); }
.topbar .meta { margin-left: auto; font-size: 11px; color: var(--muted); }

.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 500;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a {
  flex: 1; text-align: center; padding: 9px 0 7px;
  color: var(--muted); font-size: 11px; font-weight: 600;
}
.bottomnav a .ic { display: block; font-size: 19px; line-height: 1.1; }
.bottomnav a.active { color: var(--accent); }

/* ---- search ---- */
.searchwrap { position: relative; margin: 10px 0; }
.searchwrap input {
  width: 100%; padding: 13px 14px;
  font-size: 16px;
  border: 1px solid var(--baseline); border-radius: 10px;
  background: var(--surface); color: var(--ink);
}
.searchwrap input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.results {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 400;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  max-height: 55vh; overflow: auto;
  box-shadow: 0 6px 24px rgba(0,0,0,0.12);
}
.results .grouphdr {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 8px 12px 2px;
}
.results .item {
  display: block; padding: 10px 12px; border-top: 1px solid var(--grid);
  color: var(--ink); cursor: pointer;
}
.results .item:active, .results .item:hover { background: var(--plane); }
.results .item .sub { font-size: 12px; color: var(--muted); }

/* ---- cards / stats ---- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; margin: 10px 0;
}
.cardtitle { font-size: 13px; font-weight: 700; color: var(--ink-2); margin: 0 0 8px; text-transform: uppercase; letter-spacing: .03em; }
.statgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: 10px; }
.stat .v { font-size: 19px; font-weight: 700; }
.stat .l { font-size: 11px; color: var(--muted); }
.stat .d { font-size: 12px; font-weight: 600; }
.stat .d.pos { color: var(--up); }
.stat .d.neg { color: var(--down); }

.decilebar { display: flex; gap: 2px; margin-top: 3px; }
.decilebar i { flex: 1; height: 6px; border-radius: 2px; background: var(--grid); }
.decilebar i.on { background: var(--s1); }

h1.pagetitle { font-size: 21px; margin: 12px 0 2px; }
.subtitle { color: var(--muted); font-size: 13px; margin: 0 0 6px; }
.crumb { font-size: 13px; margin: 8px 0 0; }

/* ---- filters ---- */
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.filters select, .filters input {
  padding: 7px 9px; font-size: 13px;
  border: 1px solid var(--baseline); border-radius: 8px;
  background: var(--surface); color: var(--ink);
  max-width: 110px;
}
.chip {
  padding: 7px 11px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--baseline); border-radius: 999px;
  background: var(--surface); color: var(--ink-2); cursor: pointer;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---- sales list ---- */
.salerow {
  display: flex; align-items: baseline; gap: 10px;
  padding: 10px 2px; border-top: 1px solid var(--grid);
  color: var(--ink); cursor: pointer;
}
.salerow:hover { background: var(--plane); }
.salerow .addr { flex: 1; min-width: 0; }
.salerow .addr .a { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.salerow .addr .s { font-size: 12px; color: var(--muted); }
.salerow .price { font-weight: 700; white-space: nowrap; }
.salerow .date { font-size: 12px; color: var(--muted); white-space: nowrap; }
.loadmore { width: 100%; padding: 10px; margin-top: 8px; border: 1px solid var(--baseline); border-radius: 8px; background: var(--surface); color: var(--accent); font-weight: 600; cursor: pointer; }

/* ---- tables ---- */
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .03em;
  color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--baseline);
  cursor: pointer; white-space: nowrap;
}
table.data th.sorted { color: var(--accent); }
table.data td { padding: 8px 6px; border-bottom: 1px solid var(--grid); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr.rowlink { cursor: pointer; }
table.data tr.rowlink:hover { background: var(--plane); }
.tablewrap { overflow-x: auto; }

/* ---- charts ---- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin: 2px 0 6px; }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 300;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 9px; font-size: 12px; box-shadow: 0 4px 14px rgba(0,0,0,0.15);
  white-space: nowrap; display: none;
}
.tooltip .t { font-weight: 700; }

/* ---- map ---- */
#map { height: calc(100vh - 210px); min-height: 320px; border-radius: 12px; z-index: 0; }
.maplegend {
  display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--ink-2);
  margin-top: 6px; flex-wrap: wrap;
}
.maplegend .sw { width: 22px; height: 10px; border-radius: 2px; display: inline-block; }
.leaflet-container { background: var(--plane); font: inherit; }

.note { font-size: 12px; color: var(--muted); }
.err { padding: 14px; background: var(--surface); border: 1px solid var(--down); border-radius: 10px; color: var(--down); }
.spin { text-align: center; color: var(--muted); padding: 30px 0; }
