/* Price per marla map. Colour tokens live on :root; dark mode re-steps them
   (the map ramp flips so "expensive" is always the high-contrast end). */

:root {
  color-scheme: light;
  --surface-0: #eef0f2;
  --surface-1: #fcfcfb;
  --surface-2: #f3f3f1;
  --border: #e2e1dd;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #7a7974;
  --accent: #1c5cab;
  --seg-on: #0b0b0b;
  --seg-on-text: #fcfcfb;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 8px 24px rgb(0 0 0 / 0.08);
  --radius: 14px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-0: #111110;
    --surface-1: #1a1a19;
    --surface-2: #232321;
    --border: #33332f;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #8d8c85;
    --accent: #86b6ef;
    --seg-on: #f0efec;
    --seg-on-text: #1a1a19;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px rgb(0 0 0 / 0.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #111110;
  --surface-1: #1a1a19;
  --surface-2: #232321;
  --border: #33332f;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #8d8c85;
  --accent: #86b6ef;
  --seg-on: #f0efec;
  --seg-on-text: #1a1a19;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px rgb(0 0 0 / 0.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--surface-0); color: var(--text-primary); }
body { overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }

#map { position: fixed; inset: 0; background: var(--surface-0); }

/* ---------- panel ---------- */
.panel {
  position: fixed; top: 16px; left: 16px; bottom: 16px; width: 360px; z-index: 1000;
  display: flex; flex-direction: column;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.sheet-handle { display: none; }
.panel-head { padding: 18px 18px 12px; border-bottom: 1px solid var(--border); }
.eyebrow { margin: 0 0 2px; font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); font-weight: 600; }
.city-select {
  appearance: none; -webkit-appearance: none; border: 0; background: transparent; padding: 0 22px 0 0; margin: 0 0 12px;
  font-size: 28px; font-weight: 700; letter-spacing: -0.02em; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%), linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
  background-position: right 6px top 58%, right 0 top 58%; background-size: 6px 6px; background-repeat: no-repeat;
}
.city-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 6px; }

.seg { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  flex: 1; border: 0; background: transparent; border-radius: 8px; padding: 8px 10px; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--text-secondary); white-space: nowrap;
}
.seg button[aria-checked="true"] { background: var(--seg-on); color: var(--seg-on-text); }
.seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.seg-sm button { padding: 5px 8px; font-size: 13px; }

.panel-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.headline { padding: 16px 18px 6px; }
.hero { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hero small { font-size: 15px; font-weight: 500; color: var(--text-secondary); letter-spacing: 0; }
.hero-sub { margin-top: 4px; font-size: 13px; color: var(--text-secondary); line-height: 1.45; }

.controls { padding: 8px 18px 4px; display: grid; gap: 10px; }
.control { display: grid; grid-template-columns: 52px 1fr; align-items: center; gap: 8px; }
.control-label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.control.hidden { display: none; }
.small-select {
  justify-self: start; border: 1px solid var(--border); background: var(--surface-1); border-radius: 8px; padding: 5px 8px; font-size: 13px;
}

.legend { padding: 12px 18px 4px; }
.legend-scale { display: flex; gap: 2px; height: 12px; }
.legend-scale span { flex: 1; border-radius: 3px; }
.legend-labels { display: flex; justify-content: space-between; margin-top: 5px; font-size: 11.5px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.legend-labels span { flex: 1; text-align: center; }
.legend-labels span:first-child { text-align: left; }
.legend-labels span:last-child { text-align: right; }
.legend-note { margin: 6px 0 0; font-size: 11.5px; color: var(--text-muted); }

.list-wrap { padding: 10px 0 0; border-top: 1px solid var(--border); margin-top: 12px; flex: 1 0 auto; display: flex; flex-direction: column; }
.list-head { display: grid; gap: 8px; padding: 0 18px 8px; }
.list-head h2 { font-size: 13px; margin: 0; font-weight: 700; }
.list-head input {
  width: 100%; border: 1px solid var(--border); background: var(--surface-2); border-radius: 8px; padding: 7px 10px; font-size: 13px;
}
.list-head input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.area-list { list-style: none; margin: 0; padding: 0 8px 8px; }
.area-list li button {
  width: 100%; display: grid; grid-template-columns: 12px 1fr auto; align-items: center; gap: 10px;
  border: 0; background: transparent; text-align: left; padding: 7px 10px; border-radius: 8px; cursor: pointer;
}
.area-list li button:hover, .area-list li button:focus-visible { background: var(--surface-2); outline: none; }
.area-list .dot { width: 12px; height: 12px; border-radius: 50%; }
.area-list .dot.low { background: transparent !important; border: 2px dashed; }
.area-list .name { font-size: 13.5px; font-weight: 600; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; }
.area-list .path { display: block; font-size: 11.5px; font-weight: 400; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.area-list .val { font-size: 13px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.area-list .val small { display: block; font-size: 11px; font-weight: 400; color: var(--text-muted); }
.area-list .empty { padding: 12px 10px; font-size: 13px; color: var(--text-muted); }

.panel-foot { padding: 10px 18px 16px; border-top: 1px solid var(--border); }
.panel-foot p { margin: 0; font-size: 11.5px; line-height: 1.5; color: var(--text-muted); }
.panel-foot p + p { margin-top: 8px; }
.panel-foot a { color: var(--accent); font-weight: 600; }

/* ---------- map marks & popups ---------- */
.leaflet-container { font: inherit; background: var(--surface-0); }
.leaflet-tooltip.tip {
  background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow); padding: 6px 9px; font-size: 12.5px; line-height: 1.35;
}
.leaflet-tooltip.tip::before { display: none; }
.tip strong { display: block; font-size: 13px; }
.tip .muted { color: var(--text-secondary); }
.leaflet-popup-content-wrapper { background: var(--surface-1); color: var(--text-primary); border-radius: 12px; box-shadow: var(--shadow); }
.leaflet-popup-tip { background: var(--surface-1); }
.leaflet-popup-content { margin: 14px 16px; font-size: 13px; line-height: 1.4; min-width: 220px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--text-muted); }
.pop h3 { margin: 0; font-size: 16px; }
.pop .pop-path { color: var(--text-muted); font-size: 12px; margin: 2px 0 10px; }
.pop .pop-big { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pop .pop-big small { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.pop dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 10px 0 0; font-variant-numeric: tabular-nums; }
.pop dt { color: var(--text-secondary); }
.pop dd { margin: 0; text-align: right; font-weight: 600; }
.pop .warn { margin: 10px 0 0; font-size: 12px; color: var(--text-secondary); }
.leaflet-control-attribution { font-size: 10px; background: color-mix(in srgb, var(--surface-1) 80%, transparent) !important; color: var(--text-muted); }
.leaflet-control-attribution a { color: var(--text-secondary); }
.leaflet-bar a { background: var(--surface-1); color: var(--text-primary); border-color: var(--border); }
.leaflet-bar a:hover { background: var(--surface-2); }
.leaflet-control-zoom { border: 1px solid var(--border) !important; box-shadow: var(--shadow) !important; }

/* ---------- phone: panel becomes a bottom sheet ---------- */
@media (max-width: 760px) {
  .panel {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 62vh;
    border-radius: var(--radius) var(--radius) 0 0; border-bottom: 0;
  }
  .sheet-handle {
    display: flex; justify-content: center; border: 0; background: transparent; padding: 8px 0 0; cursor: pointer;
  }
  .sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--border); }
  .panel-head { padding: 6px 16px 10px; }
  .city-select { font-size: 24px; margin-bottom: 8px; }
  .headline { padding: 12px 16px 4px; }
  .hero { font-size: 28px; }
  .controls, .legend { padding-left: 16px; padding-right: 16px; }
  .list-head { padding: 0 16px 8px; }
  .panel.collapsed .panel-body { display: none; }
  .leaflet-top.leaflet-left { top: 0; }
  .leaflet-control-zoom { display: none; }
}
