/* ====================================================================
   PROPERTY ANALYZER — Bloomberg-inspired terminal aesthetic
   Dark, dense, monospaced numerics, blue accent
==================================================================== */

:root {
  /* Surface */
  --bg-0: #07090c;
  --bg-1: #0d1117;
  --bg-2: #131923;
  --bg-3: #1a2230;
  --bg-hover: #1f2a3a;
  --bg-elev: #182231;

  /* Borders */
  --border-1: #1c2533;
  --border-2: #28344a;
  --border-3: #3a4a66;

  /* Text */
  --text-0: #e8eef7;
  --text-1: #c4cdd9;
  --text-2: #8a95a6;
  --text-3: #5a6678;
  --text-4: #3d4859;

  /* Accent - blue */
  --accent: #3b82f6;
  --accent-hi: #60a5fa;
  --accent-lo: #1e3a8a;
  --accent-dim: rgba(59, 130, 246, 0.15);
  --accent-glow: rgba(59, 130, 246, 0.35);

  /* Verdicts */
  --buy: #10b981;
  --buy-dim: rgba(16, 185, 129, 0.12);
  --watch: #f59e0b;
  --watch-dim: rgba(245, 158, 11, 0.12);
  --pass: #6b7280;
  --pass-dim: rgba(107, 114, 128, 0.12);
  --skip: #ef4444;
  --skip-dim: rgba(239, 68, 68, 0.12);

  /* Semantic */
  --pos: #10b981;
  --neg: #ef4444;

  /* Type */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --font-display: "Inter", system-ui, sans-serif;

  /* Sizes */
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg-0);
  color: var(--text-0);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
  overflow: hidden;
}

/* Subtle grid pattern */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--border-1) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-1) 1px, transparent 1px);
  background-size: 80px 80px;
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
}

.mono { font-family: var(--font-mono); font-feature-settings: "tnum"; }
.tnum { font-variant-numeric: tabular-nums; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-1); }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-3); }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* ====================== APP SHELL ====================== */
.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: 44px 1fr 28px;
  height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border-2);
  padding: 0 16px;
  gap: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
}
.brand-mark {
  width: 22px; height: 22px;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--accent), #1e40af);
  display: grid; place-items: center;
  color: #fff;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 11px;
  box-shadow: 0 0 0 1px var(--accent-glow), 0 0 12px var(--accent-glow);
}
.brand-name { color: var(--text-0); }
.brand-sub { color: var(--text-3); font-weight: 400; font-size: 11px; margin-left: 6px; letter-spacing: 0.04em; text-transform: uppercase;}

.nav {
  display: flex;
  gap: 2px;
  height: 100%;
  align-items: stretch;
}
.nav-item {
  display: flex; align-items: center;
  padding: 0 14px;
  font-size: 12px;
  color: var(--text-2);
  border-bottom: 2px solid transparent;
  transition: all 0.12s;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.nav-item:hover { color: var(--text-0); background: var(--bg-2); }
.nav-item.active {
  color: var(--text-0);
  border-bottom-color: var(--accent);
  background: var(--bg-2);
}
.nav-item .badge {
  margin-left: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--bg-3);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--text-2);
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}
.live-pill {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 10px;
  color: var(--text-2);
  letter-spacing: 0.08em;
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--buy);
  box-shadow: 0 0 8px var(--buy);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.fx-rates {
  display: flex; gap: 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
}
.fx-rates strong { color: var(--text-0); font-weight: 500; margin-left: 4px; }

/* ====================== STATUS BAR ====================== */
.statusbar {
  background: var(--bg-1);
  border-top: 1px solid var(--border-2);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 18px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  letter-spacing: 0.04em;
}
.statusbar .group { display: flex; gap: 8px; align-items: center; }
.statusbar strong { color: var(--text-1); font-weight: 500; }

/* ====================== MAIN ====================== */
.main {
  overflow: hidden;
  background: var(--bg-0);
  position: relative;
}

/* ====================== KPI STRIP ====================== */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  background: var(--bg-1);
  border-bottom: 1px solid var(--border-2);
}
.kpi {
  padding: 12px 16px;
  border-right: 1px solid var(--border-1);
  position: relative;
}
.kpi:last-child { border-right: none; }
.kpi-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-bottom: 6px;
  display: flex; justify-content: space-between; align-items: center;
}
.kpi-label .ind { font-size: 9px; color: var(--text-4); }
.kpi-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--text-0);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  display: flex; align-items: baseline; gap: 6px;
}
.kpi-value .unit { font-size: 11px; color: var(--text-3); font-weight: 400; }
.kpi-delta {
  font-family: var(--font-mono);
  font-size: 11px;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.kpi-delta.pos { color: var(--pos); }
.kpi-delta.neg { color: var(--neg); }
.kpi-delta.neu { color: var(--text-3); }
.kpi-spark {
  position: absolute;
  bottom: 8px;
  right: 12px;
  height: 24px;
  width: 60px;
  opacity: 0.55;
}

/* ====================== WORKBENCH ====================== */
.workbench {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: calc(100% - 90px);
}

/* ----- Filter rail ----- */
.rail {
  background: var(--bg-1);
  border-right: 1px solid var(--border-2);
  overflow-y: auto;
  padding-bottom: 24px;
}
.rail-section {
  border-bottom: 1px solid var(--border-1);
  padding: 12px 16px;
}
.rail-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  margin: 0 0 10px;
  display: flex; justify-content: space-between; align-items: center;
}
.rail-title button {
  font-size: 9px;
  color: var(--accent-hi);
  letter-spacing: 0.08em;
}
.rail-title button:hover { color: var(--accent); }

.checkbox-list { display: grid; gap: 4px; }
.cbx {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px;
  border-radius: 3px;
  font-size: 12px;
  color: var(--text-1);
  cursor: pointer;
  user-select: none;
  transition: background 0.1s;
}
.cbx:hover { background: var(--bg-2); }
.cbx input { display: none; }
.cbx .box {
  width: 14px; height: 14px; border-radius: 2px;
  border: 1px solid var(--border-3);
  background: var(--bg-2);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.cbx input:checked + .box {
  background: var(--accent);
  border-color: var(--accent);
}
.cbx input:checked + .box::after {
  content: '';
  width: 4px; height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: translateY(-1px) rotate(45deg);
}
.cbx .count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
}

.range-block { margin-bottom: 14px; }
.range-block:last-child { margin-bottom: 0; }
.range-label {
  display: flex; justify-content: space-between;
  font-size: 11px;
  color: var(--text-2);
  margin-bottom: 6px;
}
.range-label strong { color: var(--text-0); font-family: var(--font-mono); font-weight: 500; }
.range-track {
  height: 4px;
  background: var(--bg-3);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
}
.range-fill {
  position: absolute;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}
.range-handle {
  position: absolute;
  top: 50%;
  width: 12px; height: 12px;
  background: #fff;
  border: 2px solid var(--accent);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  cursor: grab;
}

.chip-row { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  font-size: 11px;
  padding: 4px 10px;
  border: 1px solid var(--border-2);
  border-radius: 3px;
  color: var(--text-2);
  background: var(--bg-2);
  cursor: pointer;
  transition: all 0.1s;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}
.chip:hover { border-color: var(--border-3); color: var(--text-1); }
.chip.on {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent-hi);
}

.toggle-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px;
  color: var(--text-1);
  padding: 4px 0;
}
.toggle {
  width: 28px; height: 16px;
  background: var(--bg-3);
  border-radius: 8px;
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
}
.toggle::after {
  content:'';
  position: absolute;
  top: 2px; left: 2px;
  width: 12px; height: 12px;
  background: var(--text-2);
  border-radius: 50%;
  transition: all 0.15s;
}
.toggle.on { background: var(--accent); }
.toggle.on::after { left: 14px; background: #fff; }

/* ====================== CONTENT AREA ====================== */
.content {
  overflow-y: auto;
  background: var(--bg-0);
  position: relative;
}

/* ====================== PANELS ====================== */
.panel {
  background: var(--bg-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-md);
  overflow: hidden;
}
.panel-header {
  display: flex; align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-1);
  background: var(--bg-1);
}
.panel-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-1);
  font-weight: 600;
}
.panel-title .accent { color: var(--accent-hi); }
.panel-sub {
  font-size: 11px;
  color: var(--text-3);
  margin-left: 12px;
  font-family: var(--font-mono);
}
.panel-actions {
  margin-left: auto;
  display: flex; gap: 6px;
}
.icon-btn {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: 3px;
  color: var(--text-3);
  transition: all 0.1s;
}
.icon-btn:hover { background: var(--bg-3); color: var(--text-0); }
.tab-row {
  display: flex; gap: 0;
}
.tab {
  padding: 4px 10px;
  font-size: 11px;
  color: var(--text-3);
  border-radius: 3px;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.tab:hover { color: var(--text-1); }
.tab.on { color: var(--accent-hi); background: var(--accent-dim); }

/* ====================== TABLE ====================== */
.dt {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.dt thead th {
  background: var(--bg-1);
  text-align: left;
  padding: 8px 10px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  font-weight: 500;
  border-bottom: 1px solid var(--border-2);
  position: sticky;
  top: 0;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.dt thead th:hover { color: var(--text-0); }
.dt thead th.num { text-align: right; }
.dt thead th .sort { color: var(--accent); margin-left: 3px; font-size: 9px; }
.dt tbody tr {
  border-bottom: 1px solid var(--border-1);
  transition: background 0.08s;
  cursor: pointer;
}
.dt tbody tr:hover { background: var(--bg-2); }
.dt tbody tr.selected { background: var(--accent-dim); }
.dt tbody td {
  padding: 8px 10px;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.dt tbody td.num {
  text-align: right;
  font-family: var(--font-mono);
}
.dt tbody td.zone { color: var(--text-0); font-weight: 500; }
.dt tbody td.url { color: var(--accent-hi); font-family: var(--font-mono); font-size: 11px; }

.delta {
  font-family: var(--font-mono);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.delta.neg { color: var(--pos); } /* cheaper is positive signal */
.delta.pos { color: var(--neg); }
.delta.zero { color: var(--text-3); }

.verdict-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
}
.verdict-pill.BUY { background: var(--buy-dim); color: var(--buy); border: 1px solid rgba(16, 185, 129, 0.3); }
.verdict-pill.WATCH { background: var(--watch-dim); color: var(--watch); border: 1px solid rgba(245, 158, 11, 0.3); }
.verdict-pill.PASS { background: var(--pass-dim); color: var(--text-2); border: 1px solid rgba(107, 114, 128, 0.3); }
.verdict-pill.SKIP { background: var(--skip-dim); color: var(--skip); border: 1px solid rgba(239, 68, 68, 0.3); }

.score-bar {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
}
.score-bar .track {
  width: 36px; height: 4px;
  background: var(--bg-3);
  border-radius: 2px;
  overflow: hidden;
}
.score-bar .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--skip), var(--watch) 50%, var(--buy));
}
.flag-outlier {
  color: var(--watch);
  font-size: 11px;
  margin-left: 4px;
}

.src-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 2px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.op-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  text-transform: uppercase;
}

/* ====================== DASHBOARD GRID ====================== */
.grid-dashboard {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 12px;
  padding: 12px;
}
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.col-span-2 { grid-column: 1 / -1; }

/* ====================== CHARTS ====================== */
.chart-wrap { padding: 14px 16px; }
.chart-svg { display: block; width: 100%; height: auto; }
.legend {
  display: flex; gap: 14px;
  padding: 0 14px 12px;
  font-size: 11px;
  color: var(--text-2);
  font-family: var(--font-mono);
  flex-wrap: wrap;
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 2px; }

/* tooltip for charts */
.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--bg-3);
  border: 1px solid var(--border-3);
  border-radius: 4px;
  padding: 6px 9px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-0);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  z-index: 50;
  white-space: nowrap;
  transform: translate(-50%, -110%);
  opacity: 0;
  transition: opacity 0.1s;
}
.chart-tooltip.show { opacity: 1; }
.chart-tooltip strong { color: var(--accent-hi); display: block; margin-bottom: 3px; font-weight: 500; }

/* ====================== DETAIL DRAWER ====================== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.drawer-backdrop.on { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 28px;
  width: 720px;
  max-width: 90vw;
  background: var(--bg-1);
  border-left: 1px solid var(--border-2);
  z-index: 101;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.2, 1);
  display: flex; flex-direction: column;
  box-shadow: -20px 0 60px rgba(0,0,0,0.6);
}
.drawer.on { transform: translateX(0); }
.drawer-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-2);
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--bg-1);
}
.drawer-body { overflow-y: auto; flex: 1; padding: 16px; }
.drawer-close {
  margin-left: auto;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 4px;
  color: var(--text-2);
}
.drawer-close:hover { background: var(--bg-3); color: var(--text-0); }

.dprop-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-0);
  margin: 0 0 4px;
}
.dprop-sub {
  font-size: 11px;
  color: var(--text-3);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

.dprop-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-sm);
  margin-bottom: 16px;
}
.dprop-cell {
  background: var(--bg-1);
  padding: 10px 12px;
}
.dprop-cell .lab {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  margin-bottom: 4px;
}
.dprop-cell .val {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-0);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.dprop-cell .val .small { font-size: 10px; color: var(--text-3); margin-left: 3px; }

.score-block {
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: var(--r-md);
  padding: 14px;
  margin-bottom: 16px;
}
.score-headline {
  display: flex; align-items: baseline; gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-1);
  margin-bottom: 12px;
}
.score-headline .big {
  font-family: var(--font-mono);
  font-size: 36px;
  font-weight: 700;
  color: var(--text-0);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.score-headline .big .of { font-size: 14px; color: var(--text-3); font-weight: 400; }

.score-row {
  display: grid;
  grid-template-columns: 90px 1fr 60px 50px;
  gap: 10px;
  align-items: center;
  padding: 5px 0;
  font-size: 11px;
}
.score-row .lab { color: var(--text-2); }
.score-row .bar {
  height: 6px;
  background: var(--bg-3);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}
.score-row .bar-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, var(--accent-lo), var(--accent));
  border-radius: 3px;
}
.score-row .num { font-family: var(--font-mono); font-size: 11px; color: var(--text-0); text-align: right; font-variant-numeric: tabular-nums; }
.score-row .wt { font-family: var(--font-mono); font-size: 10px; color: var(--text-3); text-align: right; }

.summary-card {
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: var(--r-md);
  padding: 14px;
  margin-bottom: 16px;
  font-size: 12px;
  color: var(--text-1);
  line-height: 1.55;
}
.summary-card h4 {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-hi);
  margin: 0 0 8px;
  display: flex; align-items: center; gap: 6px;
}
.summary-card .model-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-3);
  margin-left: auto;
  font-weight: 400;
  letter-spacing: 0.04em;
}

.flag-list { display: grid; gap: 5px; margin-top: 8px; }
.flag-item {
  display: flex; gap: 8px;
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 4px 8px;
  border-radius: 3px;
  align-items: flex-start;
}
.flag-item.risk { background: var(--skip-dim); color: #fca5a5; }
.flag-item.upside { background: var(--buy-dim); color: #6ee7b7; }
.flag-item .ico { font-weight: 700; }

.comp-mini {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr 0.7fr;
  gap: 6px;
  font-size: 11px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-1);
  align-items: center;
  font-family: var(--font-mono);
}
.comp-mini.head {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  background: var(--bg-2);
}
.comp-mini .marker { color: var(--accent-hi); }

/* ====================== ZONES VIEW ====================== */
.zones-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 12px;
}
.zone-card {
  background: var(--bg-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-md);
  padding: 14px 16px;
}
.zone-card-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 12px;
}
.zone-card-head h3 {
  font-size: 14px;
  margin: 0;
  font-weight: 600;
}
.zone-card-stats {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border-1);
  margin-bottom: 14px;
}
.zone-stat {
  background: var(--bg-1);
  padding: 8px 10px;
}
.zone-stat .lab {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-bottom: 4px;
}
.zone-stat .val {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-0);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.zone-stat .val .small { font-size: 10px; color: var(--text-3); }

/* top-3 opportunity preview inside each zone card */
.zone-top3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.vcard { min-width: 0; }

/* ====================== VERDICTS VIEW ====================== */
.verdict-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 12px;
}
.vboard-col {
  background: var(--bg-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-md);
  display: flex; flex-direction: column;
  max-height: calc(100vh - 200px);
}
.vboard-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-1);
  display: flex; align-items: center; gap: 8px;
}
.vboard-head h4 {
  font-family: var(--font-mono);
  font-size: 11px;
  margin: 0;
  letter-spacing: 0.08em;
}
.vboard-head .count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
}
.vboard-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}
.vcard {
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.1s;
}
.vcard:hover { border-color: var(--border-3); background: var(--bg-3); }
.vcard-top {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 4px;
}
.vcard-zone { font-size: 12px; font-weight: 600; }
.vcard-score {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-hi);
}
.vcard-mid {
  display: flex; gap: 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-2);
  margin-bottom: 6px;
}
.vcard-summary {
  font-size: 11px;
  color: var(--text-2);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.vcard-bot {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
}

/* ====================== SEARCH BAR / TOOLBAR ====================== */
.toolbar {
  background: var(--bg-1);
  border-bottom: 1px solid var(--border-1);
  padding: 8px 12px;
  display: flex; align-items: center; gap: 10px;
}
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 4px;
  padding: 5px 10px;
  flex: 1;
  max-width: 360px;
}
.search input {
  background: none; border: none; outline: none;
  color: var(--text-0);
  font-family: var(--font-mono);
  font-size: 12px;
  flex: 1;
}
.search input::placeholder { color: var(--text-3); }
.search .kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  background: var(--bg-3);
  padding: 1px 5px;
  border-radius: 2px;
  border: 1px solid var(--border-2);
}

.tb-stats {
  margin-left: auto;
  display: flex; gap: 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
}
.tb-stats strong { color: var(--text-0); font-weight: 500; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  border: 1px solid var(--border-2);
  background: var(--bg-2);
  color: var(--text-1);
  text-transform: uppercase;
}
.btn:hover { border-color: var(--border-3); color: var(--text-0); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: var(--accent-hi); }

/* ====================== COMPARE TRAY ====================== */
.compare-tray {
  position: fixed;
  bottom: 28px; left: 50%;
  transform: translate(-50%, 100%);
  background: var(--bg-2);
  border: 1px solid var(--border-3);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  padding: 10px 14px;
  display: flex; gap: 12px;
  align-items: center;
  z-index: 90;
  box-shadow: 0 -8px 24px rgba(0,0,0,0.6);
  transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.2, 1);
}
.compare-tray.on { transform: translate(-50%, 0); }
.compare-slot {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px;
  background: var(--bg-1);
  border: 1px dashed var(--border-2);
  border-radius: 4px;
  min-width: 130px;
  font-size: 11px;
  color: var(--text-3);
  font-family: var(--font-mono);
}
.compare-slot.filled {
  border-style: solid;
  border-color: var(--accent);
  color: var(--text-0);
}
.compare-slot .x { color: var(--text-3); cursor: pointer; }
.compare-slot .x:hover { color: var(--neg); }

/* ====================== PROPERTY DETAIL CHART ====================== */
.zone-distribution-chart {
  position: relative;
  margin: 10px 0;
}

/* ====================== UTILITY ====================== */
.muted { color: var(--text-3); }
.divider {
  height: 1px;
  background: var(--border-1);
  margin: 12px 0;
}

/* fade-in for view changes */
.view {
  animation: fadein 0.18s ease-out;
}
@keyframes fadein {
  from { opacity: 0; transform: translateY(2px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ====================================================================
   RESPONSIVE — desktop terminal → tablet → phone
   Mobile-only chrome (filter drawer FAB, backdrop, close) is hidden by
   default and revealed at the tablet breakpoint.
==================================================================== */
.rail-fab { display: none; }
.rail-backdrop { display: none; }
.rail-close { display: none; }

/* Small laptops: narrower rail, dashboard stacks, KPIs to 3 cols.
   The rail is still a normal sidebar here (pointer + width available). */
@media (max-width: 1100px) and (min-width: 901px) {
  .kpi-strip { grid-template-columns: repeat(3, 1fr); }
  .grid-dashboard { grid-template-columns: 1fr; }
  .verdict-board { grid-template-columns: repeat(2, 1fr); }
  .workbench { grid-template-columns: 240px 1fr; }
}

/* ───────── Tablet & phone (≤900px): the app becomes a scrolling document
   and the filter rail turns into an off-canvas drawer ───────── */
@media (max-width: 900px) {
  body { overflow: auto; }
  /* The single implicit grid column defaults to max-content, so a wide child
     (the flex topbar) would stretch the whole shell. Pin it to the viewport. */
  .app {
    height: auto; min-height: 100vh;
    grid-template-rows: auto 1fr auto;
    grid-template-columns: minmax(0, 1fr);
    max-width: 100vw;
  }
  .main, .workbench, .content, .view { min-width: 0; }
  .main { overflow: visible; }
  /* defeat the inline height:calc(...) set on the workbench */
  .workbench { display: block; height: auto !important; }
  .content { overflow: visible; }

  /* Off-canvas filter drawer */
  .rail {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: 290px; max-width: 86vw;
    z-index: 120;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.2, 1);
    box-shadow: 24px 0 60px rgba(0,0,0,0.6);
  }
  .rail.rail-open { transform: translateX(0); }
  .rail-backdrop {
    display: block;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(2px);
    z-index: 119;
  }
  .rail-close {
    display: grid; place-items: center;
    width: 22px; height: 22px;
    border-radius: 4px;
    color: var(--text-2);
    font-size: 12px;
  }
  .rail-close:hover { background: var(--bg-3); color: var(--text-0); }

  /* Floating button that opens the drawer (sits above the status bar) */
  .rail-fab {
    display: inline-flex; align-items: center; gap: 6px;
    position: fixed;
    left: 12px; bottom: 40px;
    z-index: 88;
    padding: 11px 16px;
    border-radius: 24px;
    background: var(--accent);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    box-shadow: 0 8px 24px rgba(0,0,0,0.55), 0 0 0 1px var(--accent-glow);
  }
  .rail-fab:hover { background: var(--accent-hi); }

  /* Topbar: keep on one scrollable row, drop the least-critical bits */
  .topbar { gap: 12px; padding: 0 10px; overflow-x: auto; }
  .topbar::-webkit-scrollbar { display: none; }
  .brand-sub { display: none; }
  .nav-item { padding: 0 11px; }
  .topbar-right { gap: 10px; }
  .fx-rates, .live-pill { display: none; }

  /* KPI strip: 3 across on tablet */
  .kpi-strip { grid-template-columns: repeat(3, 1fr); }

  /* Everything stacks */
  .grid-dashboard { grid-template-columns: 1fr; padding: 10px; gap: 10px; }
  .row-2 { grid-template-columns: 1fr; }
  .verdict-board { grid-template-columns: 1fr 1fr; padding: 10px; }
  .vboard-col { max-height: none; }
  /* minmax(0,1fr) stops a wide card / its mono values from blowing out the grid */
  .zones-grid { padding: 10px; grid-template-columns: minmax(0, 1fr); }
  .zone-card-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }

  /* Nothing may force the page wider than the viewport; wide content
     (data table, heatmap) scrolls inside its own panel instead. */
  .content, .view, .panel { max-width: 100%; }
  .panel { overflow-x: auto; }
  .chart-wrap { overflow-x: auto; }

  /* Toolbar wraps */
  .toolbar { flex-wrap: wrap; }
  .search { max-width: none; }

  /* Detail drawer: full width */
  .drawer { width: 100%; max-width: 100%; bottom: 0; }
  .dprop-grid { grid-template-columns: repeat(2, 1fr); }

  /* Status bar scrolls rather than overflowing */
  .statusbar { overflow-x: auto; white-space: nowrap; }
  .statusbar::-webkit-scrollbar { display: none; }
}

/* ───────── Phone (≤560px): tighter type, 2-up KPIs, single-col verdicts ───────── */
@media (max-width: 560px) {
  body { font-size: 12px; }
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .kpi { padding: 10px 12px; }
  .kpi-value { font-size: 18px; }
  .kpi-spark { display: none; }
  .verdict-board { grid-template-columns: 1fr; }
  .zone-card-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .zone-top3 { grid-template-columns: 1fr; }
  .brand-name { font-size: 12px; }
  .nav-item { padding: 0 9px; font-size: 11px; }
  .nav-item .badge { margin-left: 5px; }
  .score-headline .big { font-size: 28px; }
  .rail-fab { bottom: 36px; }
}
