/* Урок Просто — «Статистика» (/app/stats): служебная страница владельца. Макета у неё нет — оформлена китом нового
   дизайна: карточки .up-card, таблицы, сегмент периода и график в токенах кита, обе темы. Новых блоков нет: состав
   страницы прежний (сводка по неделям или дням, воронки, генерации по дням). */
.up-stats .up-hero { max-width: 1120px; }
.up-stats .up-title .up-lead { max-width: 720px; margin-left: auto; margin-right: auto; }
.x-st-stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.x-st-h { margin: 0; font-family: var(--font-display); font-size: 18px; line-height: 24px; font-weight: 800; letter-spacing: -.01em; color: var(--ink); text-wrap: balance; }
.up-stats .up-card { gap: 14px; padding: 20px 22px; }
.up-stats a:not([class]) { color: var(--ws-accent-ink); font-weight: 600; text-decoration: none; }
.up-stats a:not([class]):hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- таблицы: строки на тонких линиях, числа — табличными цифрами ---------- */
.x-st-wrap { min-width: 0; overflow-x: auto; }
.x-st-table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 20px; color: var(--ink); }
.x-st-table th { padding: 8px 16px 8px 0; border-bottom: 1px solid var(--line-strong); text-align: left; vertical-align: bottom; font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-2); }
.x-st-table td { padding: 10px 16px 10px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.x-st-table tr:last-child td { border-bottom: 0; }
.x-st-table th:last-child, .x-st-table td:last-child { padding-right: 0; }
.x-st-num { font-variant-numeric: tabular-nums; }
.stats-table col:first-child { width: 38%; }

/* ---------- сводка: шапка, период, плитки главных цифр ---------- */
.up-stats { --an-series-1: var(--ws-accent); --an-series-2: #f0563f; }
.an-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 24px; }
.an-head p { margin-top: 4px; max-width: 720px; }
/* период — сегмент кита (.up-seg): здесь варианты — подписи с радиокнопкой, а не кнопки */
.x-st-seg { display: inline-flex; flex: 0 0 auto; flex-wrap: wrap; gap: 4px; max-width: 100%; padding: 4px; border-radius: 999px; background: var(--surface-2); }
.x-st-seg-opt { position: relative; display: inline-flex; align-items: center; height: 32px; padding: 0 14px; border-radius: 999px; color: var(--text-2); font-size: 14px; line-height: 20px; font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: color .15s var(--ease-out), background-color .15s var(--ease-out); }
.x-st-seg-opt input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.x-st-seg-opt:hover { color: var(--ink); }
.x-st-seg-opt:has(input:checked) { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(31, 27, 58, .12), 0 3px 8px -3px rgba(60, 40, 120, .28); }
.up[data-theme="dark"] .x-st-seg-opt:has(input:checked) { box-shadow: 0 1px 2px rgba(0, 0, 0, .5); }
.x-st-seg-opt:has(input:focus-visible) { box-shadow: 0 0 0 2px var(--ws-accent); }
/* пока грузится другой период — прежние числа и строка периода бледнее, без прыжка вёрстки */
.an-report.is-loading, .an-head .is-loading { opacity: .55; transition: opacity .2s var(--ease-out); }
.an-error { color: var(--error); }
.an-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 12px; }
@media (min-width: 1024px) { .an-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.an-tile { display: grid; align-content: start; gap: 4px; min-width: 0; padding: 16px 20px; border: 1px solid var(--up-card-line, var(--line)); border-radius: 18px; background: var(--surface); }
.an-tile__label, .an-tile__sub { font-size: 13px; line-height: 18px; color: var(--text-2); text-wrap: pretty; }
.an-tile__value { font-family: var(--font-display); font-size: 28px; line-height: 36px; font-weight: 800; letter-spacing: -.01em; color: var(--ink); overflow-wrap: anywhere; }
/* «мало данных» — заметная, но тихая метка */
.an-low { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 6px; background: var(--warning-tint); color: var(--warning); font-size: 12px; line-height: 18px; font-weight: 500; white-space: nowrap; vertical-align: 1px; }
.an-rate { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; }
.an-rate .an-low { margin-left: 0; }
.an-share { font-size: 13px; line-height: 18px; color: var(--text-2); }
.an-block > .x-st-h + p { margin-top: -8px; }
/* числа и доли не переносятся; заголовки колонок и первая колонка — переносятся (8 колонок у форматов) */
.an-table td { white-space: nowrap; }
.an-table td:first-child { white-space: normal; }
@media (max-width: 1279px) { .an-table th, .an-table td { padding-right: 8px; } }
.an-total td { font-weight: 600; border-bottom: 0; border-top: 1px solid var(--line-strong); }
.an-hint code { padding: 0 4px; border-radius: 6px; background: var(--surface-2); font-size: .92em; }

/* ---------- график: колонки по неделям или дням, две серии рядом ---------- */
.an-chart { --an-axis-w: 48px; display: grid; gap: 8px; margin: 0; }
.an-chart > * { min-width: 0; }
.an-chart__legend { display: flex; flex-wrap: wrap; gap: 4px 20px; font-size: 13px; line-height: 18px; color: var(--text-2); }
.an-chart__key { display: inline-block; width: 12px; height: 12px; margin-right: 6px; border-radius: 3px; vertical-align: -1px; }
.an-chart__key--1, .an-chart__bar--1 { background: var(--an-series-1); }
.an-chart__key--2, .an-chart__bar--2 { background: var(--an-series-2); }
.an-chart__plot { position: relative; height: 180px; margin-left: var(--an-axis-w); border-bottom: 1px solid var(--line-strong); }
.an-chart__grid { position: absolute; right: 0; left: 0; border-top: 1px solid var(--line); }
.an-chart__tick { position: absolute; top: -10px; right: calc(100% + 8px); font-size: 12px; line-height: 20px; color: var(--text-2); }
.an-chart__groups { position: absolute; inset: 0; display: flex; align-items: flex-end; }
.an-chart__group { display: flex; flex: 1 1 0; align-items: flex-end; justify-content: center; gap: 2px; height: 100%; min-width: 0; border-radius: 6px 6px 0 0; transition: background-color .15s var(--ease-out); }
.an-chart__group:hover { background: var(--surface-2); }
.an-chart__bar { display: block; width: min(24px, 40%); border-radius: 4px 4px 0 0; }
.an-chart__axis { display: flex; margin-left: var(--an-axis-w); font-size: 12px; line-height: 16px; color: var(--text-2); }
.an-chart__axis span { flex: 1 1 0; min-width: 0; text-align: center; }
@media (max-width: 767px) { .an-chart--dense .an-chart__axis span:nth-child(even) { visibility: hidden; } }
.an-chart--daily .an-chart__bar { width: min(24px, calc(50% - 3px)); }
.an-chart--daily .an-chart__axis span:not(:nth-child(3n + 1)) { visibility: hidden; }
@media (max-width: 767px) {
  .an-chart--daily .an-chart__group { gap: 1px; }
  .an-chart--daily .an-chart__bar { width: calc(50% - 2px); }
  .an-chart--daily .an-chart__axis span:not(:nth-child(6n + 1)) { visibility: hidden; }
}
.an-chart__table summary { width: fit-content; font-size: 13px; line-height: 18px; font-weight: 600; color: var(--ws-accent-ink); cursor: pointer; }
.an-chart__table[open] summary { margin-bottom: 8px; }

@media (max-width: 767px) {
  .up-stats .up-card { padding: 16px; }
}
/* узкий экран: таблицы складываются в карточки-строки по data-label */
@media (max-width: 479px) {
  .stats-table col:first-child { width: auto; }
  .stats-table:not(.stats-table--funnel) .x-st-num { text-align: right; }
  .stats-table--funnel thead, .an-table thead { display: none; }
  .stats-table--funnel tr, .an-table tr { display: grid; gap: 4px; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .stats-table--funnel tr:last-child, .an-table tr:last-child { border-bottom: 0; }
  .stats-table--funnel td, .an-table td { padding: 0; border: 0; white-space: normal; }
  .stats-table--funnel td:first-child, .an-table td:first-child { font-weight: 600; }
  .stats-table--funnel td:not(:first-child), .an-table td:not(:first-child) { display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .stats-table--funnel td:not(:first-child)::before, .an-table td:not(:first-child)::before { content: attr(data-label); font-size: 14px; line-height: 20px; font-weight: 600; color: var(--text-2); text-align: left; align-self: baseline; }
  .an-total td { border-top: 0; }
  .an-share { text-align: right; }
}
