/* =============================================================================
   stats.css — Сайдбар + Дашборды статистики
   Pixel-perfect по референсу
   ============================================================================= */

/* ===================== ПЕРЕМЕННЫЕ ТЕМЫ ===================== */

:root {
  --s-bg:          #f4f0eb;
  --s-card:        #ffffff;
  --s-card-border: rgba(0, 0, 0, 0.07);
  --s-text:        #1a1a1a;
  --s-text-muted:  rgba(0, 0, 0, 0.38);
  --s-text-sub:    rgba(0, 0, 0, 0.52);
  --s-divider:     rgba(0, 0, 0, 0.07);
  --s-hover:       rgba(0, 0, 0, 0.04);
  --s-active-bg:   rgba(0, 0, 0, 0.06);
  --s-accent:      #d6453c;
  --s-shadow:      0 1px 2px rgba(0,0,0,0.06), 0 3px 10px rgba(0,0,0,0.05);
  --s-shadow-card: 0 1px 3px rgba(0,0,0,0.07), 0 6px 18px rgba(0,0,0,0.05);
  --s-grid-dot:    rgba(0, 0, 0, 0.12);
  --s-grid-line:   rgba(0, 0, 0, 0.05);
}

html[data-app-theme="dark"] {
  --s-bg:          #0e1116;
  --s-card:        #161b27;
  --s-card-border: rgba(255, 255, 255, 0.06);
  --s-text:        #e8eaf3;
  --s-text-muted:  rgba(255, 255, 255, 0.35);
  --s-text-sub:    rgba(255, 255, 255, 0.52);
  --s-divider:     rgba(255, 255, 255, 0.07);
  --s-hover:       rgba(255, 255, 255, 0.05);
  --s-active-bg:   rgba(255, 255, 255, 0.07);
  --s-accent:      #ff6259;
  --s-shadow:      0 1px 3px rgba(0,0,0,0.3), 0 4px 14px rgba(0,0,0,0.2);
  --s-shadow-card: 0 1px 4px rgba(0,0,0,0.35), 0 8px 24px rgba(0,0,0,0.22);
  --s-grid-dot:    rgba(255, 255, 255, 0.11);
  --s-grid-line:   rgba(255, 255, 255, 0.045);
}

/* ===================== SVG ИКОНКИ ===================== */

.site-icon {
  display: block;
  flex-shrink: 0;
  opacity: 0.65;
}
html[data-app-theme="dark"] .site-icon {
  filter: brightness(0) invert(1);
  opacity: 0.55;
}

/* ===================== БОКОВОЙ САЙДБАР ===================== */

.side-nav {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: 180px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  background: var(--s-card);
  border-right: 1px solid var(--s-card-border);
  padding: 22px 10px 16px;
  gap: 1px;
  overflow-y: auto;
  overflow-x: hidden;
  transition: background 0.3s, border-color 0.3s, opacity 0.25s ease;
  opacity: 0;
  pointer-events: none;
}

.side-nav-header {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--s-text-muted);
  padding: 0 8px 10px;
  flex-shrink: 0;
}

.side-nav-divider {
  height: 1px;
  background: var(--s-divider);
  margin: 6px 8px;
  flex-shrink: 0;
}

.side-nav-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 8px 8px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--s-text);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
  flex-shrink: 0;
  min-height: 36px;
}

.side-nav-btn:hover   { background: var(--s-hover); }
.side-nav-btn.active  { background: var(--s-active-bg); }

.side-nav-btn.active::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--s-accent);
}

.side-nav-icon { display: none !important; }

.side-nav-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--s-text-sub);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.side-nav-btn.active .side-nav-label {
  font-weight: 600;
  color: var(--s-text);
}

.side-nav-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--s-text-muted);
  background: var(--s-hover);
  border-radius: 10px;
  padding: 1px 7px;
  flex-shrink: 0;
  line-height: 1.6;
}

.side-nav-btn.active .side-nav-count { color: var(--s-accent); }
.side-nav-tooltip { display: none !important; }

/* Подвал сайдбара: карточка-описание + кнопка PDF, прижат к низу */
.side-nav-foot {
  margin-top: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 12px;
}

.side-nav-about {
  position: relative;
  border-radius: 10px;
  background: var(--s-hover);
  border: 1px solid var(--s-card-border);
  padding: 12px 12px 12px 14px;
  overflow: hidden;
}
.side-nav-about::before {
  content: '';
  position: absolute;
  left: 0; top: 10px; bottom: 10px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--s-accent);
}
.side-nav-about-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--s-text);
  margin-bottom: 5px;
}
.side-nav-about-text {
  font-size: 11px;
  line-height: 1.5;
  color: var(--s-text-sub);
}

/* Кнопка "Скачать сводку" */
.side-nav-summary-btn {
  flex-shrink: 0;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--s-card-border);
  border-radius: 8px;
  background: var(--s-card);
  color: var(--s-text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: border-color 0.12s, box-shadow 0.12s, background 0.12s;
}
.side-nav-summary-btn svg { opacity: 0.7; }
.side-nav-summary-btn:hover {
  border-color: var(--s-accent);
  color: var(--s-accent);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.content-section { padding-left: 180px !important; }

/* ===================== ПАНЕЛИ ВИДОВ ===================== */

.view-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.view-panel.view-hidden { display: none !important; }

/* Подсветка совпадений в результатах поиска */
mark.search-hl {
  background: rgba(255, 196, 0, 0.35);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}

/* Режим поиска: несколько панелей видны одновременно — убираем их собственный
   скролл и flex-растяжение, чтобы вся выдача скроллилась единым пластом через #out */
#out.search-mode {
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#out.search-mode::-webkit-scrollbar { display: none; }
#out.search-mode .view-panel {
  flex: none;
  overflow: visible;
  min-height: auto;
}
#out.search-mode .view-body {
  flex: none;
  overflow: visible;
}

.view-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 24px 14px;
  flex-shrink: 0;
  z-index: 5;
}

.view-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  flex: 1;
}

.view-count {
  font-size: 13px;
  color: var(--s-text-muted);
  font-weight: 500;
  background: var(--s-hover);
  padding: 3px 10px;
  border-radius: 20px;
}

.view-body {
  flex: 1;
  padding: var(--view-pad-y) var(--view-pad-x) 32px;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.view-body::-webkit-scrollbar { display: none; }

.view-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--s-text-muted);
  font-size: 14px;
}

/* ===================== СЕКЦИЯ СТАТИСТИКИ ===================== */

.stats-section {
  padding: 16px 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  flex: 1;
  min-height: 0;
  /* График (flex:1) заполняет высоту, дашборд помещается в один экран.
     overflow-y:auto — страховка для невысоких окон, без пустого места снизу */
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.stats-section::-webkit-scrollbar { display: none; }

.stats-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.stats-h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.stats-sub {
  font-size: 12px;
  color: var(--s-text-muted);
  margin: 3px 0 0;
}

/* ===================== МЕТРИКИ ===================== */

.stats-metrics-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  flex-shrink: 0;
}

.metric-chip {
  background: var(--s-card);
  border: 1px solid var(--s-card-border);
  border-radius: 10px;
  padding: 12px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  box-shadow: var(--s-shadow-card);
  transition: transform 0.14s ease, box-shadow 0.14s ease;
  position: relative;
  overflow: hidden;
}

.metric-chip:hover {
  transform: translateY(-2px);
  box-shadow: 0 3px 10px rgba(0,0,0,0.1), 0 10px 28px rgba(0,0,0,0.07);
}

/* Цветная полоска сверху */
.metric-chip::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  border-radius: 10px 10px 0 0;
  opacity: 0;
  transition: opacity 0.14s;
}
.metric-chip:hover::before { opacity: 1; }

.mc-roads  .metric-chip::before { background: #e05252; }
.mc-water  .metric-chip::before { background: #3dbcb4; }
.mc-bord   .metric-chip::before { background: #68a87a; }
.mc-land   .metric-chip::before { background: #4a9dbf; }
.mc-labels .metric-chip::before { background: #c9a832; }
.mc-poi    .metric-chip::before { background: #9b6ec7; }

.metric-chip-icon {
  width: 16px; height: 16px;
  margin-bottom: 1px;
  opacity: 0.55;
  display: block;
}
html[data-app-theme="dark"] .metric-chip-icon {
  filter: brightness(0) invert(1);
  opacity: 0.45;
}

.metric-chip-value {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}

.metric-chip-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--s-text-muted);
  line-height: 1;
}

/* Цвета значений метрик */
.mc-all    .metric-chip-value { color: var(--s-text); }
.mc-roads  .metric-chip-value { color: #e05252; }
.mc-water  .metric-chip-value { color: #3dbcb4; }
.mc-bord   .metric-chip-value { color: #68a87a; }
.mc-land   .metric-chip-value { color: #4a9dbf; }
.mc-labels .metric-chip-value { color: #c9a832; }
.mc-poi    .metric-chip-value { color: #9b6ec7; }

/* ===================== ОСНОВНОЙ РЯД (CHART + DISTRIBUTION) ===================== */

.stats-main-row {
  display: grid;
  grid-template-columns: 1fr 230px;
  gap: 10px;
  align-items: stretch;
  /* График растягивается и заполняет всё свободное место между метриками
     и нижним рядом — дашборд кончается ровно внизу экрана, без пустоты */
  flex: 1 1 auto;
  min-height: 200px;
  /* Ограничиваем рост графика на высоких / ультраширких мониторах */
  max-height: 420px;
}

/* Правая колонка: Распределение + Цветовая гамма */
.stats-right-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow: hidden;
}

.stats-card {
  background: var(--s-card);
  border: 1px solid var(--s-card-border);
  border-radius: 12px;
  padding: 16px 18px 14px;
  box-shadow: var(--s-shadow-card);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow: hidden;
}

.chart-card { display: flex; flex-direction: column; overflow: hidden; }
/* svg-chart fills via flex: 1 defined below */


.stats-card-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  color: var(--s-text);
  flex-shrink: 0;
}

/* Распределение: заголовок крупнее, без upper-case — как на референсе */
.dist-card .stats-card-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  color: var(--s-text);
}

/* Больше не используем stats-bottom-row */
.stats-bottom-row { display: none; }

/* Обёртка для SVG + оверлей точек */
.chart-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Мелкоячеистая сетка — рисуется как SVG pattern только внутри прямоугольника графика */
.chart-mesh-line { stroke: var(--s-grid-line); stroke-width: 1; }
.chart-mesh-dot  { fill: var(--s-grid-dot); }

/* Оверлей для HTML-кружков — не искажаются как SVG-circle в non-uniform SVG */
.chart-dots-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Идеальный кружок на кривой */
.chart-dot {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  border: 1.5px solid var(--s-card, #fff);
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
  transition: none;
}

/* ===================== SVG CHART ===================== */


.svg-chart {
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow: visible;
}

.chart-grid-line {
  stroke: var(--s-divider);
  stroke-width: 1;
}

/* Мелкие подписи осей — 7px */
.chart-axis-label {
  font-size: 7px;
  fill: var(--s-text-muted, rgba(0,0,0,0.32));
  font-family: inherit;
}

/* Линии графика — 0.75px ультратонкие */
.chart-line-path {
  fill: none;
  stroke-width: 0.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Засечки по оси X — тонкие и частые */
.chart-minor-tick {
  stroke: currentColor;
  stroke-width: 0.75;
  opacity: 0.18;
}

.chart-col {
  fill: transparent;
  cursor: crosshair;
}
.chart-col:hover { fill: rgba(128,128,128,0.05); }

.chart-crosshair {
  stroke: var(--s-text-muted, rgba(0,0,0,0.28));
  stroke-width: 1;
  stroke-dasharray: 3 2;
  pointer-events: none;
}

.chart-hover-dot {
  stroke: var(--s-card, #fff);
  stroke-width: 2;
  pointer-events: none;
}

/* Легенда */
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  flex-shrink: 0;
  padding-top: 2px;
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--s-text-sub);
}

.chart-legend-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ===================== ТУЛТИП ГРАФИКА ===================== */

#chartTooltip {
  position: fixed;
  z-index: 9000;
  background: var(--s-card, #fff);
  border: 1px solid var(--s-card-border, rgba(0,0,0,0.08));
  border-radius: 10px;
  padding: 9px 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.16);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s, transform 0.12s;
  min-width: 130px;
  max-width: 195px;
  font-size: 12px;
  color: var(--s-text, #1a1a1a);
}
#chartTooltip.visible { opacity: 1; transform: translateY(0); }

.ct-zoom {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--s-text-muted);
  margin-bottom: 6px;
}

.ct-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 3px;
}
.ct-row:last-child { margin-bottom: 0; }

.ct-dot  { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.ct-label { flex: 1; color: var(--s-text-sub); }
.ct-val  { font-weight: 700; }

/* ===================== РАСПРЕДЕЛЕНИЕ ===================== */

.dist-rows {
  display: flex;
  flex-direction: column;
  /* Равномерно распределяем строки по высоте карточки */
  justify-content: flex-start;
  gap: 10px;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.dist-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Название категории */
.dist-label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--s-text-sub);
  width: 54px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Трек — чуть толще и с заметным фоном */
.dist-track {
  flex: 1;
  height: 7px;
  border-radius: 99px;
  background: var(--s-divider);
  overflow: hidden;
  position: relative;
}

/* Заполненная часть — яркая пилюля */
.dist-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  opacity: 0.88;
}

/* Значение — цветное, жирное, крупнее */
.dist-val {
  font-size: 13px;
  font-weight: 700;
  width: 28px;
  text-align: right;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}

/* ===================== ЦВЕТОВАЯ ПАЛИТРА ===================== */

.palette-card {
  background: var(--s-card);
  border: 1px solid var(--s-card-border);
  border-radius: 12px;
  padding: 14px 16px 12px;
  box-shadow: var(--s-shadow-card);
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
  flex-shrink: 0;
}

/* Тело карточки: дуги сверху, цвета снизу */
.palette-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

/* Область дуг — занимает всю ширину */
.palette-arcs-area {
  width: 100%;
  display: flex;
  justify-content: flex-start;   /* ���� ���������� � ������ ������� ���� */
}

/* SVG дуг — крупное */
.palette-arcs-svg {
  width: 130px;
  height: 130px;
  display: block;
  overflow: visible;
}

/* Горизонтальный ряд цветов — две строчки по 3 */
.palette-swatches-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px 6px;
  width: 100%;
}

.pal-item {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.pal-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  display: block;
}

.pal-lbl {
  font-size: 10px;
  color: var(--s-text-sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===================== КОНТРАСТНОСТЬ ===================== */

.contrast-card {
  background: var(--s-card);
  border: 1px solid var(--s-card-border);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: var(--s-shadow-card);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Процент + метка */
.contrast-value-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-shrink: 0;
}

.contrast-pct {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1;
  position: relative;
  cursor: default;
}

.contrast-zone {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
}

.cz-red    { color: #e74c3c; }
.cz-orange { color: #e67e22; }
.cz-green  { color: #27ae60; }

/* Радужная полоса — полная непрозрачность */
.contrast-bar-outer {
  position: relative;
  height: 10px;
  border-radius: 6px;
  overflow: hidden;
  background: linear-gradient(to right,
    #e74c3c 0%,
    #e67e22 18%,
    #f1c40f 32%,
    #2ecc71 44%,
    #2ecc71 56%,
    #f1c40f 68%,
    #e67e22 82%,
    #e74c3c 100%);
}

.contrast-needle-wrap {
  position: relative;
  height: 10px;
  margin-top: -10px;
}

/* Маркер позиции */
.contrast-needle {
  position: absolute;
  top: -4px;
  width: 4px;
  height: 18px;
  border-radius: 2px;
  transform: translateX(-50%);
  transition: left 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 1px 5px rgba(0,0,0,0.35);
}

/* Тултип при наведении на процент */
.contrast-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: 240px;
  background: var(--s-card, #fff);
  border: 1px solid var(--s-card-border, rgba(0,0,0,0.08));
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--s-text, #1a1a1a);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.14s, transform 0.14s;
  z-index: 200;
  box-shadow: 0 8px 28px rgba(0,0,0,0.14);
}

.contrast-tooltip::after {
  content: '';
  position: absolute;
  top: 100%; left: 16px;
  border: 5px solid transparent;
  border-top-color: var(--s-card, #fff);
}

.contrast-pct:hover .contrast-tooltip { opacity: 1; transform: translateY(0); }

.ct-tip-title {
  font-weight: 700;
  font-size: 12.5px;
  margin-bottom: 5px;
}

/* ===================== АНИМАЦИИ ПОЯВЛЕНИЯ ===================== */

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.metric-chip   { animation: fadeUp 0.28s ease both; }
.stats-card    { animation: fadeUp 0.32s ease both; }
.palette-card  { animation: fadeUp 0.32s ease both; }
.contrast-card { animation: fadeUp 0.32s ease both; }

.stats-metrics-row .metric-chip:nth-child(1) { animation-delay: 0.02s; }
.stats-metrics-row .metric-chip:nth-child(2) { animation-delay: 0.05s; }
.stats-metrics-row .metric-chip:nth-child(3) { animation-delay: 0.08s; }
.stats-metrics-row .metric-chip:nth-child(4) { animation-delay: 0.11s; }
.stats-metrics-row .metric-chip:nth-child(5) { animation-delay: 0.14s; }
.stats-metrics-row .metric-chip:nth-child(6) { animation-delay: 0.17s; }
.stats-metrics-row .metric-chip:nth-child(7) { animation-delay: 0.20s; }
.stats-main-row   .stats-card:nth-child(1)   { animation-delay: 0.10s; }
.stats-main-row   .stats-card:nth-child(2)   { animation-delay: 0.15s; }
.stats-bottom-row .palette-card              { animation-delay: 0.20s; }
.stats-bottom-row .contrast-card             { animation-delay: 0.24s; }


/* =============================================================================
   НИЖНИЙ РЯД ДАШБОРДОВ (метаданные · конфликты · топ-категории · недавние)
   ============================================================================= */

.stats-bottom-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  flex-shrink: 0;
}

.dash-card { animation: fadeUp 0.32s ease both; }
.stats-bottom-cards .dash-card:nth-child(1) { animation-delay: 0.22s; }
.stats-bottom-cards .dash-card:nth-child(2) { animation-delay: 0.26s; }
.stats-bottom-cards .dash-card:nth-child(3) { animation-delay: 0.30s; }
.stats-bottom-cards .dash-card:nth-child(4) { animation-delay: 0.34s; }

/* Шапка карточки: заголовок + бейдж статуса */
.dash-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.dash-badge {
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.02em;
  padding: 4px 8px;
  border-radius: 7px;
}
.db-ok   { color: #27ae60; background: rgba(39, 174, 96, 0.13); }
.db-warn { color: #e67e22; background: rgba(230, 126, 34, 0.15); }

/* Строки «иконка · ключ · значение» (метаданные / конфликты) */
.dash-rows {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dash-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 2px;
  border-bottom: 1px solid var(--s-divider);
}
.dash-row:last-child { border-bottom: none; }

.dash-row-ic {
  width: 15px; height: 15px;
  opacity: 0.5;
  flex-shrink: 0;
}
html[data-app-theme="dark"] .dash-row-ic {
  filter: brightness(0) invert(1);
  opacity: 0.4;
}

.dash-row-k {
  flex: 1;
  font-size: 12.5px;
  color: var(--s-text-sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-row-v {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--s-text);
  flex-shrink: 0;
  white-space: nowrap;
}
.dv-good { color: #27ae60; }
.dv-warn { color: #e67e22; }
.dv-bad  { color: #e05252; }

.dash-empty {
  font-size: 12px;
  line-height: 1.55;
  color: var(--s-text-muted);
  padding: 10px 2px;
}

/* ---- Донат «Топ категории слоёв» ---- */
.donut-body {
  display: flex;
  align-items: center;
  gap: 16px;
}

.donut-wrap {
  flex-shrink: 0;
  width: 104px;
  height: 104px;
}
.donut-svg { width: 100%; height: 100%; display: block; }

.donut-legend {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.donut-leg-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
}
.donut-leg-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.donut-leg-lbl {
  flex: 1;
  color: var(--s-text-sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.donut-leg-val {
  font-weight: 700;
  color: var(--s-text);
  flex-shrink: 0;
}
.donut-leg-val em {
  font-style: normal;
  font-weight: 500;
  color: var(--s-text-muted);
}

/* ---- Недавно изменённые слои ---- */
.recent-rows {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.recent-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 2px;
  border-bottom: 1px solid var(--s-divider);
}
.recent-row:last-child { border-bottom: none; }

.recent-ic {
  width: 15px; height: 15px;
  opacity: 0.5;
  flex-shrink: 0;
}
html[data-app-theme="dark"] .recent-ic {
  filter: brightness(0) invert(1);
  opacity: 0.4;
}

.recent-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--s-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40%;
}

.recent-tag {
  font-size: 10.5px;
  font-family: Consolas, monospace;
  color: var(--s-text-muted);
  background: var(--s-hover);
  border-radius: 6px;
  padding: 2px 7px;
  white-space: nowrap;
}

.recent-time {
  margin-left: auto;
  font-size: 11px;
  color: var(--s-text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.dash-more-btn {
  margin-top: 4px;
  align-self: flex-start;
  border: none;
  background: none;
  color: var(--s-accent);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
  transition: opacity 0.12s;
}
.dash-more-btn:hover { opacity: 0.75; }

/* ===================== RESPONSIVE / АДАПТИВ ===================== */

/* Ультраширокие мониторы (>2200px) — ограничиваем ширину контента */
@media (min-width: 2200px) {
  .stats-section {
    max-width: 1800px;
    margin: 0 auto;
  }
}

/* Широкие мониторы (>1800px) — чуть увеличиваем правую колонку */
@media (min-width: 1800px) {
  .stats-main-row {
    grid-template-columns: 1fr 280px;
  }
}

@media (max-width: 1400px) {
  .stats-metrics-row {
    grid-template-columns: repeat(4, 1fr);
  }
  .stats-bottom-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1100px) {
  .stats-bottom-cards { grid-template-columns: repeat(2, 1fr); }
  .stats-metrics-row {
    grid-template-columns: repeat(4, 1fr);
  }
  .stats-main-row {
    grid-template-columns: 1fr 200px;
  }
}

@media (max-width: 900px) {
  .stats-metrics-row {
    grid-template-columns: repeat(3, 1fr);
  }
  .stats-main-row {
    grid-template-columns: 1fr;
    max-height: none;
  }
  .stats-right-col {
    flex-direction: row;
    gap: 10px;
  }
  .stats-bottom-cards {
    grid-template-columns: 1fr;
  }
}
