/* Блок «Квартиры от застройщика» (ориентир: ТЗ / маркетплейсы) */

.flats-block {
  --flats-line: #ececf1;
  --flats-muted: #6b6b74;
}

.flats-block__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 20px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--flats-line);
}

.flats-block__head-text {
  flex: 1;
  min-width: 0;
}

.flats-block__title {
  font-family: var(--font-serif, Georgia, serif);
  font-size: clamp(18px, 1.85vw, 24px);
  font-weight: 700;
  margin: 0;
  color: #1f1f22;
  line-height: 1.35;
letter-spacing:0.03em;
}

/* Одна строка как в ТЗ: «Квартиры от застройщика. Цены — 20 марта» */
.flats-block__title-meta {
  font-weight: 500;
  color: var(--flats-muted);
}

.flats-block__title-meta time {
  font-weight: 600;
  color: #2b2b2f;
}

.flats-block__info {
  flex-shrink: 0;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--flats-line);
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  color: #2b2b2f;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.flats-block__info:hover {
  border-color: rgba(227, 6, 19, 0.35);
  background: rgba(227, 6, 19, 0.04);
}

.flats-block__info-panel {
  margin: -8px 0 18px;
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.55;
  color: #4b4b53;
  background: #f8f9fb;
  border: 1px solid var(--flats-line);
  border-radius: 12px;
}

.flats-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 0;
  border: 1px solid var(--flats-line);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
}

.flats-toolbar__block {
  padding: 14px 16px;
  border-bottom: 1px solid var(--flats-line);
}

.flats-toolbar__block:last-child {
  border-bottom: 0;
}

.flats-toolbar__block--compact {
  padding-top: 10px;
  padding-bottom: 10px;
}

.flats-area-hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: #c2410c;
}

.flats-completion-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.flats-toolbar__hint {
  margin: 0;
  max-width: 42rem;
  font-size: 12px;
  line-height: 1.45;
  color: var(--flats-muted);
}

.flats-more-panel__lead {
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--flats-muted);
}

.flats-input-group-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.flats-input-group {
  display: flex;
  align-items: center;
  background: #fff;
  border: 1px solid var(--flats-line);
  border-radius: 8px;
  padding: 0 10px;
  height: 38px;
}

.flats-input-sep {
  color: var(--flats-muted);
  margin: 0 4px;
  font-size: 13px;
}

.flats-toggle-group {
  display: flex;
  background: #f4f5f7;
  padding: 3px;
  border-radius: 8px;
  margin-left: 8px;
}

.flats-toggle-btn {
  border: 0;
  background: transparent;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #6b6b74;
  cursor: pointer;
}

.flats-toggle-btn.is-active {
  background: #fff;
  color: #2b2b2f;
  box-shadow: 0 2px 4px rgba(30,30,36,0.08);
}

.flats-toolbar__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
}

.flats-toolbar__label {
  font-size: 13px;
  font-weight: 600;
  color: #2b2b2f;
  flex-shrink: 0;
}

.flats-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.flats-chip {
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--flats-line);
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  color: #2b2b2f;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.flats-chip:hover {
  border-color: rgba(227, 6, 19, 0.4);
}

.flats-chip.is-active {
  border-color: rgba(227, 6, 19, 0.55);
  background: rgba(227, 6, 19, 0.1);
  color: #1a1a1e;
}

.flats-field-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  font-size: 13px;
  color: #2b2b2f;
}

.flats-field-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.flats-input {
  width: 72px;
  max-width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--flats-line);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}

.flats-select {
  min-height: 36px;
  padding: 0 32px 0 12px;
  border: 1px solid var(--flats-line);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  cursor: pointer;
}

.flats-more-toggle {
  align-self: flex-start;
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 700;
  color: #e30613;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.flats-more-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  padding: 14px;
  background: #fafbfc;
  border: 1px solid var(--flats-line);
  border-radius: 12px;
}

.flats-sort-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin: 16px 0 14px;
  padding: 12px 0;
  border-top: 1px solid var(--flats-line);
  font-size: 13px;
  color: var(--flats-muted);
}

.flats-sort-row__label {
  font-weight: 600;
  color: #2b2b2f;
}

.flats-sort-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.flats-sort-pill {
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--flats-line);
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  color: #2b2b2f;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.flats-sort-pill:hover {
  border-color: rgba(227, 6, 19, 0.35);
}

.flats-sort-pill.is-active {
  border-color: rgba(227, 6, 19, 0.55);
  background: rgba(227, 6, 19, 0.08);
  color: #1a1a1e;
}

.flats-sort-pill__caret {
  display: inline-block;
  margin-left: 2px;
  font-size: 11px;
  color: #e30613;
}

/* Обёртка: шапка таблицы + строки */
.flats-list-wrap {
  border: 1px solid var(--flats-line);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
}

.flats-list-head {
  display: grid;
  grid-template-columns: 76px minmax(120px, 1.1fr) minmax(100px, 0.7fr) minmax(140px, 1fr) minmax(120px, 0.9fr) auto;
  gap: 12px 16px;
  align-items: center;
  padding: 12px 18px;
  background: #f4f5f7;
  border-bottom: 1px solid var(--flats-line);
  font-size: 12px;
  font-weight: 700;
  color: var(--flats-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.flats-list-head__cell--thumb {
  text-align: center;
}

.flats-list-head__cell--action {
  min-width: 140px;
}

/* Список строк */
.flats-list {
  display: flex;
  flex-direction: column;
  border: 0;
  border-radius: 0;
  overflow: visible;
  background: #fff;
}

.flats-row {
  display: grid;
  grid-template-columns: 76px minmax(120px, 1.1fr) minmax(100px, 0.7fr) minmax(140px, 1fr) minmax(120px, 0.9fr) auto;
  gap: 12px 16px;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid #f0f0f3;
  text-decoration: none;
  color: inherit;
  transition: background 0.18s ease;
  animation: flatsFadeIn 0.22s ease both;
}

.flats-row__thumb {
  width: 76px;
  height: 56px;
  border-radius: 10px;
  overflow: hidden;
  background: #eef0f3;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.flats-row__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.flats-row__thumb--empty::after {
  content: 'Нет плана';
  font-size: 9px;
  font-weight: 600;
  color: #a8aeb6;
  text-align: center;
  line-height: 1.15;
  padding: 4px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.flats-row--grouped .flats-row__thumb {
  display: none;
}

.flats-row__rooms {
  font-size: 15px;
  font-weight: 700;
  color: #1f1f22;
  text-transform: lowercase;
}

.flats-row__area {
  font-size: 14px;
  color: #2b2b2f;
}

.flats-row__m2 {
  font-size: 13px;
  color: var(--flats-muted);
}

.flats-row__plan {
  justify-self: end;
  font-size: 13px;
  font-weight: 600;
  color: #e30613;
  white-space: nowrap;
}

a.flats-row:hover,
[role="button"].flats-row:hover {
  background: #fafbfc;
}

.flats-row:last-child {
  border-bottom: 0;
}

/* Группированная строка (Яндекс-стайл) */
.flats-row--grouped {
  grid-template-columns: minmax(0, 1.2fr) minmax(180px, 0.9fr) minmax(180px, 1fr);
  padding: 24px 18px;
  cursor: pointer;
}

.flats-row--grouped:focus-visible {
  outline: 2px solid rgba(227, 6, 19, 0.35);
  outline-offset: -2px;
}

.flats-row__title {
  font-size: 19px;
  font-weight: 700;
  color: #1f1f22;
  margin-bottom: 2px;
}

.flats-row__subtitle {
  display: block;
  font-size: 14px;
  color: var(--flats-muted);
}

.flats-row__price-box {
  text-align: center;
}

.flats-row__price {
  font-size: 19px;
  font-weight: 800;
  color: #1f1f22;
}

.flats-row__variants {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 16px;
  text-align: right;
}

.flats-row__count-box {
  display: flex;
  flex-direction: column;
}

.flats-row__layouts {
  font-size: 15px;
  font-weight: 700;
  color: #1f1f22;
}

.flats-row__apartments {
  font-size: 13px;
  color: var(--flats-muted);
}

.flats-row__chevron {
  width: 20px;
  height: 20px;
  color: #c1c1cb;
  transform: rotate(-90deg);
  transition: transform 0.25s ease, color 0.2s;
}

.flats-row--grouped.is-expanded .flats-row__chevron {
  transform: rotate(0deg);
}

.flats-row:hover .flats-row__chevron,
.flats-row:focus-visible .flats-row__chevron {
  color: #2b2b2f;
}

/* Вложенный список (Аккордеон) */
.flats-nested-list {
  background: #fdfdfe;
  border-top: 1px solid #f0f0f3;
  animation: flatsFadeIn 0.3s ease;
}

.flats-row--nested {
  display: none !important;
}

/* Карточки планировок (Layout Cards) */
.flats-layout-card {
  display: flex;
  background: #fdfdfe;
  border-bottom: 1px solid #f0f0f3;
  padding: 24px 18px;
  gap: 32px;
  align-items: center;
}

.flats-layout-card:last-child {
  border-bottom: 0;
}

.flats-layout-card__media {
  width: 250px;
  height: 200px;
  flex-shrink: 0;
  background: #f4f5f8;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.flats-layout-card__media img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  mix-blend-mode: multiply;
}

.flats-layout-card__noimg {
  color: #a0a6ae;
  font-size: 14px;
}

.flats-layout-card__info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex-grow: 1;
}

.flats-layout-card__title {
  font-size: 19px;
  font-weight: 700;
  color: #1f1f22;
  margin-bottom: 16px;
}

.flats-layout-card__props {
  display: grid;
  grid-template-columns: auto auto;
  column-gap: 16px;
  row-gap: 8px;
  font-size: 14px;
  margin-bottom: 24px;
  color: #1f1f22;
}

.flats-layout-card__props span {
  color: #888d94;
}

.flats-layout-card__from {
  font-size: 13px;
  font-weight: 700;
  color: #1a7f37;
  margin: 0 0 10px;
}

.flats-layout-card__btn--disabled {
  opacity: 0.55;
  pointer-events: none;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  background: #e8e9ed !important;
  color: #6e6e6e !important;
}

.flats-layout-card__price-wrap {
  margin-bottom: 24px;
}

.flats-layout-card__price {
  font-size: 19px;
  font-weight: 800;
  color: #1f1f22;
  margin-bottom: 4px;
}

.flats-layout-card__m2 {
  font-size: 14px;
  color: var(--flats-muted);
}

.flats-layout-card__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 18px;
  background: var(--home-red, #e30613);
  border-radius: 8px;
  border: 0;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  align-self: flex-start;
  transition: background 0.2s, opacity 0.2s, color 0.2s;
}

.flats-pin-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: #f4f5f8;
  border-bottom: 1px solid var(--flats-line, #e8e8ed);
  font-size: 14px;
  color: #1f1f22;
}

.flats-pin-bar__text {
  font-weight: 600;
}

.flats-pin-bar__clear {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--flats-line, #e8e8ed);
  background: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  color: var(--flats-muted, #6e6e6e);
  transition: border-color 0.2s, color 0.2s;
}

.flats-pin-bar__clear:hover {
  border-color: #e30613;
  color: #e30613;
}

.flats-layout-card__btn:hover {
  background: var(--home-red-deep, #b8040f);
  color: #fff;
}

.flats-show-more-wrap {
  margin-top: 16px;
  display: flex;
  justify-content: center;
}

.flats-show-more {
  min-height: 44px;
  padding: 0 24px;
  border-radius: 12px;
  border: 1px solid var(--flats-line);
  background: #fff;
  font-size: 14px;
  font-weight: 700;
  color: #2b2b2f;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.flats-show-more:hover {
  border-color: rgba(227, 6, 19, 0.45);
  background: rgba(227, 6, 19, 0.06);
}

.flats-empty {
  padding: 28px 16px;
  text-align: center;
  border: 1px dashed var(--flats-line);
  border-radius: 14px;
  background: #fafbfc;
}

.flats-empty__title {
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 8px;
}

.flats-empty__desc {
  font-size: 14px;
  color: var(--flats-muted);
  margin: 0 0 16px;
}

.flats-empty__reset {
  min-height: 42px;
  padding: 0 20px;
  border-radius: 10px;
  border: 0;
  background: #e30613;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

@keyframes flatsFadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 900px) {
  .flats-list-head {
    display: none;
  }

  .flats-row {
    grid-template-columns: 1fr 1fr;
    gap: 10px 12px;
  }

  .flats-row.flats-row--detail {
    grid-template-columns: 88px 1fr;
    grid-template-rows: auto auto auto auto;
    align-items: start;
  }

  .flats-row.flats-row--detail .flats-row__thumb {
    grid-column: 1;
    grid-row: 1 / span 4;
    width: 88px;
    height: 66px;
    align-self: start;
  }

  .flats-row.flats-row--detail .flats-row__rooms {
    grid-column: 2;
    grid-row: 1;
  }

  .flats-row.flats-row--detail .flats-row__area {
    grid-column: 2;
    grid-row: 2;
  }

  .flats-row.flats-row--detail .flats-row__price-box {
    grid-column: 2;
    grid-row: 3;
  }

  .flats-row.flats-row--detail .flats-row__m2 {
    grid-column: 2;
    grid-row: 4;
  }

  .flats-row.flats-row--detail .flats-row__plan {
    grid-column: 1 / -1;
    grid-row: 5;
    justify-self: start;
    padding-top: 4px;
  }

  .flats-row--grouped {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .flats-row__price-box {
    text-align: left;
  }

  .flats-row__variants {
    justify-content: space-between;
    text-align: left;
  }

  .flats-list-head--nested,
  .flats-row--nested {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }

  .flats-row:not(.flats-row--detail) .flats-row__plan {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .flats-row:not(.flats-row--detail) .flats-row__price {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .flats-field-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .flats-input-group-wrap {
    width: 100%;
    flex-wrap: wrap;
  }

  .flats-toggle-group {
    margin-left: 0;
  }

  .flats-sort-pills {
    width: 100%;
  }

  .flats-sort-pill {
    flex: 1 1 auto;
    justify-content: center;
  }

  .flats-list-head--nested {
    display: none;
  }

  .flats-row--nested {
    display: none !important;
  }

  .flats-layout-card {
    flex-direction: column;
    padding: 16px;
    gap: 16px;
  }

  .flats-layout-card__media {
    width: 100%;
    height: 220px;
  }
}
