/* Pocket Agent Pro — warm editorial, luxury-brokerage feel */
:root {
  --paper: #faf7f1;
  --card: #ffffff;
  --ink: #1c1917;
  --ink-2: #57534e;
  --ink-3: #a8a29e;
  --line: #e9e3d8;
  --brand: #0f766e;
  --brand-deep: #115e59;
  --brand-tint: #f0fdfa;
  --amber: #b45309;
  --fresh: #0d9488;
  --watch: #d97706;
  --stale: #dc2626;
  --shadow: 0 1px 2px rgba(28,25,23,.05), 0 8px 24px -12px rgba(28,25,23,.18);
  --radius: 18px;
  --serif: "Playfair Display", Georgia, serif;
  --sans: "Karla", -apple-system, sans-serif;
  --num: "Space Grotesk", "Karla", sans-serif;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  font-family: var(--sans);
  background: var(--paper);
  background-image: radial-gradient(rgba(15,118,110,.045) 1px, transparent 1px);
  background-size: 26px 26px;
  color: var(--ink);
  display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ---------- header ---------- */
.topbar {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 14px 26px;
  background: rgba(250,247,241,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 1100;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { width: 44px; height: 44px; border-radius: 12px; display: block; box-shadow: 0 6px 16px -6px rgba(15,118,110,.6); }
.brand-name { font-family: var(--serif); font-weight: 700; font-size: 19px; letter-spacing: -.01em; }
.brand-sub { font-size: 11.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .14em; font-weight: 600; }
.tabs { display: flex; gap: 4px; margin-left: auto; background: #f1ece2; padding: 4px; border-radius: 999px; }
.tab {
  border: 0; background: transparent; cursor: pointer;
  font: 600 14px var(--sans); color: var(--ink-2);
  padding: 8px 18px; border-radius: 999px;
  transition: all .18s ease;
}
.tab:hover { color: var(--ink); }
.tab.active { background: var(--card); color: var(--brand-deep); box-shadow: var(--shadow); }
.data-age { font-size: 12px; color: var(--ink-3); min-width: 110px; text-align: right; }

/* ---------- layout ---------- */
main { flex: 1; display: flex; flex-direction: column; }
.panel { display: none; flex: 1; }
.panel.active { display: block; animation: rise .35s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
#panel-map.active { position: relative; display: flex; }
.section-head { max-width: 1060px; margin: 42px auto 8px; padding: 0 24px; }
h1 { font-family: var(--serif); font-weight: 800; font-size: clamp(30px, 4.5vw, 44px); letter-spacing: -.02em; }
h1 em { font-style: italic; color: var(--brand); }
.lede { color: var(--ink-2); margin-top: 8px; font-size: 16px; max-width: 560px; }
.muted { color: var(--ink-3); font-weight: 400; }
.foot {
  padding: 18px 26px; font-size: 11.5px; color: var(--ink-3);
  border-top: 1px solid var(--line); text-align: center;
}

/* ---------- map ---------- */
#map { flex: 1; min-height: calc(100vh - 76px); z-index: 1; background: #eae6dd; }
.map-card {
  position: absolute; z-index: 1000;
  background: rgba(255,255,255,.94); backdrop-filter: blur(6px);
  border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; box-shadow: var(--shadow);
  font-size: 13px;
}
.layers-card { top: 16px; right: 16px; }
.search-card { top: 16px; left: 16px; padding: 8px; width: min(340px, calc(100vw - 32px)); }
.search-card form { display: flex; gap: 6px; }
.search-card input {
  flex: 1; border: 0; outline: 0; background: transparent;
  font: 500 14px var(--sans); padding: 6px 10px; color: var(--ink);
}
.search-card button {
  border: 0; cursor: pointer; background: var(--brand-deep); color: #f0fdfa;
  font: 700 15px var(--sans); width: 34px; height: 34px; border-radius: 10px;
}
.search-card button:hover { background: var(--brand); }
.map-search-note { font-size: 12px; color: var(--ink-3); padding: 4px 10px 2px; }
.map-search-note:empty { display: none; }
.search-pin-icon { filter: drop-shadow(0 2px 4px rgba(28,25,23,.4)); }
.legend-card { bottom: 26px; right: 16px; }
.farm-card { bottom: 26px; left: 16px; width: min(300px, calc(100vw - 32px)); padding: 0; overflow: hidden; border: 1.5px solid #f0c14b; }
.farm-head { display: flex; gap: 11px; align-items: center; background: linear-gradient(135deg, #f6b93b, #e79c1a); padding: 12px 14px; }
.farm-star { font-size: 22px; color: #fff; filter: drop-shadow(0 1px 2px rgba(0,0,0,.2)); }
.farm-title { font: 800 15px var(--serif); color: #fff; letter-spacing: -.01em; }
.farm-sub { font-size: 11.5px; color: #fff6e0; margin-top: 1px; font-weight: 600; }
.farm-panel { padding: 12px 14px; }
.farm-list { display: flex; flex-direction: column; gap: 5px; margin-bottom: 8px; }
.farm-item { display: flex; justify-content: space-between; align-items: center; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; font-size: 12.5px; }
.farm-item .k { color: var(--ink-3); font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; margin-left: 6px; }
.farm-item button { border: 0; background: none; color: var(--stale); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; }
.farm-add { display: flex; gap: 6px; }
.farm-add select { flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font: 500 12.5px var(--sans); background: #fff; }
.farm-add button { border: 0; background: var(--brand-deep); color: #f0fdfa; border-radius: 8px; font: 700 12.5px var(--sans); padding: 0 14px; cursor: pointer; }
.farm-add button:hover { background: var(--brand); }
.farm-note { font-size: 11px; color: var(--ink-3); margin-top: 8px; font-style: italic; }
.map-card-title { font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); margin-bottom: 8px; }
.switch { display: flex; gap: 8px; align-items: center; padding: 3px 0; cursor: pointer; }
.switch em { color: var(--ink-3); font-style: normal; font-size: 11px; }
.switch input { accent-color: var(--brand); }
.legend-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; color: var(--ink-2); }
.legend-row i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.15); }
.legend-row .sold-dot { background: #a8a29e; }
.hood-label {
  background: none; border: none; box-shadow: none;
  font: italic 600 12px var(--serif); color: rgba(17,94,89,.85);
  text-shadow: 0 1px 3px rgba(255,255,255,.9);
  white-space: nowrap;
}
.leaflet-popup-content-wrapper { border-radius: 14px; box-shadow: var(--shadow); font-family: var(--sans); }
.pop { width: 230px; }
.pop img { width: 100%; height: 120px; object-fit: cover; border-radius: 10px; margin-bottom: 8px; background: #f1ece2; }
.pop .pop-price { font-family: var(--num); font-weight: 700; font-size: 20px; }
.pop .pop-addr { color: var(--ink-2); font-size: 13px; margin: 2px 0 6px; }
.pop .pop-facts { font-size: 12px; color: var(--ink-3); }
.pop .badge { margin-top: 6px; }
.pop a { color: var(--brand); font-weight: 700; font-size: 12.5px; text-decoration: none; }

/* ---------- badges & chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
  padding: 3px 9px; border-radius: 999px;
}
.badge.fresh { background: #ecfdf5; color: #047857; }
.badge.watch { background: #fffbeb; color: #b45309; }
.badge.stale { background: #fef2f2; color: #b91c1c; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.city-chips { max-width: 1060px; margin: 18px auto 0; padding: 0 24px; }
.chip {
  border: 1px solid var(--line); background: var(--card); cursor: pointer;
  font: 600 13px var(--sans); color: var(--ink-2);
  padding: 7px 14px; border-radius: 999px; transition: all .15s ease;
}
.chip:hover { border-color: var(--brand); color: var(--brand-deep); }
.chip.active { background: var(--brand-deep); border-color: var(--brand-deep); color: #f0fdfa; }

/* ---------- cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px;
}
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.card-title { font-weight: 700; font-size: 15px; }
.eyebrow { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--brand); margin-bottom: 6px; }

/* ---------- home value ---------- */
.value-hero { max-width: 760px; margin: 56px auto 10px; padding: 0 24px; text-align: center; }
.value-hero .lede { margin-inline: auto; }
.searchbar {
  display: flex; margin-top: 26px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px; box-shadow: var(--shadow);
  transition: box-shadow .2s;
}
.searchbar:focus-within { box-shadow: 0 0 0 3px rgba(15,118,110,.18), var(--shadow); }
.searchbar input {
  flex: 1; border: 0; outline: 0; background: transparent;
  font: 500 16px var(--sans); padding: 10px 18px; color: var(--ink);
}
.searchbar button {
  border: 0; cursor: pointer; background: var(--brand-deep); color: #f0fdfa;
  font: 700 15px var(--sans); padding: 12px 26px; border-radius: 999px;
  transition: background .15s;
}
.searchbar button:hover { background: var(--brand); }
.searchbar button:disabled { opacity: .6; cursor: wait; }
.lookup-note { margin-top: 14px; font-size: 13.5px; color: var(--ink-2); min-height: 20px; }
.lookup-note a { color: var(--brand); }
.lookup-result {
  max-width: 1060px; margin: 26px auto 60px; padding: 0 24px;
  display: grid; grid-template-columns: 1.15fr .85fr; gap: 20px; align-items: start;
}
.lookup-result.hidden { display: none; }
.lookup-left { display: flex; flex-direction: column; gap: 20px; }
.value-label { font-size: 12.5px; font-weight: 600; color: var(--ink-3); margin-bottom: 2px; }
.value-label:empty { display: none; }
.value-big { font-family: var(--num); font-weight: 600; font-size: clamp(40px, 6vw, 58px); letter-spacing: -.02em; line-height: 1.05; }
.value-big.softer { font-size: clamp(30px, 4.5vw, 42px); }
.range-wrap { margin: 14px 0 4px; }
.range-bar { position: relative; height: 8px; border-radius: 999px; background: #f1ece2; overflow: visible; }
.range-fill { position: absolute; inset: 0 18% 0 18%; background: linear-gradient(90deg, #99f6e4, var(--brand)); border-radius: 999px; }
.range-tick { position: absolute; top: -4px; left: 50%; width: 4px; height: 16px; background: var(--ink); border-radius: 2px; transform: translateX(-50%); }
.range-labels { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink-3); margin-top: 6px; }
.fact-row { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 16px; }
.fact { text-align: left; }
.fact b { display: block; font-family: var(--num); font-size: 20px; font-weight: 600; }
.fact span { font-size: 11.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .08em; }
.value-card .chips { margin-top: 16px; }
.place-chip { background: var(--brand-tint); border: 1px solid #ccfbf1; color: var(--brand-deep); font-weight: 700; font-size: 12.5px; padding: 5px 12px; border-radius: 999px; }
.crosscheck { margin-top: 14px; font-size: 12.5px; color: var(--ink-3); }
.report-btn {
  margin-top: 18px; width: 100%; cursor: pointer;
  border: 0; border-radius: 12px; background: var(--brand-deep); color: #f0fdfa;
  font: 700 14.5px var(--sans); padding: 13px; transition: background .15s;
}
.report-btn:hover { background: var(--brand); }
.school-list { margin-top: 16px; border-top: 1px dashed var(--line); padding-top: 12px; }
.school-list:empty { display: none; }
.school-row { display: flex; align-items: baseline; gap: 8px; padding: 3px 0; font-size: 13.5px; }
.school-row .s-level { width: 86px; flex: none; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.school-row .s-name { font-weight: 700; color: var(--ink); }
.school-row .s-meta { font-size: 12px; color: var(--ink-3); }
.school-note { font-size: 11px; color: var(--ink-3); margin-top: 6px; font-style: italic; }
.writeup { font-size: 15px; line-height: 1.65; color: var(--ink-2); white-space: pre-wrap; }
.writeup-toggles { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.writeup-toggles:empty { display: none; }
.wtoggle {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border: 1px solid var(--line); background: var(--paper);
  font: 600 12.5px var(--sans); color: var(--ink-3);
  padding: 6px 12px; border-radius: 999px; transition: all .15s ease;
  user-select: none;
}
.wtoggle input { display: none; }
.wtoggle .tick { font-size: 11px; display: none; }
.wtoggle.on { background: var(--brand-tint); border-color: #99f6e4; color: var(--brand-deep); }
.wtoggle.on .tick { display: inline; }
.wtoggle:hover { border-color: var(--brand); }
.copy-btn {
  border: 1px solid var(--line); background: var(--paper); cursor: pointer;
  font: 700 12.5px var(--sans); color: var(--brand-deep);
  padding: 7px 14px; border-radius: 999px; transition: all .15s;
}
.copy-btn:hover { border-color: var(--brand); }
.copy-btn.done { background: var(--brand-deep); color: #fff; border-color: var(--brand-deep); }
.comps-list { display: flex; flex-direction: column; }
.comp {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px;
  padding: 12px 2px; border-bottom: 1px solid #f4f0e8;
}
.comp:last-child { border-bottom: 0; }
.comp .c-addr { font-weight: 700; font-size: 14px; }
.comp .c-facts { font-size: 12px; color: var(--ink-3); }
.comp .c-price { font-family: var(--num); font-weight: 600; font-size: 16px; text-align: right; }
.comp .c-meta { font-size: 12px; color: var(--ink-3); text-align: right; }

/* ---------- trend chart ---------- */
.trend-card.hidden { display: none; }
.sold-trend { max-width: 1012px; margin: 20px auto 0; }
@media (min-width: 1060px) { .sold-trend { margin-inline: auto; } }
.trend-stats { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0 6px; }
.trend-stat {
  flex: 1; min-width: 140px; background: var(--paper); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 14px;
}
.trend-stat b { display: block; font-family: var(--num); font-weight: 700; font-size: 19px; }
.trend-stat b.up { color: #047857; }
.trend-stat b.down { color: #b91c1c; }
.trend-stat span { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .07em; font-weight: 600; }
.trend-stat .sub { display: block; font-size: 11.5px; color: var(--ink-2); text-transform: none; letter-spacing: 0; margin-top: 2px; font-weight: 500; }
.trend-chart { position: relative; }
.trend-chart svg { width: 100%; height: auto; display: block; }
.trend-chart .axis-text { font: 500 10.5px var(--sans); fill: var(--ink-3); }
.trend-chart .grid { stroke: #f0ebe1; stroke-width: 1; }
.trend-chart .series-label { font: 700 11px var(--sans); }
.trend-tip {
  position: absolute; pointer-events: none; display: none;
  background: var(--ink); color: #faf7f1; font: 500 12px var(--sans);
  padding: 7px 10px; border-radius: 9px; white-space: nowrap; z-index: 5;
  transform: translate(-50%, -110%);
}
.trend-note { font-size: 11px; color: var(--ink-3); font-style: italic; margin-top: 8px; }

/* ---------- stats & sold ---------- */
.stat-row {
  max-width: 1060px; margin: 26px auto 0; padding: 0 24px;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
}
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.stat b { display: block; font-family: var(--num); font-weight: 600; font-size: clamp(22px, 2.6vw, 30px); letter-spacing: -.01em; }
.stat span { font-size: 11.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .09em; font-weight: 600; }
.sold-grid {
  max-width: 1060px; margin: 20px auto 60px; padding: 0 24px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px;
}
.sold-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); text-decoration: none; color: var(--ink);
  transition: transform .18s ease, box-shadow .18s ease;
}
.sold-card:hover { transform: translateY(-3px); box-shadow: 0 2px 4px rgba(28,25,23,.06), 0 16px 32px -12px rgba(28,25,23,.25); }
.sold-card img, .sold-card .noimg { width: 100%; height: 150px; object-fit: cover; display: block; background: linear-gradient(135deg, #f1ece2, #e5ded1); }
.sold-card .noimg { display: grid; place-items: center; font-size: 34px; }
.sold-body { padding: 14px 16px 16px; }
.sold-price { font-family: var(--num); font-weight: 700; font-size: 21px; display: flex; align-items: baseline; gap: 8px; }
.vs-list { font: 700 12px var(--sans); }
.vs-list.over { color: #047857; }
.vs-list.under { color: #b91c1c; }
.sold-addr { font-size: 13.5px; color: var(--ink-2); margin-top: 3px; }
.sold-facts { font-size: 12px; color: var(--ink-3); margin-top: 7px; }

/* ---------- overpriced table ---------- */
.table-card { max-width: 1060px; margin: 20px auto 60px; padding: 8px 6px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-3); font-weight: 700; padding: 12px 14px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th.num, td.num { text-align: right; }
td { padding: 13px 14px; border-bottom: 1px solid #f4f0e8; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #fdfbf7; }
.score-pill {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  font-family: var(--serif); font-weight: 800; font-size: 16px;
  background: conic-gradient(var(--pc, var(--watch)) calc(var(--p, 50) * 1%), #f1ece2 0);
}
.score-pill i { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--card); font-style: normal; font-family: var(--num); font-weight: 700; }
.prop-cell b { display: block; font-size: 14.5px; }
.prop-cell span { font-size: 12px; color: var(--ink-3); }
.cut-detail { font-size: 11.5px; color: var(--stale); font-weight: 700; }
.op-link { color: var(--brand); font-weight: 700; text-decoration: none; font-size: 13px; white-space: nowrap; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .lookup-result { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .tabs { order: 3; width: 100%; justify-content: space-between; }
  .tab { flex: 1; text-align: center; padding: 8px 6px; }
  .data-age { display: none; }
  .layers-card { top: 10px; right: 10px; font-size: 12px; }
  .legend-card { display: none; }
  #map { min-height: calc(100vh - 130px); }
}
