/* ============================================================
   Слой компоновки: шапка страницы, панель инструментов, карточки
   показателей, состояния. Подключается в корневом макете, доступен
   всем разделам.

   Прежняя версия меняла только цвета — расположение оставалось
   пэхапэшным: страница начиналась сразу с крошек и таблицы, фильтры
   висели голыми select справа от крошек, у показателей не было ни
   иерархии, ни иконок. Здесь задаётся именно раскладка.
   ============================================================ */

/* ===================== ШАПКА СТРАНИЦЫ ===================== */

.page-head{ margin:2px 0 18px }

.page-head__crumbs{
  display:flex; align-items:center; flex-wrap:wrap;
  font-size:12px; color:var(--muted); margin-bottom:8px;
}
.page-head__crumb{ display:inline-flex; align-items:center }
.page-head__crumb i{ font-size:9px; margin:0 8px; opacity:.6 }
.page-head__crumb a{ transition:color var(--fast) }
.page-head__crumb a:hover{ color:var(--text-dim) }
.page-head__crumb:last-child a{ color:var(--text-dim) }

.page-head__row{
  display:flex; align-items:flex-start; justify-content:space-between;
  gap:14px; flex-wrap:wrap;
}
.page-head__main{ display:flex; align-items:center; gap:14px; min-width:0 }

.page-head__icon{
  flex:none; width:40px; height:40px; border-radius:11px;
  display:grid; place-items:center; font-size:17px;
  color:var(--accent); background:var(--accent-soft);
  border:1px solid var(--border-accent);
}

.page-head__text{ min-width:0 }
.page-head__title{
  font:22px/1.2 Roboto-Medium, Arial, sans-serif;
  margin:0; letter-spacing:-.2px; color:var(--text);
}

.page-head__actions{ display:flex; align-items:center; gap:10px; flex-wrap:wrap }
.page-head__tools{ margin-top:14px }

@media (max-width:700px){
  .page-head__title{ font-size:20px }
  .page-head__icon{ width:40px; height:40px; font-size:17px }
  .page-head__actions{ width:100% }
}

/* ===================== ПАНЕЛЬ ИНСТРУМЕНТОВ ===================== */

.toolbar{
  display:flex; align-items:center; justify-content:space-between;
  gap:10px; flex-wrap:wrap;
  padding:10px 12px;
  background:var(--surface-2);
  border:1px solid var(--border);
  border-radius:var(--radius);
}
.toolbar__controls{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; min-width:0 }
.toolbar__meta{ color:var(--muted); font-size:13px; white-space:nowrap }

.search-field{ position:relative; display:inline-flex; align-items:center; min-width:0 }
.search-field__icon{
  position:absolute; left:13px; font-size:13px; color:var(--muted);
  pointer-events:none; transition:color var(--fast);
}
.search-field__input{
  width:270px; max-width:100%;
  padding:10px 34px 10px 34px;
  background:var(--surface-3); color:var(--text);
  border:1px solid var(--border); border-radius:var(--radius-sm);
  font-family:inherit; font-size:14px; outline:none;
  transition:border-color var(--fast), background var(--fast), box-shadow var(--fast);
}
.search-field__input::placeholder{ color:var(--muted) }
.search-field__input:hover{ border-color:var(--border-strong) }
.search-field__input:focus{
  border-color:var(--border-accent); background:var(--surface-hover);
  box-shadow:0 0 0 3px var(--accent-soft);
}
.search-field:focus-within .search-field__icon{ color:var(--accent) }
.search-field__clear{
  position:absolute; right:8px;
  width:22px; height:22px; border-radius:50%;
  display:grid; place-items:center;
  border:0; background:transparent; color:var(--muted); cursor:pointer;
  font-size:12px; transition:background var(--fast), color var(--fast);
}
.search-field__clear:hover{ background:var(--surface-hover); color:var(--text) }

.select-field{ position:relative; display:inline-flex; align-items:center }
.select-field__icon{
  position:absolute; left:13px; font-size:13px; color:var(--muted); pointer-events:none;
}
.select-field__input{
  appearance:none;
  padding:10px 34px 10px 34px;
  background:var(--surface-3); color:var(--text-dim);
  border:1px solid var(--border); border-radius:var(--radius-sm);
  font-family:inherit; font-size:14px; outline:none; cursor:pointer;
  transition:border-color var(--fast), background var(--fast), box-shadow var(--fast);
}
.select-field__input:hover{ border-color:var(--border-strong) }
.select-field__input:focus{ border-color:var(--border-accent); box-shadow:0 0 0 3px var(--accent-soft) }
.select-field__input option{ background:var(--surface); color:var(--text) }
.select-field__caret{
  position:absolute; right:12px; font-size:10px; color:var(--muted); pointer-events:none;
}
/* Без иконки слева отступ лишний. */
.select-field:not(:has(.select-field__icon)) .select-field__input{ padding-left:14px }

/* ===================== КАРТОЧКА ПОКАЗАТЕЛЯ ===================== */

.stat{  position:relative; overflow:hidden;
  display:flex; flex-direction:column; gap:3px;
  padding:14px 15px;
  background:var(--surface);
  border:1px solid var(--border); border-radius:var(--radius);
  transition:border-color var(--base), transform var(--base);
}
.stat:hover{ border-color:var(--border-strong) }

.stat__top{ display:flex; align-items:center; justify-content:space-between; margin-bottom:8px }

.stat__icon{
  width:32px; height:32px; border-radius:9px;
  display:grid; place-items:center; font-size:13px;
  background:var(--surface-3); color:var(--muted);
  border:1px solid var(--border);
  transition:color var(--fast), background var(--fast);
}
.stat--good .stat__icon{ color:var(--good); background:var(--good-soft); border-color:rgba(48,209,88,.28) }
.stat--warn .stat__icon{ color:var(--warn); background:var(--warn-soft); border-color:rgba(255,159,10,.28) }
.stat--bad .stat__icon{ color:var(--bad); background:var(--bad-soft); border-color:rgba(255,69,58,.28) }

.stat__delta{
  display:inline-flex; align-items:center; gap:5px;
  font-size:12px; padding:4px 9px; border-radius:999px;
  font-variant-numeric:tabular-nums;
}
.stat__delta.is-up{ color:var(--good); background:var(--good-soft) }
.stat__delta.is-down{ color:var(--bad); background:var(--bad-soft) }

.stat__value{
  font:23px/1.15 Roboto-Medium, Arial, sans-serif;
  letter-spacing:-.3px; font-variant-numeric:tabular-nums;
  display:flex; align-items:baseline; gap:7px; flex-wrap:wrap;
}
.stat--good .stat__value{ color:var(--good) }
.stat--bad .stat__value{ color:var(--bad) }

.stat__note{ font-size:12.5px; color:var(--muted); font-family:Roboto-Regular }
.stat__label{ color:var(--text-dim); font-size:13px; margin-top:auto; padding-top:6px }
.stat__hint{ color:var(--muted); font-size:11.5px }

/* ===================== СОСТОЯНИЯ ===================== */

.empty{
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:10px; padding:34px 20px; text-align:center;
}
.empty__icon{
  width:60px; height:60px; border-radius:18px;
  display:grid; place-items:center; font-size:24px;
  color:var(--muted); background:var(--surface-3);
  border:1px solid var(--border);
}
.empty__title{ font:16px/1.3 Roboto-Medium, Arial, sans-serif; color:var(--text) }
.empty__hint{ color:var(--muted); font-size:13.5px; max-width:46ch; line-height:1.55 }
.empty__action{ margin-top:6px }

.skeleton{
  display:block;
  background:linear-gradient(90deg, var(--surface-3) 0%, var(--surface-hover) 50%, var(--surface-3) 100%);
  background-size:200% 100%;
  animation:skeleton 1.3s ease-in-out infinite;
}
@keyframes skeleton{ from{ background-position:200% 0 } to{ background-position:-200% 0 } }

.skeleton-rows{ display:flex; flex-direction:column; gap:14px; padding:18px }
.skeleton-rows__row{ display:flex; gap:14px }
.skeleton-rows__row > *{ flex:1 }

/* ===================== СЕГМЕНТЫ ===================== */

.seg{
  display:inline-flex; padding:3px; gap:2px;
  background:var(--surface-2); border:1px solid var(--border);
  border-radius:999px;
}
.seg__item{
  position:relative; overflow:hidden;
  display:inline-flex; align-items:center; gap:7px;
  border:0; background:transparent; cursor:pointer;
  padding:7px 15px; border-radius:999px;
  font-family:inherit; font-size:13px; color:var(--muted);
  transition:color var(--fast), background var(--fast);
}
.seg__item:hover{ color:var(--text) }
.seg__item.is-active{
  color:#fff;
  background:linear-gradient(135deg, var(--accent) 0%, var(--accent-press) 100%);
  box-shadow:var(--shadow-accent);
}

/* ===================== СЕТКИ РАСКЛАДКИ ===================== */

/* Показатели.
 *
 * Колонок столько, сколько влезает, но не уже 178px. Карточки в одном ряду
 * обязаны быть одной высоты: с align-items:start они тянулись каждая под
 * свой текст — 140, 154, 168 и 169 пикселей в одном ряду, — и ряд выглядел
 * рваным. Ровняет grid-auto-rows:1fr вместе с растягиванием карточки на
 * всю ячейку (сама .stat — flex-колонка, ей нужно height:100%). */
.stats-grid{
  display:grid; gap:12px;
  grid-template-columns:repeat(auto-fill, minmax(178px, 1fr));
  grid-auto-rows:1fr;
}
.stats-grid > *{ min-width:0 }
.stats-grid > .stat,
.stats-grid > * > .stat{ height:100% }

/* Две колонки с прилипающей боковой: карточки сущностей. */
.detail-grid{ display:grid; gap:14px; grid-template-columns:minmax(0,1fr) 340px; align-items:start }
.detail-grid__side{ position:sticky; top:calc(var(--header-h) + 22px) }
@media (max-width:1100px){
  .detail-grid{ grid-template-columns:1fr }
  .detail-grid__side{ position:static }
}

/* Разнокалиберная сетка дашборда. */
.bento{ display:grid; gap:14px; grid-template-columns:repeat(12, minmax(0, 1fr)); align-items:stretch }
.bento > .span-4{ grid-column:span 4 }
.bento > .span-5{ grid-column:span 5 }
.bento > .span-6{ grid-column:span 6 }
.bento > .span-7{ grid-column:span 7 }
.bento > .span-8{ grid-column:span 8 }
.bento > .span-12{ grid-column:span 12 }
@media (max-width:1200px){
  .bento > [class*='span-']{ grid-column:span 12 }
}
