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

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

:root {
  --ink: #3B4FC4;
  --ink-light: #4a5bc9;
  --cream: #faf7f2;
  --paper: #ffffff;
  --card-elevated: #ffffff;
  --row-alt: #faf8f4;
  --charcoal: #36454f;
  --gold: #18E9D9;
  --gold-light: #6ff0e6;
  --gold-pale: #f3ead9;
  --border: #e6e1d8;
  --red: #c0392b;
  --green: #1a6b3c;
  --shadow: 0 2px 16px rgba(59,79,196,0.10);
  --shadow-lg: 0 8px 40px rgba(59,79,196,0.15);
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
}

/* HEADER — always uses the BRANDING colours (--brand-primary / --brand-accent),
   never the resettable Theme Colours palette, so the top banner stays
   consistent regardless of light/dark theme customisation. */
.site-header {
  background: var(--brand-primary, var(--ink));
  padding: 0 2.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
  position: relative; /* anchors the horizontally-centered company logo below */
}

.header-company-logo {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-height: 48px;
  max-width: 240px;
  object-fit: contain;
  display: none;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.logo-badge {
  background: var(--brand-accent, var(--gold));
  color: var(--brand-primary, var(--ink));
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 1rem;
  padding: 4px 10px;
  letter-spacing: 0.08em;
}

.logo-text {
  /* Company name / slogan always render in the branding accent colour,
     independent of theme colours. */
  color: var(--brand-accent, var(--gold));
  font-size: 0.75rem;
  font-weight: 300;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  line-height: 1.3;
}

.site-nav { display: flex; gap: 0.5rem; align-items: center; }

.nav-link {
  color: rgba(248,246,241,0.7);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.4rem 0.9rem;
  border-radius: 2px;
  transition: color 0.2s, background 0.2s;
}

.nav-link:hover, .nav-link.active {
  color: var(--gold);
  background: rgba(184,150,12,0.1);
}

/* PAGE WRAPPER */
.page-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 3rem 2rem 4rem;
}

.page-title {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  color: var(--ink);
  margin-bottom: 0.4rem;
  font-weight: 700;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--ink-light);
  font-weight: 300;
  letter-spacing: 0.05em;
  margin-bottom: 2.5rem;
  text-transform: uppercase;
}

/* DIVIDER */
.section-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 2rem 0 1.5rem;
}
.section-divider span {
  font-family: 'Playfair Display', serif;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold);
  white-space: nowrap;
  font-weight: 700;
}
.section-divider::before, .section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* FORM CARD */
.form-card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2rem 2.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

/* FORM GRID */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.5rem; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem 1.5rem; }
.form-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem 1rem; }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }
.col-span-4 { grid-column: span 4; }

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-light);
}

input[type="text"], input[type="number"], input[type="email"],
input[type="tel"], input[type="date"], input[type="password"],
select, textarea {
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--paper);
  color: var(--ink);
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(184,150,12,0.12);
}

textarea { resize: vertical; min-height: 70px; }

/* RADIO CHECKBOXES */
.check-group { display: flex; gap: 1.5rem; align-items: center; padding-top: 0.5rem; }
.check-group label { font-size: 0.8rem; text-transform: none; letter-spacing: 0; display: flex; align-items: center; gap: 0.4rem; color: var(--ink); font-weight: 400; cursor: pointer; }
.check-group input[type="checkbox"], .check-group input[type="radio"] { width: auto; accent-color: var(--gold); }

/* BUTTONS */
.btn {
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.75rem 2rem;
  border: none;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-block;
}

.btn-primary {
  background: var(--ink);
  color: var(--cream);
}
.btn-primary:hover { background: #0e0689; }

.btn-gold {
  background: var(--gold);
  color: var(--ink);
}
.btn-gold:hover { background: #e6b32f; }

.btn-outline {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--ink); }

.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #a93226; }

/* TOAST */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 1rem 1.5rem;
  border-radius: 3px;
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 9999;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
  max-width: 340px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--green); color: white; }
.toast.error { background: var(--red); color: white; }

/* LISTING NUMBER BANNER */
.listing-banner {
  background: var(--gold-pale);
  border: 1px solid var(--gold-light);
  border-left: 4px solid var(--gold);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.82rem;
}
.listing-banner strong { font-family: 'Playfair Display', serif; font-size: 1.1rem; color: var(--gold); }

/* TABLE */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.data-table th {
  background: var(--brand-primary, var(--ink));
  color: #fff;
  padding: 0.65rem 1rem;
  text-align: left;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
}
.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.data-table tbody tr:hover td { background: var(--gold-pale) !important; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 2px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
/* .pill-tag: identical to the block above, under its own name.
   FIX: this file had two separate ".badge" rules -- this one (a plain
   inline pill, used by the Listings/Leads admin tables and the record
   drawer for status/type labels) and a second one further down (a
   position:absolute corner-ribbon style, used only for "Featured"/"New"
   ribbons on public listing CARDS). Both used the literal class name
   "badge", so the LATER rule in the file (position:absolute) won the
   cascade for every element with that class, including the admin ones --
   that's what was pushing the drawer's Residential/Rent/Open pills up and
   out of flow, overlapping the title. The admin/internal usages
   (listings.html, leads.html) were switched to this class instead;
   .badge/.badge-featured/.badge-new stay exactly as they were, only used
   by lib/publicTemplates.js's server-rendered public listing cards, so
   they can no longer collide with anything else. The colour sub-classes
   (.badge-res/-com/-sale/-rent) only ever set background/colour, never
   position, so they're safe to keep sharing between both. */
.pill-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 2px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.badge-res { background: #e8f4fd; color: #1a5276; }
.badge-com { background: #fef9e7; color: #7d6608; border: 1px solid var(--gold-light); }
.badge-sale { background: #eafaf1; color: #1a6b3c; }
.badge-rent { background: #fdedec; color: #922b21; }

/* MODAL */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(26,26,46,0.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--paper);
  border-radius: 4px;
  padding: 2.5rem;
  max-width: 460px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.25s;
}
.docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.9rem;
}
.doc-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--cream);
}
.doc-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-light);
  cursor: pointer;
}
.doc-check input { width: auto; accent-color: var(--gold); }
.doc-item input[type="file"] {
  font-size: 0.75rem;
  padding: 0.3rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--paper);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-lg {
  max-width: 720px;
  width: 92%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.modal-lg .modal-header {
  padding: 1.5rem 2rem 1rem;
  border-bottom: 1px solid var(--border);
}
.modal-lg .modal-header h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
  margin: 0;
}
.modal-lg .modal-body {
  padding: 1.5rem 2rem;
  overflow-y: auto;
  font-size: 0.82rem;
  line-height: 1.7;
  color: var(--ink-light);
  flex: 1;
}
.modal-lg .modal-body h3 {
  font-size: 0.85rem;
  color: var(--ink);
  margin: 1.25rem 0 0.4rem;
  letter-spacing: 0.02em;
}
.modal-lg .modal-body h3:first-child { margin-top: 0; }
.modal-lg .modal-body p { margin: 0 0 0.6rem; }
.modal-lg .modal-footer {
  padding: 1rem 2rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.modal-lg .scroll-hint {
  font-size: 0.72rem;
  color: var(--ink-light);
  font-style: italic;
}
.declaration-box {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: var(--gold-pale);
  border: 1px solid var(--gold-light);
  font-size: 0.8rem;
  line-height: 1.7;
  color: var(--ink);
}
.declaration-box .terms-link {
  color: var(--gold);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  font-family: inherit;
}
.declaration-check {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-top: 0.9rem;
  font-size: 0.8rem;
  color: var(--ink);
}
.declaration-check input { margin-top: 0.2rem; }
.declaration-check label.disabled { color: var(--ink-light); }

/* RESPONSIVE */
@media (max-width: 640px) {
  .form-grid, .form-grid-3, .form-grid-4 { grid-template-columns: 1fr 1fr; }
  .col-span-3, .col-span-4 { grid-column: span 2; }
  .form-card { padding: 1.25rem; }
  .page-container { padding: 1.5rem 1rem; }
}

/* ── Settings dropdown ───────────────────────────────────────────────────── */
#settingsDropdown,
#agentOptionsDropdown {
  background: var(--paper, #fff);
  border: 1px solid var(--border, #d6d9e0);
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.settings-menu-btn {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.7rem 1.1rem;
  background: none;
  border: none;
  border-top: none;
  border-right: none;
  border-left: none;
  text-align: left;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--brand-primary, #1208AF);
  font-weight: 400;
  font-family: inherit;
}
.settings-menu-btn:hover {
  background: var(--cream, #f8f6f2) !important;
}

/* ══════════════════════════════════════════════════════════════════
   DARK MODE  (body.dark-mode)
   Palette derived from the new brand mark's gradient (teal → indigo),
   deepened into indigo-tinted dark surfaces rather than neutral navy/grey,
   so dark mode still visibly reads as "REVR CRM" rather than a generic
   dark theme. Brand primary/accent kept for header & buttons.
══════════════════════════════════════════════════════════════════ */
body.dark-mode {
  /* Bug fix: this block used to redeclare --dm-surface-0..4, --dm-text,
     --dm-text-muted, --ink, --ink-light, --cream, --paper, --border,
     --gold-pale, and more with its own competing indigo/navy palette,
     completely overriding app-chrome.css's canonical grey dark palette
     on this one page only (listings.html is the only page that loads
     this file). Every other page (Leads, KYC, all of portal/*) always
     showed the correct canonical grey dark theme; Listings alone showed
     this different navy one -- confirmed as the actual root cause of the
     "Listings shows the wrong dark colours" bug, not a rendering issue.
     Now only declares the handful of values that are genuinely unique to
     this page and not covered by app-chrome.css's canonical block at
     all (--charcoal, --gold/--gold-light, --red/--green, shadows, the
     settings-menu divider, --dm-accent), and relies entirely on
     app-chrome.css (loaded before this file) for everything else. */
  --charcoal:   #8A97A5;          /* secondary text */
  --gold:       #31C0DF;          /* new dark-theme accent — logo wordmark colour, 8.4:1 on dark surfaces */
  --gold-light: rgba(49,192,223,0.22);
  --red:        #e07070;
  --green:      #4ec994;          /* brighter green like screenshot "OK" */
  --shadow:     0 2px 16px rgba(0,0,0,0.55);
  --shadow-lg:  0 8px 40px rgba(0,0,0,0.65);
  --dm-accent:    #5F79EA;   /* raw logo indigo — secondary accent on dark, used sparingly */

  /* Settings menu divider */
  --settings-divider: #2e3152;

  background: var(--dm-surface-0);
  color: var(--dm-text);
}

/* ── Page background ── */
/* (dead `body.dark-mode body { ... }` rule removed here -- `body` can't
   be a descendant of itself, so it never matched anything; the block
   above already sets the real body background directly.) */

/* ── Site header: same brand-primary rule as light mode, just a stronger shadow ── */
body.dark-mode .site-header {
  background: var(--brand-primary, var(--ink));
  box-shadow: 0 2px 12px rgba(0,0,0,0.5);
}

/* ── Cards & panels ── */
body.dark-mode .db-panel,
body.dark-mode .db-stats-bar,
body.dark-mode .login-card,
body.dark-mode .edit-modal-box { background: var(--dm-surface-2); border-color: var(--dm-surface-3); color: var(--dm-text); }

/* ── Stat cards ── */
body.dark-mode .stat-card { background: var(--dm-surface-2); border-color: var(--dm-surface-3); }
body.dark-mode .stat-card .stat-num  { color: var(--brand-primary, var(--dm-accent)); }
body.dark-mode .stat-card .stat-label { color: var(--dm-text-muted); }

/* ── Table ── */
.data-table tbody tr:nth-child(even) td { background: var(--row-alt, transparent); }
body.dark-mode .table-wrap { background: var(--dm-surface-1); border-color: var(--dm-surface-3); }
body.dark-mode .data-table { background: var(--dm-surface-1); }
body.dark-mode .data-table thead tr { background: var(--brand-primary, #1208AF); }
body.dark-mode .data-table th { background: var(--brand-primary, #1208AF) !important; color: #fff !important; border-color: var(--dm-surface-4) !important; }
body.dark-mode .data-table td { background: transparent; border-color: var(--dm-surface-3); color: var(--dm-text); }
body.dark-mode .data-table tbody tr { background: transparent; }
body.dark-mode .data-table tbody tr:nth-child(even) td { background: var(--dm-surface-2); }
/* Fix: target td directly with higher specificity than the base rule */
body.dark-mode .data-table tbody tr:hover td,
body.dark-mode .data-table tr:hover td { background: var(--dm-surface-4) !important; }

/* ── Inputs ── */
body.dark-mode input[type="text"],
body.dark-mode input[type="email"],
body.dark-mode input[type="tel"],
body.dark-mode input[type="number"],
body.dark-mode input[type="date"],
body.dark-mode input[type="time"],
body.dark-mode input[type="password"],
body.dark-mode select,
body.dark-mode textarea {
  background: var(--dm-surface-3);
  color: var(--dm-text);
  border-color: var(--dm-surface-4);
}
body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder { color: var(--dm-text-muted); }
body.dark-mode input:focus,
body.dark-mode select:focus,
body.dark-mode textarea:focus { border-color: var(--dm-accent); outline: none; box-shadow: 0 0 0 2px rgba(139,124,246,0.22); }

/* ── Buttons — keep brand accent for primary action buttons ── */
body.dark-mode .btn-primary { background: var(--brand-primary, #1208AF) !important; color: #fff !important; }
body.dark-mode .btn-primary:hover { filter: brightness(1.15); }
body.dark-mode .btn-gold { background: var(--brand-accent, var(--gold)) !important; color: #1a1209 !important; }
body.dark-mode .btn-gold:hover { filter: brightness(1.1); }
body.dark-mode .btn-outline { background: var(--dm-surface-3); color: var(--dm-text); border-color: var(--dm-surface-4); }
body.dark-mode .btn-outline:hover { background: var(--dm-surface-4); }

/* ── Overlays ── */
body.dark-mode .edit-modal-header { background: var(--dm-surface-0); }
body.dark-mode .edit-modal-footer { background: var(--dm-surface-2); border-color: var(--dm-surface-3); }
body.dark-mode .edit-modal-overlay { background: rgba(0,0,0,0.75); }

/* ── Search bar / toolbar ── */
body.dark-mode .vw-table-search input,
body.dark-mode #searchInput { background: var(--dm-surface-3); color: var(--dm-text); border-color: var(--dm-surface-4); }

/* ── Calendar ── */
body.dark-mode .cal-grid-cell { background: var(--dm-surface-2); border-color: var(--dm-surface-3); color: var(--dm-text); }
body.dark-mode .cal-grid-cell:hover { background: var(--dm-surface-4); }
body.dark-mode .cal-grid-cell.today { border-color: var(--dm-accent); }
body.dark-mode .cal-grid-cell.selected { background: var(--dm-surface-4); }
body.dark-mode .cal-form-grid label { color: var(--dm-text-muted); }
body.dark-mode .cal-vw-item { background: var(--dm-surface-3); border-color: var(--dm-surface-4); }

/* ── Toast ── */
body.dark-mode .toast { background: var(--dm-surface-3); color: var(--dm-text); box-shadow: 0 4px 24px rgba(0,0,0,0.5); }

/* ── Stat numbers (top of page) ── */
body.dark-mode .stat-number { color: var(--brand-primary, var(--dm-accent)); }
body.dark-mode .stat-label  { color: var(--dm-text-muted); }

/* ── Filters / pills ── */
body.dark-mode .filter-pill { background: var(--dm-surface-3); color: var(--dm-text); border-color: var(--dm-surface-4); }
body.dark-mode .filter-pill.active { background: var(--brand-primary, var(--dm-accent)); color: #fff; border-color: var(--brand-primary, var(--dm-accent)); }

/* ── Section headers ── */
body.dark-mode h2, body.dark-mode h3, body.dark-mode h4 { color: var(--dm-text); }
body.dark-mode label { color: var(--dm-text-muted); }

/* ── Viewing detail overlay ── */
body.dark-mode #viewingDetailOverlay .vw-detail-box { background: var(--dm-surface-2); color: var(--dm-text); }
body.dark-mode .vw-filter-tab { background: var(--dm-surface-3); color: var(--dm-text-muted); border-color: var(--dm-surface-4); }
body.dark-mode .vw-filter-tab.active { background: var(--brand-primary, var(--dm-accent)); color: #fff; border-color: var(--brand-primary, var(--dm-accent)); }

/* ── Viewing notes textarea ── */
body.dark-mode #viewingNotesTA { background: var(--dm-surface-3); color: var(--dm-text); border-color: var(--dm-surface-4); }

/* ── Settings & Agent Options dropdowns in dark mode ── */
body.dark-mode #settingsDropdown,
body.dark-mode #agentOptionsDropdown {
  background: var(--dm-surface-2) !important;
  border-color: var(--dm-surface-3) !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5) !important;
}
body.dark-mode .settings-menu-btn { color: var(--dm-text) !important; }
body.dark-mode .settings-menu-btn:hover { background: var(--dm-surface-3) !important; }
body.dark-mode #darkModeToggleRow,
body.dark-mode #agentDarkModeRow { color: var(--dm-text) !important; }


/* ── Dark mode toggle switch ── */
.dm-toggle-wrap {
  display: flex; align-items: center; gap: 0.5rem;
}
.dm-toggle {
  position: relative; width: 36px; height: 20px; cursor: pointer;
}
.dm-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.dm-toggle-track {
  position: absolute; inset: 0;
  background: rgba(255,255,255,0.2);
  border-radius: 20px;
  transition: background 0.25s;
}
.dm-toggle input:checked + .dm-toggle-track { background: #8b7cf6; }
.dm-toggle-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 14px; height: 14px;
  background: #fff; border-radius: 50%;
  transition: transform 0.25s;
  pointer-events: none;
}
.dm-toggle input:checked ~ .dm-toggle-thumb { transform: translateX(16px); }

/* ── Viewings filter tabs ── */
.vw-filter-tabs {
  display: flex; gap: 0.4rem; margin-bottom: 0.75rem;
}
.vw-filter-tab {
  padding: 0.3rem 0.85rem; border-radius: 20px; border: 1px solid var(--border);
  background: var(--paper); color: var(--ink-light);
  font-size: 0.78rem; font-weight: 600; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.vw-filter-tab.active {
  background: var(--ink); color: #fff; border-color: var(--ink);
}
.vw-filter-tab:hover:not(.active) { background: var(--cream); }

/* ── Viewing detail overlay ── */
#viewingDetailOverlay {
  display: none; position: fixed; inset: 0;
  background: rgba(18,8,175,0.45); z-index: 10100;
  align-items: center; justify-content: center;
}
#viewingDetailOverlay.open { display: flex; }
.vw-detail-box {
  background: var(--paper); border-radius: 10px;
  width: 100%; max-width: 560px; max-height: 90vh;
  overflow-y: auto; box-shadow: 0 16px 64px rgba(18,8,175,0.3);
  margin: 1rem;
}
.vw-detail-header {
  background: var(--ink); color: #fff;
  padding: 1rem 1.4rem; border-radius: 10px 10px 0 0;
  display: flex; align-items: center; justify-content: space-between;
}
.vw-detail-body { padding: 1.25rem 1.4rem; display: grid; gap: 0.85rem; }
.vw-detail-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
.vw-detail-field label {
  display: block; font-size: 0.72rem; font-weight: 700;
  color: var(--ink-light); text-transform: uppercase;
  letter-spacing: 0.05em; margin-bottom: 0.25rem;
}
.vw-detail-field input,
.vw-detail-field select { width: 100%; }
.vw-detail-notes-label {
  font-size: 0.72rem; font-weight: 700; color: var(--ink-light);
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.3rem;
}
#viewingNotesTA {
  width: 100%; min-height: 100px; resize: vertical;
  padding: 0.55rem 0.75rem; border: 1px solid var(--border);
  border-radius: 5px; font-size: 0.85rem; font-family: inherit;
}
.vw-detail-footer {
  padding: 0.9rem 1.4rem; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; gap: 0.6rem;
}

/* ── Form pages dark mode (residential.html, commercial.html) ── */
body.dark-mode .page-container { background: transparent; }
body.dark-mode .page-title     { color: var(--dm-text); }
body.dark-mode .page-subtitle  { color: var(--dm-text-muted); }
body.dark-mode .form-card      { background: var(--dm-surface-2); border-color: var(--dm-surface-3); }
body.dark-mode .form-card h3,
body.dark-mode .form-card h4   { color: var(--dm-text); }
body.dark-mode .form-section-title { color: var(--dm-text); border-bottom-color: var(--dm-surface-3); }
body.dark-mode .form-type-tag  { background: var(--dm-surface-3); color: var(--dm-text-muted); }
body.dark-mode .legal-note     { color: var(--dm-text-muted); }
body.dark-mode .submit-row     { border-top-color: var(--dm-surface-3); }
body.dark-mode .signature-box  { border-color: var(--dm-surface-3); background: var(--dm-surface-3); }
body.dark-mode .success-card   { background: var(--dm-surface-2); border-color: var(--dm-surface-3); color: var(--dm-text); }
body.dark-mode .floor-table th { background: var(--dm-surface-3) !important; color: var(--dm-text); }
body.dark-mode .floor-table td { border-bottom-color: var(--dm-surface-3); }
body.dark-mode .floor-table td input { color: var(--dm-text); }
body.dark-mode .floor-table tr:hover td { background: var(--dm-surface-4); }

/* =============================================================================
   PUBLIC LISTINGS SITE (§8) — tenant homepage, listing detail, aggregator
   homepage. Builds on the existing --ink/--gold/--brand-primary token system
   above rather than a parallel palette. brandColour block in
   lib/publicTemplates.js sets --brand-primary/--brand-accent per-tenant;
   the aggregator page (no tenant) falls back to the --ink/--gold defaults.
   ========================================================================== */

.public-site { background: var(--cream); }

/* ── HERO ────────────────────────────────────────────────────────────── */
.hero {
  position: relative;
  padding: 2.25rem 1.5rem 1.75rem;
  text-align: center;
  /* Text colour is set per-tenant inline (branding accent colour) on the
     tenant homepage template; this is just a sane fallback. */
  color: #fff;
  background: var(--brand-primary, var(--ink));
}
.hero-aggregator { background: linear-gradient(135deg, var(--ink), var(--gold)); }
.hero-logo-link {
  /* Bug fix: .hero-logo (the <img>) is position:absolute, escaping normal
     flow to be placed relative to .hero. A plain <a> wrapper around it
     doesn't get any size from an absolutely-positioned child, so the
     anchor was collapsing to a zero-size box sitting wherever it fell in
     flow -- nowhere near where the logo actually rendered. That made the
     link completely unclickable: you were clicking on the visible logo,
     but the real (invisible, zero-size) clickable area was somewhere
     else entirely. display:contents removes the anchor's own box so the
     img positions exactly as before, while clicks on the now-directly-
     descendant img still correctly trigger the link. */
  display: contents;
}
.hero-logo {
  /* Pinned to the left edge of the hero, vertically centered against the
     whole banner (title/slogan/about/CTA stay centered as their own
     block -- only the logo moves to the side).
     Sized at 75% of the previous 224px/770px cap (which was itself the
     3.5x size) = 168px/577px; header padding trimmed to suit the
     smaller logo (see .hero padding above). */
  position: absolute;
  left: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  max-height: 168px; max-width: 577px; object-fit: contain; margin-bottom: 0;
}
.hero-text { color: inherit; }
.hero-title { font-family: 'Playfair Display', serif; font-size: 2rem; margin-bottom: 0.4rem; color: inherit; }
.hero-slogan { font-size: 1.05rem; opacity: 0.92; margin-bottom: 0.5rem; color: inherit; }
.hero-country { font-size: 0.85rem; opacity: 0.75; margin-top: -0.15rem; margin-bottom: 0.5rem; color: inherit; }
.hero-about { max-width: 42em; margin: 0.5rem auto 0; opacity: 0.85; font-size: 0.95rem; color: inherit; }

/* ── SITE NAV (tenant pages only: Listings / Our Agents) ────────────────── */
.site-nav {
  display: flex; justify-content: center; gap: 2rem; padding: 0.9rem 1.5rem;
  background: var(--paper); border-bottom: 1px solid var(--border);
}
.site-nav-link { color: var(--charcoal); text-decoration: none; font-size: 0.9rem; font-weight: 500; opacity: 0.7; }
.site-nav-link:hover { opacity: 1; }
.site-nav-link.is-active { opacity: 1; border-bottom: 2px solid var(--ink); padding-bottom: 0.2rem; }

/* ── SITE SEARCH ──────────────────────────────────────────────────────── */
/* Client-side filter over already-rendered cards (see /public-listings
   shared-search.js) — no extra backend round-trip, since every card for
   the page is already in the DOM at render time. */
.site-search { max-width: 1200px; margin: 1.75rem auto 0; padding: 0 1.5rem; }
.site-search-box {
  display: flex; align-items: center; gap: 0.6rem; background: var(--paper);
  border: 1px solid var(--border); border-radius: 999px; padding: 0.7rem 1.2rem;
  box-shadow: var(--shadow-lg);
}
.site-search-box svg { flex: none; opacity: 0.5; }
.site-search-input {
  flex: 1 1 auto; border: none; outline: none; font: inherit; font-size: 0.95rem;
  background: transparent; color: var(--charcoal);
}
.site-search-clear {
  flex: none; border: none; background: var(--row-alt); color: var(--charcoal);
  width: 1.6rem; height: 1.6rem; border-radius: 50%; cursor: pointer; font-size: 0.9rem;
  line-height: 1; display: none;
}
.site-search-clear.is-visible { display: block; }
.site-search-empty { display: none; color: #888; padding: 1.5rem 0; text-align: center; }
.site-search-empty.is-visible { display: block; }

/* ── SITE FILTERS (Type chips + price range slider) ─────────────────────── */
.site-filter-row {
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 1.5rem 2rem;
  background: var(--paper); border: 1px solid var(--border); border-radius: 12px;
  padding: 1rem 1.25rem; margin-top: 0.9rem; box-shadow: var(--shadow);
}
.site-filter-label {
  display: block; font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: #888; margin-bottom: 0.5rem;
}
.site-filter-group { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.5rem; }
.site-filter-chip {
  display: inline-flex; align-items: center; gap: 0.4rem; cursor: pointer;
  border: 1px solid var(--border); border-radius: 999px; padding: 0.4rem 0.85rem;
  font-size: 0.85rem; color: var(--charcoal); user-select: none; transition: border-color .15s, background .15s;
}
.site-filter-chip input { accent-color: var(--ink); margin: 0; }
.site-filter-chip:has(input:checked) { border-color: var(--ink); background: var(--row-alt); font-weight: 600; }

.site-filter-price { min-width: 220px; flex: 1 1 260px; max-width: 360px; }
.price-slider { position: relative; height: 1.6rem; margin-bottom: 0.35rem; }
.price-slider-track {
  position: absolute; top: 50%; left: 0; right: 0; height: 4px; margin-top: -2px;
  background: var(--row-alt); border-radius: 999px;
}
.price-slider-range {
  position: absolute; top: 50%; height: 4px; margin-top: -2px;
  background: var(--ink); border-radius: 999px;
}
.price-range-input {
  position: absolute; top: 0; left: 0; width: 100%; margin: 0; height: 1.6rem;
  background: transparent; -webkit-appearance: none; appearance: none; pointer-events: none;
}
.price-range-input::-webkit-slider-thumb {
  -webkit-appearance: none; pointer-events: auto; width: 16px; height: 16px; border-radius: 50%;
  background: var(--ink); border: 2px solid var(--paper); box-shadow: 0 0 0 1px var(--border); cursor: pointer; margin-top: 0;
}
.price-range-input::-moz-range-thumb {
  pointer-events: auto; width: 16px; height: 16px; border-radius: 50%;
  background: var(--ink); border: 2px solid var(--paper); box-shadow: 0 0 0 1px var(--border); cursor: pointer;
}
.price-range-input::-webkit-slider-runnable-track { background: transparent; }
.price-range-input::-moz-range-track { background: transparent; }
.price-slider-readout { font-size: 0.82rem; color: var(--charcoal); text-align: center; }

/* ── LISTING GRID / CARDS ────────────────────────────────────────────── */
.site-main { max-width: 1200px; margin: 0 auto; padding: 2.5rem 1.5rem; }
.listing-section { margin-bottom: 2.5rem; }
.section-title { font-family: 'Playfair Display', serif; font-size: 1.4rem; margin-bottom: 1.1rem; color: var(--charcoal); }
.listing-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.5rem; }
.listing-card {
  background: var(--paper); border-radius: 12px; overflow: hidden;
  text-decoration: none; color: inherit; box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s; display: block;
}
.listing-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.card-media { position: relative; height: 190px; background: var(--row-alt); }
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-noimg { width: 100%; height: 100%; background: var(--row-alt); }
.badge {
  position: absolute; top: 0.6rem; padding: 0.25rem 0.65rem; border-radius: 999px;
  font-size: 0.7rem; font-weight: 600; color: #fff; letter-spacing: 0.02em;
}
.badge-featured { left: 0.6rem; background: var(--gold); color: var(--charcoal); }
.badge-new { right: 0.6rem; background: var(--ink); }
.card-body { padding: 0.9rem 1rem 1.1rem; }
.card-price { font-weight: 700; font-size: 1.05rem; color: var(--ink); }
.card-addr { font-size: 0.88rem; color: var(--charcoal); margin-top: 0.2rem; }
.card-meta { font-size: 0.8rem; color: #777; margin-top: 0.3rem; }
.card-tenant { display: flex; align-items: center; gap: 0.4rem; margin-top: 0.5rem; font-size: 0.75rem; color: #888; }
.card-tenant-logo { width: 18px; height: 18px; object-fit: contain; border-radius: 3px; }
.empty-state { color: #888; padding: 1.5rem 0; }
.site-footer {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas: "powered contact agent";
  align-items: center;
  gap: 1rem;
  padding: 1.2rem 1.5rem; font-size: 0.85rem;
  /* Background/text colour set inline per-tenant (branding colour /
     branding accent colour) -- these are just a sane fallback.
     Desktop: single row -- Powered-by (left), contact info (center),
     Agent Sign In (right). Mobile breakpoint below rearranges this into
     two rows via grid-template-areas, no HTML change needed. */
  background: var(--brand-primary, #1a1a2e); color: #ddd;
}
.site-footer-spacer { grid-area: powered; min-width: 0; }
.site-footer-contact {
  grid-area: contact;
  display: flex; gap: 1.25rem; flex-wrap: wrap; justify-content: center;
  text-align: center; font-size: 0.82rem; opacity: 0.9;
}
.site-footer-agent-link {
  grid-area: agent; justify-self: end;
  text-decoration: underline; opacity: 0.9;
}
.site-footer-agent-link:hover { opacity: 1; }
.site-powered-by {
  grid-area: powered; justify-self: start;
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.72rem;
  /* Now an <a> tag (links to revr.ocean-fog.com) -- text-decoration:none
     drops the default link underline; hover gives a subtle cue instead. */
  text-decoration: none;
  /* Fixed colour (sampled from the REVR CRM logo's own teal) -- not tied
     to tenant branding, so it reads consistently on every tenant site
     regardless of that tenant's colour scheme. */
  color: #33c7e7;
}
.site-powered-by:hover { opacity: 0.85; }
/* 350% of the original 16px display size = 56px. */
.site-powered-by img { height: 56px; object-fit: contain; }
@media (max-width: 700px) {
  .site-footer {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "contact contact"
      "powered agent";
    row-gap: 0.5rem;
  }
  .site-footer-contact { justify-content: center; }
  .site-powered-by { justify-self: start; }
  .site-footer-agent-link { justify-self: end; }
}

/* ── LISTING DETAIL PAGE ─────────────────────────────────────────────── */
.detail-header { padding: 1rem 1.5rem; }
.back-link { color: #fff; text-decoration: none; font-size: 0.9rem; opacity: 0.9; }
.back-link:hover { opacity: 1; text-decoration: underline; }
.detail-main { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }
.detail-layout { display: grid; grid-template-columns: 1fr 300px; gap: 2.5rem; align-items: start; }
.detail-content { min-width: 0; }

.gallery-grid { display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: 140px; gap: 0.5rem; margin-bottom: 1.5rem; }
.gallery-grid .gallery-tile:first-child { grid-column: span 2; grid-row: span 2; }
.gallery-tile { position: relative; border-radius: 8px; overflow: hidden; cursor: pointer; background: var(--row-alt); }
.gallery-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-more {
  position: absolute; inset: 0; background: rgba(0,0,0,0.55); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 1.2rem; font-weight: 600;
}

.detail-heading-row { margin-bottom: 1rem; }
.detail-price { font-size: 1.5rem; font-weight: 700; color: var(--ink); display: flex; align-items: center; gap: 0.6rem; }
.detail-addr { font-family: 'Playfair Display', serif; font-size: 1.3rem; font-weight: 400; margin-top: 0.2rem; color: var(--charcoal); }
.status-badge { font-size: 0.7rem; font-weight: 600; padding: 0.25rem 0.6rem; border-radius: 999px; color: #fff; letter-spacing: 0.02em; }
.status-open { background: var(--green); }
.status-rented, .status-sold { background: #777; }
.status-withdrawn { background: var(--red); }

.tags-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0 1.25rem; }
.tag-pill { background: var(--gold-pale); color: var(--charcoal); border: 1px solid var(--gold-light); padding: 0.3rem 0.75rem; border-radius: 999px; font-size: 0.8rem; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; background: var(--paper); border-radius: 10px; padding: 1.1rem; box-shadow: var(--shadow); }
.stat-item { text-align: center; }
.stat-label { font-size: 0.72rem; color: #888; text-transform: uppercase; letter-spacing: 0.03em; }
.stat-value { font-size: 0.95rem; font-weight: 600; color: var(--charcoal); margin-top: 0.15rem; }

.detail-section { margin-bottom: 1.75rem; }
.section-subtitle { font-size: 1.05rem; font-weight: 600; color: var(--charcoal); margin-bottom: 0.6rem; }
.detail-description { line-height: 1.6; color: var(--charcoal); white-space: pre-wrap; }

.tour-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1.5rem; }
.tour-tile {
  background: var(--paper); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.7rem 1.1rem; text-decoration: none; color: var(--ink); font-size: 0.88rem; font-weight: 500;
}
.tour-tile:hover { border-color: var(--ink); }

.map-embed { width: 100%; height: 320px; border: 0; border-radius: 10px; }
.map-fallback { color: #888; font-size: 0.9rem; }

.share-row { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.5rem; }
.share-btn {
  background: var(--paper); border: 1px solid var(--border); border-radius: 999px;
  padding: 0.5rem 1.1rem; font-size: 0.82rem; color: var(--charcoal); text-decoration: none;
  cursor: pointer; font-family: inherit;
}
.share-btn:hover { border-color: var(--ink); color: var(--ink); }

.agent-card {
  background: var(--paper); border-radius: 12px; padding: 1.25rem; box-shadow: var(--shadow-lg);
  position: sticky; top: 5rem; display: flex; flex-direction: column; gap: 0.6rem;
}
.agent-name { font-weight: 600; font-size: 1.05rem; color: var(--charcoal); margin-bottom: 0.3rem; }
.agent-btn {
  display: block; text-align: center; padding: 0.65rem; border-radius: 8px;
  text-decoration: none; font-size: 0.88rem; font-weight: 500;
}
.agent-call { background: var(--ink); color: #fff; }
.agent-whatsapp { background: #25D366; color: #fff; }
.agent-email { background: var(--row-alt); color: var(--charcoal); }

/* ── OUR AGENTS PAGE ──────────────────────────────────────────────────── */
.agents-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1.75rem; }
.agent-tile {
  background: var(--paper); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow);
  text-align: center; padding-bottom: 1.25rem;
}
.agent-tile-photo { width: 100%; aspect-ratio: 1 / 1; background: var(--row-alt); overflow: hidden; }
.agent-tile-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.agent-tile-initial {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-family: 'Playfair Display', serif; font-size: 2.5rem; color: var(--charcoal); opacity: 0.35;
}
.agent-tile-name { font-weight: 600; font-size: 1rem; color: var(--charcoal); margin-top: 0.9rem; }
.agent-tile-role { font-size: 0.78rem; color: #888; text-transform: uppercase; letter-spacing: 0.04em; margin-top: 0.15rem; }
.agent-tile-links { display: flex; justify-content: center; gap: 0.5rem; margin-top: 0.75rem; padding: 0 1rem; }
.agent-tile-links a {
  border: 1px solid var(--border); border-radius: 999px; padding: 0.35rem 0.8rem;
  font-size: 0.78rem; color: var(--charcoal); text-decoration: none;
}
.agent-tile-links a:hover { border-color: var(--ink); color: var(--ink); }

/* ── LIGHTBOX ─────────────────────────────────────────────────────────── */
.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,0.92); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
/* Bug fix: author stylesheets always win over the browser's built-in
   `[hidden] { display: none }` rule, even at equal selector specificity
   -- so the unconditional `display: flex` above was silently overriding
   the `hidden` attribute and leaving the lightbox visible (and its
   underlying page inert-looking, since body scroll was locked) on every
   page load, before any photo was ever clicked. The close button and
   back navigation "not working" were a symptom of this, not a separate
   bug: lbClose() was already correctly setting hidden=true, it just had
   no visual effect because this rule kept overriding it. This selector
   is more specific than `.lightbox` alone, so it now wins correctly. */
.lightbox[hidden] { display: none; }
.lb-img { max-width: 92vw; max-height: 88vh; object-fit: contain; }
.lb-close {
  position: absolute; top: 1rem; right: 1.25rem; background: none; border: none;
  color: #fff; font-size: 2rem; cursor: pointer; line-height: 1;
}
.lb-arrow {
  position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,0.12);
  border: none; color: #fff; font-size: 2.2rem; width: 3rem; height: 3rem; border-radius: 50%;
  cursor: pointer; line-height: 1;
}
.lb-prev { left: 1rem; } .lb-next { right: 1rem; }
.lb-arrow:hover { background: rgba(255,255,255,0.25); }
.lb-count { position: absolute; bottom: 1.25rem; left: 50%; transform: translateX(-50%); color: #fff; font-size: 0.85rem; opacity: 0.8; }

/* ── MOBILE ───────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .detail-layout { grid-template-columns: 1fr; }
  .agent-card { position: static; }
  .gallery-grid { grid-template-columns: repeat(2, 1fr); grid-auto-rows: 110px; }
  .gallery-grid .gallery-tile:first-child { grid-column: span 2; grid-row: span 1; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .hero {
    display: flex;
    align-items: center;
    text-align: right;
    gap: 1rem;
    /* Vertical padding cut 20% (1.5rem -> 1.2rem) to shrink header
       height; horizontal padding and everything inside (logo, text
       sizes, gap) is untouched. */
    padding: 1.2rem 1rem;
  }
  .hero-title { font-size: 1.4rem; }
  /* Mobile layout: logo sits to the left of the name/slogan/country
     block (still to its left even though the text itself is now
     right-aligned) -- doubled from the previous 56px/110px mobile size
     to 112px/220px. */
  .hero-logo {
    position: static;
    transform: none;
    max-height: 112px;
    max-width: 220px;
    flex-shrink: 0;
    margin-bottom: 0;
  }
  .hero-text { flex: 1 1 auto; min-width: 0; text-align: right; }
  .hero-about { margin: 0.5rem 0 0; max-width: none; }
  .listing-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; }
  .badge { font-size: 0.62rem; padding: 0.2rem 0.5rem; top: 0.4rem; }
  .badge-featured { left: 0.4rem; } .badge-new { right: 0.4rem; }
  .lb-arrow { width: 2.4rem; height: 2.4rem; font-size: 1.7rem; }
}
