:root {
  --bg: #f8fafc;
  --panel-bg: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-light: #dbeafe;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

html,
body {
  height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.map-layout {
  display: flex;
  height: 100vh;
  height: 100dvh;
}

.map-container {
  flex: 0 0 68%;
  min-width: 0;
  height: 100%;
  z-index: 0;
}

.side-panel {
  flex: 0 0 32%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.panel-header {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.panel-neighborhood {
  font-size: 0.95rem;
  color: var(--accent-dark);
  font-weight: 500;
}

.panel-count {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  margin-bottom: 0.75rem;
}

.btn {
  display: inline-block;
  padding: 0.5rem 0.875rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--panel-bg);
  color: var(--text);
}

.btn:hover {
  background: var(--bg);
}

.btn:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn--secondary {
  color: var(--accent-dark);
  border-color: var(--accent-light);
  background: var(--accent-light);
}

.filters {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.filters__title {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.filters__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.filters__field:last-child {
  grid-column: 1 / -1;
}

.filters__label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.filters__input {
  width: 100%;
  padding: 0.5rem 0.625rem;
  font: inherit;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}

.filters__input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

.listing-cards {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1.25rem 1.25rem;
}

.listing-cards__empty {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
  padding: 2rem 0;
}

.listing-card {
  display: flex;
  gap: 0.875rem;
  padding: 0.875rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-bg);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.listing-card:hover {
  border-color: var(--accent);
}

.listing-card:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.listing-card.is-selected {
  border-color: var(--accent-dark);
  box-shadow: 0 0 0 2px var(--accent-light);
  background: #f0f7ff;
}

.listing-card__image {
  flex: 0 0 88px;
  width: 88px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg);
}

.listing-card__body {
  flex: 1;
  min-width: 0;
}

.listing-card__price {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent-dark);
}

.listing-card__address {
  font-size: 0.85rem;
  color: var(--text);
  margin-top: 0.125rem;
}

.listing-card__details {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.listing-card__summary {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.375rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.listing-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.5rem;
}

.listing-card__tag {
  font-size: 0.7rem;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.listing-card__link {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
}

.listing-card__link:hover {
  text-decoration: underline;
}

/* Leaflet popup styles */
.listing-popup {
  min-width: 180px;
}

.listing-popup__image {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 0.5rem;
}

.listing-popup__price {
  font-weight: 600;
  font-size: 1rem;
  color: var(--accent-dark);
}

.listing-popup__address {
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.listing-popup__details {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.map-error {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  max-width: 90%;
  padding: 0.75rem 1.25rem;
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  border-radius: 8px;
  font-size: 0.9rem;
  z-index: 1000;
}

.map-error[hidden] {
  display: none;
}

.map-price-control {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 0.5rem 0.75rem;
}

.map-price-control__label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.map-price-control__input {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

@media (max-width: 768px) {
  .map-layout {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .map-container {
    flex: none;
    width: 100%;
    height: 55vh;
  }

  .side-panel {
    flex: 1;
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
    min-height: 45vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  .listing-card {
    transition: none;
  }
}
