/* Baltimore Property Intelligence — palette roles from the validated reference
   set (categorical slots 1-3 for vacant / tax-sale / both; ink tokens for text).
   Light + dark are both selected steps, not an automatic flip. */
:root {
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --ink-1: #0b0b0b;
  --ink-2: #52514e;
  --ink-muted: #898781;
  --hairline: #e1e0d9;
  --border: rgba(11, 11, 11, 0.10);
  --c-vacant: #2a78d6;    /* slot 1 blue  */
  --c-taxsale: #1baf7a;   /* slot 2 aqua  */
  --c-both: #eda100;      /* slot 3 yellow */
  --accent: #2a78d6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface-1: #1a1a19;
    --page: #0d0d0d;
    --ink-1: #ffffff;
    --ink-2: #c3c2b7;
    --ink-muted: #898781;
    --hairline: #2c2c2a;
    --border: rgba(255, 255, 255, 0.10);
    --c-vacant: #3987e5;
    --c-taxsale: #199e70;
    --c-both: #c98500;
    --accent: #3987e5;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink-1);
  background: var(--page);
}

#app { display: flex; height: 100vh; }

/* ---------------- sidebar ---------------- */
#sidebar {
  width: 340px; min-width: 300px; overflow-y: auto;
  background: var(--surface-1);
  border-right: 1px solid var(--hairline);
  padding: 16px; display: flex; flex-direction: column; gap: 18px;
}
#sidebar h1 { font-size: 17px; margin: 0 0 2px; }
#sidebar h2 { font-size: 13px; margin: 0 0 8px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.sub { margin: 0; color: var(--ink-muted); font-size: 12px; }

.tiles { display: flex; gap: 10px; }
.tile {
  flex: 1; padding: 10px 12px; border: 1px solid var(--hairline);
  border-radius: 8px; background: var(--surface-1);
}
.tile-num { font-size: 22px; font-weight: 650; }
.tile-label { font-size: 11px; color: var(--ink-muted); }

.filters, .ask { display: flex; flex-direction: column; gap: 8px; }
.check { display: flex; align-items: center; gap: 7px; color: var(--ink-2); }
.field { display: flex; flex-direction: column; gap: 4px; color: var(--ink-2); font-size: 12px; }
.field input {
  font: inherit; padding: 7px 9px; border: 1px solid var(--hairline);
  border-radius: 6px; background: var(--page); color: var(--ink-1);
}
.hint { margin: 0; font-size: 11px; color: var(--ink-muted); display: flex; align-items: center; gap: 6px; }

.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block;
       box-shadow: 0 0 0 2px var(--surface-1); }
.dot-vacant { background: var(--c-vacant); }
.dot-taxsale { background: var(--c-taxsale); }
.dot-both { background: var(--c-both); }

button {
  font: inherit; padding: 8px 12px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border); background: var(--accent); color: #fff;
}
button:hover { filter: brightness(1.08); }

textarea {
  font: inherit; width: 100%; resize: vertical; padding: 8px 9px;
  border: 1px solid var(--hairline); border-radius: 6px;
  background: var(--page); color: var(--ink-1);
}

#ask-out { border-top: 1px solid var(--hairline); padding-top: 10px; }
#ask-narration { font-size: 13px; }
pre {
  font: 11.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap; word-break: break-word;
  background: var(--page); border: 1px solid var(--hairline);
  border-radius: 6px; padding: 10px; color: var(--ink-1);
  overflow-x: auto; margin: 8px 0 0;
}
#ask-table table { border-collapse: collapse; width: 100%; margin-top: 8px; font-size: 12px; }
#ask-table th, #ask-table td {
  text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--hairline);
  font-variant-numeric: tabular-nums;
}
#ask-table th { color: var(--ink-2); font-weight: 600; }
details summary { cursor: pointer; color: var(--ink-muted); font-size: 12px; margin-top: 8px; }

footer p { font-size: 10.5px; color: var(--ink-muted); margin: 0; }

/* top opportunities (ranked lead list) */
.toplist h2 { font-size: 13px; margin: 0 0 6px; color: var(--ink-2);
              text-transform: uppercase; letter-spacing: .04em; }
.info {
  display: inline-block; cursor: help; color: var(--ink-muted);
  font-size: 12px; text-transform: none; letter-spacing: 0;
}
.info:hover, .info:focus { color: var(--accent); }
#top-leads { list-style: none; margin: 0; padding: 0; counter-reset: lead;
             display: flex; flex-direction: column; gap: 2px; }
#top-leads li {
  counter-increment: lead; position: relative; padding: 6px 8px 6px 26px;
  border-radius: 6px; cursor: pointer;
}
#top-leads li::before {
  content: counter(lead); position: absolute; left: 8px; top: 7px;
  font-size: 11px; color: var(--ink-muted); font-variant-numeric: tabular-nums;
}
#top-leads li:hover { background: var(--page); }
.lead-addr { font-size: 12.5px; font-weight: 600; display: flex;
             align-items: center; gap: 6px; }
.lead-dots { display: inline-flex; gap: 3px; }
.lead-sub { font-size: 11px; color: var(--ink-muted); }

/* ask context chip */
.ask-context { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
button.linklike {
  background: none; border: none; color: var(--accent); cursor: pointer;
  padding: 0; font-size: 11px; text-decoration: underline;
}
button.linklike:hover { filter: none; opacity: .8; }

/* dossier decision cards */
#dossier-cards { display: flex; flex-direction: column; gap: 10px; }
.card {
  border: 1px solid var(--hairline); border-radius: 8px; padding: 10px 12px;
  background: var(--surface-1);
}
.card-title {
  font-size: 11px; font-weight: 650; color: var(--ink-2);
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px;
}
.card-why { border-left: 3px solid var(--accent); }
.card p { margin: 0; font-size: 12.5px; }
.card p.why { line-height: 1.5; }
.card .muted { color: var(--ink-muted); }
.card .small { font-size: 11px; margin-top: 4px; }
.kv { display: flex; justify-content: space-between; gap: 10px;
      font-size: 12.5px; padding: 2px 0; }
.kv .k { color: var(--ink-muted); }
.kv .v { text-align: right; font-variant-numeric: tabular-nums; }
.badges { display: flex; flex-wrap: wrap; gap: 5px; }
.badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--page); border: 1px solid var(--hairline); color: var(--ink-1);
}
.conf { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 4px;
        border: 1px solid var(--hairline); color: var(--ink-2); vertical-align: 1px; }
.conf-high   { color: #006300; border-color: #0ca30c55; }
.conf-medium { color: #8a5a00; border-color: #fab21955; }
.conf-low    { color: #a32c2c; border-color: #d03b3b55; }
@media (prefers-color-scheme: dark) {
  .conf-high   { color: #0ca30c; }
  .conf-medium { color: #fab219; }
  .conf-low    { color: #e66767; }
}
/* market-stress bar: single-hue sequential ramp (light = A/strongest,
   dark = J/most distressed) — position, not good/bad color judgment */
.stress { margin-top: 4px; }
.stress-bar {
  position: relative; height: 8px; border-radius: 4px; margin: 6px 0 4px;
  border: 1px solid var(--hairline);
  background: linear-gradient(90deg, #cde2fb, #5598e7, #0d366b);
}
.stress-marker {
  position: absolute; top: -3px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--ink-1);
  border: 2px solid var(--surface-1); box-shadow: 0 0 0 1px var(--hairline);
}
.stress-ends {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--ink-muted);
}

#dossier-raw { margin-top: 10px; }
#dossier-raw summary { cursor: pointer; color: var(--ink-muted); font-size: 12px; }
.card table { border-collapse: collapse; width: 100%; margin-top: 6px; font-size: 12px; }
.card th, .card td {
  text-align: left; padding: 3px 6px; border-bottom: 1px solid var(--hairline);
  font-variant-numeric: tabular-nums;
}
.card th { color: var(--ink-2); font-weight: 600; }

/* saved searches */
.save-row { display: flex; gap: 6px; }
.save-row input {
  flex: 1; font: inherit; padding: 7px 9px; border: 1px solid var(--hairline);
  border-radius: 6px; background: var(--page); color: var(--ink-1);
}
button.secondary {
  background: var(--page); color: var(--ink-1); border: 1px solid var(--hairline);
}
#s-list { list-style: none; margin: 4px 0 0; padding: 0; display: flex;
          flex-direction: column; gap: 2px; }
#s-list li {
  display: flex; align-items: center; gap: 6px; font-size: 12.5px;
  padding: 5px 7px; border-radius: 6px; cursor: pointer; color: var(--ink-2);
}
#s-list li:hover { background: var(--page); }
#s-list li .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#s-list li .del {
  border: none; background: transparent; color: var(--ink-muted);
  cursor: pointer; padding: 0 4px; font-size: 14px;
}
#s-list li .del:hover { color: var(--ink-1); filter: none; }

/* ---------------- map ---------------- */
#map { flex: 1; min-width: 0; background: var(--page); }
.leaflet-container { font: inherit; }
/* Dark-mode basemap: OSM has no keyless dark raster, so approximate one by
   filtering the light tiles. invert + hue-rotate(180) keeps water blue-ish and
   parks green-ish rather than color-negative. Leaflet puts the className on the
   tile-LAYER container (.leaflet-layer), so filtering it covers the whole
   basemap; markers/clusters live in other panes and are unaffected. */
.leaflet-layer.basemap-dark {
  filter: invert(1) hue-rotate(180deg) brightness(0.92) contrast(0.9);
}
.leaflet-popup-content { font-size: 12.5px; line-height: 1.5; margin: 10px 12px; }
.leaflet-popup-content .addr { font-weight: 650; font-size: 13px; }
.leaflet-popup-content .flags { color: var(--ink-2); }
.leaflet-popup-content button { margin-top: 6px; padding: 5px 9px; font-size: 12px; }

.cluster-icon {
  background: var(--accent); color: #fff; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 650; box-shadow: 0 0 0 2px var(--surface-1);
}

/* ---------------- dossier panel ---------------- */
#dossier {
  position: absolute; top: 12px; right: 12px; z-index: 1000;
  width: min(480px, calc(100vw - 380px));
  max-height: calc(100vh - 24px); overflow-y: auto;
  background: var(--surface-1); border: 1px solid var(--hairline);
  border-radius: 10px; padding: 14px 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .25);
}
#dossier h2 { margin: 0 30px 8px 0; font-size: 15px; }
#dossier-close {
  position: absolute; top: 8px; right: 8px; width: 28px; height: 28px;
  padding: 0; background: transparent; color: var(--ink-2);
  border: 1px solid var(--hairline); border-radius: 6px; font-size: 16px;
}
#dossier-comps { margin-top: 10px; font-size: 12px; color: var(--ink-2); }
#dossier-comps table { border-collapse: collapse; width: 100%; margin-top: 6px; }
#dossier-comps th, #dossier-comps td {
  text-align: left; padding: 3px 6px; border-bottom: 1px solid var(--hairline);
  font-variant-numeric: tabular-nums;
}
#dossier-sdat { display: inline-block; margin-top: 10px; color: var(--accent); font-size: 12.5px; }

@media (max-width: 760px) {
  #app { flex-direction: column; }
  #sidebar { width: 100%; max-height: 45vh; }
  #dossier { width: calc(100vw - 24px); }
}
