@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ── Design tokens ──────────────────────────────────────────────────────────── */
:root {
  /* Surfaces — layered dark palette */
  --bg:        #09090f;
  --surface-1: #0f1017;
  --surface-2: #14151d;
  --surface-3: #1a1b26;
  --surface-4: #21222e;

  /* Accent — violet */
  --accent:      #8b5cf6;
  --accent-dk:   #7c3aed;
  --accent-lt:   #a78bfa;
  --accent-glow: rgba(139, 92, 246, 0.14);
  --accent-ring: rgba(139, 92, 246, 0.35);

  /* Text */
  --text-1: #eeeef4;
  --text-2: #9898ae;
  --text-3: #55556a;

  /* Borders */
  --border:       rgba(255, 255, 255, 0.07);
  --border-hover: rgba(255, 255, 255, 0.14);

  /* Shadows */
  --shadow-sm:     0 1px 4px  rgba(0,0,0,.55);
  --shadow-md:     0 4px 20px rgba(0,0,0,.60);
  --shadow-accent: 0 8px 32px rgba(139, 92, 246, 0.26);

  /* Layout */
  --nav-h:     60px;
  --sidebar-w: 280px;
  --radius:    12px;
  --radius-sm:  8px;
  --radius-xs:  6px;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-1);
  background: var(--bg);
  background-image: radial-gradient(circle, rgba(255,255,255,0.022) 1px, transparent 1px);
  background-size: 28px 28px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s, opacity 0.15s;
  letter-spacing: 0.01em;
}
.btn:disabled  { opacity: .45; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dk) 100%);
  color: #fff;
  box-shadow: 0 2px 10px rgba(139,92,246,.35);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--accent-lt) 0%, var(--accent) 100%);
  box-shadow: 0 4px 20px rgba(139,92,246,.45);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: var(--border-hover);
  color: var(--text-1);
}

.btn-sm    { padding: 6px 12px; font-size: 12px; }
.btn-full  { width: 100%; }
.btn-icon  { padding: 8px; }

/* ── Form elements ──────────────────────────────────────────────────────────── */
.field       { display: flex; flex-direction: column; gap: 6px; }
.field-group { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.label-hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 11px;
  color: var(--text-3);
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
select {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-family: inherit;
  font-size: 13px;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  appearance: none;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent-ring);
  background: var(--surface-4);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
input::placeholder { color: var(--text-3); }
select option { background: var(--surface-3); color: var(--text-1); }

.form-error {
  font-size: 13px;
  color: #f87171;
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.2);
  border-radius: var(--radius-xs);
  padding: 8px 12px;
}
.form-success {
  font-size: 13px;
  color: #4ade80;
  background: rgba(74, 222, 128, 0.08);
  border: 1px solid rgba(74, 222, 128, 0.2);
  border-radius: var(--radius-xs);
  padding: 8px 12px;
}

/* ── Utilities ──────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Auth page ──────────────────────────────────────────────────────────────── */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  overflow: hidden;
  position: relative;
}

/* Full-viewport canvas sits behind everything */
.bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

/* Animated gradient blobs */
.bg-blob {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
  will-change: transform;
}

.bg-blob-1 {
  width: 560px;
  height: 560px;
  top: -180px;
  left: -140px;
  background: radial-gradient(circle, rgba(124,58,237,0.55) 0%, transparent 68%);
  filter: blur(90px);
  animation: blob-1 20s ease-in-out infinite;
}

.bg-blob-2 {
  width: 640px;
  height: 640px;
  bottom: -220px;
  right: -180px;
  background: radial-gradient(circle, rgba(168,85,247,0.45) 0%, transparent 68%);
  filter: blur(100px);
  animation: blob-2 26s ease-in-out infinite;
}

.bg-blob-3 {
  width: 380px;
  height: 380px;
  top: 38%;
  left: 42%;
  background: radial-gradient(circle, rgba(99,102,241,0.40) 0%, transparent 68%);
  filter: blur(80px);
  animation: blob-3 32s ease-in-out infinite;
}

@keyframes blob-1 {
  0%,100% { transform: translate(0,0) scale(1); }
  25%     { transform: translate(55px,-45px) scale(1.07); }
  50%     { transform: translate(15px, 65px) scale(0.94); }
  75%     { transform: translate(-45px,15px) scale(1.04); }
}
@keyframes blob-2 {
  0%,100% { transform: translate(0,0) scale(1); }
  33%     { transform: translate(-55px,35px) scale(1.06); }
  66%     { transform: translate(35px,-65px) scale(0.93); }
}
@keyframes blob-3 {
  0%,100% { transform: translate(0,0) scale(1); }
  50%     { transform: translate(50px,-40px) scale(1.12); }
}

/* Auth card — glassmorphism, floats above the blobs */
.auth-card {
  width: 100%;
  max-width: 400px;
  background: rgba(9, 9, 15, 0.78);
  border: 1px solid rgba(139, 92, 246, 0.22);
  border-radius: var(--radius);
  padding: 40px 36px;
  box-shadow: var(--shadow-md), 0 0 80px rgba(139, 92, 246, 0.07);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  animation: fadeUp .45s ease both;
  position: relative;
  z-index: 10;
}

/* Subtle top-edge highlight on the card */
.auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 12%;
  right: 12%;
  height: 1px;
  background: linear-gradient(90deg,
    transparent,
    rgba(167,139,250,0.55) 35%,
    rgba(139,92,246,0.55) 65%,
    transparent
  );
  border-radius: 1px;
}

.auth-logo {
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 9px;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #c4b5fd 0%, #8b5cf6 55%, #7c3aed 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.auth-logo-icon { /* inherits gradient from parent */ }
.auth-tagline   { color: var(--text-3); font-size: 13px; margin: 6px 0 28px; }

.auth-card .field { margin-bottom: 16px; }
.auth-card .form-error { margin-bottom: 12px; }
.auth-card label { color: var(--text-2); }

.auth-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-3);
}
.auth-footer a { color: var(--accent); }

/* ── Dashboard layout ───────────────────────────────────────────────────────── */
.dash-body { min-height: 100vh; background: var(--bg); }

.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: rgba(9, 9, 15, 0.90);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(139,92,246,0.18);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 200;
}
.navbar-brand {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #c4b5fd 0%, #8b5cf6 55%, #7c3aed 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.brand-icon {
  -webkit-text-fill-color: transparent;
  background: linear-gradient(135deg, #c4b5fd, #8b5cf6);
  -webkit-background-clip: text;
  background-clip: text;
}
.navbar-right { display: flex; align-items: center; gap: 10px; }
.navbar-user  { font-size: 13px; color: var(--text-3); }

.filter-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  letter-spacing: 0.01em;
}
.filter-toggle-btn:hover {
  background: var(--surface-3);
  border-color: var(--border-hover);
  color: var(--text-1);
}
.filter-toggle-btn.active {
  background: var(--accent-glow);
  border-color: rgba(139,92,246,.35);
  color: var(--accent-lt);
}

.dash-layout {
  display: flex;
  padding-top: var(--nav-h);
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  padding: 24px 18px 32px;
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scrollbar-width: none;
  transition: width 0.28s ease, padding 0.28s ease, opacity 0.28s ease, border-color 0.28s ease;
}
.sidebar::-webkit-scrollbar { display: none; }

/* Desktop: collapsed sidebar */
.dash-layout.filters-hidden .sidebar {
  width: 0;
  padding-left: 0;
  padding-right: 0;
  opacity: 0;
  border-right-color: transparent;
  overflow: hidden;
  pointer-events: none;
}

/* Backdrop for mobile sidebar overlay */
.sidebar-backdrop {
  display: none;
}

.sidebar-heading {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.sidebar-section      { display: flex; flex-direction: column; gap: 14px; }
.sidebar-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: -4px;
}

.sidebar-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }

.save-status { font-size: 13px; text-align: center; }

/* ── Main content ───────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 28px 28px 48px;
}

/* ── Content tabs ───────────────────────────────────────────────────────────── */
.content-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.content-tab {
  padding: 10px 18px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.content-tab:hover  { color: var(--text-2); }
.content-tab.active { color: var(--text-1); border-bottom-color: var(--accent); }

.content-pane { display: flex; flex-direction: column; gap: 20px; }

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.pane-title-row   { display: flex; align-items: center; gap: 12px; }
.pane-title       { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }

.result-count {
  display: inline-flex;
  align-items: center;
  background: var(--accent-glow);
  color: var(--accent-lt);
  border: 1px solid rgba(139,92,246,.28);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
}

.pane-last-fetch  { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.pane-header-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

/* ── SSE live status indicator ──────────────────────────────────────────────── */
.sse-status { display: flex; align-items: center; gap: 6px; }
.sse-label  { font-size: 12px; color: var(--text-3); }
.sse-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sse-live         { background: #22c55e; box-shadow: 0 0 6px #22c55e88; animation: sse-pulse 2s ease infinite; }
.sse-reconnecting { background: var(--text-3); }

@keyframes sse-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ── Skeleton loading ───────────────────────────────────────────────────────── */
#listings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }

.skeleton-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.skeleton-img {
  width: 100%;
  aspect-ratio: 16/10;
  background: var(--surface-3);
}
.skeleton-body { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.skeleton-line {
  height: 13px;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    var(--surface-3) 25%,
    var(--surface-4) 50%,
    var(--surface-3) 75%
  );
  background-size: 300% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
}
.skeleton-line.w-60 { width: 60%; }
.skeleton-line.w-40 { width: 40%; }
.skeleton-line.w-80 { width: 80%; }

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

/* ── Listing cards ──────────────────────────────────────────────────────────── */
.listing-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}
.listing-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-accent);
  border-color: rgba(139,92,246,.35);
}

.listing-thumb {
  width: 100%;
  aspect-ratio: 16/10;
  overflow: hidden;
  background: var(--surface-3);
  position: relative;
}
.listing-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}
.listing-card:hover .listing-thumb img { transform: scale(1.05); }

.listing-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  opacity: .35;
  background: var(--surface-3);
}

.listing-badge {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(12,13,18,.82);
  backdrop-filter: blur(8px);
  color: var(--text-1);
  font-size: 15px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: var(--radius-xs);
  letter-spacing: -0.02em;
}

.listing-body { padding: 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }

.listing-addr {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-1);
  line-height: 1.35;
}
.listing-addr a { color: var(--text-1); }
.listing-addr a:hover { color: var(--accent); }
.listing-city { font-size: 12px; color: var(--text-3); margin-top: -6px; }

.listing-specs { display: flex; flex-wrap: wrap; gap: 6px; }
.listing-spec {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
}

.listing-desc {
  font-size: 13px;
  color: var(--text-3);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.listing-footer {
  margin-top: auto;
  padding-top: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.listing-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.2s, transform 0.2s;
}
.listing-card:hover .listing-link { opacity: 1; transform: translateX(0); }

/* ── Live update animations ─────────────────────────────────────────────────── */
@keyframes slide-in {
  from { opacity: 0; transform: translateY(-12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)      scale(1);   }
}

.listing-card.is-new { animation: slide-in 0.3s ease forwards; }

.listing-new-badge {
  position: absolute;
  top: 10px; left: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 4px;
  pointer-events: none;
}

.price-delta {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.75;
  margin-left: 4px;
}

@keyframes price-flash {
  0%   { box-shadow: 0 0 0 0 rgba(34,197,94,.5); }
  70%  { box-shadow: 0 0 0 8px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

.listing-card.price-changed { animation: price-flash 0.6s ease; }

/* ── Enrichment pills (WOZ / Koopsom) ───────────────────────────────────────── */
.enrich-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: -2px;
}

.enrich-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--surface-4);
  color: var(--text-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.enrich-pill.enrich-woz-above {
  background: rgba(255, 85, 51, 0.12);
  border-color: rgba(255, 85, 51, 0.25);
  color: #ff8066;
}

.enrich-pill.enrich-woz-below {
  background: rgba(34, 197, 94, 0.10);
  border-color: rgba(34, 197, 94, 0.25);
  color: #4ade80;
}

.enrich-pill.enrich-tx {
  background: rgba(99, 102, 241, 0.10);
  border-color: rgba(99, 102, 241, 0.25);
  color: #a5b4fc;
}

.enrich-delta {
  font-weight: 600;
  opacity: 0.9;
}

/* Energy label tiers — Dutch standard colours */
.enrich-label { font-weight: 700; letter-spacing: 0.02em; min-width: 36px; justify-content: center; }

.enrich-label-aplus   { background: rgba(0, 154, 68,  0.18); border-color: rgba(0, 154, 68,  0.40); color: #4ade80; }
.enrich-label-a       { background: rgba(141, 198, 63, 0.15); border-color: rgba(141, 198, 63, 0.35); color: #a3e635; }
.enrich-label-b       { background: rgba(198, 214, 38, 0.15); border-color: rgba(198, 214, 38, 0.35); color: #d4e44a; }
.enrich-label-c       { background: rgba(240, 237, 0,  0.12); border-color: rgba(240, 237, 0,  0.30); color: #facc15; }
.enrich-label-d       { background: rgba(247, 166, 0,  0.15); border-color: rgba(247, 166, 0,  0.35); color: #fb923c; }
.enrich-label-e       { background: rgba(241, 90,  34, 0.15); border-color: rgba(241, 90,  34, 0.35); color: #f97316; }
.enrich-label-f       { background: rgba(237, 27,  36, 0.15); border-color: rgba(237, 27,  36, 0.35); color: #f87171; }
.enrich-label-g       { background: rgba(190, 22,  34, 0.18); border-color: rgba(190, 22,  34, 0.40); color: #fca5a5; }
.enrich-label-unknown { background: var(--surface-4); color: var(--text-3); }

/* ── Status / empty ─────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 60px 20px;
  color: var(--text-3);
  text-align: center;
  grid-column: 1 / -1;
}
.empty-state-icon { font-size: 36px; opacity: .4; }

.status-msg {
  padding: 10px 14px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  grid-column: 1 / -1;
}
.status-msg.error   { background: rgba(248,113,113,.08); border: 1px solid rgba(248,113,113,.2); color: #f87171; }
.status-msg.success { background: rgba(74,222,128,.08);  border: 1px solid rgba(74,222,128,.2);  color: #4ade80; }

/* ── Subscriptions ──────────────────────────────────────────────────────────── */
.sub-add-row { display: flex; gap: 10px; }
.sub-add-row input { flex: 1; }

.subs-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.sub-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s;
}
.sub-item:hover { border-color: var(--border-hover); }
.sub-item-left { display: flex; flex-direction: column; gap: 2px; }
.sub-email { font-size: 14px; font-weight: 500; color: var(--text-1); }
.sub-date  { font-size: 12px; color: var(--text-3); }
.sub-remove {
  background: transparent;
  border: 1px solid rgba(248,113,113,.2);
  color: #f87171;
  border-radius: var(--radius-xs);
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: inherit;
}
.sub-remove:hover { background: rgba(248,113,113,.1); border-color: rgba(248,113,113,.4); }

/* ── Animations ─────────────────────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.listing-card {
  animation: fadeUp .3s ease both;
}
/* Stagger cards via nth-child */
.listing-card:nth-child(1)  { animation-delay: .04s; }
.listing-card:nth-child(2)  { animation-delay: .08s; }
.listing-card:nth-child(3)  { animation-delay: .12s; }
.listing-card:nth-child(4)  { animation-delay: .16s; }
.listing-card:nth-child(5)  { animation-delay: .20s; }
.listing-card:nth-child(6)  { animation-delay: .24s; }
.listing-card:nth-child(7)  { animation-delay: .28s; }
.listing-card:nth-child(8)  { animation-delay: .32s; }
.listing-card:nth-child(9)  { animation-delay: .36s; }
.listing-card:nth-child(10) { animation-delay: .40s; }

/* ── Property detail drawer ──────────────────────────────────────────────────── */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 199;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.drawer-backdrop.open { opacity: 1; pointer-events: all; }

.drawer {
  position: fixed;
  top: 0; right: 0;
  width: 440px;
  max-width: 100vw;
  height: 100vh;
  background: var(--surface-1);
  border-left: 1px solid var(--border);
  z-index: 200;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  box-shadow: -12px 0 48px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
}
.drawer.open { transform: translateX(0); }

.drawer-close {
  position: sticky;
  top: 0;
  align-self: flex-end;
  z-index: 10;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: 50%;
  width: 32px; height: 32px;
  font-size: 14px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  margin: 12px 12px 0 0;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
  font-family: inherit;
}
.drawer-close:hover { background: var(--surface-3); color: var(--text-1); }

.drawer-content { flex: 1; }

.drawer-img { width: 100%; aspect-ratio: 16 / 9; overflow: hidden; }
.drawer-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.drawer-img-placeholder {
  width: 100%; aspect-ratio: 16 / 9;
  background: var(--surface-3);
  display: flex; align-items: center; justify-content: center;
  font-size: 48px; color: var(--text-3);
}

.drawer-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }

.drawer-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.drawer-addr     { font-size: 17px; font-weight: 700; color: var(--text-1); line-height: 1.3; }
.drawer-location { font-size: 13px; color: var(--text-3); margin-top: 3px; }

.drawer-price-row { display: flex; align-items: baseline; gap: 10px; }
.drawer-price     { font-size: 24px; font-weight: 700; color: var(--accent); }
.drawer-tx-type   { font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; }

.drawer-section { display: flex; flex-direction: column; gap: 10px; }
.drawer-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
}

.drawer-desc { font-size: 13px; color: var(--text-2); line-height: 1.65; }

.drawer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 4px;
}
.drawer-first-seen { font-size: 12px; color: var(--text-3); }

.drawer-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 0;
}
.drawer-spinner {
  width: 28px; height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.drawer-no-history { font-size: 13px; color: var(--text-3); }

/* ── Valuation comparison bars ───────────────────────────────────────────────── */

.vbar-row {
  display: grid;
  grid-template-columns: 90px 1fr 90px;
  align-items: center;
  gap: 10px;
}
.vbar-label { font-size: 12px; color: var(--text-3); text-align: right; white-space: nowrap; }
.vbar-value { font-size: 12px; color: var(--text-2); font-weight: 500; white-space: nowrap; }

.vbar-track {
  height: 8px;
  background: var(--surface-3);
  border-radius: 4px;
  overflow: hidden;
}
.vbar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}
.vbar-asking { background: var(--accent); }
.vbar-woz    { background: #6366f1; }
.vbar-tx     { background: #a78bfa; }

/* ── Price history chart ─────────────────────────────────────────────────────── */

.price-chart {
  width: 100%;
  height: 72px;
  display: block;
  border-radius: var(--radius-xs);
  overflow: hidden;
}

.chart-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-3);
  margin-top: -2px;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */

/* Tablet / wide mobile */
@media (max-width: 900px) {
  .main-content { padding: 20px 20px 48px; }
}

/* Mobile — sidebar becomes a full-screen overlay */
@media (max-width: 767px) {
  body { overflow-x: hidden; }

  .navbar { padding: 0 14px; }
  .navbar-brand { font-size: 15px; }
  .navbar-user { display: none; }

  .dash-layout { display: block; }

  .sidebar {
    position: fixed;
    top: var(--nav-h);
    left: 0;
    right: 0;
    bottom: 0;
    width: 100% !important;
    height: calc(100vh - var(--nav-h));
    padding: 20px 16px 40px;
    z-index: 198;
    opacity: 1 !important;
    overflow-y: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    /* Off-screen by default */
    transform: translateX(-100%);
    transition: transform 0.26s ease;
    pointer-events: none !important;
  }

  .sidebar.sidebar-open {
    transform: translateX(0);
    pointer-events: all !important;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.60);
    z-index: 197;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }
  .sidebar-backdrop.open {
    opacity: 1;
    pointer-events: all;
  }

  .main-content {
    width: 100%;
    max-width: 100%;
    padding: 18px 14px 56px;
    overflow: hidden;
  }

  #listings-grid {
    grid-template-columns: 1fr;
  }

  .pane-header {
    flex-wrap: wrap;
    gap: 10px;
  }
  .pane-title { font-size: 17px; }
  .pane-header-right { width: 100%; justify-content: space-between; }

  .content-tabs { overflow-x: auto; scrollbar-width: none; }
  .content-tabs::-webkit-scrollbar { display: none; }

  .drawer { width: 100vw; }

  .vbar-row { grid-template-columns: 70px 1fr 80px; }
  #favs-grid { grid-template-columns: 1fr; }
}

/* ── Tab count badge ─────────────────────────────────────────────────────────── */
.tab-count {
  display: inline-flex;
  align-items: center;
  background: var(--accent-glow);
  color: var(--accent-lt);
  border: 1px solid rgba(139,92,246,.28);
  border-radius: 20px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 5px;
  vertical-align: middle;
}

/* ── Favourite (heart) button on listing cards ────────────────────────────────── */
.card-fav-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 13, 18, 0.72);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-2);
  transition: color 0.18s, background 0.18s, border-color 0.18s, transform 0.15s;
  z-index: 2;
  padding: 0;
  flex-shrink: 0;
}
.card-fav-btn svg { width: 15px; height: 15px; pointer-events: none; }
.card-fav-btn:hover {
  color: #f472b6;
  border-color: rgba(244,114,182,.4);
  background: rgba(244,114,182,.1);
  transform: scale(1.12);
}
.card-fav-btn.is-fav {
  color: #f472b6;
  background: rgba(244,114,182,.15);
  border-color: rgba(244,114,182,.45);
}
.card-fav-btn.is-fav:hover { transform: scale(1.12); }

/* Pop animation when toggling */
@keyframes fav-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.35); }
  70%  { transform: scale(0.92); }
  100% { transform: scale(1); }
}
.card-fav-btn.pop { animation: fav-pop 0.32s ease forwards; }

/* ── Star rating (drawer) ────────────────────────────────────────────────────── */
.drawer-rating-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.drawer-rating-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  white-space: nowrap;
}
.star-rating {
  display: flex;
  gap: 3px;
}
.star-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  color: var(--surface-4);
  padding: 0 2px;
  line-height: 1;
  transition: color 0.12s, transform 0.1s;
  font-family: inherit;
}
.star-btn:hover          { color: #facc15; transform: scale(1.2); }
.star-btn.active         { color: #facc15; }
/* Cascade highlight on hover: all stars up to hovered one turn yellow */
.star-rating:has(.star-btn:nth-child(1):hover) .star-btn:nth-child(1) { color: #facc15; }
.star-rating:has(.star-btn:nth-child(2):hover) .star-btn:nth-child(-n+2) { color: #facc15; }
.star-rating:has(.star-btn:nth-child(3):hover) .star-btn:nth-child(-n+3) { color: #facc15; }
.star-rating:has(.star-btn:nth-child(4):hover) .star-btn:nth-child(-n+4) { color: #facc15; }
.star-rating:has(.star-btn:nth-child(5):hover) .star-btn:nth-child(-n+5) { color: #facc15; }

.drawer-fav-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.drawer-fav-btn svg { width: 13px; height: 13px; flex-shrink: 0; }
.drawer-fav-btn:hover {
  color: #f472b6;
  border-color: rgba(244,114,182,.35);
  background: rgba(244,114,182,.08);
}
.drawer-fav-btn.is-fav {
  color: #f472b6;
  border-color: rgba(244,114,182,.4);
  background: rgba(244,114,182,.1);
}

/* ── Favourites grid ─────────────────────────────────────────────────────────── */
#favs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

/* Rating badge overlaid on fav-grid cards */
.card-rating-badge {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(250,204,21,.18);
  border: 1px solid rgba(250,204,21,.35);
  border-radius: var(--radius-xs);
  color: #facc15;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  letter-spacing: 0.02em;
  pointer-events: none;
}
