/* style.css — Growth Engine Design System + Components */

/* ===== DESIGN TOKENS ===== */
:root {
  /* Type scale */
  --text-xs:   clamp(0.6875rem, 0.65rem + 0.2vw, 0.75rem);
  --text-sm:   clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-base: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-lg:   clamp(1rem, 0.9rem + 0.5vw, 1.25rem);
  --text-xl:   clamp(1.25rem, 1rem + 1vw, 1.75rem);
  --text-2xl:  clamp(1.5rem, 1rem + 2vw, 2.5rem);

  /* Fonts */
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Spacing (4px grid) */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;

  /* Radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;
  --radius-full: 9999px;

  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ===== DARK MODE (DEFAULT) ===== */
:root, [data-theme="dark"] {
  --color-bg:             #0d0f11;
  --color-surface:        #131619;
  --color-surface-2:      #1a1d22;
  --color-surface-offset: #15181c;
  --color-surface-offset-2: #1e2228;
  --color-surface-dynamic: #252a31;
  --color-divider:        #2a2f37;
  --color-border:         #333a44;

  --color-text:           #e0e2e6;
  --color-text-muted:     #8b9099;
  --color-text-faint:     #555d68;
  --color-text-inverse:   #0d0f11;

  --color-grade-aplus:    #22c55e;
  --color-grade-a:        #34d399;
  --color-grade-bplus:    #eab308;
  --color-grade-b:        #f59e0b;
  --color-grade-c:        #f97316;
  --color-grade-d:        #ef4444;

  --color-primary:        #34d399;
  --color-primary-hover:  #22c55e;
  --color-primary-active: #16a34a;
  --color-primary-highlight: #1a2e26;

  --color-success:        #22c55e;
  --color-success-highlight: #162d1e;
  --color-warning:        #eab308;
  --color-warning-highlight: #2a2510;
  --color-error:          #ef4444;
  --color-error-highlight: #2d1515;
  --color-amber:          #f59e0b;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.5);
}

/* ===== LIGHT MODE ===== */
[data-theme="light"] {
  --color-bg:             #f4f5f7;
  --color-surface:        #ffffff;
  --color-surface-2:      #fafbfc;
  --color-surface-offset: #eef0f3;
  --color-surface-offset-2: #e5e8ec;
  --color-surface-dynamic: #dde0e5;
  --color-divider:        #d0d4da;
  --color-border:         #c0c6cf;

  --color-text:           #1a1d22;
  --color-text-muted:     #6b7280;
  --color-text-faint:     #9ca3af;
  --color-text-inverse:   #f4f5f7;

  --color-grade-aplus:    #16a34a;
  --color-grade-a:        #059669;
  --color-grade-bplus:    #ca8a04;
  --color-grade-b:        #d97706;
  --color-grade-c:        #ea580c;
  --color-grade-d:        #dc2626;

  --color-primary:        #059669;
  --color-primary-hover:  #047857;
  --color-primary-active: #065f46;
  --color-primary-highlight: #d1fae5;

  --color-success:        #16a34a;
  --color-success-highlight: #dcfce7;
  --color-warning:        #ca8a04;
  --color-warning-highlight: #fef9c3;
  --color-error:          #dc2626;
  --color-error-highlight: #fee2e2;
  --color-amber:          #d97706;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.12);
}

/* ===== DASHBOARD LAYOUT ===== */
html, body { height: 100%; margin: 0; }

.dashboard {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  z-index: 50;
  padding: var(--space-3) var(--space-4);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  max-width: 100%;
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.logo-mark {
  width: 28px;
  height: 28px;
}

.logo-text {
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.logo-subtitle {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  white-space: nowrap;
  display: none;
}

@media (min-width: 768px) {
  .logo-subtitle { display: block; }
}

/* Nav tabs */
.nav-tabs {
  display: flex;
  gap: var(--space-1);
  margin-left: var(--space-4);
  flex-shrink: 0;
}

.nav-tab {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background var(--transition-interactive), color var(--transition-interactive);
  white-space: nowrap;
}

.nav-tab:hover { background: var(--color-surface-dynamic); color: var(--color-text); }
.nav-tab.active { background: var(--color-primary-highlight); color: var(--color-primary); }
a.nav-tab-link { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--color-border); background: transparent; }
a.nav-tab-link:hover { border-color: var(--color-primary); color: var(--color-primary); background: var(--color-primary-highlight); }

/* Filter bar */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: auto;
  flex-shrink: 0;
}

.filter-select, .filter-input {
  padding: var(--space-1) var(--space-2);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  color: var(--color-text);
  min-width: 0;
  transition: border-color var(--transition-interactive);
}

.filter-select:focus, .filter-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.filter-input { width: 140px; }

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: var(--space-3);
  flex-shrink: 0;
}

.icon-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  transition: background var(--transition-interactive), color var(--transition-interactive);
}

.icon-btn:hover { background: var(--color-surface-dynamic); color: var(--color-text); }

/* ===== MAIN CONTENT ===== */
.main {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Views */
.view { display: none; }
.view.active { display: block; }

/* ===== MAP VIEW ===== */
.map-section {
  position: relative;
  height: 55vh;
  min-height: 350px;
  flex-shrink: 0;
}

#map {
  width: 100%;
  height: 100%;
  z-index: 1;
  /* Prevent map from stealing scroll/touch when user scrolls the page */
  touch-action: pan-y pinch-zoom;
}

.map-legend {
  position: absolute;
  bottom: var(--space-4);
  right: var(--space-4);
  z-index: 1000;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  box-shadow: var(--shadow-md);
  font-size: var(--text-xs);
}

.legend-title {
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--color-text);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
  color: var(--color-text-muted);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ===== TABLE SECTION ===== */
.table-section {
  padding: var(--space-4);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.section-title {
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.section-count {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  font-variant-numeric: tabular-nums;
}

.table-container {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

.data-table {
  width: 100%;
  font-size: var(--text-xs);
  border-collapse: collapse;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--color-surface-offset);
  padding: var(--space-2) var(--space-3);
  text-align: left;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color var(--transition-interactive);
}

.data-table th:hover { color: var(--color-text); }
.data-table th.sorted { color: var(--color-primary); }
.data-table th .sort-arrow { font-size: 0.65em; margin-left: var(--space-1); }

.data-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-divider);
  white-space: nowrap;
  font-variant-numeric: tabular-nums lining-nums;
  vertical-align: middle;
}

.data-table tbody tr {
  cursor: pointer;
  transition: background var(--transition-interactive);
}

.data-table tbody tr:hover { background: var(--color-surface-offset); }
.data-table tbody tr.selected { background: var(--color-primary-highlight); }

.suburb-name {
  font-weight: 500;
  color: var(--color-text);
}

.state-badge {
  display: inline-block;
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  background: var(--color-surface-dynamic);
  color: var(--color-text-muted);
}

.price-cell {
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.score-cell {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.75rem;
}

.grade-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  padding: 1px var(--space-2);
  border-radius: var(--radius-full);
  font-size: 0.65rem;
  font-weight: 700;
}

.grade-aplus { background: color-mix(in oklch, var(--color-grade-aplus) 18%, var(--color-surface)); color: var(--color-grade-aplus); }
.grade-a { background: color-mix(in oklch, var(--color-grade-a) 18%, var(--color-surface)); color: var(--color-grade-a); }
.grade-bplus { background: color-mix(in oklch, var(--color-grade-bplus) 18%, var(--color-surface)); color: var(--color-grade-bplus); }
.grade-b { background: color-mix(in oklch, var(--color-grade-b) 18%, var(--color-surface)); color: var(--color-grade-b); }
.grade-c { background: color-mix(in oklch, var(--color-grade-c) 18%, var(--color-surface)); color: var(--color-grade-c); }
.grade-d { background: color-mix(in oklch, var(--color-grade-d) 18%, var(--color-surface)); color: var(--color-grade-d); }

/* ===== SOURCE BADGES ===== */
.source-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px var(--space-2);
  border-radius: var(--radius-full);
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  gap: 3px;
}
.source-hotspotting {
  background: color-mix(in oklch, #f59e0b 16%, var(--color-surface));
  color: #f59e0b;
  border: 1px solid color-mix(in oklch, #f59e0b 25%, transparent);
}
.source-hotspotting::before {
  content: '\2605';
  font-size: 0.5rem;
}
.source-htag {
  background: color-mix(in oklch, #22b8cf 16%, var(--color-surface));
  color: #22b8cf;
  border: 1px solid color-mix(in oklch, #22b8cf 25%, transparent);
}
.source-htag::before {
  content: '\25C6';
  font-size: 0.45rem;
}
.source-proptrack {
  background: color-mix(in oklch, #f97316 16%, var(--color-surface));
  color: #f97316;
  border: 1px solid color-mix(in oklch, #f97316 25%, transparent);
}
.source-proptrack::before {
  content: '\25B2';
  font-size: 0.4rem;
}

/* ===== DEX SCORES ===== */
.dex-scores-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-3);
}
.dex-score-card {
  text-align: center;
}
.dex-score-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-1);
}
.dex-score-value {
  font-size: 1.4rem;
  font-weight: 700;
  font-family: var(--font-mono);
  line-height: 1;
  margin-bottom: var(--space-1);
}
.dex-score-bar {
  height: 4px;
  background: var(--color-surface-2);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.dex-score-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}
.dex-score {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: var(--text-xs);
}
.dex-badge {
  display: inline-flex;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-size: 0.6rem;
  font-weight: 600;
  font-family: var(--font-mono);
  border: 1px solid;
}
.dex-badge.dex-na {
  color: var(--color-text-faint);
  border-color: var(--color-text-faint);
}

/* ===== THERMOMETER BADGES ===== */
.thermo-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: 1px solid currentColor;
  background: color-mix(in oklch, currentColor 12%, var(--color-surface));
  white-space: nowrap;
}

/* ===== PPI BADGES ===== */
.ppi-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px var(--space-2);
  border-radius: var(--radius-full);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.ppi-rising    { background: color-mix(in oklch, var(--color-grade-aplus) 18%, var(--color-surface)); color: var(--color-grade-aplus); }
.ppi-consistent { background: color-mix(in oklch, var(--color-grade-a) 18%, var(--color-surface)); color: var(--color-grade-a); }
.ppi-recovery  { background: color-mix(in oklch, var(--color-grade-bplus) 18%, var(--color-surface)); color: var(--color-grade-bplus); }
.ppi-plateau   { background: var(--color-surface-dynamic); color: var(--color-text-muted); }
.ppi-declining { background: color-mix(in oklch, var(--color-grade-d) 18%, var(--color-surface)); color: var(--color-grade-d); }
.ppi-snr       { background: var(--color-surface-2); color: var(--color-text-faint); }

.pct-cell {
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

.pct-positive { color: var(--color-success); }
.pct-negative { color: var(--color-error); }
.pct-neutral { color: var(--color-text-muted); }

/* ===== DETAIL PANEL ===== */
.detail-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 480px;
  max-width: 95vw;
  z-index: 100;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 350ms cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.detail-overlay.open { transform: translateX(0); }

.detail-backdrop {
  position: fixed;
  inset: 0;
  z-index: 99;
  background: rgba(0,0,0,0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

.detail-backdrop.open { opacity: 1; pointer-events: auto; }

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-divider);
  position: sticky;
  top: 0;
  background: var(--color-surface);
  z-index: 5;
}

.detail-title {
  font-size: var(--text-lg);
  font-weight: 600;
}

.detail-state {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.detail-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  transition: background var(--transition-interactive), color var(--transition-interactive);
}

.detail-close:hover { background: var(--color-surface-dynamic); color: var(--color-text); }

.detail-body { padding: var(--space-4); }

/* Grade hero in detail */
.detail-grade-hero {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  background: var(--color-surface-2);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
}

.detail-score-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xl);
  font-weight: 700;
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.detail-grade-info { flex: 1; }
.detail-grade-label { font-size: var(--text-xl); font-weight: 700; }
.detail-grade-explain { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: var(--space-1); line-height: 1.5; }

/* Metric cards grid */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(130px, 100%), 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.metric-card {
  background: var(--color-surface-2);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  border: 1px solid var(--color-divider);
}

.metric-label {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-1);
}

.metric-value {
  font-size: var(--text-lg);
  font-weight: 700;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums lining-nums;
}

.metric-delta {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  margin-top: var(--space-1);
}

/* Radar chart container */
.chart-container {
  margin-bottom: var(--space-4);
}

.chart-title {
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-3);
}

.chart-canvas-wrap {
  position: relative;
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
}

/* Score breakdown */
.score-breakdown {
  margin-bottom: var(--space-4);
}

.score-bar-group {
  margin-bottom: var(--space-3);
}

.score-bar-header {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  margin-bottom: var(--space-1);
}

.score-bar-label { color: var(--color-text-muted); }
.score-bar-value { font-family: var(--font-mono); font-weight: 600; }

.score-bar-track {
  height: 6px;
  background: var(--color-surface-dynamic);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 600ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Adjacent suburbs */
.adjacent-section { margin-bottom: var(--space-4); }

.adjacent-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-divider);
  font-size: var(--text-xs);
}

.adjacent-name { color: var(--color-text); }
.adjacent-gap { font-family: var(--font-mono); color: var(--color-primary); }

/* ===== INSIGHTS VIEW ===== */
.insights-view { padding: var(--space-4); }

.insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(350px, 100%), 1fr));
  gap: var(--space-4);
}

.insight-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.insight-card-header {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.insight-card-title {
  font-size: var(--text-sm);
  font-weight: 600;
}

.insight-card-badge {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

.insight-list { padding: 0; }

.insight-list-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--color-divider);
  font-size: var(--text-xs);
  transition: background var(--transition-interactive);
  cursor: pointer;
}

.insight-list-item:hover { background: var(--color-surface-offset); }
.insight-list-item:last-child { border-bottom: none; }

.insight-rank {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--color-text-faint);
  min-width: 20px;
}

.insight-suburb { flex: 1; font-weight: 500; color: var(--color-text); }
.insight-state { color: var(--color-text-faint); }
.insight-score { font-family: var(--font-mono); font-weight: 600; }
.insight-price { font-family: var(--font-mono); color: var(--color-text-muted); }

/* ===== METHODOLOGY VIEW ===== */
.methodology-view {
  padding: var(--space-4);
  max-width: 860px;
  margin: 0 auto;
}

.methodology-view h2 {
  font-size: var(--text-xl);
  font-weight: 600;
  margin: var(--space-8) 0 var(--space-4);
  letter-spacing: -0.01em;
}

.methodology-view h2:first-of-type { margin-top: 0; }

.methodology-view h3 {
  font-size: var(--text-lg);
  font-weight: 600;
  margin: var(--space-6) 0 var(--space-3);
}

.methodology-view p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
  line-height: 1.7;
}

.methodology-view a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--transition-interactive);
}

.methodology-view a:hover { color: var(--color-primary-hover); }

.factor-table {
  width: 100%;
  margin: var(--space-4) 0;
  font-size: var(--text-xs);
}

.factor-table th {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface-offset);
  color: var(--color-text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--color-border);
}

.factor-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-divider);
  color: var(--color-text-muted);
}

.factor-table td:first-child { color: var(--color-text); font-weight: 500; }

.grade-scale {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(140px, 100%), 1fr));
  gap: var(--space-3);
  margin: var(--space-4) 0;
}

.grade-scale-item {
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  text-align: center;
  border: 1px solid var(--color-divider);
}

.grade-scale-grade { font-size: var(--text-lg); font-weight: 700; }
.grade-scale-range { font-size: var(--text-xs); font-family: var(--font-mono); color: var(--color-text-muted); margin-top: var(--space-1); }

/* ===== HELP OVERLAY ===== */
.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.help-overlay.open { display: flex; }

.help-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  max-width: 560px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.help-card h2 { font-size: var(--text-xl); font-weight: 700; margin-bottom: var(--space-4); }

.help-step {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.help-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--color-primary-highlight);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 700;
  flex-shrink: 0;
}

.help-step-text { font-size: var(--text-sm); color: var(--color-text-muted); line-height: 1.6; }
.help-step-text strong { color: var(--color-text); }

.help-dismiss {
  display: block;
  width: 100%;
  padding: var(--space-2) var(--space-4);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: var(--text-sm);
  text-align: center;
  transition: background var(--transition-interactive);
  margin-top: var(--space-4);
}

.help-dismiss:hover { background: var(--color-primary-hover); }

/* ===== PULSE ANIMATION (A+ markers) ===== */
@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(2.5); opacity: 0; }
}

.marker-pulse {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  animation: pulse-ring 2s ease-out infinite;
}

/* ===== LEAFLET OVERRIDES (dark mode tiles) ===== */
.leaflet-container {
  background: var(--color-bg) !important;
  touch-action: pan-y pinch-zoom !important;
}

/* Override Leaflet's default touch-action:none which blocks page scroll */
.leaflet-container .leaflet-tile-pane,
.leaflet-container .leaflet-overlay-pane,
.leaflet-container .leaflet-marker-pane {
  touch-action: pan-y pinch-zoom !important;
}

.dark-tiles {
  filter: brightness(0.65) invert(1) contrast(2.8) hue-rotate(200deg) saturate(0.2) brightness(0.6);
}

[data-theme="light"] .dark-tiles {
  filter: none;
}

.leaflet-control-zoom a {
  background: var(--color-surface) !important;
  color: var(--color-text) !important;
  border-color: var(--color-border) !important;
}

.leaflet-popup-content-wrapper {
  background: var(--color-surface) !important;
  color: var(--color-text) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-lg) !important;
  border: 1px solid var(--color-border);
}

.leaflet-popup-tip { background: var(--color-surface) !important; }

.leaflet-popup-close-button {
  color: var(--color-text-muted) !important;
  font-size: 18px !important;
}
.leaflet-popup-close-button:hover { color: var(--color-text) !important; }

.leaflet-popup-content {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  margin: var(--space-3) !important;
  line-height: 1.5;
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
  .header-inner { flex-wrap: wrap; }
  .filter-bar { order: 3; width: 100%; padding-top: var(--space-2); }
  .nav-tabs { order: 2; }
  .header-actions { order: 4; }
  .filter-input { width: 100px; }
  .map-section { height: 45vh; min-height: 280px; }
  .detail-overlay { width: 100%; max-width: 100%; }
  .insights-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .nav-tabs { display: none; }
  .logo-subtitle { display: none; }
}

/* ===== LOADING STATE ===== */
.loading-shimmer {
  background: linear-gradient(90deg, var(--color-surface-offset) 25%, var(--color-surface-dynamic) 50%, var(--color-surface-offset) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ===== SCROLLBAR STYLING ===== */
.main::-webkit-scrollbar,
.detail-overlay::-webkit-scrollbar,
.table-scroll::-webkit-scrollbar { width: 6px; height: 6px; }

.main::-webkit-scrollbar-track,
.detail-overlay::-webkit-scrollbar-track,
.table-scroll::-webkit-scrollbar-track { background: transparent; }

.main::-webkit-scrollbar-thumb,
.detail-overlay::-webkit-scrollbar-thumb,
.table-scroll::-webkit-scrollbar-thumb {
  background: var(--color-surface-dynamic);
  border-radius: var(--radius-full);
}

.main::-webkit-scrollbar-thumb:hover,
.detail-overlay::-webkit-scrollbar-thumb:hover,
.table-scroll::-webkit-scrollbar-thumb:hover { background: var(--color-border); }

/* Popup styles */
.popup-header { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); }
.popup-name { font-weight: 600; font-size: var(--text-sm); }
.popup-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-1); }
.popup-metric-label { font-size: 0.65rem; color: var(--color-text-faint); text-transform: uppercase; letter-spacing: 0.04em; }
.popup-metric-value { font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 600; }

/* ===== LISTINGS VIEW ===== */
.listings-view {
  padding: var(--space-4);
}

.listings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.listings-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.listings-count-badge {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  background: var(--color-surface-dynamic);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.listings-filters {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.listings-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
}

/* Listing card */
.listing-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow var(--transition-interactive), transform var(--transition-interactive), border-color var(--transition-interactive);
  cursor: default;
}

.listing-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--color-text-faint);
}

.listing-card-header {
  position: relative;
  padding: var(--space-3) var(--space-3) 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  min-height: 28px;
}

.listing-grade-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: 0.65rem;
  font-weight: 700;
}

.listing-score-chip {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--color-text-faint);
  background: var(--color-surface-2);
  border: 1px solid var(--color-divider);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
}

.listing-card-body {
  padding: var(--space-2) var(--space-3) var(--space-3);
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.listing-address {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
  margin-top: var(--space-1);
}

.listing-price {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: -0.02em;
  line-height: 1;
}

.listing-specs {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.listing-spec {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-variant-numeric: tabular-nums;
}

.listing-spec svg {
  color: var(--color-text-faint);
  flex-shrink: 0;
}

.listing-suburb-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
}

.listing-suburb-name {
  font-weight: 500;
  color: var(--color-text-muted);
}

.listing-dom {
  margin-left: auto;
  font-size: 0.65rem;
  color: var(--color-text-faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.listing-dom.dom-fresh { color: var(--color-success); }
.listing-dom.dom-recent { color: var(--color-text-muted); }
.listing-dom.dom-stale { color: var(--color-warning); }

.listing-divider {
  border: none;
  border-top: 1px solid var(--color-divider);
  margin: 0;
}

.listing-agent-section {
  padding: var(--space-2) var(--space-3);
}

.listing-agent-name {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text);
}

.listing-agent-agency {
  font-size: 0.65rem;
  color: var(--color-text-faint);
  margin-top: 1px;
}

.listing-why {
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface-raised);
  border-top: 1px solid var(--color-divider);
}

.listing-why-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-primary);
  margin-bottom: 3px;
}

.listing-why-text {
  font-size: var(--text-xs);
  line-height: 1.45;
  color: var(--color-text-secondary);
}

.listing-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  padding: 0 var(--space-3) var(--space-3);
}

/* Shared button styles */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition-interactive), opacity var(--transition-interactive);
  white-space: nowrap;
  text-align: center;
  border: 1px solid var(--color-primary);
}

.btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  background: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition-interactive), color var(--transition-interactive);
  white-space: nowrap;
  text-align: center;
}

.btn-secondary:hover {
  background: var(--color-primary-highlight);
}

/* Listings empty state */
.listings-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--space-16);
  color: var(--color-text-faint);
  font-size: var(--text-sm);
}

/* ===== CONTACT AGENT MODAL ===== */
.contact-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0,0,0,0.65);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.contact-modal-overlay.open { display: flex; }

.contact-modal-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.contact-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--color-divider);
}

.contact-modal-agent-name {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
}

.contact-modal-agency {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.contact-modal-body {
  padding: var(--space-4) var(--space-5) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.contact-modal-contact-row {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.contact-modal-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-primary);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  transition: color var(--transition-interactive);
}

.contact-modal-link:hover { color: var(--color-primary-hover); }

.contact-modal-message-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.contact-modal-textarea {
  width: 100%;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text);
  font-family: var(--font-body);
  line-height: 1.6;
  resize: vertical;
  min-height: 110px;
  box-sizing: border-box;
  transition: border-color var(--transition-interactive);
}

.contact-modal-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

.contact-modal-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.contact-modal-actions .btn-secondary,
.contact-modal-actions .btn-primary {
  flex: 1;
  min-width: 120px;
}

/* Copy success feedback */
.btn-secondary.copied {
  background: var(--color-success-highlight);
  color: var(--color-success);
  border-color: var(--color-success);
}

/* ===== LISTINGS RESPONSIVE ===== */
@media (max-width: 1100px) {
  .listings-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .listings-header { flex-direction: column; align-items: flex-start; }
  .listings-filters { width: 100%; }
  .listings-grid { grid-template-columns: 1fr; }
  .contact-modal-actions .btn-secondary,
  .contact-modal-actions .btn-primary { min-width: 0; }
}

@media (max-width: 480px) {
  .listings-grid { grid-template-columns: 1fr; }
  .listing-specs { flex-wrap: wrap; }
}

/* ===== PAGINATION ===== */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) 0;
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-3);
  gap: var(--space-3);
  flex-wrap: wrap;
}
.pagination-info {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}
.pagination-controls {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.pagination-btn {
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
  color: var(--color-text);
  font-size: var(--text-xs);
  cursor: pointer;
  min-width: 32px;
  text-align: center;
  transition: all 180ms cubic-bezier(0.16, 1, 0.3, 1);
}
.pagination-btn:hover:not(:disabled) {
  background: var(--color-surface-3, var(--color-surface-dynamic));
  border-color: var(--color-text-muted);
}
.pagination-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.pagination-btn.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.pagination-ellipsis {
  color: var(--color-text-faint);
  font-size: var(--text-xs);
  padding: 0 var(--space-1);
}
.pagination-size {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.pagination-size label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.pagination-size select {
  padding: var(--space-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
  color: var(--color-text);
  font-size: var(--text-xs);
  cursor: pointer;
}

/* ===== OFF-MARKET ===== */
.offmarket-view {
  padding: var(--space-4);
  max-width: 1400px;
  margin: 0 auto;
}
.offmarket-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.offmarket-header-left {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
}
.offmarket-count-badge {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}
.offmarket-filters {
  display: flex;
  gap: var(--space-2);
}
.offmarket-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: var(--space-4);
}
.offmarket-card {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.offmarket-card-header {
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--color-border);
}
.offmarket-card-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.offmarket-suburb-name {
  font-weight: 600;
  font-size: var(--text-sm);
}
.offmarket-card-body {
  padding: var(--space-3) var(--space-4);
}
.offmarket-section {
  margin-bottom: var(--space-3);
}
.offmarket-section:last-child {
  margin-bottom: 0;
}
.offmarket-section-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}
.offmarket-streets {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}
.street-pill {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: 999px;
  background: color-mix(in oklch, var(--color-primary) 15%, var(--color-surface-2));
  border: 1px solid color-mix(in oklch, var(--color-primary) 30%, var(--color-border));
  font-size: var(--text-xs);
  color: var(--color-text);
  font-family: var(--font-mono);
}
.offmarket-rationale {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.5;
  margin-top: var(--space-2);
}
.offmarket-signals {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.5;
}
.offmarket-signal-label {
  font-weight: 600;
  color: var(--color-text);
  display: inline;
}
.offmarket-signal-item {
  margin-bottom: var(--space-2);
}
.offmarket-signal-item:last-child {
  margin-bottom: 0;
}
.offmarket-land-size {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.offmarket-empty {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  color: var(--color-text-faint);
  font-size: var(--text-sm);
}
.live-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-success);
  margin-right: var(--space-1);
  animation: livePulse 2s ease-in-out infinite;
  vertical-align: middle;
}
@keyframes livePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Off-market links */
.offmarket-signals a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.offmarket-signals a:hover { color: var(--color-primary-hover); }

/* Off-market responsive */
@media (max-width: 768px) {
  .offmarket-grid { grid-template-columns: 1fr; }
  .offmarket-header { flex-direction: column; align-items: flex-start; }
  .offmarket-filters { width: 100%; }
  .pagination-bar { flex-direction: column; align-items: flex-start; }
}

/* ===== TREND INDICATORS (table arrows) ===== */
.trend-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65em;
  font-style: normal;
  margin-left: 3px;
  line-height: 1;
  vertical-align: middle;
  font-variant-numeric: normal;
}
.trend-arrow.trend-up   { color: var(--color-success); }
.trend-arrow.trend-down { color: var(--color-error); }
.trend-arrow.trend-flat { color: var(--color-text-faint); }

/* ===== SPARKLINES (detail panel) ===== */
.sparkline-section {
  margin-bottom: var(--space-4);
}
.sparkline-section-title {
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-3);
  color: var(--color-text);
}
.sparkline-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}
.sparkline-card {
  background: var(--color-surface-2);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
}
.sparkline-label {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-2);
}
.sparkline-canvas-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}
.sparkline-canvas-wrap canvas {
  display: block;
  max-width: 100%;
}
.sparkline-insufficient {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  text-align: center;
  padding: var(--space-3) 0;
  font-style: italic;
}

/* ===== TRENDS VIEW ===== */
.trends-view {
  padding: var(--space-4);
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

.trends-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.trends-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* Momentum summary cards */
.trends-momentum-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
  gap: var(--space-3);
}
.trends-momentum-card {
  background: var(--color-surface-2);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}
.trends-momentum-label {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-2);
}
.trends-momentum-value {
  font-size: var(--text-xl);
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--color-text);
  line-height: 1.1;
}
.trends-momentum-sub {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin-top: var(--space-1);
  font-family: var(--font-mono);
}
.trends-momentum-value.value-positive { color: var(--color-success); }
.trends-momentum-value.value-negative { color: var(--color-error); }
.trends-momentum-value.value-neutral  { color: var(--color-text); }

/* Grade movement timeline */
.trends-grade-timeline {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.trends-grade-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--color-divider);
  font-size: var(--text-xs);
  transition: background var(--transition-interactive);
}
.trends-grade-row:last-child { border-bottom: none; }
.trends-grade-row:hover { background: var(--color-surface-offset); }
.trends-grade-date {
  font-family: var(--font-mono);
  color: var(--color-text-faint);
  min-width: 80px;
  flex-shrink: 0;
}
.trends-grade-suburb {
  flex: 1;
  font-weight: 500;
  color: var(--color-text);
  min-width: 120px;
}
.trends-grade-state {
  color: var(--color-text-faint);
  flex-shrink: 0;
}
.trends-grade-change {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}
.trends-grade-arrow {
  font-size: 0.7rem;
  color: var(--color-text-muted);
}
.trends-grade-type {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px var(--space-2);
  border-radius: var(--radius-full);
  flex-shrink: 0;
}
.trends-grade-type.type-promotion {
  background: var(--color-success-highlight);
  color: var(--color-success);
}
.trends-grade-type.type-demotion {
  background: var(--color-error-highlight);
  color: var(--color-error);
}
.trends-grade-type.type-initial {
  background: var(--color-surface-dynamic);
  color: var(--color-text-faint);
}
.trends-grade-empty {
  padding: var(--space-8) var(--space-4);
  text-align: center;
  color: var(--color-text-faint);
  font-size: var(--text-sm);
}

/* Suburb metric charts */
.trends-charts-grid {
  width: 100%;
}
.trends-chart-placeholder {
  padding: var(--space-10);
  text-align: center;
  color: var(--color-text-faint);
  font-size: var(--text-sm);
  background: var(--color-surface-2);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
}
.trends-charts-inner {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
}
.trends-chart-card {
  background: var(--color-surface-2);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}
.trends-chart-card--full {
  grid-column: 1 / -1;
}
.trends-chart-insufficient {
  padding: var(--space-8) var(--space-4);
  text-align: center;
  color: var(--color-text-faint);
  font-size: var(--text-sm);
  font-style: italic;
}

/* Listing flow */
.trends-listing-flow-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
  gap: var(--space-2);
}
.trends-listing-flow-legend {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.trends-flow-legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.trends-flow-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ===== TRENDS RESPONSIVE ===== */
@media (max-width: 768px) {
  .trends-momentum-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .trends-charts-inner {
    grid-template-columns: 1fr;
  }
  .trends-grade-row {
    flex-wrap: wrap;
    gap: var(--space-2);
  }
  .trends-section-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
@media (max-width: 480px) {
  .trends-momentum-grid {
    grid-template-columns: 1fr;
  }
  .sparkline-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== SHORTLIST SYSTEM ===== */

/* Shortlist buttons on card header */
.shortlist-btns {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.sl-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--color-divider);
  background: transparent;
  color: var(--color-text-faint);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s ease;
  padding: 0;
}

.sl-btn:hover {
  border-color: var(--color-text-secondary);
  color: var(--color-text-secondary);
}

.sl-heart.active {
  background: rgba(34, 197, 94, 0.15);
  border-color: #22c55e;
  color: #22c55e;
}

.sl-reject.active {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
  color: #ef4444;
}

/* Rejected card dimming */
.listing-rejected {
  opacity: 0.5;
}

.listing-rejected:hover {
  opacity: 0.75;
}

/* Shortlisted card left accent */
.listing-shortlisted {
  border-left: 3px solid #22c55e;
}

/* Shortlist filter bar */
.shortlist-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  margin-bottom: 12px;
  gap: 12px;
  flex-wrap: wrap;
}

.sl-filter-group {
  display: flex;
  gap: 4px;
  background: var(--color-surface-raised);
  border-radius: 6px;
  padding: 3px;
}

.sl-filter-btn {
  padding: 5px 12px;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 0.72rem;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.sl-filter-btn:hover {
  color: var(--color-text-primary);
  background: rgba(255,255,255,0.05);
}

.sl-filter-btn.active {
  background: var(--color-primary);
  color: #fff;
}

/* Share action buttons */
.sl-share-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.btn-share {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border: 1px solid var(--color-divider);
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 0.7rem;
  font-weight: 500;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.btn-share:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: rgba(99, 102, 241, 0.08);
}

/* Share mode header */
.share-mode-header {
  padding: 32px 24px 24px;
  text-align: center;
  border-bottom: 1px solid var(--color-divider);
  margin-bottom: 16px;
}

.share-mode-inner {
  max-width: 480px;
  margin: 0 auto;
}

.share-mode-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}

.share-mode-logo .logo-mark {
  width: 24px;
  height: 24px;
}

.share-mode-title {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

.share-mode-heading {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 6px;
}

.share-mode-sub {
  font-size: 0.75rem;
  color: var(--color-text-faint);
}

/* Toast notification */
.ge-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  border: 1px solid var(--color-divider);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 9999;
  pointer-events: none;
}

.ge-toast.show {
  transform: translateX(-50%) translateY(0);
}

/* Mobile adjustments */
@media (max-width: 640px) {
  .shortlist-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .sl-filter-group {
    overflow-x: auto;
  }
  .sl-share-actions {
    justify-content: stretch;
  }
  .sl-share-actions .btn-share {
    flex: 1;
    justify-content: center;
  }
}

/* ===== LISTING CARD BADGES (walkability, price, noise, green) ===== */
.listing-price-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.price-position-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  white-space: nowrap;
}
.pp-below { background: rgba(34,197,94,0.15); color: #16a34a; }
.pp-above { background: rgba(239,68,68,0.15); color: #dc2626; }
.pp-at { background: rgba(148,163,184,0.12); color: var(--text-muted); }

.listing-badges-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.walk-badge, .noise-badge, .green-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
}
.walk-badge svg, .noise-badge svg, .green-badge svg { flex-shrink: 0; }
.walk-high { background: rgba(34,197,94,0.12); color: #16a34a; }
.walk-med { background: rgba(234,179,8,0.12); color: #a16207; }
.walk-low { background: rgba(239,68,68,0.1); color: #dc2626; }
.noise-high { background: rgba(239,68,68,0.1); color: #dc2626; }
.noise-moderate { background: rgba(234,179,8,0.12); color: #a16207; }
.noise-low { background: rgba(34,197,94,0.1); color: #16a34a; }
.green-badge { background: rgba(34,197,94,0.1); color: #16a34a; }

/* ===== PROPERTY DETAIL MODAL ===== */
.pd-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  pointer-events: none;
  visibility: hidden;
}
.pd-overlay.open {
  pointer-events: auto;
  visibility: visible;
}
.pd-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.pd-overlay.open .pd-backdrop { opacity: 1; }
.pd-card {
  position: relative;
  width: 440px;
  max-width: 96vw;
  height: 100vh;
  overflow-y: auto;
  background: var(--bg-primary);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 24px rgba(0,0,0,0.15);
  padding: var(--space-5);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}
.pd-overlay.open .pd-card {
  transform: translateX(0);
}
.pd-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3);
}
.pd-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.pd-sl-tag {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 3px;
}
.pd-sl-shortlisted { background: rgba(34,197,94,0.15); color: #16a34a; }
.pd-sl-rejected { background: rgba(239,68,68,0.1); color: #dc2626; }
.pd-address {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.pd-price-row {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.pd-price {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
}
.pd-type {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-secondary);
  padding: 1px 6px;
  border-radius: 3px;
}
.pd-specs {
  display: flex;
  gap: var(--space-3);
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}
.pd-section {
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}
.pd-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.pd-walk-score {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 3px;
  text-transform: none;
  letter-spacing: 0;
}

/* Price positioning bar */
.pd-pp-bar {
  position: relative;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, #22c55e 0%, #94a3b8 50%, #ef4444 100%);
  margin: var(--space-3) 0 var(--space-1) 0;
}
.pd-pp-marker {
  position: absolute;
  top: -4px;
  width: 16px;
  height: 16px;
  background: var(--text-primary);
  border: 2px solid var(--bg-primary);
  border-radius: 50%;
  transform: translateX(-50%);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.pd-pp-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.pd-pp-stats {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-3);
}
.pd-stat {
  display: flex;
  flex-direction: column;
}
.pd-stat-val {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
}
.pd-stat-label {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* Walkability category bars */
.pd-cat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.pd-cat-name {
  width: 80px;
  font-size: 0.72rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.pd-cat-bar-bg {
  flex: 1;
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 3px;
  overflow: hidden;
}
.pd-cat-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}
.pd-cat-score {
  width: 24px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: right;
}
.pd-amenity-count {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Nearest amenities grid */
.pd-amenities-grid {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.pd-amenity-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  padding: 3px 0;
}
.pd-amenity-icon { font-size: 0.85rem; width: 20px; text-align: center; flex-shrink: 0; }
.pd-amenity-type { color: var(--text-secondary); text-transform: capitalize; min-width: 80px; }
.pd-amenity-name { color: var(--text-primary); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pd-amenity-dist { color: var(--text-muted); font-weight: 600; flex-shrink: 0; }

/* Environment */
.pd-env-item {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  line-height: 1.4;
}

/* Suburb metrics grid */
.pd-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}
.pd-metric {
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  padding: 8px;
  border-radius: 6px;
}
.pd-metric-val {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
}
.pd-metric-label {
  font-size: 0.65rem;
  color: var(--text-muted);
}

/* WHY section */
.pd-why {
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* Agent section */
.pd-agent {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Actions */
.pd-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
}
.pd-actions .btn-secondary, .pd-actions .btn-primary {
  flex: 1;
  justify-content: center;
}

/* Mobile responsive */
@media (max-width: 520px) {
  .pd-card {
    width: 100vw;
    max-width: 100vw;
  }
  .pd-metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ===== LRBA CALCULATOR ===== */
.lrba-section { border: 1px solid var(--accent); border-radius: 8px; padding: var(--space-4); margin: var(--space-4) calc(-1 * var(--space-2)); background: rgba(0,210,190,0.03); }
.lrba-form { display: flex; flex-direction: column; gap: 10px; }
.lrba-row { display: flex; align-items: center; gap: 8px; }
.lrba-row label { width: 110px; font-size: 0.78rem; color: var(--text-secondary); flex-shrink: 0; }
.lrba-input { flex: 1; background: var(--bg-primary); border: 1px solid var(--border); border-radius: 4px; padding: 6px 10px; font-size: 0.82rem; color: var(--text-primary); outline: none; font-family: inherit; }
.lrba-input:focus { border-color: var(--accent); }
.lrba-range-wrap { flex: 1; display: flex; align-items: center; gap: 8px; }
.lrba-range { flex: 1; accent-color: var(--accent); }
.lrba-range-wrap span { font-size: 0.78rem; font-weight: 600; color: var(--accent); min-width: 42px; text-align: right; }
.lrba-calc-btn { margin-top: 6px; width: 100%; justify-content: center; }
.lrba-results { margin-top: var(--space-3); }
.lrba-results-header { font-size: 0.82rem; font-weight: 700; color: var(--text-primary); margin-bottom: var(--space-2); padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.lrba-card { background: var(--bg-secondary); border-radius: 6px; padding: 12px; margin-bottom: 10px; }
.lrba-card-title { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 8px; }
.lrba-line { display: flex; justify-content: space-between; font-size: 0.78rem; padding: 3px 0; color: var(--text-secondary); }
.lrba-line span:last-child { font-weight: 600; color: var(--text-primary); }
.lrba-total { font-weight: 700 !important; border-top: 1px solid var(--border); padding-top: 6px; margin-top: 4px; }
.lrba-total span { color: var(--text-primary) !important; font-weight: 700 !important; }
.lrba-metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.lrba-metric { text-align: center; padding: 8px; background: var(--bg-primary); border-radius: 6px; }
.lrba-metric-val { font-size: 1.1rem; font-weight: 800; color: var(--text-primary); }
.lrba-metric-label { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.lrba-note { font-size: 0.68rem; color: var(--text-muted); line-height: 1.4; margin-top: 10px; padding: 8px 10px; background: var(--bg-secondary); border-radius: 4px; }
.lrba-report-actions { margin-top: 12px; }
.lrba-report-btn { width: 100%; justify-content: center; }

/* ===== REPORT PREVIEW OVERLAY ===== */
.report-preview-overlay {
  position: fixed; inset: 0; z-index: 1200;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
}
.report-preview-overlay.open { opacity: 1; pointer-events: auto; }
.report-preview-card {
  width: 90vw; max-width: 880px; height: 90vh;
  background: var(--bg-primary); border-radius: 12px;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,0.3);
  transform: scale(0.95); transition: transform 0.3s ease;
}
.report-preview-overlay.open .report-preview-card { transform: scale(1); }
.report-preview-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.report-preview-title { font-size: 0.9rem; font-weight: 700; color: var(--text-primary); }
.report-preview-actions { display: flex; gap: 8px; align-items: center; }
.report-preview-iframe { flex: 1; border: none; width: 100%; background: #f8fafc; }

@media (max-width: 600px) {
  .report-preview-card { width: 100vw; height: 100vh; border-radius: 0; }
  .report-preview-actions .btn-secondary span { display: none; }
  .lrba-row { flex-direction: column; align-items: flex-start; gap: 4px; }
  .lrba-row label { width: auto; }
}
