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

:root {
  --surface: #fbfaf7;
  --surface-2: #eee9e1;
  --panel: rgba(251, 250, 247, .94);
  --text: #2b2b2b;
  --muted: #8b867d;
  --line: #d8d0c4;
  --primary: #356f7d;
  --primary-dark: #285866;
  --free: #2f7d58;
  --reserved: #c28a52;
  --sold: #d9d3c9;
}

html,
body {
  height: 100%;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--surface);
}

body {
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 74px;
  padding: 16px 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: 0;
  flex-shrink: 0;
}

.map-title {
  display: grid;
  gap: 4px;
}

.map-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.map-title strong {
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(22px, 2vw, 34px);
  font-weight: 700;
  line-height: 1;
}

.legend {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--text);
  font-size: 14px;
  white-space: nowrap;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend .dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.dot--free { background: var(--free); }
.dot--reserved { background: var(--reserved); }
.dot--sold { background: var(--sold); border: 1px solid #c9c0b4; }

.layout {
  flex: 1;
  display: flex;
  min-height: 0;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.sidebar {
  width: 340px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(10px);
}

.search {
  position: relative;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.search input {
  width: 100%;
  min-height: 48px;
  padding: 12px 40px 12px 14px;
  border: 1px solid var(--line);
  border-radius: 0;
  color: var(--text);
  font-size: 14px;
  background: #fff;
}

.search input::placeholder {
  color: var(--muted);
}

.search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(53, 111, 125, .13);
}

.search button {
  position: absolute;
  right: 26px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.search button:hover { color: var(--text); }

.results {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.result {
  display: flex;
  gap: 12px;
  padding: 12px 18px;
  cursor: pointer;
  border-bottom: 1px solid rgba(216, 208, 196, .58);
}

.result:hover {
  background: rgba(238, 233, 225, .72);
}

.result__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 7px;
  background: var(--muted);
}

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

.result__title {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.22;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result__subtitle {
  margin-top: 4px;
  color: #716b62;
  font-size: 12px;
  line-height: 1.28;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.result--empty {
  padding: 28px 18px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.map-canvas-wrap {
  flex: 1;
  position: relative;
  min-width: 0;
  background: var(--surface-2);
}

.map-canvas {
  position: absolute;
  inset: 0;
}

.fallback-map {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--surface-2);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.fallback-map:active {
  cursor: grabbing;
}

.fallback-tiles,
.fallback-project-tiles,
.fallback-overlay {
  position: absolute;
  inset: 0;
}

.fallback-tiles,
.fallback-project-tiles {
  z-index: 0;
  overflow: hidden;
}

.fallback-project-tiles {
  z-index: 1;
  pointer-events: none;
}

.fallback-tile {
  position: absolute;
  width: 256px;
  height: 256px;
  max-width: none;
  user-select: none;
  pointer-events: none;
}

.fallback-project-tile {
  position: absolute;
  width: 256px;
  height: 256px;
  max-width: none;
  user-select: none;
  pointer-events: none;
}

.fallback-overlay {
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: auto;
}

.fallback-plot {
  cursor: pointer;
}

.fallback-plot polygon {
  transition: fill .16s ease, stroke .16s ease, stroke-width .16s ease;
}

.fallback-plot:hover polygon {
  stroke: var(--primary-dark);
  stroke-width: 2.6;
}

.fallback-plot-label {
  pointer-events: none;
}

.fallback-plot-label circle {
  fill: rgba(53, 111, 125, .94);
  stroke: rgba(255, 255, 255, .92);
  stroke-width: 2.5;
  filter: drop-shadow(0 2px 5px rgba(43, 43, 43, .28));
}

.fallback-plot-label text {
  fill: #fff;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  font-weight: 800;
  text-anchor: middle;
  dominant-baseline: middle;
  paint-order: stroke;
  stroke: rgba(43, 43, 43, .55);
  stroke-width: 2px;
}

.fallback-popup {
  position: absolute;
  z-index: 4;
  width: min(360px, calc(100% - 36px));
  max-height: calc(100% - 36px);
  overflow-y: auto;
  padding: 18px;
  border: 1px solid var(--line);
  background: rgba(251, 250, 247, .97);
  box-shadow: 0 18px 42px rgba(43, 43, 43, .24);
  transform: translate(-50%, calc(-100% - 18px));
  cursor: default;
  user-select: text;
}

.fallback-popup[hidden] {
  display: none;
}

.fallback-controls {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 3;
  display: grid;
  gap: 8px;
}

.fallback-controls button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  background: rgba(251, 250, 247, .96);
  color: var(--text);
  box-shadow: 0 8px 20px rgba(43, 43, 43, .12);
  cursor: pointer;
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}

.fallback-controls button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.fallback-lead {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 3;
  width: min(340px, calc(100% - 36px));
  padding: 16px;
  border: 1px solid var(--line);
  background: rgba(251, 250, 247, .97);
  color: var(--text);
  box-shadow: 0 10px 28px rgba(43, 43, 43, .14);
  cursor: default;
  user-select: text;
}

.plot-labels-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.plot-labels-layer[hidden] {
  display: none;
}

.plot-number-label {
  position: absolute;
  left: 0;
  top: 0;
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255, 255, 255, .92);
  border-radius: 999px;
  background: rgba(53, 111, 125, .92);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .22);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .28);
  white-space: nowrap;
  cursor: pointer;
  pointer-events: auto;
  user-select: none;
}

.status {
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 2;
  max-width: min(460px, calc(100% - 36px));
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: rgba(251, 250, 247, .95);
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 10px 28px rgba(43, 43, 43, .12);
}

.status[hidden] { display: none; }
.status.status--error { color: #a02d2d; }

/* Plot form inside Yandex balloon */
.plot-form,
.fallback-lead {
  max-width: 290px;
  padding: 10px 4px 4px;
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.fallback-lead {
  max-width: none;
  padding: 16px;
}

.plot-form h3,
.fallback-lead h3 {
  margin-bottom: 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 21px;
  line-height: 1.05;
}

.plot-form .meta,
.fallback-lead .meta {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.plot-form input[type=text],
.plot-form input[type=tel],
.fallback-lead input[type=text],
.fallback-lead input[type=tel] {
  width: 100%;
  min-height: 42px;
  margin-bottom: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--text);
  font-size: 14px;
}

.plot-form input:focus,
.fallback-lead input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(53, 111, 125, .13);
}

.plot-form .form-consent,
.fallback-lead .form-consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 2px 0 10px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  cursor: pointer;
}

.plot-form .form-consent input[type=checkbox],
.fallback-lead .form-consent input[type=checkbox] {
  width: 15px;
  height: 15px;
  min-height: auto;
  margin: 1px 0 0;
  flex-shrink: 0;
  accent-color: var(--primary);
}

.plot-form .form-consent a,
.fallback-lead .form-consent a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.plot-form button,
.fallback-lead button {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--primary);
  border-radius: 0;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.plot-form button:hover,
.fallback-lead button:hover { background: var(--primary-dark); }
.plot-form button:disabled,
.fallback-lead button:disabled { opacity: .6; cursor: wait; }
.plot-form .success,
.fallback-lead .success { color: var(--free); font-size: 13px; padding: 8px 0; text-align: center; }
.plot-form .error,
.fallback-lead .error { color: #a02d2d; font-size: 12px; margin: 4px 0 8px; }

@media (max-width: 860px) {
  html,
  body {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
    padding: 10px 12px;
  }

  .map-title {
    gap: 2px;
  }

  .map-title span {
    font-size: 10px;
    letter-spacing: .12em;
  }

  .map-title strong {
    font-size: 20px;
    line-height: 1.1;
  }

  .legend {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    font-size: 11px;
    white-space: normal;
  }

  .legend span {
    gap: 6px;
    min-width: 0;
  }

  .legend .dot {
    width: 10px;
    height: 10px;
  }

  .layout { flex-direction: column; }

  .sidebar {
    width: 100%;
    height: 132px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .search {
    padding: 10px;
  }

  .search input {
    min-height: 42px;
    padding: 10px 38px 10px 12px;
    font-size: 13px;
  }

  .search button {
    right: 20px;
  }

  .results {
    display: flex;
    min-height: 0;
    max-height: 80px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0;
  }

  .result {
    min-width: 220px;
    padding: 9px 10px;
    border-right: 1px solid rgba(216, 208, 196, .58);
    border-bottom: 0;
  }

  .result--empty {
    width: 100%;
    min-width: 100%;
    padding: 16px 12px;
  }

  .map-canvas-wrap {
    flex: 1;
    min-height: 0;
  }

  .fallback-popup {
    left: 50% !important;
    top: auto !important;
    right: auto;
    bottom: 78px;
    width: calc(100% - 20px);
    max-height: min(58dvh, 420px);
    transform: none;
  }

  .fallback-controls {
    top: 10px;
    left: 10px;
  }

  .fallback-controls button {
    width: 38px;
    height: 38px;
    font-size: 23px;
  }

  .fallback-lead {
    top: auto;
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
    max-width: none;
    font-size: 12px;
  }

  .status {
    left: 10px;
    right: 10px;
    bottom: 10px;
    max-width: none;
    font-size: 12px;
  }

  .plot-form {
    max-width: min(290px, calc(100vw - 56px));
  }
}

@media (max-width: 420px) {
  .topbar {
    padding: 8px 10px;
  }

  .map-title strong {
    font-size: 18px;
  }

  .sidebar {
    height: 118px;
  }

  .results {
    max-height: 66px;
  }
}
