/* Редизайн: list (главная). Загружается после styles.css и переопределяет его.
   Все правила привязаны к элементам главной (#filtersForm, #objectsGrid, #listPagination, #emptyState, #scrollTopButton, #resultsMeta),
   чтобы не задеть статистику, пользователей и профиль, где те же базовые классы. */

/* ---------- Фильтры: компактный тулбар ---------- */
.filters-card:has(#filtersForm) {
  padding: 12px;
  border-radius: var(--radius-lg);
}

#filtersForm {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  margin: 0;
}

#filtersForm .field {
  position: relative;
  display: block;
  margin: 0;
  min-width: 0;
}

#filtersForm .field > span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  margin: -1px;
  padding: 0;
  border: 0;
}

#filtersForm .field input,
#filtersForm .field select {
  width: 100%;
  min-height: 44px;
  height: 44px;
  box-sizing: border-box;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface-strong);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  padding: 0 14px;
}

#filtersForm .field--search input {
  padding-left: 44px;
}

#filtersForm .field__icon {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  color: var(--text-soft);
  pointer-events: none;
}

#filtersForm .field input:focus-visible,
#filtersForm .field select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- Шапка списка ---------- */
.list-card:has(#objectsGrid) .list-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.list-card:has(#objectsGrid) .list-card__top h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}

#resultsMeta {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin: 0;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(102, 113, 128, 0.12);
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 700;
}

/* ---------- Таблица объектов: металлическая тёмная ---------- */
#objectsGrid .objects-table {
  overflow: hidden;
  border: 1px solid rgba(166, 184, 204, 0.18);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--surface-dark-strong) 0%, var(--surface-dark) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 18px 34px rgba(15, 20, 28, 0.18);
}

#objectsGrid .objects-table__head,
#objectsGrid .objects-table__row {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) 110px minmax(130px, 1fr) minmax(170px, 1.2fr) 150px;
  gap: 16px;
  align-items: center;
  min-width: 0;
  padding: 14px 18px;
}

#objectsGrid .objects-table__head {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(244, 247, 251, 0.6);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#objectsGrid .objects-table .objects-table__row {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: transparent;
  cursor: pointer;
  transition: background 180ms ease, box-shadow 180ms ease;
  content-visibility: auto;
  contain-intrinsic-size: 88px;
}

#objectsGrid .objects-table .objects-table__row:first-of-type {
  border-top: 0;
}

#objectsGrid .objects-table .objects-table__row:hover {
  background: rgba(255, 255, 255, 0.06);
  transform: none;
}

#objectsGrid .objects-table .objects-table__row:hover .objects-table__title strong {
  color: var(--text-inverse);
}

#objectsGrid .objects-table .objects-table__row:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  box-shadow: none;
}

#objectsGrid .objects-table .objects-table__row--fresh {
  background: transparent;
}

#objectsGrid .objects-table .objects-table__row--stale {
  background: transparent;
  box-shadow: inset 3px 0 0 var(--danger);
}

#objectsGrid .objects-table .objects-table__row--stale:hover {
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 3px 0 0 var(--danger);
}

#objectsGrid .objects-table__title {
  display: grid;
  gap: 6px;
  min-width: 0;
}

#objectsGrid .objects-table__title strong {
  color: rgba(244, 247, 251, 0.9);
  font-size: 1rem;
  letter-spacing: -0.02em;
  transition: color 180ms ease;
}

#objectsGrid .objects-table__muted {
  color: rgba(244, 247, 251, 0.7);
  line-height: 1.5;
}

#objectsGrid .objects-table__cell {
  min-width: 0;
}

#objectsGrid .objects-table__cell::before {
  content: none;
}

/* ≤1100px: каждая строка — карточка */
@media (max-width: 1100px) {
  #objectsGrid .objects-table {
    padding: 10px;
  }

  #objectsGrid .objects-table__head {
    display: none;
  }

  #objectsGrid .objects-table .objects-table__row,
  #objectsGrid .objects-table .objects-table__row + .objects-table__row,
  #objectsGrid .objects-table .objects-table__row:first-of-type {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 16px;
    padding: 14px 16px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
  }

  #objectsGrid .objects-table .objects-table__row + .objects-table__row {
    margin-top: 10px;
  }

  #objectsGrid .objects-table .objects-table__row--stale {
    box-shadow: inset 3px 0 0 var(--danger);
  }

  #objectsGrid .objects-table__title {
    grid-column: 1 / -1;
  }

  #objectsGrid .objects-table__title strong {
    font-size: 16px;
    font-weight: 700;
  }

  #objectsGrid .objects-table__cell {
    display: grid;
    gap: 4px;
    align-content: start;
  }

  #objectsGrid .objects-table__cell::before {
    content: attr(data-label);
    color: rgba(244, 247, 251, 0.78);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  #objectsGrid .objects-table__title::before {
    content: none;
  }
}

/* ---------- Пагинация ---------- */
#listPagination:not(.hidden) {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

#listPagination .pagination__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface-strong);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 180ms ease, border-color 180ms ease;
}

#listPagination .pagination__button svg {
  width: 20px;
  height: 20px;
  flex: none;
}

#listPagination .pagination__button:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

#listPagination .pagination__button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

#listPagination .pagination__button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#listPagination .pagination__status {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 14px;
  color: var(--text-soft);
  white-space: nowrap;
}

/* ---------- Пустое состояние ---------- */
#emptyState {
  padding: 32px 20px;
  text-align: center;
  border-radius: var(--radius-md);
  border: 1px solid rgba(166, 184, 204, 0.18);
  background: linear-gradient(180deg, var(--surface-dark-strong) 0%, var(--surface-dark) 100%);
  color: var(--text-inverse);
}

#emptyState h3 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 800;
}

#emptyState p {
  margin: 0 0 16px;
  color: rgba(244, 247, 251, 0.75);
}

/* ---------- Кнопка «Наверх» ---------- */
#scrollTopButton {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--glass-border-strong);
  background: linear-gradient(180deg, rgba(43, 53, 67, 0.92) 0%, rgba(27, 35, 47, 0.9) 100%);
  color: var(--text-inverse);
  box-shadow: var(--glass-shadow-md);
  cursor: pointer;
}

#scrollTopButton svg {
  width: 20px;
  height: 20px;
}

#scrollTopButton:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- Адаптив ---------- */
@media (max-width: 900px) {
  #filtersForm {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #filtersForm .field--search {
    grid-column: 1 / -1;
  }
}

@media (max-width: 600px) {
  #filtersForm {
    grid-template-columns: minmax(0, 1fr);
  }

  #filtersForm .field--search {
    grid-column: auto;
  }

  #objectsGrid .objects-table__cell[data-label="Город / статус"],
  #objectsGrid .objects-table__cell[data-label="Последняя выгрузка"] {
    grid-column: 1 / -1;
  }

  #listPagination .pagination__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    margin: -1px;
    padding: 0;
    border: 0;
  }

  #listPagination .pagination__button {
    padding: 0;
    min-width: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #objectsGrid .objects-table .objects-table__row,
  #objectsGrid .objects-table__title strong,
  #listPagination .pagination__button {
    transition: none;
  }

  #objectsGrid.is-rendered .objects-table__row {
    animation: none;
  }
}

/* ============================================
   Мобильная вёрстка 320–414px: карточки строк на главной
   ============================================ */
@media (max-width: 1100px) {
  #objectsGrid .objects-table .objects-table__row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #objectsGrid .objects-table .objects-table__row > * {
    min-width: 0;
  }
}

#objectsGrid .badge {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: left;
}
