/* ── Reset & Base ─────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0c14;
  --bg-gradient: linear-gradient(165deg, #0a0c14 0%, #0f1420 50%, #0a0c14 100%);
  --surface: #121520;
  --surface2: #1a1e2e;
  --surface3: #222738;
  --border: #252a3a;
  --border-light: #2e3450;
  --text: #e8eaf2;
  --text-dim: #7b82a0;
  --text-muted: #555b78;
  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --accent-glow: rgba(108, 92, 231, 0.15);
  --green: #00cec9;
  --green-dim: #00b894;
  --yellow: #fbc531;
  --red: #e17055;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);
  --shadow-md: 0 8px 32px rgba(0,0,0,0.3);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.4);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Header / Nav ────────────────────────── */
header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: visible;
}
header::before {
  content: '';
  position: absolute;
  top: -60%;
  left: 50%;
  transform: translateX(-50%);
  width: 120%;
  height: 200%;
  background: radial-gradient(ellipse at center, rgba(108,92,231,0.06) 0%, transparent 60%);
  pointer-events: none;
  clip-path: inset(0);
}

.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1500px;
  margin: 0 auto;
  padding: 1rem 2rem;
  position: relative;
  z-index: 100;
}
.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.logo-icon {
  font-size: 1.4rem;
  color: var(--accent-light);
  filter: drop-shadow(0 0 6px rgba(162, 155, 254, 0.4));
}
.logo-text {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--accent-light), var(--green));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.nav-tagline {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.nav-link {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  transition: color var(--transition);
}
.nav-link:hover { color: var(--accent-light); }
.nav-user {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  color: var(--muted);
  font: inherit;
  transition: background 0.15s;
}
.nav-user:hover { background: rgba(162,155,254,0.10); }
.nav-user-wrapper {
  position: relative;
}
.nav-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--green));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: #fff;
}
.nav-user-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 180px;
  padding: 0.4rem 0;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  z-index: 1000;
}
.nav-user-dropdown.hidden { display: none; }
.dropdown-mobile-only { display: none; }
.dropdown-item {
  display: block;
  width: 100%;
  padding: 0.55rem 1rem;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.85rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s;
}
.dropdown-item:hover { background: rgba(162,155,254,0.10); }
.dropdown-logout { color: #e17055; }
.dropdown-logout:hover { background: rgba(225,112,85,0.10); }
.dropdown-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.3rem 0;
}

.hero {
  text-align: center;
  padding: 2.5rem 2rem 3rem;
  position: relative;
  z-index: 1;
}
.hero h1 {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--text);
}
.gradient-text {
  background: linear-gradient(135deg, var(--accent-light) 0%, var(--green) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.subtitle {
  color: var(--text-dim);
  margin-top: 0.6rem;
  font-size: 1.05rem;
  font-weight: 400;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}

/* ── Search Panel ────────────────────────── */
.search-panel {
  max-width: 1200px;
  margin: -1.5rem auto 2rem;
  padding: 1.8rem 2rem 1.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  position: relative;
  z-index: 2;
}
.search-panel-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.2rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--border);
}
.panel-icon { font-size: 1.1rem; }
.panel-title {
  font-size: 0.88rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
.search-row {
  display: flex;
  align-items: flex-end;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.input-group label {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.label-value {
  color: var(--accent-light);
  font-weight: 700;
}
.location-group { flex: 1 1 260px; }
.price-group    { flex: 1 1 180px; }

.input-icon-wrap {
  position: relative;
}
.input-icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.95rem;
  pointer-events: none;
}
#location {
  padding: 0.7rem 1rem 0.7rem 2.4rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
}
#location:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
#location::placeholder {
  color: var(--text-muted);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--surface2);
  outline: none;
  margin-top: 0.3rem;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--accent-light);
  box-shadow: 0 0 8px rgba(108,92,231,0.3);
  transition: transform var(--transition), box-shadow var(--transition);
}
input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 0 12px rgba(108,92,231,0.5);
}

.btn-search {
  padding: 0.7rem 2rem;
  background: linear-gradient(135deg, var(--accent), #5b4bd5);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(108,92,231,0.25);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.btn-icon { font-size: 1rem; }
.btn-search:hover {
  background: linear-gradient(135deg, #5b4bd5, #4a3bc4);
  box-shadow: 0 6px 24px rgba(108,92,231,0.4);
  transform: translateY(-1px);
}
.btn-search:active { transform: translateY(0) scale(0.98); }
.btn-search:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.search-hint {
  margin-top: 0.8rem;
  font-size: 0.76rem;
  color: var(--text-muted);
}
.search-hint strong {
  color: var(--accent-light);
  font-weight: 600;
}

/* ── Loading ─────────────────────────────── */
.loading {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-dim);
}
.spinner-wrap {
  position: relative;
  width: 56px;
  height: 56px;
  margin: 0 auto 1.5rem;
}
.spinner {
  width: 56px;
  height: 56px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-light);
  border-right-color: var(--green);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
.spinner-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.4;
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 0.2; transform: translate(-50%, -50%) scale(0.8); } 50% { opacity: 0.6; transform: translate(-50%, -50%) scale(1.2); } }

.loading-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.3rem;
}
.loading-detail {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 0.3rem;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}
.loading-timer {
  font-size: 1rem;
  color: var(--accent-light);
  font-variant-numeric: tabular-nums;
  margin-top: 0.8rem;
  font-weight: 600;
}
.loading-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.loading-steps .step {
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  background: var(--surface2);
  border: 1px solid var(--border);
}
.loading-steps .step.active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent-light);
  font-weight: 600;
}
.step-arrow { color: var(--border-light); }

/* ── Error ───────────────────────────────── */
.error-msg {
  max-width: 1200px;
  margin: 0 auto 1.5rem;
  padding: 1rem 1.5rem;
  background: rgba(225, 112, 85, 0.08);
  border: 1px solid rgba(225, 112, 85, 0.25);
  border-radius: var(--radius-sm);
  color: var(--red);
  text-align: center;
  font-weight: 500;
}

/* ── Results ─────────────────────────────── */
.results {
  max-width: 1500px;
  margin: 0 auto 3rem;
  padding: 0 1.5rem;
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.results-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.2rem;
}
.results h2 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.2rem;
}
.results h2 span {
  color: var(--accent-light);
  font-weight: 600;
}
.result-summary {
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* ── Summary Cards ──────────────────────── */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.2rem;
}
.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  transition: border-color var(--transition);
}
.summary-card:hover {
  border-color: var(--border-light);
}
.summary-card-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.summary-card-value {
  font-size: 1.3rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.summary-card-value.positive { color: var(--green); }
.summary-card-value.negative { color: var(--red); }
.summary-card-value.neutral  { color: var(--accent-light); }

/* ── Global Mortgage Controls ───────────── */
.mortgage-controls {
  display: flex;
  gap: 2.5rem;
  margin-bottom: 1.2rem;
  padding: 1rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.mortgage-control {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 220px;
}
.mortgage-control label {
  font-size: 0.82rem;
  color: var(--text-dim);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.control-label-icon { font-size: 0.9rem; }
.mortgage-control label span:not(.control-label-icon) {
  color: var(--accent-light);
  font-weight: 700;
}
.global-slider-wrap {
  width: 220px;
}
.term-select {
  width: 220px;
  padding: 0.45rem 0.7rem;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--transition);
  appearance: auto;
}
.term-select:focus {
  outline: none;
  border-color: var(--accent);
}
.term-select:hover {
  border-color: var(--border-light);
}

/* ── Table ───────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  position: relative;
  z-index: 10;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  white-space: nowrap;
}
thead {
  background: var(--surface2);
  position: sticky;
  top: 0;
  z-index: 2;
}
th {
  padding: 0.8rem 1rem;
  text-align: left;
  font-weight: 700;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  user-select: none;
}
th.sortable { cursor: pointer; transition: color var(--transition); }
th.sortable:hover { color: var(--accent-light); }
th.sort-asc::after  { content: ' ▲'; font-size: 0.65rem; color: var(--accent-light); }
th.sort-desc::after { content: ' ▼'; font-size: 0.65rem; color: var(--accent-light); }

td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid rgba(37, 42, 58, 0.6);
  font-variant-numeric: tabular-nums;
}
tbody tr {
  background: var(--surface);
  transition: background var(--transition);
}
tbody tr:nth-child(even):not(.opt-row) { background: rgba(18, 21, 32, 0.5); }
tbody tr:hover:not(.opt-row) { background: var(--surface2); }

a.property-link {
  color: var(--accent-light);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.78rem;
  transition: color var(--transition);
}
a.property-link:hover { color: #fff; text-decoration: underline; }

.link-sep {
  color: var(--text-muted);
  margin: 0 0.25rem;
  font-size: 0.75rem;
}

/* Risk badges */
.badge {
  display: inline-block;
  padding: 0.22rem 0.7rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.badge-low    { background: rgba(0,206,201,0.12); color: var(--green); }
.badge-medium { background: rgba(251,197,49,0.12); color: var(--yellow); }
.badge-high   { background: rgba(225,112,85,0.12); color: var(--red); }

/* Positive / negative values */
.val-pos { color: var(--green); }
.val-neg { color: var(--red); }

/* ── Optimize button ────────────────────── */
.btn-optimize {
  background: var(--surface2);
  color: var(--accent-light);
  border: 1px solid var(--border);
  padding: 0.35rem 0.8rem;
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
  letter-spacing: 0.01em;
}
.btn-optimize:hover {
  background: var(--accent-glow);
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(108,92,231,0.15);
}
.btn-optimize.active {
  background: rgba(225, 112, 85, 0.1);
  color: var(--red);
  border-color: rgba(225, 112, 85, 0.3);
}

/* ── Optimized sub-row ──────────────────── */
.opt-row {
  background: rgba(0, 206, 201, 0.04) !important;
  border-left: 3px solid var(--green);
}
.opt-row:hover {
  background: rgba(0, 206, 201, 0.08) !important;
}
.opt-row td {
  padding: 0.5rem 1rem;
  font-size: 0.82rem;
  color: var(--green);
  border-bottom: 1px solid rgba(0, 206, 201, 0.1);
}
.opt-label {
  font-weight: 700;
  font-size: 0.78rem !important;
  color: var(--green) !important;
}
.opt-delta-pos {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--green);
  margin-left: 4px;
}
.opt-delta-neg {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--red);
  margin-left: 4px;
}
.opt-notes-cell {
  white-space: normal !important;
  max-width: 360px;
}
.opt-notes {
  padding: 0.3rem 0;
}
.opt-notes-title {
  font-weight: 700;
  color: var(--accent-light);
  font-size: 0.78rem;
  margin-bottom: 0.3rem;
}
.opt-note-item {
  color: var(--text-dim);
  font-size: 0.74rem;
  line-height: 1.5;
  margin-bottom: 0.15rem;
}
.opt-disclaimer {
  margin-top: 0.4rem;
  font-size: 0.7rem;
  color: var(--yellow);
  font-style: italic;
  line-height: 1.4;
}

/* ── Footer ──────────────────────────────── */
footer {
  text-align: center;
  padding: 2rem 1.5rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.footer-inner {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.footer-brand {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-bottom: 0.2rem;
}
.footer-brand .logo-icon {
  font-size: 1rem;
}
.footer-disclaimer {
  font-size: 0.72rem;
  font-style: italic;
  color: var(--text-muted);
  opacity: 0.7;
}

/* Nightly rate inline slider */
.nightly-cell, .occ-cell { min-width: 140px; }

/* ── Hover tooltip for computed cells ──── */
.has-tooltip {
  position: relative;
  cursor: help;
}
.tooltip-box {
  display: none;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
  min-width: 240px;
  z-index: 100;
  box-shadow: var(--shadow-lg);
  white-space: nowrap;
  font-size: 0.8rem;
}
/* Default: open above */
.has-tooltip .tooltip-box {
  bottom: calc(100% + 8px);
}
.tooltip-box::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--border-light);
}
/* First two rows: open below (avoids clipping by table-wrap overflow) */
tr:nth-child(-n+2) .has-tooltip .tooltip-box {
  bottom: auto;
  top: calc(100% + 8px);
}
tr:nth-child(-n+2) .has-tooltip .tooltip-box::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: var(--border-light);
}
.has-tooltip:hover .tooltip-box { display: block; }
.tooltip-title {
  font-weight: 800;
  color: var(--accent-light);
  margin-bottom: 0.4rem;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.18rem 0;
  color: var(--text-dim);
  font-size: 0.8rem;
}
.tooltip-row span:last-child {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 600;
}
.tooltip-total span {
  font-weight: 800 !important;
  color: var(--accent-light) !important;
}
.tooltip-hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.35rem 0;
}
.nightly-slider-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
.nightly-val {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--accent-light);
  font-variant-numeric: tabular-nums;
}
.slider-pct {
  font-weight: 400;
  font-size: 0.73rem;
  color: var(--text-muted);
  opacity: 0.85;
}
.slider-track-wrap {
  position: relative;
  width: 100%;
  height: 18px;
  display: flex;
  align-items: center;
}
.slider-track-wrap input[type="range"] {
  width: 100%;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  position: relative;
  z-index: 2;
}
.slider-track-wrap input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: var(--surface3);
}
.slider-track-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--accent-light);
  cursor: pointer;
  margin-top: -5px;
  box-shadow: 0 0 6px rgba(108,92,231,0.3);
}
.slider-default-mark {
  position: absolute;
  top: 50%;
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 1.5px;
  pointer-events: none;
  opacity: 0.9;
  transform: translate(-50%, -50%) rotate(45deg);
  z-index: 3;
}
.nightly-delta {
  font-size: 0.7rem;
  font-weight: 700;
  height: 1rem;
  font-variant-numeric: tabular-nums;
}
.delta-pos { color: var(--green); }
.delta-neg { color: var(--red); }
.nightly-slider {
  cursor: pointer;
}

.hidden { display: none !important; }

/* ── Theme Toggle ────────────────────────── */
.theme-toggle {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--transition);
  padding: 0;
}
.theme-toggle:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

/* Light theme overrides */
[data-theme="light"] {
  --bg: #f8f9fc;
  --bg-gradient: linear-gradient(165deg, #f8f9fc 0%, #eef0f7 50%, #f8f9fc 100%);
  --surface: #ffffff;
  --surface2: #f2f3f8;
  --surface3: #e6e8f0;
  --border: #d8dbe6;
  --border-light: #bfc3d4;
  --text: #1e2234;
  --text-dim: #4a5072;
  --text-muted: #7a80a0;
  --accent: #5a4bd4;
  --accent-light: #6c5ce7;
  --accent-glow: rgba(90, 75, 212, 0.10);
  --green: #0a9e8e;
  --green-dim: #088a7c;
  --yellow: #d4a017;
  --red: #d04f3a;
  --shadow-sm: 0 1px 4px rgba(30,34,52,0.06);
  --shadow-md: 0 4px 20px rgba(30,34,52,0.08);
  --shadow-lg: 0 12px 40px rgba(30,34,52,0.10);
}

/* Header & Nav */
[data-theme="light"] header {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
}
[data-theme="light"] header::before {
  background: radial-gradient(ellipse at center, rgba(90,75,212,0.04) 0%, transparent 60%);
}
[data-theme="light"] .logo-icon { color: var(--accent); }

/* Hero */
[data-theme="light"] .hero h1 { color: #1e2234; }
[data-theme="light"] .gradient-text {
  background: linear-gradient(135deg, #5a4bd4 0%, #0a9e8e 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Search Panel */
[data-theme="light"] .search-panel {
  background: #ffffff;
  border-color: var(--border);
  box-shadow: 0 2px 12px rgba(30,34,52,0.06);
}
[data-theme="light"] .search-panel-header {
  border-bottom-color: var(--border);
}
[data-theme="light"] input[type="text"],
[data-theme="light"] input[type="number"],
[data-theme="light"] input[type="email"],
[data-theme="light"] input[type="password"] {
  background: #f2f3f8;
  border-color: var(--border);
  color: var(--text);
}
[data-theme="light"] input[type="text"]:focus,
[data-theme="light"] input[type="number"]:focus,
[data-theme="light"] input[type="email"]:focus,
[data-theme="light"] input[type="password"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(90,75,212,0.12);
}

/* Summary Cards */
[data-theme="light"] .summary-card {
  background: #ffffff;
  border-color: var(--border);
}
[data-theme="light"] .summary-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(90,75,212,0.08);
}

/* Mortgage Controls */
[data-theme="light"] .mortgage-controls {
  background: #ffffff;
  border-color: var(--border);
}

/* Table */
[data-theme="light"] .table-wrap {
  border: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(30,34,52,0.05);
}
[data-theme="light"] thead {
  background: #eef0f7;
}
[data-theme="light"] th {
  color: #4a5072;
  border-bottom-color: var(--border);
}
[data-theme="light"] td {
  border-bottom: 1px solid #eaecf4;
}
[data-theme="light"] tbody tr {
  background: #ffffff;
}
[data-theme="light"] tbody tr:nth-child(even):not(.opt-row) {
  background: #f6f7fb;
}
[data-theme="light"] tbody tr:hover:not(.opt-row) {
  background: #eef0f8;
}
[data-theme="light"] a.property-link:hover { color: #3d2fb3; }

/* Value colors — stronger contrast on light */
[data-theme="light"] .val-pos { color: #0a8a7c; }
[data-theme="light"] .val-neg { color: #c94232; }

/* Buttons */
[data-theme="light"] .btn-optimize {
  background: #f2f3f8;
  color: var(--accent);
  border-color: var(--border);
}
[data-theme="light"] .btn-optimize:hover {
  background: rgba(90,75,212,0.08);
  border-color: var(--accent);
}
[data-theme="light"] .btn-export {
  background: #f2f3f8;
  border-color: var(--border);
}
[data-theme="light"] .btn-export:hover {
  background: rgba(90,75,212,0.08);
  border-color: var(--accent);
  color: var(--accent);
}

/* Optimize sub-row */
[data-theme="light"] .opt-row {
  background: rgba(10,158,142,0.05) !important;
  border-left-color: #0a9e8e;
}
[data-theme="light"] .opt-row:hover {
  background: rgba(10,158,142,0.09) !important;
}
[data-theme="light"] .opt-row td {
  border-bottom-color: rgba(10,158,142,0.12);
}

/* Slider tracks */
[data-theme="light"] input[type="range"] {
  background: #dcdee6;
}
[data-theme="light"] input[type="range"]::-webkit-slider-thumb {
  box-shadow: 0 1px 4px rgba(30,34,52,0.18);
}

/* Tooltip */
[data-theme="light"] .tooltip-box {
  background: #1e2234;
  color: #e8eaf2;
  border-color: #333856;
  box-shadow: 0 8px 32px rgba(30,34,52,0.25);
}

/* Footer */
[data-theme="light"] footer {
  background: #ffffff;
  border-top: 1px solid var(--border);
}

/* Theme toggle */
[data-theme="light"] .btn-theme {
  background: #f2f3f8;
  border-color: var(--border);
  color: var(--text-dim);
}
[data-theme="light"] .btn-theme:hover {
  background: rgba(90,75,212,0.08);
  border-color: var(--accent);
}

/* ── Export Button ───────────────────────── */
.btn-export {
  padding: 0.5rem 1.2rem;
  background: var(--surface2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-export:hover {
  border-color: var(--accent);
  color: var(--accent-light);
  background: var(--accent-glow);
}

/* ── Favorites column ───────────────────── */
.fav-col { width: 36px; min-width: 36px; }
.btn-fav {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0;
  transition: transform 0.15s;
  line-height: 1;
}
.btn-fav:hover { transform: scale(1.25); }
.btn-fav.saved { animation: heartPop 0.3s ease; }
@keyframes heartPop { 0% { transform: scale(1); } 50% { transform: scale(1.4); } 100% { transform: scale(1); } }

/* ── Responsive ──────────────────────────── */
@media (max-width: 900px) {
  .search-row { flex-direction: column; }
  .hero h1 { font-size: 1.6rem; }
  .hero { padding: 1.5rem 1rem 2rem; }
  .subtitle { font-size: 0.9rem; }
  .nav-tagline { display: none; }
  .nav-links { gap: 0.6rem; }
  .summary-cards { grid-template-columns: repeat(2, 1fr); }
  .mortgage-controls { flex-direction: column; gap: 1rem; }
  .mortgage-control { min-width: 0; }
  .global-slider-wrap { width: 100%; }
  .term-select { width: 100%; }
  .search-panel { margin: -1rem auto 1.5rem; padding: 1.2rem 1rem 1rem; }
  .results-header { flex-direction: column; gap: 0.8rem; }
  .btn-export { align-self: flex-start; }
  .market-insights { padding: 0 1rem; }
  .market-insights-cards { grid-template-columns: repeat(2, 1fr); }
  #mapSection { padding: 0 1rem; }
  .filter-row { gap: 0.6rem; }
  .filter-group { flex: 1 1 120px; min-width: 100px; }
}
@media (max-width: 600px) {
  /* Nav — hide Calculator/Pricing/Methodology bar links; show in dropdown instead */
  .nav-bar { padding: 0.8rem 1rem; }
  .nav-links .nav-link[href="/calculator.html"],
  .nav-links .nav-link[href="/pricing.html"],
  .nav-links .nav-link[href="/methodology.html"] { display: none; }
  .dropdown-mobile-only { display: block; }
  .nav-links { gap: 0.5rem; }
  .logo-text { font-size: 1rem; }

  /* Hero */
  .hero h1 { font-size: 1.3rem; }
  .hero { padding: 1.2rem 0.8rem 1.5rem; }
  .subtitle { font-size: 0.82rem; }

  /* Search panel */
  .search-panel { margin: -0.5rem 0.5rem 1rem; padding: 1rem 0.8rem 0.8rem; }
  .search-panel-header { margin-bottom: 0.8rem; }
  .panel-title { font-size: 0.78rem; }
  .input-group { width: 100%; }
  .location-group, .price-group { flex: 1 1 100%; }
  .btn-search { width: 100%; justify-content: center; }
  .search-hint { font-size: 0.72rem; }

  /* Header */
  header { border-bottom: none; }

  /* Summary & market cards */
  .summary-cards { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
  .summary-card { padding: 0.7rem 0.8rem; }
  .summary-card-label { font-size: 0.65rem; }
  .summary-card-value { font-size: 1rem; }
  .market-insights-cards { grid-template-columns: 1fr; }
  .market-insights { padding: 0 0.5rem; }

  /* Results table */
  .results { padding: 0 0.5rem; }
  .table-wrap { max-width: 100vw; -webkit-overflow-scrolling: touch; }
  th, td { padding: 0.4rem 0.5rem; font-size: 0.72rem; }
  th { font-size: 0.65rem; }
  .score-badge { width: 36px; height: 36px; font-size: 0.75rem; }
  .badge { padding: 0.18rem 0.5rem; font-size: 0.65rem; }
  .nightly-cell, .occ-cell { min-width: 110px; }
  .opt-notes-cell { max-width: 200px; }

  /* Charts */
  .charts-section { grid-template-columns: 1fr; }
  .chart-card { min-height: 220px; }

  /* Pricing */
  .pricing-grid { grid-template-columns: 1fr; }

  /* Map section */
  #mapSection { padding: 0 0.5rem; }

  /* Filter row */
  .filter-row { gap: 0.5rem; }
  .filter-group { flex: 1 1 100%; min-width: 0; }
  .filter-select { font-size: 0.82rem; }

  /* Mortgage controls */
  .mortgage-controls { padding: 0.8rem 1rem; }
  .mortgage-control { min-width: 0; }
  .global-slider-wrap { width: 100%; }
  .term-select { width: 100%; }

  /* Disclaimer modal */
  .disclaimer-modal-content { min-width: auto; width: 95vw; }
  .disclaimer-text { padding: 1rem 1.2rem 1.2rem; }

  /* Compare modal */
  .compare-modal { align-items: flex-start; padding: 0; }
  .compare-modal-content { min-width: auto; width: 100vw; max-height: 100vh; border-radius: 0; }
  .compare-modal-header { position: sticky; top: 0; z-index: 10; padding: 0.8rem 1rem; }
  .compare-modal-header h3 { font-size: 0.95rem; }
  .compare-close { width: 36px; height: 36px; font-size: 1.2rem; flex-shrink: 0; }
  .compare-table-wrap { padding: 0.5rem 0.8rem 1rem; overflow-x: auto; }
  .compare-table { font-size: 0.72rem; }
  .compare-table th, .compare-table td { padding: 0.35rem 0.5rem; }

  /* Footer */
  footer { padding: 1.5rem 1rem; }
}

/* ── Very small phones ──────────────────── */
@media (max-width: 400px) {
  .nav-bar { padding: 0.6rem 0.6rem; }
  .logo-text { font-size: 0.9rem; }
  .hero h1 { font-size: 1.1rem; }
  .subtitle { font-size: 0.78rem; }
  .search-panel { margin: -0.3rem 0.3rem 0.8rem; padding: 0.8rem 0.6rem 0.6rem; }
  .summary-card { padding: 0.7rem 0.8rem; }
  .summary-card-value { font-size: 1.1rem; }
  .market-card { padding: 0.7rem 0.8rem; }
  .market-card-value { font-size: 1.1rem; }
  th, td { padding: 0.3rem 0.4rem; font-size: 0.68rem; }
  th { font-size: 0.6rem; letter-spacing: 0.02em; }
  .score-badge { width: 30px; height: 30px; font-size: 0.65rem; }
  .btn-optimize { padding: 0.25rem 0.5rem; font-size: 0.68rem; }
  .results h2 { font-size: 1.1rem; }
  .result-summary { font-size: 0.78rem; }
  .nightly-cell, .occ-cell { min-width: 90px; }
  .compare-fab { bottom: 1rem; right: 1rem; padding: 0.6rem 1rem; font-size: 0.82rem; }
}

/* ── Charts Section ─────────────────────── */
.charts-section {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.2rem;
}
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  position: relative;
  min-height: 280px;
  transition: border-color var(--transition);
}
.chart-card:hover { border-color: var(--border-light); }
.chart-card canvas { width: 100% !important; height: 100% !important; }
@media (max-width: 1100px) {
  .charts-section { grid-template-columns: 1fr 1fr; }
  .charts-section .chart-card:last-child { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
  .charts-section { grid-template-columns: 1fr; }
  .charts-section .chart-card:last-child { grid-column: auto; }
}
[data-theme="light"] .chart-card {
  background: #ffffff;
  border-color: var(--border);
}
[data-theme="light"] .chart-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(90,75,212,0.08);
}

/* ── Investment Score Badge ─────────────── */
.score-badge {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 800;
  line-height: 1;
  color: #fff;
  position: relative;
}
.score-grade {
  font-size: 0.55rem;
  font-weight: 700;
  opacity: 0.85;
  letter-spacing: 0.04em;
  margin-top: 1px;
}
.score-A  { background: linear-gradient(135deg, var(--green), #00b894); box-shadow: 0 0 10px rgba(0,206,201,0.3); }
.score-B  { background: linear-gradient(135deg, var(--green-dim), #0a9e8e); box-shadow: 0 0 10px rgba(0,184,148,0.25); }
.score-C  { background: linear-gradient(135deg, var(--yellow), #d4a017); box-shadow: 0 0 10px rgba(251,197,49,0.25); }
.score-D  { background: linear-gradient(135deg, var(--red), #c0392b); box-shadow: 0 0 10px rgba(225,112,85,0.25); }
.score-F  { background: linear-gradient(135deg, #c0392b, #962d22); box-shadow: 0 0 10px rgba(192,57,43,0.3); }

/* ── Compare Column & FAB ──────────────── */
.compare-col { width: 32px; min-width: 32px; text-align: center; }
.compare-check {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  vertical-align: middle;
}
#compareSelectAll {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
.compare-fab {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 0.8rem 1.6rem;
  background: linear-gradient(135deg, var(--accent), #5b4bd5);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(108,92,231,0.4);
  z-index: 1000;
  transition: all var(--transition);
  animation: fabPop 0.25s ease;
}
.compare-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(108,92,231,0.5);
}
@keyframes fabPop { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ── Compare Modal ─────────────────────── */
.compare-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}
.compare-modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 95vw;
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow-lg);
  width: fit-content;
  min-width: 600px;
}
.compare-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.compare-modal-header h3 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
}
.compare-close {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.compare-close:hover {
  background: rgba(225,112,85,0.1);
  color: var(--red);
  border-color: rgba(225,112,85,0.3);
}
.compare-table-wrap { padding: 1rem 1.5rem 1.5rem; overflow-x: auto; }
.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
.compare-table th {
  padding: 0.6rem 1rem;
  text-align: left;
  font-weight: 700;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.compare-table td {
  padding: 0.55rem 1rem;
  border-bottom: 1px solid rgba(37,42,58,0.4);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.compare-metric-label {
  font-weight: 700;
  color: var(--text-dim);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.compare-best {
  color: var(--green) !important;
  font-weight: 700;
  background: rgba(0,206,201,0.06);
}
[data-theme="light"] .compare-modal-content {
  background: #ffffff;
}
[data-theme="light"] .compare-table td {
  border-bottom-color: #eaecf4;
}
[data-theme="light"] .compare-best {
  background: rgba(10,158,142,0.08);
}

/* ── Filter Controls ───────────────────── */
.filter-row {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.filter-group { flex: 1 1 150px; min-width: 130px; }
.filter-select {
  width: 100%;
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%237b82a0' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  padding-right: 2rem;
}
.filter-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
[data-theme="light"] .filter-select {
  background-color: #f2f3f8;
  border-color: var(--border);
  color: var(--text);
}

/* ── Market Insights Panel ─────────────── */
.market-insights {
  max-width: 1500px;
  margin: 0 auto 1.5rem;
  padding: 0 1.5rem;
  animation: fadeIn 0.3s ease;
}
.market-insights-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}
.market-location {
  font-size: 0.85rem;
  color: var(--accent-light);
  font-weight: 600;
  margin-left: auto;
}
.market-insights-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}
.market-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  transition: border-color var(--transition);
}
.market-card:hover { border-color: var(--border-light); }
.market-card-icon { font-size: 1.2rem; margin-bottom: 0.2rem; }
.market-card-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.market-card-value {
  font-size: 1.3rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--accent-light);
}
[data-theme="light"] .market-card {
  background: #ffffff;
  border-color: var(--border);
}

/* ── Property Detail Modal ─────────────── */
.detail-modal-content {
  min-width: 700px;
  max-width: 1000px;
  width: 90vw;
}
.detail-modal-body {
  padding: 1.5rem;
  max-height: 80vh;
  overflow-y: auto;
}
.detail-header {
  margin-bottom: 1.5rem;
}
.detail-address {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 0.3rem;
}
.detail-header-links {
  display: flex;
  gap: 0.8rem;
  margin-bottom: 0.6rem;
}
.detail-header-links a {
  color: var(--accent-light);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
}
.detail-header-links a:hover { text-decoration: underline; }
.detail-header-stats {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  font-size: 0.88rem;
  color: var(--text-dim);
}
.detail-header-stats span { font-weight: 600; color: var(--text); }
.detail-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.detail-chart-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  min-height: 280px;
}
.detail-chart-card canvas { width: 100% !important; height: 100% !important; }
.detail-section {
  margin-bottom: 1.5rem;
}
.detail-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-light);
  margin-bottom: 0.8rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}
.detail-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}
.detail-metric {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0.8rem;
  background: var(--surface2);
  border-radius: 6px;
  font-size: 0.84rem;
}
.detail-metric-label { color: var(--text-dim); }
.detail-metric-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.detail-metric-value.pos { color: var(--green); }
.detail-metric-value.neg { color: var(--red); }
.detail-risk-badge {
  display: inline-block;
  padding: 0.3rem 0.8rem;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 700;
}
.detail-risk-badge.low    { background: rgba(0,206,201,0.1); color: var(--green); }
.detail-risk-badge.medium { background: rgba(251,197,49,0.1); color: var(--yellow); }
.detail-risk-badge.high   { background: rgba(225,112,85,0.1); color: var(--red); }
.detail-risk-note {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-top: 0.4rem;
  font-style: italic;
}

/* ── Sensitivity Analysis Table ────────── */
.sensitivity-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
.sensitivity-table th {
  padding: 0.6rem 0.8rem;
  text-align: center;
  font-weight: 700;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}
.sensitivity-table td {
  padding: 0.5rem 0.8rem;
  text-align: center;
  border-bottom: 1px solid rgba(37,42,58,0.4);
  font-variant-numeric: tabular-nums;
}
.sensitivity-table td:first-child {
  text-align: left;
  font-weight: 600;
  color: var(--text-dim);
}
.sensitivity-table .col-pessimistic { color: var(--red); }
.sensitivity-table .col-base { color: var(--text); }
.sensitivity-table .col-optimistic { color: var(--green); }
.sensitivity-table th.col-pessimistic { color: var(--red); background: rgba(225,112,85,0.05); }
.sensitivity-table th.col-base { color: var(--text); }
.sensitivity-table th.col-optimistic { color: var(--green); background: rgba(0,206,201,0.05); }
.sensitivity-assumptions {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 0.6rem;
  font-style: italic;
}

/* Clickable rows cursor */
tbody tr[data-idx] { cursor: pointer; }

@media (max-width: 768px) {
  .detail-charts { grid-template-columns: 1fr; }
  .detail-metrics-grid { grid-template-columns: 1fr 1fr; }
  .detail-modal-content { min-width: auto; width: 98vw; }
  .detail-modal-body { padding: 1rem; }
  .detail-address { font-size: 1rem; }
  .detail-header-stats { gap: 0.8rem; font-size: 0.82rem; }
  .detail-chart-card { min-height: 220px; }
}
@media (max-width: 480px) {
  .detail-metrics-grid { grid-template-columns: 1fr; }
  .detail-modal-body { padding: 0.8rem; }
  .detail-header-links { flex-wrap: wrap; gap: 0.5rem; }
  .sensitivity-table { font-size: 0.76rem; }
  .sensitivity-table th, .sensitivity-table td { padding: 0.35rem 0.5rem; }
}
[data-theme="light"] .detail-chart-card { background: #f2f3f8; }
[data-theme="light"] .detail-metric { background: #f2f3f8; }
[data-theme="light"] .sensitivity-table th.col-pessimistic { background: rgba(208,79,58,0.05); }
[data-theme="light"] .sensitivity-table th.col-optimistic { background: rgba(10,158,142,0.05); }

/* ── Share button in detail header ────────── */
.btn-share-property {
  background: rgba(108,92,231,0.12);
  color: var(--accent-light);
  border: 1px solid rgba(108,92,231,0.25);
  border-radius: 6px;
  padding: 0.3rem 0.8rem;
  font-size: 0.82rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-share-property:hover { background: rgba(108,92,231,0.22); }
.btn-share-fav {
  background: rgba(108,92,231,0.12);
  color: var(--accent-light);
  border: 1px solid rgba(108,92,231,0.25);
  border-radius: 6px;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  margin-left: 0.3rem;
}
.btn-share-fav:hover { background: rgba(108,92,231,0.22); }

/* ── Favorites Notes ───────────────────── */
.fav-notes {
  width: 100%;
  min-height: 40px;
  max-height: 80px;
  resize: vertical;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  padding: 0.5rem 0.6rem;
  margin-top: 0.6rem;
  outline: none;
  transition: border-color var(--transition);
}
.fav-notes:focus { border-color: var(--accent); }
.fav-notes::placeholder { color: var(--text-muted); }
.fav-notes-saved {
  font-size: 0.7rem;
  color: var(--green);
  font-weight: 600;
  margin-top: 0.2rem;
  opacity: 0;
  transition: opacity 0.3s;
}
.fav-notes-saved.show { opacity: 1; }

/* ── Source Badges ──────────────────────── */
.src-info {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-muted);
  opacity: 0.5;
  cursor: help;
  margin-left: 0.2rem;
  vertical-align: middle;
  transition: opacity var(--transition);
}
.src-info:hover {
  opacity: 1;
  color: var(--accent-light);
}

/* ── Disclaimer Modal ──────────────────── */
.disclaimer-modal-content {
  min-width: 400px;
  max-width: 560px;
  width: 90vw;
}
.disclaimer-text {
  padding: 1.5rem 2rem 2rem;
}
.disclaimer-text p {
  font-size: 0.9rem;
  color: var(--text-dim);
  line-height: 1.7;
  margin-bottom: 1rem;
}
.disclaimer-text p:last-of-type {
  margin-bottom: 1.5rem;
  font-weight: 600;
  color: var(--text);
}
.disclaimer-agree-btn {
  display: block;
  width: 100%;
  padding: 0.85rem 1.5rem;
  background: linear-gradient(135deg, var(--accent), #5b4bd5);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
}
.disclaimer-agree-btn:hover {
  box-shadow: 0 6px 24px rgba(108,92,231,0.4);
  transform: translateY(-1px);
}

/* ── Column Config ─────────────────────── */
.table-controls {
  position: relative;
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.75rem;
}
.col-config-btn {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.col-config-btn:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-sm);
}
.col-config-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 0.5rem 0;
  min-width: 200px;
  max-height: 320px;
  overflow-y: auto;
}
.col-config-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  font-size: 0.82rem;
  color: var(--text-dim);
  cursor: pointer;
  transition: background var(--transition);
}
.col-config-item:hover {
  background: var(--surface2);
  color: var(--text);
}
.col-config-item input[type="checkbox"] {
  accent-color: var(--accent);
}
.col-hidden { display: none !important; }
[data-theme="light"] .col-config-dropdown {
  background: #ffffff;
  border-color: var(--border);
}
[data-theme="light"] .disclaimer-modal-content {
  background: #ffffff;
}

/* ── Property Map ──────────────────────── */
#propertyMap {
  border: 1px solid var(--border);
  margin-top: 1rem;
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.section-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}
#toggleMap {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
#toggleMap:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.map-legend {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.map-legend-title {
  font-weight: 700;
  margin-bottom: 0.3rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}
.map-legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.map-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.map-popup .popup-title {
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
  color: #222;
}
.map-popup .popup-row {
  font-size: 0.78rem;
  color: #444;
  line-height: 1.5;
}
.map-popup .popup-row strong {
  font-weight: 600;
}
#mapSection {
  max-width: 1500px;
  margin: 1.5rem auto;
  padding: 0 2rem;
}

/* ── Rental Comps Table ───────────────── */
.comps-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
.comps-table th {
  padding: 0.6rem 0.8rem;
  text-align: left;
  font-weight: 700;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}
.comps-table td {
  padding: 0.5rem 0.8rem;
  border-bottom: 1px solid rgba(37,42,58,0.4);
  font-variant-numeric: tabular-nums;
}
.comps-table tr:hover {
  background: var(--surface2);
}
.comps-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
  padding: 1rem 0;
}
