:root {
  --bg: #0e141b;
  --surface: #121b25;
  --surface-soft: #182433;
  --surface-hi: #1e2c3e;
  --ink: #eef2f7;
  --muted: #bdc9d9;
  --dim: #8b9cb3;
  --gold: #c5973a;
  --gold-soft: #e2c27a;
  --gold-glow: rgba(197, 151, 58, 0.35);
  --teal: #4fb8a5;
  --blue: #4885ca;
  --red: #d66b5e;
  --green: #6fbf73;
  --amber: #e2a23d;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.18);
  --max: 1280px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body.market-dashboard {
  font-family: "Outfit", sans-serif;
  background:
    radial-gradient(circle at 12% 18%, rgba(197, 151, 58, 0.14), transparent 38%),
    radial-gradient(circle at 88% 6%, rgba(72, 133, 202, 0.16), transparent 42%),
    radial-gradient(circle at 50% 110%, rgba(79, 184, 165, 0.10), transparent 45%),
    linear-gradient(180deg, #0e141b 0%, #0a0f15 100%);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ---------- Layout ---------- */
.dash {
  max-width: var(--max);
  margin: 0 auto;
  padding: 36px 24px 96px;
  display: flex;
  flex-direction: column;
  gap: 44px;
}

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(135deg, rgba(24, 36, 51, 0.92), rgba(18, 27, 37, 0.82));
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 36px;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at top right, rgba(197, 151, 58, 0.12), transparent 60%);
  pointer-events: none;
}

.hero-head { position: relative; max-width: 780px; }
.eyebrow {
  margin: 0 0 8px;
  font-family: "Barlow Condensed", sans-serif;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.84rem;
  color: var(--gold);
}

.hero h1 {
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  font-weight: 600;
  line-height: 1.08;
  margin: 0 0 14px;
  color: var(--ink);
}
.hero h1 span { color: var(--gold); font-style: italic; }

.lede {
  font-size: 1.08rem;
  color: var(--muted);
  max-width: 720px;
  margin: 0 0 32px;
}

/* ---------- Year scrubber ---------- */
.year-scrubber {
  position: relative;
  padding: 22px 24px 20px;
  background: rgba(14, 20, 27, 0.65);
  border: 1px solid var(--line);
  border-radius: 16px;
  margin-bottom: 28px;
}

.scrubber-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 14px;
}

.scrubber-label {
  margin: 0;
  font-family: "Barlow Condensed", sans-serif;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: var(--muted);
}

.scrubber-year {
  margin: 2px 0 0;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(2.4rem, 5vw, 3.4rem);
  font-weight: 600;
  color: var(--gold);
  line-height: 1;
  letter-spacing: 0.02em;
}

.scrubber-hint {
  font-size: 0.8rem;
  color: var(--dim);
  font-style: italic;
  text-align: right;
  max-width: 240px;
}

input[type="range"]#yearSlider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: linear-gradient(to right, rgba(197, 151, 58, 0.55), rgba(197, 151, 58, 0.15));
  border-radius: 999px;
  outline: none;
  cursor: grab;
}
input[type="range"]#yearSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  background: var(--gold);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(197, 151, 58, 0.22), 0 4px 12px rgba(0,0,0,0.5);
  cursor: grab;
  transition: transform 0.15s ease;
}
input[type="range"]#yearSlider:active::-webkit-slider-thumb { transform: scale(1.15); cursor: grabbing; }
input[type="range"]#yearSlider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  background: var(--gold);
  border: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(197, 151, 58, 0.22), 0 4px 12px rgba(0,0,0,0.5);
  cursor: grab;
}

.scrubber-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  color: var(--dim);
}
.scrubber-ticks span { flex: 1; text-align: center; }
.scrubber-ticks span:first-child { text-align: left; }
.scrubber-ticks span:last-child { text-align: right; }

/* ---------- KPI cards ---------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  position: relative;
}

.kpi {
  background: linear-gradient(160deg, rgba(30, 44, 62, 0.78), rgba(18, 27, 37, 0.55));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 16px;
  position: relative;
  transition: transform 0.25s ease, border-color 0.25s ease;
}
.kpi:hover { transform: translateY(-2px); border-color: var(--line-strong); }

.kpi-label {
  margin: 0 0 10px;
  font-family: "Barlow Condensed", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  color: var(--muted);
}

.kpi-value {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.01em;
  line-height: 1.1;
}

.kpi-delta {
  margin: 6px 0 0;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
}
.kpi-delta.up { color: var(--green); }
.kpi-delta.down { color: var(--red); }
.kpi-delta.flat { color: var(--muted); }

.kpi-sub {
  margin: 6px 0 0;
  font-size: 0.82rem;
  color: var(--dim);
  letter-spacing: 0.02em;
}

.kpi-accent {
  background: linear-gradient(160deg, rgba(197, 151, 58, 0.22), rgba(197, 151, 58, 0.05));
  border-color: rgba(197, 151, 58, 0.45);
}
.kpi-accent .kpi-value { color: var(--gold-soft); }

/* ---------- Blocks ---------- */
.block {
  background: linear-gradient(180deg, rgba(24, 36, 51, 0.75), rgba(18, 27, 37, 0.6));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 26px 26px 30px;
}

.block-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 22px;
}

.block-eyebrow {
  margin: 0 0 6px;
  font-family: "Barlow Condensed", sans-serif;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-size: 0.76rem;
  color: var(--gold);
}

.block h2 {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: 1.65rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.15;
}

.block-sub {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.98rem;
  max-width: 640px;
}

/* ---------- Chips ---------- */
.chip-group {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.chip {
  background: transparent;
  color: var(--muted);
  border: 0;
  padding: 8px 14px;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.chip:hover { color: var(--ink); }
.chip.is-active {
  background: rgba(197, 151, 58, 0.18);
  color: var(--gold-soft);
  box-shadow: inset 0 0 0 1px rgba(197, 151, 58, 0.4);
}

/* ---------- Charts ---------- */
.chart-wrap {
  position: relative;
  width: 100%;
  height: 320px;
}
.chart-wrap.chart-xl { height: 460px; }
.chart-wrap.chart-lg { height: 400px; }
.chart-wrap.chart-sm { height: 260px; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

/* ---------- Heatmap ---------- */
.heatmap {
  display: grid;
  grid-template-columns: 80px repeat(12, 1fr);
  gap: 6px;
  margin-bottom: 16px;
}

.heatmap-row-label {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 10px;
  font-family: "Barlow Condensed", sans-serif;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-size: 0.8rem;
}

.heatmap-head {
  font-family: "Barlow Condensed", sans-serif;
  letter-spacing: 0.1em;
  color: var(--dim);
  font-size: 0.76rem;
  text-align: center;
  text-transform: uppercase;
  padding: 4px 0;
}

.heatmap-cell {
  height: 56px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: "Outfit", sans-serif;
  font-size: 0.74rem;
  color: rgba(14, 20, 27, 0.78);
  font-weight: 600;
  position: relative;
  transition: transform 0.15s ease;
  cursor: default;
}
.heatmap-cell small { display: block; font-size: 0.62rem; font-weight: 500; opacity: 0.8; }
.heatmap-cell:hover { transform: translateY(-2px) scale(1.04); z-index: 2; box-shadow: 0 8px 20px rgba(0,0,0,0.35); }
.heatmap-cell.empty { background: rgba(255, 255, 255, 0.03); cursor: default; }
.heatmap-cell.empty:hover { transform: none; box-shadow: none; }

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
  font-family: "Barlow Condensed", sans-serif;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--muted);
}
.heatmap-gradient {
  display: inline-block;
  width: 180px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(to right, rgba(79, 184, 165, 0.55), rgba(197, 151, 58, 0.95));
}

/* ---------- Time Machine ---------- */
.time-machine { background: linear-gradient(160deg, rgba(197, 151, 58, 0.12), rgba(24, 36, 51, 0.5)); border-color: rgba(197, 151, 58, 0.35); }

.tm-wrap {
  display: grid;
  grid-template-columns: minmax(0, 280px) 1fr;
  gap: 24px;
  align-items: stretch;
}

.tm-input {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tm-input > span {
  font-family: "Barlow Condensed", sans-serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: var(--muted);
}

.tm-field {
  display: flex;
  align-items: center;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(197, 151, 58, 0.35);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 1.8rem;
  font-family: "Cormorant Garamond", serif;
  color: var(--gold-soft);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.tm-field:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(197, 151, 58, 0.18);
}
.tm-prefix { margin-right: 6px; color: var(--gold); }
.tm-field input {
  flex: 1;
  background: transparent;
  border: 0;
  color: var(--ink);
  font-size: 1.8rem;
  font-family: "Cormorant Garamond", serif;
  outline: none;
  width: 100%;
  min-width: 0;
}
.tm-field input::-webkit-outer-spin-button,
.tm-field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.tm-results {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.tm-card {
  background: rgba(14, 20, 27, 0.55);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 16px;
}

.tm-card-accent {
  background: linear-gradient(160deg, rgba(197, 151, 58, 0.22), rgba(197, 151, 58, 0.05));
  border-color: rgba(197, 151, 58, 0.5);
}

.tm-label {
  margin: 0 0 6px;
  font-family: "Barlow Condensed", sans-serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--muted);
}

.tm-value {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.1;
}
.tm-card-accent .tm-value { color: var(--gold-soft); }

.tm-sub {
  margin: 6px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

/* ---------- Communities ---------- */
.community-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.community-card {
  background: rgba(14, 20, 27, 0.55);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.community-card:hover { transform: translateY(-2px); border-color: rgba(197, 151, 58, 0.4); }

.community-name {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--gold-soft);
}

.community-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  gap: 10px;
}
.community-row span:first-child { color: var(--muted); }
.community-row span:last-child { color: var(--ink); font-variant-numeric: tabular-nums; }

.community-yoy {
  margin-top: 4px;
  font-family: "Barlow Condensed", sans-serif;
  letter-spacing: 0.1em;
  font-size: 0.78rem;
}
.community-yoy.up { color: var(--green); }
.community-yoy.down { color: var(--red); }

/* ---------- Extremes ---------- */
.extremes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.extreme-card {
  background: rgba(14, 20, 27, 0.55);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}
.extreme-card .kpi-label { margin-bottom: 6px; }
.extreme-card .extreme-val {
  font-family: "Cormorant Garamond", serif;
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
  color: var(--ink);
}
.extreme-card .extreme-year {
  font-family: "Barlow Condensed", sans-serif;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
  color: var(--gold);
  margin-top: 4px;
}

/* ---------- Definitions ---------- */
.definitions {
  margin: 0;
  padding: 0 0 0 18px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.7;
}
.definitions li { margin-bottom: 10px; }
.definitions strong { color: var(--ink); }

/* ---------- CTA ---------- */
.cta {
  background: linear-gradient(135deg, rgba(197, 151, 58, 0.18), rgba(18, 27, 37, 0.6));
  border: 1px solid rgba(197, 151, 58, 0.4);
  border-radius: 22px;
  padding: 32px;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: space-between;
  align-items: center;
}
.cta h2 {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: 1.9rem;
  font-weight: 600;
  max-width: 640px;
  color: var(--ink);
}
.cta-sub {
  margin: 8px 0 0;
  color: var(--muted);
  max-width: 640px;
}
.cta-btn {
  display: inline-block;
  border: 1px solid var(--gold);
  color: var(--gold);
  padding: 14px 24px;
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.84rem;
  border-radius: 999px;
  transition: background 0.2s ease, color 0.2s ease;
  cursor: pointer;
}
.cta-btn:hover { background: var(--gold); color: #090909; }

/* ---------- Footnote ---------- */
.footnote {
  text-align: center;
  color: var(--dim);
  font-size: 0.86rem;
  padding: 8px 16px;
  max-width: 900px;
  margin: 0 auto;
}

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .community-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tm-wrap { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .dash { padding: 24px 14px 72px; gap: 32px; }
  .hero { padding: 24px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .community-grid { grid-template-columns: 1fr; }
  .tm-results { grid-template-columns: 1fr; }
  .extremes { grid-template-columns: 1fr; }
  .chart-wrap { height: 280px; }
  .chart-wrap.chart-xl { height: 360px; }
  .chart-wrap.chart-lg { height: 320px; }
  .heatmap { grid-template-columns: 60px repeat(12, 1fr); gap: 4px; }
  .heatmap-cell { height: 42px; font-size: 0.62rem; }
  .heatmap-cell small { display: none; }
  .block-head { flex-direction: column; align-items: flex-start; }
  .scrubber-head { flex-direction: column; align-items: flex-start; }
  .scrubber-hint { text-align: left; }
  .cta { flex-direction: column; align-items: flex-start; }
}

/* ---------- Motion ---------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.block, .hero, .cta { animation: fadeUp 0.6s ease both; }
.block:nth-child(2) { animation-delay: 0.05s; }
.block:nth-child(3) { animation-delay: 0.08s; }

@media (prefers-reduced-motion: reduce) {
  .block, .hero, .cta { animation: none; }
  .kpi { transition: none; }
}
