/* 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; height: fit-content; position: sticky; top: 86px;
}
.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); }

/* 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); }

.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; }

/* 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); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .filters { position: static; }
  .charts { grid-template-columns: 1fr; }
  .mainnav { display: none; }
}
