/* ============================================================
   Страница статистики. Всё вложено в .st-app и имеет префикс st-,
   чтобы не пересекаться с uikit, bootstrap, Radzen и site.css
   ============================================================ */

.st-app {
    color-scheme: light;

    --st-ground: #eef1f5;
    --st-surface: #ffffff;
    --st-surface-2: #f6f8fa;
    --st-ink: #0f1620;
    --st-ink-2: #4c5866;
    --st-ink-3: #7b8798;
    --st-hairline: #dde3ea;
    --st-hairline-2: #eaeef3;
    --st-accent: #2a78d6;
    --st-accent-soft: rgba(42, 120, 214, .10);
    --st-accent-ring: rgba(42, 120, 214, .32);
    --st-good: #006300;
    --st-bad: #b02b2b;
    --st-warning: #fab219;
    --st-grid: #e7ebf0;
    --st-baseline: #c8d0da;
    --st-shadow: rgba(15, 22, 32, .14);

    --st-s1: #2a78d6;
    --st-s2: #eb6834;
    --st-s3: #1baf7a;
    --st-s4: #eda100;
    --st-s5: #e87ba4;
    --st-s6: #008300;
    --st-s7: #4a3aa7;
    --st-s8: #e34948;

    --st-radius: 10px;
    --st-radius-sm: 6px;

    --st-sans: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    --st-mono: "Cascadia Mono", Consolas, "SFMono-Regular", ui-monospace, monospace;

    background: var(--st-ground);
    color: var(--st-ink);
    font-family: var(--st-sans);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 224px minmax(0, 1fr);
}

@media (prefers-color-scheme: dark) {
    .st-app:not(.st-light) {
        color-scheme: dark;
        --st-ground: #0d1117;
        --st-surface: #161b22;
        --st-surface-2: #1b212a;
        --st-ink: #eef2f7;
        --st-ink-2: #aab6c4;
        --st-ink-3: #7b8798;
        --st-hairline: #262d37;
        --st-hairline-2: #1f2630;
        --st-accent: #3987e5;
        --st-accent-soft: rgba(57, 135, 229, .16);
        --st-accent-ring: rgba(57, 135, 229, .45);
        --st-good: #0ca30c;
        --st-bad: #e66767;
        --st-grid: #212933;
        --st-baseline: #333c48;
        --st-shadow: rgba(0, 0, 0, .5);
        --st-s1: #3987e5;
        --st-s2: #d95926;
        --st-s3: #199e70;
        --st-s4: #c98500;
        --st-s5: #d55181;
        --st-s6: #008300;
        --st-s7: #9085e9;
        --st-s8: #e66767;
    }
}

.st-app.st-dark {
    color-scheme: dark;
    --st-ground: #0d1117;
    --st-surface: #161b22;
    --st-surface-2: #1b212a;
    --st-ink: #eef2f7;
    --st-ink-2: #aab6c4;
    --st-ink-3: #7b8798;
    --st-hairline: #262d37;
    --st-hairline-2: #1f2630;
    --st-accent: #3987e5;
    --st-accent-soft: rgba(57, 135, 229, .16);
    --st-accent-ring: rgba(57, 135, 229, .45);
    --st-good: #0ca30c;
    --st-bad: #e66767;
    --st-grid: #212933;
    --st-baseline: #333c48;
    --st-shadow: rgba(0, 0, 0, .5);
    --st-s1: #3987e5;
    --st-s2: #d95926;
    --st-s3: #199e70;
    --st-s4: #c98500;
    --st-s5: #d55181;
    --st-s6: #008300;
    --st-s7: #9085e9;
    --st-s8: #e66767;
}

.st-app *,
.st-app *::before,
.st-app *::after { box-sizing: border-box; }

.st-app [hidden] { display: none !important; }

/* ---------- левая колонка ---------- */
.st-rail {
    border-right: 1px solid var(--st-hairline);
    background: var(--st-surface);
    padding: 18px 12px 24px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.st-brand { display: flex; align-items: center; gap: 9px; padding: 0 8px; text-decoration: none; color: inherit; }
.st-brand:hover { color: inherit; }
.st-brand-mark {
    width: 22px; height: 22px; border-radius: 5px; background: var(--st-accent);
    display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 12px;
}
.st-brand-name { font-weight: 600; letter-spacing: -.01em; }
.st-brand-sub { font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--st-ink-3); }

.st-rail-group { display: flex; flex-direction: column; gap: 2px; }
.st-rail-label { font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--st-ink-3); padding: 0 8px 6px; }

.st-rail-item {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 7px 9px; border: 0; background: none; width: 100%;
    border-radius: var(--st-radius-sm);
    font: inherit; font-size: 13.5px; color: var(--st-ink-2);
    cursor: pointer; text-align: left;
}
.st-rail-item:hover { background: var(--st-surface-2); color: var(--st-ink); }
.st-rail-item.st-current { background: var(--st-accent-soft); color: var(--st-accent); font-weight: 600; }
.st-rail-item .st-count { font-family: var(--st-mono); font-size: 11px; color: var(--st-ink-3); font-variant-numeric: tabular-nums; }
.st-rail-item.st-current .st-count { color: var(--st-accent); }

.st-rail-foot { margin-top: auto; padding: 0 8px; display: flex; flex-direction: column; gap: 10px; }

/* ---------- шапка ---------- */
.st-topbar { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; padding: 18px 28px 14px; }
.st-topbar h1 { font-size: 19px; font-weight: 600; letter-spacing: -.015em; margin: 0; }
.st-meta { font-size: 12.5px; color: var(--st-ink-3); }
.st-spacer { flex: 1; }

/* ---------- фильтры ---------- */
.st-filters {
    position: sticky; top: 0; z-index: 30;
    background: var(--st-ground);
    border-bottom: 1px solid var(--st-hairline);
    padding: 10px 28px;
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}

.st-seg { display: inline-flex; background: var(--st-surface); border: 1px solid var(--st-hairline); border-radius: var(--st-radius-sm); padding: 2px; gap: 2px; }
.st-seg button { border: 0; background: none; cursor: pointer; font: inherit; font-size: 13px; color: var(--st-ink-2); padding: 5px 10px; border-radius: 4px; white-space: nowrap; }
.st-seg button:hover { background: var(--st-surface-2); color: var(--st-ink); }
.st-seg button.st-on { background: var(--st-accent); color: #fff; font-weight: 500; }

.st-field { display: inline-flex; align-items: center; gap: 6px; }
.st-field > label { font-size: 11.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--st-ink-3); }

.st-app input[type="date"],
.st-app select,
.st-app input[type="search"],
.st-app input[type="text"] {
    font: inherit; font-size: 13px; color: var(--st-ink);
    background: var(--st-surface); border: 1px solid var(--st-hairline);
    border-radius: var(--st-radius-sm); padding: 5px 8px;
}
.st-app input[type="date"] { font-family: var(--st-mono); font-size: 12px; }

.st-btn {
    font: inherit; font-size: 13px; font-weight: 500;
    border: 1px solid var(--st-hairline); background: var(--st-surface); color: var(--st-ink);
    border-radius: var(--st-radius-sm); padding: 6px 12px; cursor: pointer;
    display: inline-flex; align-items: center; gap: 6px;
}
.st-btn:hover { background: var(--st-surface-2); }
.st-btn-primary { background: var(--st-accent); border-color: var(--st-accent); color: #fff; }
.st-btn-primary:hover { background: var(--st-accent); filter: brightness(.92); }
.st-btn-ghost { border-color: transparent; background: none; color: var(--st-ink-2); }
.st-btn-ghost:hover { background: var(--st-surface-2); color: var(--st-ink); }
.st-btn:disabled { opacity: .55; cursor: default; }

.st-app :focus-visible { outline: 2px solid var(--st-accent-ring); outline-offset: 2px; border-radius: 4px; }

.st-chip {
    font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
    padding: 3px 7px; border-radius: 999px; border: 1px solid var(--st-hairline);
    color: var(--st-ink-3); background: var(--st-surface); white-space: nowrap;
}
.st-chip.st-cached { color: var(--st-accent); border-color: var(--st-accent-ring); }
.st-chip.st-live { color: var(--st-good); border-color: color-mix(in srgb, var(--st-good) 45%, var(--st-hairline)); }

/* ---------- контент ---------- */
.st-content { padding: 20px 28px 64px; display: flex; flex-direction: column; gap: 18px; }

.st-notice {
    display: flex; align-items: flex-start; gap: 10px;
    border: 1px solid color-mix(in srgb, var(--st-warning) 42%, var(--st-hairline));
    background: color-mix(in srgb, var(--st-warning) 9%, var(--st-surface));
    border-radius: var(--st-radius); padding: 10px 12px; font-size: 13px; color: var(--st-ink-2);
}
.st-notice.st-error {
    border-color: color-mix(in srgb, var(--st-bad) 45%, var(--st-hairline));
    background: color-mix(in srgb, var(--st-bad) 8%, var(--st-surface));
}
.st-notice b { color: var(--st-ink); font-weight: 600; }
.st-notice .st-spacer { flex: 1; }

.st-card { background: var(--st-surface); border: 1px solid var(--st-hairline); border-radius: var(--st-radius); }
.st-card-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 13px 16px; border-bottom: 1px solid var(--st-hairline-2); }
.st-card-title { font-size: 14.5px; font-weight: 600; letter-spacing: -.01em; }
.st-card-sub { font-size: 12.5px; color: var(--st-ink-3); }
.st-card-body { padding: 14px 16px 16px; }

/* ---------- плитки ---------- */
.st-tiles { display: grid; gap: 12px; grid-template-columns: minmax(0, 1.6fr) repeat(4, minmax(0, 1fr)); }
@media (max-width: 1180px) { .st-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .st-tiles { grid-template-columns: 1fr; } }

.st-tile { padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 6px; min-height: 118px; }
.st-tile .st-t-label { font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--st-ink-3); }
.st-tile .st-t-value { font-size: 26px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.st-tile.st-hero .st-t-value { font-size: 46px; letter-spacing: -.03em; }
.st-tile .st-t-foot { display: flex; align-items: flex-end; gap: 8px; margin-top: auto; padding-top: 10px; }
.st-delta { font-family: var(--st-mono); font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.st-delta.st-up { color: var(--st-good); }
.st-delta.st-down { color: var(--st-bad); }
.st-t-vs { color: var(--st-ink-3); font-size: 11px; white-space: nowrap; }
.st-skeleton-value { display: inline-block; width: 90px; height: 26px; border-radius: 6px; background: var(--st-hairline-2); }

/* ---------- график ---------- */
.st-chart { position: relative; min-height: 300px; }
.st-chart svg { display: block; width: 100%; }
.st-chart.st-busy { opacity: .45; transition: opacity .18s ease; }
.st-chart-empty { padding: 40px 0; text-align: center; color: var(--st-ink-3); font-size: 13px; }

.st-tooltip {
    position: absolute; pointer-events: none; z-index: 5;
    background: var(--st-surface); border: 1px solid var(--st-hairline);
    border-radius: var(--st-radius-sm); padding: 8px 10px;
    box-shadow: 0 6px 22px var(--st-shadow);
    min-width: 160px; opacity: 0; transition: opacity .1s ease;
}
.st-tooltip.st-on { opacity: 1; }
.st-tt-date { font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--st-ink-3); margin-bottom: 6px; }
.st-tt-row { display: flex; align-items: center; gap: 8px; padding: 1.5px 0; }
.st-tt-key { width: 14px; height: 2px; border-radius: 1px; flex: none; }
.st-tt-name { font-size: 12px; color: var(--st-ink-2); flex: 1; white-space: nowrap; }
.st-tt-val { font-family: var(--st-mono); font-size: 12.5px; font-weight: 600; color: var(--st-ink); font-variant-numeric: tabular-nums; }

.st-legend { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 10px; }
.st-legend button {
    display: inline-flex; align-items: center; gap: 7px;
    border: 1px solid transparent; background: none; cursor: pointer;
    padding: 3px 8px 3px 6px; border-radius: 999px;
    font: inherit; font-size: 12.5px; color: var(--st-ink-2);
}
.st-legend button:hover { background: var(--st-surface-2); }
.st-legend .st-key { width: 16px; height: 2px; border-radius: 1px; flex: none; }
.st-legend .st-val { font-family: var(--st-mono); font-size: 11.5px; color: var(--st-ink-3); font-variant-numeric: tabular-nums; }

/* ---------- таблицы ---------- */
.st-table-scroll { overflow-x: auto; }
.st-app table.st-table { border-collapse: collapse; width: 100%; font-size: 13px; background: transparent; margin: 0; }
.st-app table.st-table thead th {
    font-size: 11.5px; letter-spacing: .07em; text-transform: uppercase;
    color: var(--st-ink-3); font-weight: 600; text-align: left;
    padding: 0 10px 8px; border-bottom: 1px solid var(--st-hairline); white-space: nowrap; background: transparent;
}
.st-app table.st-table thead th.st-num { text-align: right; }
.st-app table.st-table thead th.st-sortable { cursor: pointer; user-select: none; }
.st-app table.st-table thead th.st-sortable:hover { color: var(--st-ink); }
.st-app table.st-table thead th .st-arrow { color: var(--st-accent); margin-left: 3px; }
.st-app table.st-table tbody td { padding: 7px 10px; border-bottom: 1px solid var(--st-hairline-2); vertical-align: middle; background: transparent; }
.st-app table.st-table tbody td.st-num { text-align: right; font-family: var(--st-mono); font-variant-numeric: tabular-nums; }
.st-app table.st-table tbody tr.st-expandable { cursor: pointer; }
.st-app table.st-table tbody tr.st-expandable:hover > td { background: var(--st-surface-2); }
.st-app table.st-table tbody tr.st-detail > td { background: var(--st-surface-2); padding: 0; }
.st-detail-inner { padding: 8px 10px 12px 34px; }
.st-detail-inner .st-card-sub { margin-bottom: 6px; }

.st-share { display: flex; align-items: center; gap: 8px; }
.st-share-track { display: block; flex: 1; height: 6px; min-width: 60px; background: var(--st-hairline-2); border-radius: 3px; overflow: hidden; }
.st-share-fill { display: block; height: 100%; background: var(--st-s1); border-radius: 0 3px 3px 0; }
.st-share-pct { font-family: var(--st-mono); font-size: 11.5px; color: var(--st-ink-3); width: 46px; text-align: right; font-variant-numeric: tabular-nums; }

.st-name-cell { display: flex; align-items: center; gap: 8px; }
.st-tw { width: 12px; text-align: center; color: var(--st-ink-3); font-size: 10px; flex: none; }
.st-dot { display: block; width: 9px; height: 9px; border-radius: 3px; flex: none; }
.st-muted { color: var(--st-ink-3); }
.st-mono { font-family: var(--st-mono); font-variant-numeric: tabular-nums; }
.st-code { font-family: var(--st-mono); font-size: 11px; color: var(--st-ink-3); }
.st-app input[type="checkbox"] { accent-color: var(--st-accent); width: 14px; height: 14px; cursor: pointer; margin: 0; }

.st-skel { height: 9px; border-radius: 4px; background: var(--st-hairline-2); }
.st-skel + .st-skel { margin-top: 8px; }

/* ---------- малые мультиплеты ---------- */
.st-multiples { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 900px) { .st-multiples { grid-template-columns: 1fr; } }
.st-mult { border: 1px solid var(--st-hairline-2); border-radius: var(--st-radius-sm); padding: 12px 14px 10px; }
.st-mult h3 { margin: 0 0 2px; font-size: 13px; font-weight: 600; }
.st-hbar-row { display: grid; grid-template-columns: 74px 1fr 72px; align-items: center; gap: 10px; padding: 2.5px 0; }
.st-hbar-name { font-family: var(--st-mono); font-size: 12px; color: var(--st-ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-hbar-track { display: block; height: 12px; }
.st-hbar-fill { display: block; height: 12px; background: var(--st-s1); border-radius: 0 4px 4px 0; }
.st-hbar-val { font-family: var(--st-mono); font-size: 12px; color: var(--st-ink-2); text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 860px) {
    .st-app { grid-template-columns: 1fr; }
    .st-rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; }
    .st-rail-group { flex-direction: row; flex-wrap: wrap; }
    .st-rail-label, .st-rail-foot { display: none; }
    .st-topbar, .st-filters, .st-content { padding-left: 16px; padding-right: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    .st-app * { transition: none !important; }
}

.st-section { display: flex; flex-direction: column; gap: 18px; }

/* ---------- индикация загрузки ---------- */

/* тонкая полоса под фильтрами: видно, что запрос идёт, но разметка не прыгает */
.st-progress {
    position: absolute;
    left: 0; right: 0; bottom: -1px;
    height: 2px;
    overflow: hidden;
}
.st-progress > span {
    display: block; height: 100%; width: 40%;
    background: var(--st-accent);
    animation: st-slide 1.1s ease-in-out infinite;
}
@keyframes st-slide {
    from { transform: translateX(-110%); }
    to { transform: translateX(360%); }
}

.st-content { position: relative; }

/* полотно поверх содержимого раздела: данные под ним всё равно вот-вот заменятся */
.st-veil {
    position: absolute;
    inset: -8px -8px 0;
    z-index: 20;
    background: color-mix(in srgb, var(--st-ground) 66%, transparent);
    cursor: progress;
}

.st-veil-card {
    position: sticky;
    top: 96px;
    width: max-content;
    max-width: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--st-surface);
    border: 1px solid var(--st-hairline);
    border-radius: var(--st-radius);
    padding: 12px 16px;
    box-shadow: 0 8px 26px var(--st-shadow);
}

.st-veil-title { font-size: 13.5px; font-weight: 600; }
.st-veil-hint { font-size: 12px; color: var(--st-ink-3); }

.st-spinner {
    width: 16px; height: 16px; flex: none;
    border: 2px solid var(--st-hairline);
    border-top-color: var(--st-accent);
    border-radius: 50%;
    animation: st-spin .8s linear infinite;
}

.st-btn .st-spinner {
    width: 12px; height: 12px;
    border-color: rgba(255, 255, 255, .35);
    border-top-color: #fff;
}

.st-btn:not(.st-btn-primary) .st-spinner {
    border-color: var(--st-hairline);
    border-top-color: var(--st-accent);
}

@keyframes st-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    .st-progress > span { animation: none; width: 100%; opacity: .55; }
    .st-spinner { animation: none; border-top-color: var(--st-accent); }
}

/* ---------- страница до первого запроса ---------- */
.st-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 56px 24px;
    text-align: center;
}

.st-empty-title { font-size: 15px; font-weight: 600; }
.st-empty-text { font-size: 13px; color: var(--st-ink-2); line-height: 1.7; max-width: 46ch; }
