:root {
  --page: #ffffff;
  --text: #07131d;
  --muted: #6b7280;
  --soft: #f4f6f9;
  --soft-2: #f8f9fb;
  --line: #e3e6ed;
  --red: #ef0b08;
  --red-dark: #d70603;
  --radius-sm: 12px;
  --radius: 18px;
  --radius-lg: 26px;
  --shadow-sm: 0 4px 16px rgba(18, 22, 34, 0.06);
  --shadow: 0 18px 44px rgba(18, 22, 34, 0.10);
  --shadow-lg: 0 30px 70px rgba(18, 22, 34, 0.16);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--page); }

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  background: var(--page);
  font-size: 16px;
}

button,
input { font: inherit; }

button { cursor: pointer; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.map-app {
  display: flex;
  flex-direction: column;
  width: fit-content;
  margin: 0 auto;
  padding: 66px 0 54px;
}

.map-header {
  display: flex;
  align-items: end;
  gap: 24px;
  margin-bottom: 26px;
}

.map-header h1 {
  color: #101820;
  font-size: clamp(28px, 2.7vw, 34px);
  line-height: 1.08;
  font-weight: 600;
  letter-spacing: -0.025em;
  overflow-wrap: anywhere;
  margin: 0px;
}

.map-lead {
  max-width: 790px;
  margin: 0;
  color: #222b36;
  font-size: clamp(20px, 1.55vw, 26px);
  line-height: 1.32;
  letter-spacing: -.025em;
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(300px, 340px) minmax(0, 1fr);
  align-items: start;
  gap: 16px;
  min-height: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.map-sidebar {
  display: grid;
  grid-template-rows: auto auto 1fr;
  align-content: start;
  gap: 16px;
  min-height: min(620px, calc(100svh - 210px));
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
}

.search .icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.search input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  color: var(--text);
  background: #fff;
  box-shadow: 0 6px 20px rgba(17,24,39,.035);
  font-size: 16px;
  line-height: 1;
  letter-spacing: -.03em;
}

.search input::placeholder {
  color: #7a7d85;
  opacity: 1;
}

.search input:focus {
  border-color: #c9ced8;
  box-shadow: 0 0 0 4px rgba(239,11,8,.07), 0 10px 24px rgba(17,24,39,.055);
}

.category-card {
  width: 100%;
  max-height: min(560px, calc(100svh - 260px));
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
  scrollbar-width: thin;
  scrollbar-color: #d5dae4 transparent;
}

.category-card::-webkit-scrollbar { width: 8px; }
.category-card::-webkit-scrollbar-thumb { border-radius: 999px; background: #d5dae4; }

.filters { display: grid; gap: 10px; }

.filter-group { display: grid; gap: 9px; }

.filter-children {
  display: none;
  max-height: 310px;
  overflow: auto;
  gap: 8px;
  padding: 2px 0 2px 14px;
  scrollbar-width: thin;
  scrollbar-color: #d5dae4 transparent;
}

.filter-group.is-open .filter-children { display: grid; }

.filter {
  width: 100%;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: #2e344c;
  text-align: left;
  background: linear-gradient(180deg, #f8f9fb 0%, #f2f4f7 100%);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: -.02em;
  transition: background 180ms ease, color 180ms ease, border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.filter:hover {
  border-color: rgba(225, 6, 0, 0.3);
  color: var(--red);
}

.filter.is-active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(180deg, var(--red) 0%, var(--red-dark) 100%);
  box-shadow: 0 14px 26px rgba(239, 11, 8, .22);
}

.filter-dot,
.filter-count { display: none; }

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

.filter-media {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 0;
  background: none;
  box-shadow: inset 0 0 0 1px rgba(226, 232, 240, .9);
}

.filter-media[hidden] { display: none; }

.filter-icon {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.filter--zone .filter-media {
  width: 26px;
  height: 26px;
  flex-basis: 26px;
  border-radius: 0;
}

.filter.is-active .filter-media {
  background: none;
  box-shadow: none;
}

.filter.is-hidden-by-search,
.filter-group.is-hidden-by-search {
  display: none !important;
}

.filters.is-empty::after {
  content: "Ничего не найдено";
  display: block;
  padding: 14px 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.filter-chevron {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  position: relative;
  opacity: .85;
  transition: transform 180ms ease;
}

.filter-chevron::before {
  content: "";
  position: absolute;
  inset: 3px 4px 5px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.filter-group.is-open .filter-chevron { transform: rotate(180deg); }

.filter--parent { font-weight: 500; }

.filter--zone {
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: #fff;
  color: #3a4154;
  font-size: 13px;
  font-weight: 500;
  box-shadow: inset 0 0 0 1px #edf0f5;
}

.filter--zone::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--category-color, #b9c9ae);
}

.filter--with-icon.filter--zone::before {
  display: none;
}

.filter--zone.is-active {
  background: color-mix(in srgb, var(--category-color, #94B880) 16%, white);
  color: color-mix(in srgb, var(--category-color, #94B880) 72%, #283044);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--category-color, #94B880) 52%, transparent);
}

.map-legend {
  align-self: end;
  display: flex;
  flex-wrap: wrap;
  gap: 20px 28px;
  padding: 18px 4px 0;
  color: #2d334a;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.legend-icon {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: var(--red);
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
}

.legend-icon--parking {
  border: 2px solid var(--red);
  border-radius: 4px;
}

.legend-icon--entrance::before {
  content: "";
  position: absolute;
  width: 14px;
  height: 13px;
  left: 4px;
  bottom: 2px;
  border: 2px solid var(--red);
  border-top: 0;
  border-radius: 2px;
}

.legend-icon--entrance::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  left: 5px;
  top: 1px;
  border-left: 2px solid var(--red);
  border-top: 2px solid var(--red);
  transform: rotate(45deg);
  border-radius: 2px 0 0 0;
}

.help { display: none; }

    .map-area {
  position: relative;
  min-width: 0;
  align-self: start;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 20px 58px rgba(17, 24, 39, .08);
  width: 650px;
}

.viewport {
  height: clamp(620px, 43vw, 760px);
  min-height: 0;
  overflow: hidden;
  outline: none;
  touch-action: none;
  cursor: grab;
  display: grid;
  place-items: center;
  background: #fff;
}

.viewport.is-dragging { cursor: grabbing; }

.viewport:focus-visible { box-shadow: inset 0 0 0 3px rgba(239, 11, 8, .16); }

.map-svg {
  width: 100%;
  height: 100%;
  display: block;
  background: #fff;
}


.map-controls {
  display: none;
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 20;
  gap: 8px;
  align-items: center;
}

.map-controls button {
  width: 42px;
  height: 42px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .96);
  color: #20242b;
  box-shadow: 0 6px 18px rgba(17, 24, 39, .12);
  font: inherit;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.map-controls button:hover {
  background: #fff;
}

.map-controls button:active {
  transform: translateY(1px);
}

.map-controls button:focus-visible {
  outline: 3px solid rgba(239, 11, 8, .22);
  outline-offset: 2px;
}


.details,
.details--hidden {
  display: none !important;
}

/* Базовый слой не участвует в hit-testing, поэтому не перекрывает цветовые зоны. */
#base-layer { pointer-events: none; }
#base-layer image { pointer-events: none; }

/*
  Цвета торговых зон приходят из zoneColorScheme в data/map-data.json.
  В SVG хранится только геометрия; app.js переносит палитру в CSS-переменные.
*/
#zones-layer,
#bus-layer {
  fill: none;
}

#zones-layer [data-zone="true"] {
  pointer-events: all;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

#zones-layer [data-zone="true"]:not(g),
#zones-layer g[data-zone="true"] [data-zone-part="true"] {
  stroke: transparent;
  stroke-width: 10;
  paint-order: stroke fill;
  fill: var(--zone-gray-fill, #C8C8C8);
  fill-opacity: 1;
  opacity: 1;
  transition: fill 220ms ease, fill-opacity 220ms ease, opacity 180ms ease, stroke 220ms ease;
}

#zones-layer [data-zone="true"].is-hovered:not(g),
#zones-layer g[data-zone="true"].is-hovered [data-zone-part="true"] {
  fill: var(--zone-hover-fill, var(--zone-fill));
  fill-opacity: var(--zone-fill-opacity, 1);
  opacity: var(--zone-opacity, 1);
  stroke: transparent;
}

#zones-layer [data-zone="true"].is-active:not(g),
#zones-layer g[data-zone="true"].is-active [data-zone-part="true"] {
  fill: var(--zone-active-fill, var(--zone-fill));
  fill-opacity: var(--zone-fill-opacity, 1);
  opacity: var(--zone-opacity, 1);
  stroke: transparent;
}

#zones-layer [data-zone="true"].is-category-highlighted:not(g),
#zones-layer g[data-zone="true"].is-category-highlighted [data-zone-part="true"] {
  fill: var(--zone-highlight-fill, var(--zone-fill));
  fill-opacity: var(--zone-fill-opacity, 1);
  opacity: var(--zone-opacity, 1);
  stroke: transparent;
  stroke-width: 10px;
}

#zones-layer [data-zone="true"].is-category-blinking:not(g),
#zones-layer g[data-zone="true"].is-category-blinking [data-zone-part="true"] {
  animation: map-category-outline-pulse 1500ms ease-in-out 1;
}

@keyframes map-category-outline-pulse {
  0%, 50% {
    fill: var(--zone-gray-fill, #C8C8C8);
    fill-opacity: 1;
    opacity: 1;
    stroke: var(--zone-outline-color, var(--zone-category-color));
    stroke-width: 2.5px;
    stroke-opacity: 1;
    vector-effect: non-scaling-stroke;
  }
  25%, 75%, 100% {
    fill: var(--zone-highlight-fill, var(--zone-fill));
    fill-opacity: var(--zone-fill-opacity, 1);
    opacity: var(--zone-opacity, 1);
    stroke: transparent;
    stroke-width: 10px;
    stroke-opacity: 0;
  }
}

#zones-layer [data-zone="true"]:focus,
#zones-layer [data-zone="true"]:focus-visible { outline: none; }

#zones-layer [data-zone="true"].is-muted:not(g),
#zones-layer [data-zone="true"].is-muted.is-hovered:not(g),
#zones-layer g[data-zone="true"].is-muted [data-zone-part="true"],
#zones-layer g[data-zone="true"].is-muted.is-hovered [data-zone-part="true"] {
  fill: var(--zone-gray-fill, #C8C8C8);
  fill-opacity: 1;
  opacity: .14;
  stroke: transparent;
  stroke-width: 10;
}

/*
  Объекты вне активного таба остаются кликабельными. При наведении или выборе
  они временно возвращают цвет из JSON, не сбрасывая активный таб.
*/
#zones-layer [data-zone="true"].is-muted.is-hovered:not(g),
#zones-layer g[data-zone="true"].is-muted.is-hovered [data-zone-part="true"] {
  fill: var(--zone-hover-fill, var(--zone-fill));
  fill-opacity: var(--zone-fill-opacity, 1);
  opacity: var(--zone-opacity, 1);
  stroke: transparent;
  stroke-width: 10px;
}

#zones-layer [data-zone="true"].is-muted.is-active:not(g),
#zones-layer g[data-zone="true"].is-muted.is-active [data-zone-part="true"] {
  fill: var(--zone-active-fill, var(--zone-fill));
  fill-opacity: var(--zone-fill-opacity, 1);
  opacity: var(--zone-opacity, 1);
  stroke: transparent;
  stroke-width: 10px;
}

@media (prefers-reduced-motion: reduce) {
  #zones-layer [data-zone="true"]:not(g),
  #zones-layer g[data-zone="true"] [data-zone-part="true"] { transition: none; }
  #zones-layer [data-zone="true"].is-category-blinking:not(g),
  #zones-layer g[data-zone="true"].is-category-blinking [data-zone-part="true"] { animation: none; }
}

.map-popover {
  position: absolute;
  z-index: 9;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: min(360px, calc(100% - 32px));
  padding: 14px 44px 14px 14px;
  border: 1px solid #e3e6ed;
  border-radius: 18px;
  color: #17221e;
  background: rgba(255,255,255,.96);
  box-shadow: 0 18px 45px rgba(17,24,39,.18);
  backdrop-filter: blur(10px);
}

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

.map-popover__close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #79808d;
  background: transparent;
  font-size: 22px;
  line-height: 1;
}

.map-popover__close:hover {
  color: var(--red);
  background: #fff0f0;
}

.map-popover__image {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  object-fit: contain;
  border-radius: 0;
  background: none;
}

.map-popover__image[hidden] { display: none !important; }

.map-popover__content { min-width: 0; }

.map-popover__title {
  margin: 0 0 4px;
  font-size: 17px;
  line-height: 1.16;
  font-weight: 800;
  letter-spacing: -.02em;
}

.map-popover__description {
  margin: 0;
  color: #5f6673;
  font-size: 14px;
  line-height: 1.36;
}

.card,
.details-empty { display: none; }

@media (max-width: 1200px) {
  .map-app {
    width: min(100% - 40px, 1060px);
    padding-top: 34px;
  }


  .map-header { grid-template-columns: 1fr; }

  .map-layout {
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 16px;
  }

  .viewport { height: 640px; }

  .map-area {
    width: 100%;
  }
}

@media (max-width: 900px) {

  .map-app {
    width: min(100% - 28px, 720px);
    padding: 26px 0 34px;
  }

  .map-layout { grid-template-columns: 1fr; }

  /* На мобильной версии карта отображается раньше поиска, табов и легенды. */
  .map-area {
    order: 1;
  }

  .map-sidebar {
    order: 2;
    min-height: 0;
  }

  .category-card { max-height: 380px; }

  .viewport { height: 560px; }

  .map-controls {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .map-legend {
    align-self: start;
    font-size: 16px;
  }

  .map-popover {
    position: absolute;
    left: 14px !important;
    right: 14px;
    bottom: 14px;
    top: auto !important;
    width: auto;
  }
}

@media (max-width: 520px) {
  .map-app { width: 100%; }

  .map-header h1 { font-size: 34px; }

  .map-lead { font-size: 17px; }

  .search input {
    height: 58px;
    padding-left: 56px;
    font-size: 17px;
  }

  .category-card { padding: 10px; }

  .filter {
    min-height: 45px;
    padding: 0 14px;
    border-radius: 14px;
    font-size: 16px;
  }

  .viewport { height: 400px; }
}

/* Офисы остаются частью графической схемы, но полностью отключены от интерактивности. */
#zones-layer .is-map-object-disabled,
#zones-layer .is-map-object-disabled * {
  pointer-events: none !important;
  cursor: default !important;
}

/* Неинтерактивные офисы: серый фон вместо исходного фиолетового. */
#zones-layer .is-map-object-disabled [data-zone-part="true"],
#zones-layer .is-map-object-disabled[data-zone-part="true"] {
  fill: #C8C8C8 !important;
  fill-opacity: 1 !important;
  opacity: 1 !important;
  stroke: #888888 !important;
}

/* Левая остановка бесплатного транспорта: сохраняем конструктивную серую рамку из макета. */
#zones-layer #free-transport-stop-1[data-zone="true"]:not(.is-category-blinking) {
  stroke: #D5DAE3;
  stroke-width: 8;
}

.map-tab__icon {
  display: block;
  flex: 0 0 21px;
  width: 21px;
  height: 21px;

  background-image: var(--icon-normal);
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

/* Наведение мышью */
.map-tab:hover .map-tab__icon {
  background-image: var(--icon-hover, var(--icon-normal));
}

/* Активный таб */
.map-tab.is-active .map-tab__icon {
  background-image: var(--icon-active, var(--icon-normal));
}

/* Активное состояние должно иметь приоритет над hover */
.map-tab.is-active:hover .map-tab__icon {
  background-image: var(--icon-active, var(--icon-normal));
}
@media (min-width: 2084px) {
  .map-area {
    width: 800px;
  }
}