:root {
  color-scheme: light;
  --ink: #1d2430;
  --muted: #647084;
  --line: #d8dde6;
  --panel: #ffffff;
  --canvas: #eef1f5;
  --mine: #176b87;
  --active: #2d7d46;
  --sold: #8b3f2f;
  --pending: #7a5c15;
  --shadow: 0 16px 40px rgba(22, 30, 43, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  height: 100dvh;
  min-height: 620px;
}

.map-panel {
  position: relative;
  min-width: 0;
}

.map {
  width: 100%;
  height: 100%;
  background: #dfe7ea;
}

.topbar {
  position: absolute;
  z-index: 500;
  top: max(14px, env(safe-area-inset-top));
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 520px;
  padding: 12px 12px 12px 14px;
  border: 1px solid rgba(216, 221, 230, 0.92);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 30px rgba(22, 30, 43, 0.14);
  backdrop-filter: blur(10px);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.1;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
}

.filter-strip {
  position: absolute;
  z-index: 500;
  left: 14px;
  bottom: 18px;
  display: flex;
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(216, 221, 230, 0.92);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 30px rgba(22, 30, 43, 0.14);
  backdrop-filter: blur(10px);
}

.filter {
  min-width: 58px;
  height: 38px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.filter.is-active {
  color: var(--ink);
  border-color: var(--line);
  background: #f0f3f7;
  font-weight: 700;
}

.detail-panel {
  display: flex;
  flex-direction: column;
  overflow: auto;
  border-left: 1px solid var(--line);
  background: var(--panel);
  box-shadow: -14px 0 30px rgba(22, 30, 43, 0.08);
}

.sheet-handle {
  display: none;
}

#detailContent {
  padding: 22px;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
}

.pill.mine {
  background: var(--mine);
}

.pill.active {
  background: var(--active);
}

.pill.sold {
  background: var(--sold);
}

.pill.pending {
  background: var(--pending);
}

.price-delta {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  text-align: right;
}

.address {
  margin: 0 0 4px;
  font-size: 1.55rem;
  line-height: 1.16;
}

.subaddress {
  margin: 0 0 18px;
  color: var(--muted);
}

.price-block {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.metric,
.note-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.metric {
  padding: 12px;
}

.metric-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.metric-value {
  display: block;
  font-size: 1.16rem;
  font-weight: 800;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.note-block {
  padding: 14px;
  margin-bottom: 12px;
}

.note-block h2 {
  margin: 0 0 8px;
  font-size: 0.92rem;
}

.note-block p {
  margin: 0;
  color: #344154;
  font-size: 0.94rem;
  line-height: 1.45;
}

.fact-table {
  display: grid;
  gap: 8px;
}

.fact-row {
  display: grid;
  grid-template-columns: 94px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  color: #344154;
  font-size: 0.88rem;
  line-height: 1.3;
}

.fact-row span {
  color: var(--muted);
  font-weight: 700;
}

.fact-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 750;
}

.geocode-warning {
  color: #6d5210;
}

.marker {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 3px solid #fff;
  border-radius: 50%;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(22, 30, 43, 0.28);
}

.marker.mine {
  background: var(--mine);
}

.marker.active {
  background: var(--active);
}

.marker.sold {
  background: var(--sold);
}

.marker.pending {
  background: var(--pending);
}

@media (max-width: 780px) {
  .app-shell {
    display: block;
    min-height: 100dvh;
  }

  .map-panel {
    height: 100dvh;
  }

  .topbar {
    max-width: none;
  }

  .filter-strip {
    left: 10px;
    right: 10px;
    bottom: calc(56dvh + 16px + env(safe-area-inset-bottom));
    justify-content: space-between;
  }

  .leaflet-bottom.leaflet-right {
    bottom: calc(56dvh + 78px + env(safe-area-inset-bottom));
  }

  .filter {
    flex: 1;
    min-width: 0;
  }

  .detail-panel {
    position: fixed;
    z-index: 700;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 56dvh;
    min-height: 235px;
    border-top: 1px solid var(--line);
    border-left: 0;
    border-radius: 8px 8px 0 0;
    box-shadow: var(--shadow);
  }

  .sheet-handle {
    display: block;
    width: 42px;
    height: 4px;
    margin: 9px auto 0;
    border-radius: 999px;
    background: #c7ced9;
  }

  #detailContent {
    padding: 14px 16px max(22px, env(safe-area-inset-bottom));
  }

  .address {
    font-size: 1.24rem;
  }

  .price-block,
  .grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .metric {
    padding: 10px;
  }

  .metric-value {
    font-size: 1rem;
  }

  .fact-row {
    grid-template-columns: 84px minmax(0, 1fr);
  }
}

@media (max-width: 390px) {
  .price-block,
  .grid {
    grid-template-columns: 1fr;
  }

  .filter-strip {
    bottom: calc(56dvh + 16px + env(safe-area-inset-bottom));
  }
}
