/*
 * Адаптивность — финальный слой (подключается последним).
 * Брейкпоинты:
 *   ≥ 1280      — компьютер: полное боковое меню;
 *   901–1279    — ноутбук и планшет горизонтально: меню-«рельс» из иконок;
 *   601–900     — планшет вертикально: нижняя панель, контент в 2–3 колонки;
 *   ≤ 600       — телефон;  ≤ 360 — узкий телефон.
 */

/* ---------- Общее для всех ширин ---------- */
/* Карточки списка на главной: адрес на всю ширину, статус и срок — отдельной строкой */
.dash-map .result { flex-wrap: wrap; row-gap: 6px; }
.dash-map .result-main { flex-basis: 100%; }
.dash-map .result-side { flex-direction: row; align-items: center; justify-content: space-between; width: 100%; }
.dash-map .result-addr, .dash-map .result-sub { white-space: normal; }

/* Полоса фактов в карточке места: колонки по ширине, значения не рвутся посередине */
.pl-facts { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.pl-fact-val { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.pl-fact > div { min-width: 0; }

/* Заголовок в шапке не выталкивает кнопки */
.topbar-title { min-width: 0; flex: 1 1 auto; }
.topbar-title h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 901–1279: компактное меню-«рельс» ---------- */
@media (min-width: 901px) and (max-width: 1279px) {
  :root { --sidebar: 76px; }
  .sidebar { padding: 18px 10px 12px; align-items: stretch; }
  .logo { justify-content: center; padding: 6px 0 18px; }
  .logo > span:not(.logo-bar), .nav-group, .nav-link .nav-full, .nav-cta-text,
  .nav-user > span:not(.avatar) { display: none; }
  .nav-cta { width: 48px; height: 44px; padding: 0; margin: 0 auto 14px; }
  .nav-link { justify-content: center; padding: 12px 0; }
  .nav-link + .nav-link { margin-top: 2px; }
  .nav-link.active::before { left: -10px; }
  .nav-user { justify-content: center; padding: 10px 0; }
  .user-btn .hide-mobile { display: none; }
  .topbar-search { flex: 0 1 300px; }

  .pl-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* Главная: список чуть уже, карта шире */
  .dash-map { grid-template-columns: 300px 1fr; }
}

/* ---------- ≤ 900: нижняя панель, вертикальные раскладки ---------- */
@media (max-width: 900px) {
  /* Главная: карта сверху, список с фильтрами — обычным блоком под ней (без шторки) */
  .dash-map {
    display: flex; flex-direction: column; height: auto; min-height: 0; overflow: visible;
    margin: 0 -16px; border-radius: 0; border-left: 0; border-right: 0;
  }
  .dash-map .map-wrap {
    position: relative; inset: auto; height: 62vh; height: 62dvh; min-height: 340px; max-height: 720px;
    scroll-margin-top: 64px;
  }
  .dash-map .map-side {
    position: static; transform: none; height: auto; z-index: auto;
    border-radius: 0; box-shadow: none; border-top: 1px solid var(--line);
  }
  .dash-map .map-side-head { position: static; }
  .dash-map .map-side-filters { padding: 14px 16px 10px; }
  .dash-map .map-side-list { max-height: none; overflow: visible; padding-bottom: 8px; }
  .dash-map .leaflet-bottom { bottom: 0; }
  .sheet-handle { display: none; }

  /* Карточка места */
  .pl-hero-actions { width: 100%; }
}

/* ---------- 601–900: планшет вертикально ---------- */
@media (min-width: 601px) and (max-width: 900px) {
  /* Показатели — сеткой 3 × 2 вместо ленты с прокруткой */
  .dash-kpis {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px;
    overflow: visible; margin: 0 0 14px; padding: 0;
  }
  .dash-kpis .kpi { flex: none; min-height: 0; }
  .dash-map .map-wrap { height: 56vh; }
  .pl-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- ≤ 600: телефон ---------- */
@media (max-width: 600px) {
  .pl-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pl-fact { flex-direction: column; align-items: flex-start; gap: 8px; }
  /* Список мест (карточки): номер и статус переносятся, а не вылезают за край */
  .table.responsive td[data-m=num] { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
  .table.responsive td { min-width: 0; }
  .table.responsive .ls-mob .pg-st, .table.responsive .badge { max-width: 100%; white-space: normal; }
  /* Длинные статусы («Договор заканчивается») переносятся внутри узких колонок */
  .pl .badge { max-width: 100%; white-space: normal; height: auto; min-height: 24px; padding-top: 3px; padding-bottom: 3px; text-align: left; }
}

/* ---------- ≤ 360: узкий телефон ---------- */
@media (max-width: 360px) {
  .sidebar { padding-left: 2px; padding-right: 2px; gap: 0; }
  .sidebar > * { flex: 1 1 0; }
  .nav-link { min-width: 0; padding: 6px 0; font-size: 10px; letter-spacing: -0.01em; }
  .nav-link .nav-short { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .nav-link[data-nav=new] svg { width: 40px; height: 40px; padding: 10px; }
  .content { padding-left: 12px; padding-right: 12px; }
  .dash-map { margin: 0 -12px; }
  .dash-kpis { margin-left: -12px; margin-right: -12px; padding-left: 12px; padding-right: 12px; scroll-padding: 0 12px; }
  .pl-facts { grid-template-columns: 1fr; }
  .pl-fact { flex-direction: row; align-items: center; }
  .topbar { padding-left: 12px; padding-right: 12px; }
}

/* Список мест на ноутбуке: без миниатюры и колонки «Тип», чтобы таблица помещалась целиком */
@media (min-width: 901px) and (max-width: 1279px) {
  .ls-table th:nth-child(1), .ls-table td:nth-child(1),
  .ls-table th:nth-child(4), .ls-table td:nth-child(4) { display: none; }
}
/* Полосы в аналитике — ровный цвет без градиента */
.an-hbar-fill { background: var(--brand); }
