/* Theme tokens live in themes.css. styles.css references tokens only. */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial;
  background: radial-gradient(1200px 600px at 80% -10%, var(--hero-glow) 0, transparent 60%), var(--bg);
  background-color: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  transition: background-color .25s ease, color .25s ease;
}

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 14px 28px; border-bottom: 1px solid var(--line);
  background: var(--bg2);
  position: sticky; top: 0; z-index: 20; backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.brand .logo { font-size: 26px; color: var(--brand); }
.brand h1 { font-size: 20px; margin: 0; letter-spacing: .3px; }
.brand small { color: var(--muted); }
.mainnav { display: flex; gap: 6px; margin-left: 12px; }
.navlink {
  background: transparent; color: var(--muted); border: 0; cursor: pointer;
  padding: 8px 14px; border-radius: 10px; font-size: 14px; font-weight: 600;
}
.navlink:hover { color: var(--ink); background: var(--panel); }
.navlink.active { color: var(--brand-ink); background: var(--brand); }
.topstat { margin-left: auto; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.themepick { display: flex; align-items: center; gap: 8px; }
.themepick .swatches { display: flex; gap: 5px; }
.themepick .sw {
  width: 18px; height: 18px; border-radius: 50%; cursor: pointer; padding: 0;
  border: 2px solid var(--line); transition: transform .12s, border-color .12s;
}
.themepick .sw:hover { transform: scale(1.18); }
.themepick .sw.active { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }
.themepick select {
  width: auto; padding: 7px 10px; font-size: 13px; font-weight: 600; cursor: pointer;
}

/* Hero */
.view { padding: 28px; max-width: 1320px; margin: 0 auto; }
.hidden { display: none !important; }
.hero { text-align: center; padding: 22px 0 8px; }
.hero h2 { font-size: 30px; margin: 0 0 8px; }
.hero p { color: var(--muted); margin: 0 auto 18px; max-width: 640px; }
.searchbar { display: flex; gap: 10px; justify-content: center; max-width: 620px; margin: 0 auto; }
.searchbar input { flex: 1; }
.quickstats { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.quickstats .qs { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; }
.quickstats .qs b { display: block; font-size: 22px; color: var(--brand2); font-variant-numeric: tabular-nums; }
.quickstats .qs span { font-size: 12px; color: var(--muted); }

/* Inputs */
input, select {
  background: var(--bg2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; font-size: 14px; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
.btn {
  background: var(--panel2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 16px; font-weight: 700; cursor: pointer; font-size: 14px;
}
.btn:hover { filter: brightness(1.12); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; margin-top: 8px; }

/* Layout */
.layout { display: grid; grid-template-columns: 260px 1fr; gap: 22px; margin-top: 22px; }
.filters {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; position: sticky; top: 86px;
  /* Cap to the viewport so a tall filter list never runs off-screen; scroll
     internally when it does, keeping every filter (and the buttons) reachable. */
  max-height: calc(100vh - 100px); overflow-y: auto;
}
.filters h3 { margin: 0 0 12px; }
.filters label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 12px; font-weight: 600; }
.filters label select, .filters label input { margin-top: 5px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Results */
.results-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
#resultCount { color: var(--muted); font-size: 14px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 12px; color: var(--ink); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); gap: 18px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; transition: transform .12s, border-color .12s;
  display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-3px); border-color: var(--brand); }
.card .thumb { aspect-ratio: 16/10; background: var(--bg2); object-fit: cover; width: 100%; }
.card-ext {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55); color: #fff; border-radius: 8px; text-decoration: none;
  font-size: 15px; font-weight: 800; backdrop-filter: blur(2px); transition: background .12s, transform .12s;
}
.card-ext:hover { background: var(--brand); transform: scale(1.08); }
.card .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; }
.card .price { font-size: 18px; font-weight: 800; color: var(--brand2); }
.card .price .per { font-size: 12px; color: var(--muted); font-weight: 600; }
.card .title { font-size: 14px; font-weight: 600; line-height: 1.3; min-height: 36px; }
.card .loc { font-size: 12px; color: var(--muted); }
.card .meta { display: flex; gap: 10px; font-size: 12px; color: var(--muted); margin-top: 2px; }
.card .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.tag { font-size: 10.5px; padding: 3px 8px; border-radius: 999px; font-weight: 700; letter-spacing: .2px; }
.tag.type { background: var(--tag-type-bg); color: var(--tag-type-ink); }
.tag.status { background: var(--tag-status-bg); color: var(--tag-status-ink); }
.tag.av-active { background: var(--av-active-bg); color: var(--av-active-ink); }
.tag.av-sold { background: var(--av-sold-bg); color: var(--av-sold-ink); }
.tag.av-expired { background: var(--av-expired-bg); color: var(--av-expired-ink); }
.tag.av-removed_by_source { background: var(--av-removed-bg); color: var(--av-removed-ink); }
.tag.av-temporarily_unavailable { background: var(--av-unavail-bg); color: var(--av-unavail-ink); }

/* Per-card ROI badge */
.roi { display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  margin-top: 8px; padding: 7px 9px; border-radius: 9px;
  background: var(--av-active-bg); border: 1px solid var(--line); }
.roi small { font-size: 9.5px; opacity: .8; font-weight: 600; margin-left: 1px; }
.roi-pct { font-weight: 800; font-size: 13px; color: var(--av-active-ink); }
.roi-amt { font-weight: 700; font-size: 12.5px; color: var(--ink); }

/* Per-card gross-yield badge (real, source-data only; N/A otherwise) */
.yieldrow { display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  margin-top: 6px; padding: 6px 9px; border-radius: 9px;
  background: var(--panel2); border: 1px solid var(--line); }
.yieldrow-k { font-size: 11px; color: var(--muted); font-weight: 600; }
.yieldrow-v { font-weight: 800; font-size: 13px; color: var(--brand2); font-variant-numeric: tabular-nums; }
.yieldrow-v small { font-size: 9.5px; color: var(--muted); font-weight: 600; }
.yieldrow.na .yieldrow-v { color: var(--muted); }

/* Pager */
.pager { display: flex; gap: 6px; justify-content: center; margin: 26px 0 10px; flex-wrap: wrap; }
.pager button { background: var(--panel); border: 1px solid var(--line); color: var(--ink); border-radius: 8px; padding: 8px 13px; cursor: pointer; font-weight: 600; }
.pager button.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.pager button:disabled { opacity: .4; cursor: default; }

/* Dashboard */
.muted { color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 16px; margin: 20px 0; }
.statcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.statcard b { display: block; font-size: 28px; color: var(--brand); font-variant-numeric: tabular-nums; }
.statcard span { color: var(--muted); font-size: 13px; }
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.panel h3 { margin: 0 0 14px; }
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar { display: grid; grid-template-columns: 150px 1fr 56px; align-items: center; gap: 10px; font-size: 13px; }
.bar .label { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .track { background: var(--bg2); border-radius: 6px; height: 14px; overflow: hidden; }
.bar .fill { height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand2)); }
.bar .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }

table.runs { width: 100%; border-collapse: collapse; font-size: 13px; }
table.runs th, table.runs td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.runs th { color: var(--muted); font-weight: 600; }

/* Control */
.control-actions { display: flex; align-items: center; gap: 12px; margin: 16px 0 18px; }
.badge { padding: 6px 12px; border-radius: 999px; font-weight: 700; font-size: 12px; }
.badge.idle { background: var(--panel2); color: var(--muted); }
.badge.running { background: rgba(245,185,66,.18); color: var(--gold); }
.livestats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 14px; margin-bottom: 18px; }
.weblist { display: flex; flex-wrap: wrap; gap: 10px; }
.websrc { display: flex; align-items: center; gap: 10px; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.websrc .info { display: flex; flex-direction: column; gap: 2px; }
.websrc .nm { font-weight: 700; font-size: 14px; }
.websrc .eng { font-size: 11px; color: var(--muted); }
.websrc .pill { font-size: 10px; padding: 2px 7px; border-radius: 999px; font-weight: 700; }
.pill.ok { background: var(--av-active-bg); color: var(--av-active-ink); }
.pill.tune { background: var(--av-expired-bg); color: var(--av-expired-ink); }
.weblist.excluded .websrc { opacity: .8; }
.weblist.excluded .nm { color: var(--muted); }
.websrc .why { font-size: 11px; color: var(--muted); max-width: 230px; }
.log { background: var(--log-bg); border: 1px solid var(--line); border-radius: 10px; padding: 14px; height: 320px; overflow: auto; font-size: 12.5px; line-height: 1.55; color: var(--log-ink); white-space: pre-wrap; }
.log .lv-error { color: var(--lv-error); }
.log .lv-success { color: var(--lv-success); }
.log .lv-info { color: var(--lv-info); }

/* Modal */
.modal { position: fixed; inset: 0; background: var(--overlay); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal-card { background: var(--bg2); border: 1px solid var(--line); border-radius: 16px; max-width: 760px; width: 100%; max-height: 90vh; overflow: auto; position: relative; box-shadow: var(--shadow); }
.modal-close { position: absolute; top: 12px; right: 12px; background: rgba(0,0,0,.4); color: #fff; border: 0; width: 34px; height: 34px; border-radius: 999px; cursor: pointer; font-size: 16px; }
.modal-hero { width: 100%; aspect-ratio: 16/8; object-fit: cover; }
.modal-inner { padding: 22px 26px 28px; }
.modal-inner h2 { margin: 0 0 6px; }
.modal-price { font-size: 26px; font-weight: 800; color: var(--brand2); margin: 8px 0; }
.srclink-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 4px 0 14px; }
.srclink {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  background: var(--brand); color: var(--brand-ink); font-weight: 700; font-size: 14px;
  padding: 10px 16px; border-radius: 10px; transition: filter .12s;
}
.srclink:hover { filter: brightness(1.1); }
.srclink .ext { font-size: 15px; }
.srclink-host { color: var(--muted); font-size: 12px; }
.kv { display: grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); gap: 12px; margin: 16px 0; }
.kv div { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.kv span { display: block; font-size: 11px; color: var(--muted); }
.kv b { font-size: 15px; }
.amenities { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
/* Valuation / investment outlook block */
.valuation { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 18px; }
.valuation h3 { margin: 0 0 4px; display: flex; align-items: center; gap: 8px; }
.estimate-tag { font-size: 10px; font-weight: 800; letter-spacing: .4px; text-transform: uppercase;
  background: var(--av-expired-bg); color: var(--av-expired-ink); padding: 2px 8px; border-radius: 999px; }
.valuation .small { font-size: 12px; margin: 0 0 14px; }
.kv.valstats b.up { color: var(--brand2); }
.valchart { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 8px 4px; margin: 6px 0 14px; }
svg.vc { width: 100%; height: auto; display: block; }
.vc-grid { stroke: var(--line); stroke-width: 1; }
.vc-ylab { fill: var(--muted); font-size: 10px; text-anchor: end; }
.vc-xlab { fill: var(--muted); font-size: 10px; text-anchor: middle; }
.vc-xlab.now { fill: var(--brand); font-weight: 700; }
.vc-area { fill: var(--brand); opacity: .12; }
.vc-line { fill: none; stroke: var(--brand2); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.vc-line.vc-future { stroke: var(--brand); stroke-dasharray: 5 4; opacity: .85; }
.vc-nowline { stroke: var(--brand); stroke-width: 1; stroke-dasharray: 3 3; opacity: .6; }
.vc-now { fill: var(--brand); stroke: var(--panel); stroke-width: 2; }
.valtable { width: 100%; border-collapse: collapse; font-size: 13px; }
.valtable th, .valtable td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.valtable th { color: var(--muted); font-weight: 600; }
.valtable tr.now { background: var(--av-active-bg); }
.valtable tr.now td { font-weight: 700; }
.valtable tr.proj td { color: var(--muted); }

/* Gross rental yield block (detail modal) */
.yieldblock .yield-na { display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
  background: var(--panel); border: 1px dashed var(--line); border-radius: 12px; padding: 16px 18px; margin: 6px 0 4px; }
.yieldblock .yield-na b { font-size: 22px; color: var(--muted); }
.yieldblock .yield-na span { font-size: 12.5px; color: var(--muted); }
.kv.yieldstats b.up { color: var(--brand2); }
svg.yg { width: 100%; height: auto; display: block; }
.yg-track { fill: var(--bg2); stroke: var(--line); stroke-width: 1; }
.yg-fill { fill: var(--brand2); }
.yg-marker { stroke: var(--brand); stroke-width: 2.5; stroke-linecap: round; }
.yg-val { fill: var(--ink); font-size: 14px; font-weight: 800; }

.history { margin-top: 18px; }
.history table { width: 100%; border-collapse: collapse; font-size: 13px; }
.history th, .history td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.history th { color: var(--muted); }

.foot { text-align: center; color: var(--muted); padding: 28px; font-size: 13px; border-top: 1px solid var(--line); margin-top: 30px; }

/* Food Park */
.card { position: relative; }
.fp-photo-tag {
  position: absolute; top: 8px; left: 8px; z-index: 2;
  background: rgba(0,0,0,.55); color: #fff; font-size: 10px; font-weight: 700;
  letter-spacing: .3px; text-transform: uppercase; padding: 3px 8px; border-radius: 7px;
  backdrop-filter: blur(2px);
}
.fp-section { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 16px; }
.fp-section h3 { margin: 0 0 12px; }
.fp-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin: 12px 0 4px; }
.fp-gallery img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.fp-gallery img.main { grid-column: span 2; aspect-ratio: 16/9; }
.fp-contacts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.fp-contact-row { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.fp-contact-row span { display: block; font-size: 11px; color: var(--muted); }
.fp-contact-row b { font-size: 14px; word-break: break-word; }
.fp-contact-row a { color: var(--brand2); text-decoration: none; }
.fp-contact-row a:hover { text-decoration: underline; }
.fp-map { width: 100%; height: 320px; border: 1px solid var(--line); border-radius: 12px; display: block; }
.fp-maplink { display: inline-block; margin-top: 8px; font-size: 12px; text-decoration: none; }
.fp-nomap { padding: 24px; text-align: center; background: var(--panel); border: 1px dashed var(--line); border-radius: 12px; }
.fp-competitors { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.fp-competitor { display: flex; flex-direction: column; gap: 3px; text-align: left; cursor: pointer; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit; color: inherit; transition: border-color .15s, transform .15s; }
.fp-competitor:hover { border-color: var(--brand2); transform: translateY(-1px); }
.fp-comp-name { font-size: 14px; font-weight: 600; }

/* Toast */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 24px);
  background: var(--brand); color: var(--brand-ink); padding: 12px 20px;
  border-radius: 12px; font-weight: 700; font-size: 14px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 100; max-width: 90vw;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Documents — Social Listening dashboard */
.doc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 6px; }
.doc-head h2 { margin: 0 0 4px; font-size: 24px; }
.doc-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.doc-month { width: auto; padding: 7px 10px; font-size: 13px; font-weight: 600; cursor: pointer; }
.doc-period { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
.doc-pill { background: transparent; color: var(--muted); border: 0; cursor: pointer; padding: 6px 16px; border-radius: 999px; font-size: 13px; font-weight: 600; text-transform: capitalize; }
.doc-pill:hover { color: var(--ink); }
.doc-pill.active { background: var(--brand); color: var(--brand-ink); }
.doc-src { margin-left: 8px; font-size: 11px; padding: 2px 8px; border-radius: 999px; vertical-align: middle; }
.doc-src.live { background: var(--av-active-bg); color: var(--av-active-ink); }
.doc-src.file { background: var(--panel2); color: var(--muted); }
.doc-src.sample { background: var(--av-expired-bg); color: var(--av-expired-ink); }

.doc-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 18px 0; }
.doc-kpi { padding: 16px 18px; margin: 0; }
.doc-kpi-val { font-size: 30px; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; margin-top: 4px; }
.doc-kpi-delta { margin-top: 6px; font-size: 13px; }
.doc-trend.up { color: #16a34a; }
.doc-trend.down { color: #dc2626; }
.doc-trend.flat { color: var(--muted); }

.doc-cols3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.doc-cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.doc-cols3 .panel, .doc-cols2 .panel { margin: 0; }
.doc-stack { display: flex; flex-direction: column; gap: 16px; }
.doc-panel-h { margin-bottom: 12px; font-weight: 600; }

.doc-donut-wrap { display: flex; justify-content: center; padding: 4px 0 10px; }
.doc-donut { width: 160px; height: 160px; display: block; }
.doc-legend { display: flex; justify-content: space-around; font-size: 13px; flex-wrap: wrap; gap: 6px; text-transform: capitalize; }

.doc-themes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; font-size: 13px; }
.doc-themes li { display: flex; justify-content: space-between; gap: 10px; }

.doc-posts { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; font-size: 13px; }
.doc-posts li { display: flex; gap: 10px; }
.doc-rank { width: 18px; flex: none; }
.doc-posts a { color: var(--brand2); text-decoration: underline; text-decoration-color: var(--line); }
.doc-posts a:hover { text-decoration-color: var(--brand2); }
.doc-excerpt { color: var(--ink); opacity: .8; margin-top: 3px; line-height: 1.4; }

.doc-branches { width: 100%; border-collapse: collapse; font-size: 13px; }
.doc-branches td { padding: 6px 4px; border-bottom: 1px solid var(--line); }
.doc-branches td.num { text-align: right; font-variant-numeric: tabular-nums; }
.doc-bsent { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc-bsent span { margin-left: 6px; }

.doc-dq { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; text-align: center; }
.doc-dq-n { font-size: 22px; font-weight: 800; color: var(--brand2); font-variant-numeric: tabular-nums; }
.doc-dq-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; font-size: 12px; }
.doc-err { color: #dc2626; }

@media (max-width: 1100px) {
  .doc-cols3 { grid-template-columns: 1fr; }
  .doc-kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .filters { position: static; max-height: none; overflow-y: visible; }
  .charts { grid-template-columns: 1fr; }
  .mainnav { display: none; }
  .doc-cols2 { grid-template-columns: 1fr; }
}
