/* ---------- Design system ---------- */
:root {
  --navy: #0F1B2D;
  --navy-soft: #1A2A42;
  --gold: #C9A961;
  --gold-soft: #B39847;
  --cream: #FAF7F2;
  --charcoal: #2A2A2A;
  --burgundy: #6B2436;
  --sage: #9A9A7E;
  --bronze: #B07D43;
  --silver: #B8B8B8;
  --line: #E8E4DC;
  --shadow-sm: 0 1px 3px rgba(15, 27, 45, 0.08);
  --shadow-md: 0 4px 12px rgba(15, 27, 45, 0.10);
  --shadow-lg: 0 12px 40px rgba(15, 27, 45, 0.16);
  --serif: 'Playfair Display', Georgia, serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius: 8px;
  --radius-lg: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--cream);
  color: var(--charcoal);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--navy); text-decoration: none; }
a:hover { color: var(--gold); }

/* ---------- Header ---------- */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 32px;
  background: var(--navy);
  color: var(--cream);
  border-bottom: 1px solid rgba(201, 169, 97, 0.2);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.brand { display: flex; flex-direction: column; gap: 2px; }
.brand-mark {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 4px;
  color: var(--gold);
  line-height: 1;
}
.brand-tag {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: rgba(250, 247, 242, 0.6);
}

.site-nav { display: flex; gap: 28px; }
.nav-link {
  color: rgba(250, 247, 242, 0.75);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 500;
  padding-bottom: 4px;
  border-bottom: 1px solid transparent;
  transition: all 0.2s ease;
}
.nav-link:hover, .nav-link.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

/* ---------- App layout ---------- */
.app {
  display: grid;
  grid-template-columns: 1fr 420px;
  height: calc(100vh - 65px);
  overflow: hidden;
}

/* ---------- Map column ---------- */
.map-column {
  position: relative;
  background: var(--navy);
}
#map {
  width: 100%;
  height: 100%;
}

/* Map overlay panels */
.layer-controls {
  position: absolute;
  top: 16px;
  left: 16px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 8px;
  display: flex;
  gap: 4px;
  z-index: 500;
  flex-wrap: wrap;
  max-width: 540px;
}

.layer-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--charcoal);
  font-weight: 500;
  transition: background 0.15s ease;
}
.layer-btn:hover { background: rgba(15, 27, 45, 0.05); }
.layer-btn.active {
  background: var(--navy);
  color: var(--cream);
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot-gold { background: var(--gold); }
.dot-bronze { background: var(--bronze); }
.dot-navy { background: var(--navy); }
.dot-sage { background: var(--sage); }
.layer-btn.active .dot { box-shadow: 0 0 0 2px var(--cream); }

.commute-panel {
  position: absolute;
  top: 80px;
  left: 16px;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 16px;
  width: 280px;
  z-index: 500;
}
.commute-header {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 16px;
  color: var(--navy);
  margin-bottom: 12px;
}
.commute-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: var(--sans);
  font-size: 13px;
  margin-bottom: 12px;
}
.commute-times {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.commute-times label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
}
.commute-btn {
  width: 100%;
  background: var(--gold);
  color: var(--navy);
  border: none;
  padding: 10px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  font-family: var(--sans);
}
.commute-btn:hover { background: var(--gold-soft); }
.commute-message {
  margin-top: 8px;
  font-size: 12px;
  color: var(--burgundy);
}

.map-legend {
  position: absolute;
  bottom: 24px;
  left: 16px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  z-index: 500;
  font-size: 12px;
}
.legend-title {
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 11px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
  color: var(--charcoal);
}
.legend-pin {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.legend-pin.coming { background: var(--gold); border: 2px solid var(--navy); }
.legend-pin.active { background: var(--navy); }
.legend-pin.pending { background: var(--silver); }

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--cream);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel {
  background: white;
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.panel-hero {
  background: var(--navy);
  color: var(--cream);
  padding: 24px;
}
.panel-hero .panel-title {
  font-family: var(--serif);
  font-size: 22px;
  margin: 0 0 8px 0;
  color: var(--gold);
  font-weight: 700;
  line-height: 1.2;
}
.panel-hero .panel-sub {
  margin: 0;
  font-size: 13px;
  color: rgba(250, 247, 242, 0.85);
  line-height: 1.5;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.panel-head h2 {
  font-family: var(--serif);
  font-size: 17px;
  color: var(--navy);
  font-weight: 700;
  margin: 0;
}

.badge {
  background: var(--cream);
  color: var(--navy);
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--line);
}
.badge-gold {
  background: var(--gold);
  color: var(--navy);
  border-color: var(--gold);
}

.link-btn {
  background: none;
  border: none;
  color: var(--gold);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.link-btn:hover { color: var(--gold-soft); }

.empty-state {
  text-align: center;
  padding: 24px 12px;
  color: rgba(42, 42, 42, 0.55);
}
.empty-icon {
  font-size: 36px;
  color: var(--gold);
  margin-bottom: 8px;
  opacity: 0.6;
}
.empty-title {
  font-weight: 600;
  color: var(--charcoal);
  margin-bottom: 4px;
}
.empty-sub { font-size: 12px; line-height: 1.5; }

.empty-state-small {
  text-align: center;
  padding: 16px 12px;
  color: rgba(42, 42, 42, 0.5);
  font-size: 13px;
}

/* Filters */
.filter-group {
  margin-bottom: 14px;
}
.filter-group:last-child { margin-bottom: 0; }
.filter-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--charcoal);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.chip-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.chip {
  padding: 6px 12px;
  border: 1px solid var(--line);
  background: white;
  border-radius: 16px;
  font-size: 12px;
  cursor: pointer;
  font-family: var(--sans);
  color: var(--charcoal);
  transition: all 0.15s ease;
}
.chip:hover { border-color: var(--gold); }
.chip.chip-active {
  background: var(--navy);
  color: var(--cream);
  border-color: var(--navy);
}

.range-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.range-input, .select-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: var(--sans);
  font-size: 13px;
  background: white;
}
.range-dash {
  color: rgba(42, 42, 42, 0.4);
  font-size: 12px;
}
.select-input { width: 100%; }

/* Polygon list */
.polygon-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.polygon-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--cream);
}
.polygon-row-info { display: flex; flex-direction: column; gap: 2px; }
.polygon-row-name { font-weight: 600; font-size: 13px; }
.polygon-row-meta { font-size: 11px; color: rgba(42, 42, 42, 0.6); }
.polygon-row-delete {
  background: none;
  border: none;
  color: var(--burgundy);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 8px;
}

/* Match list */
.match-list { display: flex; flex-direction: column; gap: 12px; max-height: 600px; overflow-y: auto; }
.listing-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
  background: white;
}
.listing-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--gold);
}
.listing-photo {
  width: 100%;
  height: 140px;
  background: var(--cream) center/cover;
  position: relative;
}
.listing-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--gold);
  color: var(--navy);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  animation: pulse 2.4s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201, 169, 97, 0.55); }
  50% { box-shadow: 0 0 0 6px rgba(201, 169, 97, 0); }
}
.listing-body { padding: 12px 14px 14px; }
.listing-price {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 20px;
  color: var(--navy);
  line-height: 1;
}
.listing-address {
  font-size: 13px;
  color: var(--charcoal);
  margin-top: 4px;
}
.listing-stats {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  font-size: 12px;
  color: rgba(42, 42, 42, 0.7);
}
.listing-stats span strong { color: var(--charcoal); }

/* Buttons */
.btn {
  border: none;
  padding: 10px 16px;
  border-radius: 6px;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn-secondary {
  background: var(--cream);
  color: var(--charcoal);
  border: 1px solid var(--line);
  width: 100%;
}
.btn-secondary:hover { background: var(--line); }

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}
.toast {
  background: var(--navy);
  color: var(--cream);
  padding: 12px 18px;
  border-radius: 6px;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  pointer-events: auto;
  animation: toast-in 0.3s ease;
  max-width: 320px;
}
.toast.toast-success { border-left: 4px solid var(--gold); }
.toast.toast-error { border-left: 4px solid var(--burgundy); }
.toast.toast-warning { border-left: 4px solid #E8A33D; }
@keyframes toast-in {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Footer */
.site-footer {
  background: var(--navy);
  color: rgba(250, 247, 242, 0.8);
  padding: 32px 40px 16px;
  border-top: 2px solid var(--gold);
}
.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 32px;
  max-width: 1400px;
  margin: 0 auto 24px;
}
.footer-section h3 {
  color: var(--gold);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin: 0 0 10px;
  font-weight: 600;
}
.footer-section p { font-size: 13px; line-height: 1.6; margin: 0; }
.footer-section a { color: var(--gold); }
.footer-section a:hover { color: var(--cream); }
.fair-housing-line { margin-top: 12px; font-size: 12px; display: flex; gap: 8px; align-items: flex-start; }
.fh-mark {
  background: var(--gold);
  color: var(--navy);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}
.footer-base {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid rgba(201, 169, 97, 0.2);
  padding-top: 14px;
  font-size: 11px;
  color: rgba(250, 247, 242, 0.5);
  max-width: 1400px;
  margin: 0 auto;
}

/* Custom Leaflet styles */
.leaflet-draw-toolbar a { background-color: white !important; }
.custom-listing-marker {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.custom-listing-marker .pin {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 3px solid var(--cream);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: white;
  font-weight: 700;
}
.custom-listing-marker .pin.pin-coming { background: var(--gold); border-color: var(--navy); animation: pulse 2.4s infinite; }
.custom-listing-marker .pin.pin-active { background: var(--navy); }
.custom-listing-marker .pin.pin-pending { background: var(--silver); }

.custom-poi-marker {
  display: flex;
  align-items: center;
  justify-content: center;
}
.poi-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  color: white;
  border: 2px solid white;
}
.poi-badge.tier-1 { background: var(--gold); color: var(--navy); }
.poi-badge.tier-2 { background: var(--silver); color: var(--navy); }
.poi-badge.tier-3 { background: var(--bronze); }

.leaflet-popup-content-wrapper {
  border-radius: var(--radius) !important;
  font-family: var(--sans);
}

/* Responsive */
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; height: auto; }
  .map-column { height: 60vh; }
  .sidebar { max-height: 70vh; }
  .site-nav { display: none; }
}
