/**
 * SubTo Deal Finder — Visual overhaul (light + dark)
 * Design tokens + component polish. Loaded after base styles.
 */

/* ── Design tokens ── */
:root {
  --bg-page: #F8F9FA;
  --bg-header: #FFFFFF;
  --bg-nav: #0F1923;
  --bg-card: #FFFFFF;
  --bg-sidebar: #FFFFFF;
  --bg-signal-bar: #1A2A3A;
  --bg-kpi-card: #FFFFFF;
  --bg-search-btn: #2563EB;
  --bg-lookupbtn: #1D4ED8;
  --bg-surface: #F1F5F9;
  --border-card: rgba(0, 0, 0, 0.05);
  --border-nav: none;
  --text-primary: #0F172A;
  --text-secondary: #64748B;
  --text-nav-inactive: #94A3B8;
  --text-nav-active: #FFFFFF;
  --text-logo: #0F172A;
  --text-logo-sub: #2563EB;
  --text-kpi-number: #0F172A;
  --text-kpi-label: #64748B;
  --accent-green: #22C55E;
  --accent-blue: #2563EB;
  --score-bg: #166534;
  --score-text: #FFFFFF;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --quick-pill-bg: #F1F5F9;
  --quick-pill-border: #E2E8F0;
  --quick-pill-text: #475569;
  --toggle-track-on: #2563EB;
  --tab-active-color: #0F172A;
  --tab-active-border: #0F172A;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.12);

  /* Legacy semantic bridge */
  --bg: var(--bg-page);
  --panel: var(--bg-card);
  --border: #E2E8F0;
  --text: var(--text-primary);
  --text2: var(--text-secondary);
  --text3: #94A3B8;
  --acc: var(--accent-blue);
  --acc-t: #1D4ED8;
  --acc2: #EFF6FF;
  --sage: var(--accent-green);
  --sage-light: #F0FDF4;
  --surface-1: var(--bg-page);
  --surface-2: var(--bg-card);
  --surface-3: var(--bg-surface);
}

body.dark,
[data-theme="dark"] {
  --bg-page: #0D1117;
  --bg-header: #161B22;
  --bg-nav: #0D1117;
  --bg-card: #161B22;
  --bg-sidebar: #0D1117;
  --bg-signal-bar: #161B22;
  --bg-kpi-card: #161B22;
  --bg-search-btn: #238636;
  --bg-lookupbtn: #238636;
  --bg-surface: #21262D;
  --border-card: rgba(255, 255, 255, 0.06);
  --text-primary: #E6EDF3;
  --text-secondary: #9CA3AF;
  --text-nav-inactive: #8B949E;
  --text-logo: #E6EDF3;
  --text-logo-sub: #3FB950;
  --text-kpi-number: #E6EDF3;
  --text-kpi-label: #8B949E;
  --accent-green: #3FB950;
  --accent-blue: #58A6FF;
  --score-bg: #238636;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --quick-pill-bg: #21262D;
  --quick-pill-border: #30363D;
  --quick-pill-text: #C9D1D9;
  --toggle-track-on: #238636;
  --tab-active-color: #E6EDF3;
  --tab-active-border: #3FB950;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.45);

  --bg: var(--bg-page);
  --panel: var(--bg-card);
  --border: #30363D;
  --text: var(--text-primary);
  --text2: var(--text-secondary);
  --text3: #8B949E;
  --acc: var(--accent-green);
  --acc-t: var(--accent-green);
  --acc2: rgba(63, 185, 80, 0.12);
  --sage: var(--accent-green);
  --surface-1: var(--bg-page);
  --surface-2: var(--bg-card);
  --surface-3: var(--bg-surface);
}

body.dark,
[data-theme="dark"] body,
body.dark-mode {
  background:
    radial-gradient(circle at top, rgba(63, 185, 80, 0.04), transparent 40%),
    var(--bg-page) !important;
}

body {
  background-color: var(--bg-page) !important;
  color: var(--text-primary);
}

/* ── §1 Header ── */
.app-nav {
  background: var(--bg-header) !important;
  border-bottom: 1px solid var(--border-card) !important;
  height: auto;
  min-height: 54px;
  padding: 8px 20px;
}

body.dark .app-nav {
  background: var(--bg-header) !important;
}

.nav-brand {
  color: var(--text-logo) !important;
  font-weight: 700;
}

.nav-badge,
.nav-brand-wrap .nav-badge {
  color: var(--text-logo-sub) !important;
  border-color: var(--border) !important;
  background: transparent !important;
  font-weight: 600;
}

.nav-center #property-lookup-input {
  height: 44px !important;
  border-radius: var(--radius-md) !important;
  padding: 0 14px !important;
  box-shadow: var(--shadow-sm) !important;
  background: #FFFFFF !important;
  border: 1px solid #E2E8F0 !important;
  color: var(--text-primary) !important;
  font-size: 14px !important;
}

body.dark .nav-center #property-lookup-input {
  background: #21262D !important;
  border-color: #30363D !important;
  color: var(--text-primary) !important;
}

.nav-center #property-lookup-input::placeholder {
  color: var(--text-secondary) !important;
}

.nav-center #property-lookup-btn {
  height: 44px !important;
  border-radius: 10px !important;
  background: var(--bg-lookupbtn) !important;
  color: #FFFFFF !important;
  font-weight: 600 !important;
  padding: 0 16px !important;
}

.nav-center #property-lookup-btn:hover {
  filter: brightness(1.08);
}

#stats-bar {
  color: var(--accent-blue) !important;
  font-weight: 600;
}

body.dark #stats-bar {
  color: var(--accent-green) !important;
}

#how-it-works-btn,
#auth-btn,
.theme-toggle-btn {
  color: var(--text-secondary) !important;
}

.theme-toggle-btn {
  color: var(--text-primary) !important;
}

#plan-badge.nav-plan-badge {
  background: var(--accent-green) !important;
  color: #FFFFFF !important;
  border: none !important;
}

/* ── §2 Sign-in banner ── */
#sign-in-banner.sign-in-cta-banner {
  background: var(--bg-signal-bar) !important;
  border-bottom: none !important;
}

body.dark #sign-in-banner.sign-in-cta-banner {
  background: var(--bg-signal-bar) !important;
  border-bottom: 1px solid #30363D !important;
}

#sign-in-banner.sign-in-cta-banner p {
  color: #FFFFFF !important;
}

#sign-in-banner-btn {
  background: var(--bg-lookupbtn) !important;
  border-radius: 10px !important;
  color: #FFFFFF !important;
  font-weight: 600 !important;
}

/* ── §3 Quick searches ── */
.quick-search-section {
  background: var(--bg-surface) !important;
  border-bottom: 1px solid var(--border-card) !important;
  height: auto !important;
  min-height: 44px;
  padding: 10px 16px !important;
}

.quick-search-section > p {
  color: var(--text-secondary) !important;
  font-size: 13px !important;
}

.quick-template-pill {
  background: var(--quick-pill-bg) !important;
  border: 1px solid var(--quick-pill-border) !important;
  color: var(--quick-pill-text) !important;
  border-radius: 999px !important;
  padding: 4px 14px !important;
  font-size: 13px !important;
}

.quick-template-pill:hover {
  border-color: var(--accent-blue) !important;
  background: var(--quick-pill-bg) !important;
}

body.dark .quick-template-pill:hover {
  border-color: var(--accent-green) !important;
}

.quick-template-pill.quick-template-active {
  background-color: #16a34a !important;
  color: #ffffff !important;
  border: 1px solid #15803d !important;
}
.quick-template-pill.quick-template-active .quick-template-label,
.quick-template-pill.quick-template-active .quick-template-help,
.quick-template-pill.quick-template-active .filter-help-btn {
  color: #ffffff !important;
}
.quick-template-pill.quick-template-active:hover {
  background-color: #15803d !important;
  color: #ffffff !important;
}
@media (hover: none) {
  .quick-template-pill.quick-template-active:hover {
    background-color: #16a34a !important;
  }
}

/* ── §13 Recently viewed ── */
#recently-viewed-row {
  background: var(--bg-surface) !important;
  padding: 10px 16px 12px !important;
}

.recently-viewed-label {
  color: var(--text-secondary) !important;
  font-size: 12px !important;
}

.recently-viewed-label-muted {
  color: var(--text-secondary);
  font-weight: 400;
}

.recently-viewed-scroll {
  max-height: none;
  align-items: stretch;
  overflow-x: auto;
  overflow-y: visible;
}

.rv-example-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  max-height: 48px;
  padding: 6px 12px 6px 6px;
  border-radius: var(--radius-md);
  border: 1px solid #E2E8F0;
  background: #F8F9FA;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}

body.dark .rv-example-pill {
  background: #21262D;
  border-color: #30363D;
}

.rv-example-pill:hover {
  background: #F1F5F9;
}

body.dark .rv-example-pill:hover {
  background: #2D333B;
}

.rv-example-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #1A2A1E 0%, #2D4A35 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.rv-example-lines {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.rv-example-addr {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  white-space: nowrap;
}

body.dark .rv-example-addr {
  color: #C9D1D9;
}

.rv-example-meta {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.rv-example-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  flex-shrink: 0;
  margin-left: 4px;
}

.recently-viewed-empty {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0;
  padding: 6px 0;
  white-space: nowrap;
}

body.dark .recently-viewed-empty {
  color: #8B949E !important;
}

/* ── §4 Nav rail (always dark) ── */
#app-nav-rail {
  background: var(--bg-nav) !important;
  border-right: none !important;
  width: 56px;
}

.nav-rail-logo {
  width: 28px !important;
  height: 28px !important;
  font-size: 16px !important;
  background: rgba(255, 255, 255, 0.08) !important;
}

.nav-rail-wordmark {
  color: var(--text-nav-inactive) !important;
}

.nav-rail-item {
  color: var(--text-nav-inactive) !important;
}

.nav-rail-item:hover {
  color: #FFFFFF !important;
  background: rgba(255, 255, 255, 0.06) !important;
}

.nav-rail-item.active {
  background: linear-gradient(90deg, rgba(34, 197, 94, 0.15), transparent) !important;
  border-left: 3px solid var(--accent-green) !important;
  border-radius: 0 10px 10px 0 !important;
  color: #FFFFFF !important;
}

.nav-rail-item.active .nav-rail-label,
.nav-rail-item.active i {
  color: #FFFFFF !important;
}

.nav-rail-soon-dot {
  background: var(--accent-green) !important;
}

.nav-rail-plan-badge {
  color: var(--text-nav-inactive) !important;
}

/* ── §5 Sidebar ── */
#filter-sidebar {
  background: var(--bg-sidebar) !important;
  border-right: 1px solid var(--border-card) !important;
}

.sidebar-tab-panels {
  background: var(--bg-sidebar) !important;
}

.sidebar-tab-btn {
  color: var(--text-secondary) !important;
  background: var(--bg-sidebar) !important;
}

.sidebar-tab-btn {
  min-height: 44px !important;
  font-size: 14px !important;
}

.sidebar-tab-btn.active {
  color: var(--tab-active-color) !important;
  border-bottom: 3px solid var(--tab-active-border) !important;
  font-weight: 600 !important;
}

.toggle-label-text {
  color: var(--text-primary) !important;
  font-weight: 500 !important;
}

.toggle-label-text small {
  color: var(--text-secondary) !important;
  font-size: 12px !important;
}

.toggle-switch input:checked + .toggle-slider,
.toggle-switch input:checked + .toggle-track {
  background-color: var(--toggle-track-on) !important;
}

.sidebar-field label,
.filter-check-row span {
  color: var(--text-primary) !important;
}

.sidebar-field-hint {
  color: var(--text-secondary) !important;
  font-size: 12px !important;
}

.sidebar-search-sticky {
  background: var(--bg-sidebar) !important;
  border-bottom: 1px solid var(--border-card) !important;
}

#sidebar-search-btn,
.sidebar-search-sticky #sidebar-search-btn {
  background: var(--bg-search-btn) !important;
  color: #FFFFFF !important;
  border-radius: 10px !important;
  font-weight: 600 !important;
  padding: 10px !important;
  width: 100% !important;
}

#sidebar-search-btn:hover {
  filter: brightness(1.06);
}

.sidebar-footer {
  background: var(--bg-sidebar) !important;
  border-top: 1px solid var(--border-card) !important;
}

#sidebar-match-count {
  color: var(--accent-blue) !important;
}

body.dark #sidebar-match-count {
  color: var(--accent-green) !important;
}

.sidebar-match-label {
  color: var(--text-secondary) !important;
}

body.dark .sidebar-match-label,
body.dark .section-empty {
  color: #8B949E !important;
}

/* ── §6 KPI bar ── */
.kpi-summary-bar {
  display: flex !important;
  flex-wrap: nowrap !important;
  gap: 10px !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-surface) !important;
  border-bottom: 1px solid var(--border-card) !important;
  padding: 12px 16px !important;
  grid-template-columns: unset !important;
}

.kpi-card {
  flex: 0 0 auto;
  min-width: 140px;
  background: var(--bg-kpi-card) !important;
  border: 1px solid var(--border-card) !important;
  border-right: 1px solid var(--border-card) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-sm) !important;
  padding: 10px 14px !important;
}

.kpi-value {
  font-size: 24px !important;
  font-weight: 700 !important;
  color: var(--text-kpi-number) !important;
  line-height: 1.1 !important;
}

.kpi-label {
  font-size: 13px !important;
  color: var(--text-kpi-label) !important;
}

.kpi-sub {
  font-size: 12px !important;
  color: var(--text-kpi-label) !important;
}

.kpi-card:first-child .kpi-icon { color: var(--accent-blue) !important; }
.kpi-card--elite .kpi-icon { color: var(--accent-green) !important; }
.kpi-card--elite .kpi-value {
  color: var(--accent-blue) !important;
}
body.dark .kpi-card--elite .kpi-value {
  color: var(--accent-green) !important;
}
.kpi-card--motivation .kpi-icon,
.kpi-card--motivation .kpi-value { color: #F97316 !important; }
.kpi-card--subto .kpi-icon,
.kpi-card--subto .kpi-value { color: var(--accent-green) !important; }
.kpi-card--spread .kpi-icon,
.kpi-card--spread .kpi-value { color: #F59E0B !important; }

.report-strip {
  background: var(--bg-card) !important;
  border-bottom: 1px solid var(--border-card) !important;
  padding: 12px 16px !important;
}

.report-strip h3 {
  color: var(--text-primary) !important;
  font-weight: 600 !important;
}

.report-strip p {
  color: var(--text-secondary) !important;
}

.report-cta-btn {
  background: #166534 !important;
  color: #FFFFFF !important;
  border-radius: 10px !important;
  border: none !important;
}

body.dark .report-cta-btn {
  background: #238636 !important;
}

/* ── §7 Property cards ── */
.results-cards {
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
  padding: 12px 16px 16px !important;
  grid-template-columns: unset !important;
}

.property-card {
  background: var(--bg-card) !important;
  border: 1px solid var(--border-card) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-sm) !important;
  margin-bottom: 0 !important;
  transition: transform 0.15s ease, box-shadow 0.15s ease !important;
}

.property-card:hover {
  transform: translateY(-1px) !important;
  box-shadow: var(--shadow-md) !important;
  border-color: var(--border-card) !important;
}

.card-photo-fallback {
  background: linear-gradient(135deg, #1A2A1E 0%, #2D4A35 100%) !important;
}

.card-photo-fallback-icon {
  color: #4ADE80 !important;
  opacity: 0.3 !important;
}

.card-tags {
  margin-bottom: 8px !important;
}

.card-footer-row {
  margin-top: 0 !important;
}

.card-photo-col {
  width: 80px !important;
}

.card-photo-wrap,
.card-photo-fallback {
  width: 80px !important;
  height: 80px !important;
  min-height: 80px !important;
}

.card-content-col {
  gap: 0 !important;
  padding: 14px !important;
}

.card-address {
  font-size: 15px !important;
  font-weight: 600 !important;
  color: var(--text-primary) !important;
  margin-bottom: 4px;
}

.card-city {
  font-size: 12px !important;
  color: var(--text-secondary) !important;
  margin-bottom: 6px;
}

.card-strategy-row {
  margin-bottom: 8px;
  gap: 8px;
}

.card-strategy-badge {
  border-radius: 999px !important;
  padding: 2px 10px !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  white-space: normal !important;
  word-break: break-word;
  max-width: 100%;
  border: 1px solid transparent;
}

.card-strategy-badge--subto {
  background: #F0FDF4;
  border-color: #BBF7D0;
  color: #166534;
}

body.dark .card-strategy-badge--subto {
  background: #0A1F12;
  border-color: #238636;
  color: #3FB950;
}

.card-strategy-badge--analyze {
  background: #EFF6FF;
  border-color: #BFDBFE;
  color: #1D4ED8;
}

body.dark .card-strategy-badge--analyze {
  background: #0D1B2A;
  border-color: #1D4ED8;
  color: #58A6FF;
}

.card-confidence {
  font-size: 12px !important;
  color: var(--text-secondary) !important;
}

.card-insight {
  font-size: 13px !important;
  color: var(--text-secondary) !important;
  margin-bottom: 6px;
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: unset !important;
}

.card-why {
  font-size: 11px !important;
  color: var(--text-secondary) !important;
  margin-bottom: 8px;
}

.card-stats-row {
  margin-bottom: 8px;
}

.card-stat {
  font-size: 12px !important;
  color: var(--text-secondary) !important;
}

.card-spread {
  color: #F59E0B !important;
  font-weight: 600 !important;
  font-size: 13px !important;
}

.card-score-badge {
  background: var(--score-bg) !important;
  color: var(--score-text) !important;
  border-radius: var(--radius-sm) !important;
}

.card-score-num {
  font-size: 20px !important;
  font-weight: 700 !important;
}

.card-score-label {
  font-size: 9px !important;
}

.card-call-priority {
  font-size: 11px !important;
  font-weight: 600 !important;
  padding: 2px 8px !important;
  border-radius: 999px !important;
  border: none !important;
  background: transparent !important;
}

.card-call-priority--now {
  color: #EF4444 !important;
  background: rgba(239, 68, 68, 0.1) !important;
}

.card-call-priority--high {
  color: #F59E0B !important;
  background: rgba(245, 158, 11, 0.12) !important;
}

.card-call-priority--follow {
  color: var(--accent-green) !important;
  background: rgba(34, 197, 94, 0.1) !important;
}

body.dark .card-call-priority--follow {
  color: #3FB950 !important;
  background: rgba(63, 185, 80, 0.12) !important;
}

.card-btn-analyze {
  background: #FFFFFF !important;
  border: 1px solid #E2E8F0 !important;
  color: #0F172A !important;
  border-radius: var(--radius-sm) !important;
  font-size: 11px !important;
  font-weight: 600 !important;
}

body.dark .card-btn-analyze {
  background: #21262D !important;
  border-color: #30363D !important;
  color: #E6EDF3 !important;
}

.card-btn-pipeline {
  border-radius: var(--radius-sm) !important;
}

/* Signal tags §7 */
.tag-pill {
  border-radius: 999px !important;
  padding: 2px 8px !important;
  font-size: 11px !important;
  font-weight: 500 !important;
}

.tag-pill.tag-distress {
  background: #FEF2F2 !important;
  border: 1px solid #FCA5A5 !important;
  color: #DC2626 !important;
}

body.dark .tag-pill.tag-distress {
  background: #2D1515 !important;
  border-color: #7F1D1D !important;
  color: #FCA5A5 !important;
}

.tag-pill.tag-neutral {
  background: #F0F9FF !important;
  border: 1px solid #BAE6FD !important;
  color: #0369A1 !important;
}

body.dark .tag-pill.tag-neutral {
  background: #0C1E2D !important;
  border-color: #075985 !important;
  color: #7DD3FC !important;
}

.tag-pill.tag-subto,
.tag-pill.tag-equity {
  background: #F0FDF4 !important;
  border: 1px solid #BBF7D0 !important;
  color: #166534 !important;
}

body.dark .tag-pill.tag-subto,
body.dark .tag-pill.tag-equity {
  background: #0A1F12 !important;
  border-color: #166534 !important;
  color: #4ADE80 !important;
}

.tag-pill.tag-tax,
.tag-pill.tag-probate {
  background: #FDF4FF !important;
  border: 1px solid #E9D5FF !important;
  color: #7C3AED !important;
}

body.dark .tag-pill.tag-tax,
body.dark .tag-pill.tag-probate {
  background: #1A0F2E !important;
  border-color: #6D28D9 !important;
  color: #C4B5FD !important;
}

.tag-pill.tag-motivation {
  background: #FFF7ED !important;
  border: 1px solid #FDBA74 !important;
  color: #C2410C !important;
}

body.dark .tag-pill.tag-motivation {
  background: #2D1A0A !important;
  border-color: #9A3412 !important;
  color: #FDBA74 !important;
}

/* §8 Sample banner */
.sample-deals-banner {
  background: #FFFBEB !important;
  border-top: 1px solid #FDE68A !important;
  border-bottom: 1px solid #FDE68A !important;
  color: #92400E !important;
  font-size: 14px !important;
  font-weight: 500 !important;
}

body.dark .sample-deals-banner {
  background: #1C1A0A !important;
  border-top: 1px solid #3D3000 !important;
  border-bottom: 1px solid #3D3000 !important;
  color: #FCD34D !important;
}

/* §9 Map */
#map-panel.map-panel {
  border-radius: var(--radius-md) !important;
  overflow: hidden !important;
  box-shadow: var(--shadow-sm) !important;
}

.map-toolbar {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  background: #F8F9FA !important;
  border-bottom: 1px solid #E2E8F0 !important;
  color: var(--text-primary) !important;
  padding: 8px 12px !important;
}

body.dark .map-toolbar {
  background: #161B22 !important;
  border-bottom: 1px solid #30363D !important;
  color: #E6EDF3 !important;
}

.map-panel-collapse-btn,
.card-btn-analyze {
  transition: background 0.15s, border-color 0.15s;
}

.map-panel-collapse-btn {
  background: #FFFFFF !important;
  border: 1px solid #E2E8F0 !important;
  color: #0F172A !important;
  border-radius: var(--radius-sm) !important;
  font-size: 11px !important;
  padding: 4px 10px !important;
}

body.dark .map-panel-collapse-btn {
  background: #21262D !important;
  border-color: #30363D !important;
  color: #E6EDF3 !important;
}

.view-switcher {
  border: 1px solid var(--border-card) !important;
  border-radius: var(--radius-sm) !important;
  overflow: hidden !important;
  box-shadow: var(--shadow-sm) !important;
}

.view-switcher-btn {
  background: var(--bg-card) !important;
  border-right: 1px solid var(--border-card) !important;
  color: var(--text-secondary) !important;
  border-radius: 0 !important;
}

.view-switcher-btn.active {
  background: var(--bg-nav) !important;
  color: #FFFFFF !important;
}

.view-switcher-btn:hover:not(.active) {
  background: var(--bg-surface) !important;
}

/* §11 Active filter chips */
.active-chips-bar {
  background: var(--bg-surface) !important;
  border-bottom: 1px solid var(--border-card) !important;
}

    .active-chip {
      background: #EFF6FF !important;
      border: 1px solid #BFDBFE !important;
      color: #1D4ED8 !important;
      border-radius: 999px !important;
      font-size: 12px !important;
      font-weight: 500 !important;
      padding: 3px 10px 3px 12px !important;
    }

body.dark .active-chip {
  background: #0D1B2A !important;
  border-color: #1D4ED8 !important;
  color: #58A6FF !important;
}

.active-chip-remove {
  color: #93C5FD !important;
}

body.dark .active-chip-remove {
  color: #3B82F6 !important;
}

.chips-clear-all {
  color: var(--accent-blue) !important;
  border-color: var(--border-card) !important;
}

body.dark .chips-clear-all {
  color: var(--accent-green) !important;
}

/* Results header */
.results-header-bar {
  background: var(--bg-card) !important;
  border-bottom: 1px solid var(--border-card) !important;
}

#results-count {
  color: var(--text-primary) !important;
  font-weight: 600 !important;
}

body.dark #results-count {
  color: #E6EDF3 !important;
}

.results-header-sub {
  color: var(--text-secondary) !important;
}

body.dark .results-header-sub {
  color: #8B949E !important;
}

.main-results-area {
  background: var(--bg-page) !important;
}

.app-top {
  background: var(--bg-page) !important;
}

/* Mobile bottom nav */
#app-bottom-nav {
  background: var(--bg-nav) !important;
  border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.nav-bottom-item {
  color: var(--text-nav-inactive) !important;
}

.nav-bottom-item.active {
  color: #FFFFFF !important;
}

@media (max-width: 900px) {
  .kpi-card--spread {
    display: flex !important;
  }
}

/* ── Mobile Responsive (max-width: 768px) ── */
@media (max-width: 768px) {

  /* Nav — stack vertically on mobile */
  .app-nav {
    flex-wrap: wrap !important;
    padding: 8px 12px !important;
    gap: 8px !important;
    height: auto !important;
  }

  .nav-left {
    flex: 1 !important;
    min-width: 0 !important;
  }

  .nav-center {
    order: 3 !important;
    width: 100% !important;
    flex: 0 0 100% !important;
  }

  .nav-center #property-lookup-input {
    width: 100% !important;
    font-size: 13px !important;
  }

  .nav-right {
    flex-shrink: 0 !important;
    gap: 6px !important;
  }

  /* Hide less important nav items on mobile */
  #stats-bar { display: none !important; }
  .nav-sep { display: none !important; }
  #how-it-works-btn { display: none !important; }
  #auth-user-label { display: none !important; }

  /* Sidebar — full width drawer on mobile */
  #filter-sidebar {
    width: 100% !important;
    max-width: 100% !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 56px !important;
    z-index: 200 !important;
    transform: translateX(-100%) !important;
    transition: transform 0.25s ease !important;
  }

  #filter-sidebar.mobile-open {
    transform: translateX(0) !important;
  }

  /* Main content — full width */
  .app-main {
    padding-left: 0 !important;
    padding-bottom: 56px !important;
  }

  /* Results area */
  .results-panel {
    flex-direction: column !important;
  }

  /* Property cards — single column */
  #results-body {
    grid-template-columns: 1fr !important;
    padding: 8px !important;
    gap: 8px !important;
  }

  /* Card layout tighter on mobile */
  .property-card {
    padding: 12px !important;
    max-width: 100% !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }

  .card-content-col {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .card-header-row {
    flex-wrap: wrap !important;
  }

  .card-call-priority {
    flex-shrink: 1 !important;
    white-space: normal !important;
    max-width: 100% !important;
  }

  .card-footer-row {
    flex-wrap: wrap !important;
  }

  .card-actions {
    flex-wrap: wrap !important;
    max-width: 100% !important;
  }

  .card-btn-analyze,
  .card-btn-pipeline {
    white-space: normal !important;
    max-width: 100% !important;
  }

  .card-photo {
    width: 60px !important;
    height: 60px !important;
    min-width: 60px !important;
  }

  /* KPI bar — 2 columns on mobile */
  .kpi-summary-bar {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    flex-wrap: wrap !important;
    overflow: hidden !important;
    gap: 6px !important;
    padding: 8px !important;
  }

  .kpi-summary-bar .kpi-card {
    flex: unset !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  #results-count {
    position: static !important;
    width: 100% !important;
    display: block !important;
    margin-bottom: 0.5rem !important;
  }

  .results-header-bar {
    height: auto !important;
    min-height: 0 !important;
    flex-wrap: wrap !important;
    overflow: visible !important;
  }

  .results-panel.view-split .results-body-row {
    flex-direction: column !important;
  }

  .results-panel.view-split #map-panel.active {
    order: -1 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 250px !important;
    min-height: 250px !important;
    flex: 0 0 250px !important;
    position: relative !important;
    top: auto !important;
  }

  .results-panel.view-split #results-table-wrap {
    order: 1 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: none !important;
  }

  .kpi-card--spread { display: none !important; }

  /* Quick search buttons — scrollable row */
  .quick-search-bar {
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch !important;
    padding-bottom: 4px !important;
    scrollbar-width: none !important;
  }

  .quick-search-bar::-webkit-scrollbar { display: none !important; }

  /* Recently viewed — scrollable */
  #recently-viewed-bar {
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
  }

  #recently-viewed-bar::-webkit-scrollbar { display: none !important; }

  /* Map — full height on mobile */
  #map-panel {
    min-height: 300px !important;
    height: 300px !important;
  }

  /* Results count bar */
  .results-toolbar {
    flex-wrap: wrap !important;
    gap: 6px !important;
    padding: 6px 10px !important;
  }

  /* View toggle buttons — smaller */
  .view-toggle-btn {
    padding: 4px 8px !important;
    font-size: 11px !important;
  }

  /* Sort dropdown */
  .sort-select {
    font-size: 11px !important;
    padding: 4px 6px !important;
  }

  /* Upgrade modal — full screen on mobile */
  #upgrade-modal > div {
    margin: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    overflow-y: auto !important;
  }

  #upgrade-plan-cards {
    grid-template-columns: 1fr !important;
  }

  /* Property modal — full screen on mobile */
  #property-modal > div {
    margin: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    overflow-y: auto !important;
  }

  /* Florida deal feed — 2 columns on mobile */
  #feed-items {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Sign in banner */
  .sign-in-cta-banner .max-w-7xl {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  /* Footer */
  .account-footer,
  footer {
    padding: 12px !important;
    font-size: 11px !important;
  }
}

/* Slightly larger phones and small tablets */
@media (min-width: 481px) and (max-width: 768px) {
  #results-body {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}
