:root {
  color-scheme: light;
  --bg: #f6f5f1;
  --surface: #fcfcfb;
  --surface-2: #f0efea;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #7a7873;
  --line: #e1e0d9;
  --axis: #c3c2b7;
  --ring: rgba(11, 11, 11, .10);
  --track: #ebeae4;
  --btn: #16324f;
  --btn-ink: #ffffff;
  --btn-hover: #1f4570;
  --focus: #2a78d6;
  --up: #006300;
  --down: #b42727;
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s4: #eda100;
  --s5: #e87ba4;
  --s6: #008300;
  --s-other: #a9a79f;
  --radius: 14px;
  --radius-sm: 9px;
  --gutter: 32px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #96948d;
    --line: #2c2c2a;
    --axis: #383835;
    --ring: rgba(255, 255, 255, .10);
    --track: #2c2c2a;
    --btn: #e8eef6;
    --btn-ink: #0d1b2a;
    --btn-hover: #ffffff;
    --focus: #3987e5;
    --up: #0ca30c;
    --down: #e66767;
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --s4: #c98500;
    --s5: #d55181;
    --s6: #0ca30c;
    --s-other: #6d6b65;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0d; --surface: #1a1a19; --surface-2: #232321; --ink: #f0efec; --ink-2: #c3c2b7;
  --muted: #96948d; --line: #2c2c2a; --axis: #383835; --ring: rgba(255,255,255,.10); --track: #2c2c2a;
  --btn: #e8eef6; --btn-ink: #0d1b2a; --btn-hover: #ffffff; --focus: #3987e5; --up: #0ca30c; --down: #e66767;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #0ca30c; --s-other: #6d6b65;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

.wrap { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 var(--gutter); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 16px; top: -48px; z-index: 50; background: var(--btn); color: var(--btn-ink); padding: 10px 14px; border-radius: var(--radius-sm); text-decoration: none; }
.skip:focus { top: 12px; }

/* Шапка */
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top__row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; }
.brand__mark { width: 24px; height: 24px; fill: var(--s1); }
.top__file { display: flex; align-items: center; gap: 12px; min-width: 0; }
.top__name { color: var(--ink-2); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 36ch; }

/* Кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid transparent;
  font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none;
  transition: background-color .18s ease, border-color .18s ease, transform .12s ease, box-shadow .18s ease;
}
.btn:active { transform: translateY(1px) scale(.985); }
.btn--primary { background: var(--btn); color: var(--btn-ink); }
.btn--primary:hover { background: var(--btn-hover); transform: translateY(-1px); }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn--ghost:hover { background: var(--surface-2); border-color: var(--axis); }

/* Вступление и загрузка */
.intro { display: grid; grid-template-columns: 1.05fr 1fr; gap: 56px; align-items: center; min-height: calc(100vh - 64px - 81px); padding-top: 48px; padding-bottom: 48px; }
.intro h1 { font-size: clamp(32px, 4.2vw, 52px); line-height: 1.06; font-weight: 700; letter-spacing: -0.025em; max-width: 15ch; }
.lead { color: var(--ink-2); font-size: 18px; max-width: 52ch; margin: 22px 0 28px; }
.facts { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; max-width: 54ch; }
.facts li { position: relative; padding-left: 22px; color: var(--ink-2); }
.facts li::before { content: ""; position: absolute; left: 0; top: .62em; width: 8px; height: 8px; border-radius: 2px; background: var(--s1); }
.facts b { color: var(--ink); font-weight: 600; }

.drop {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  gap: 8px; min-height: 380px; padding: 40px 28px; border-radius: 22px; cursor: pointer;
  background: var(--surface); border: 1.5px dashed var(--axis); box-shadow: 0 1px 0 var(--ring);
  transition: border-color .2s ease, background-color .2s ease, transform .2s ease, box-shadow .2s ease;
}
.drop:hover, .drop.is-over { border-color: var(--s1); transform: translateY(-2px); box-shadow: 0 14px 40px -20px rgba(22, 50, 79, .35); }
.drop.is-over { background: color-mix(in srgb, var(--s1) 6%, var(--surface)); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop:focus-within { outline: 2px solid var(--focus); outline-offset: 3px; }
.drop__icon { width: 84px; height: 84px; margin-bottom: 10px; transition: transform .25s ease; }
.drop:hover .drop__icon { transform: translateY(-3px); }
.drop__sheet { fill: color-mix(in srgb, var(--s6) 12%, var(--surface)); stroke: var(--s6); stroke-width: 2; }
.drop__grid { stroke: var(--s6); stroke-width: 1.5; opacity: .5; fill: none; }
.drop__badge { fill: var(--btn); }
.drop__arrow { stroke: var(--btn-ink); stroke-width: 2.4; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.drop__title { font-size: 20px; font-weight: 650; }
.drop__hint { color: var(--muted); }
.drop__btn { margin-top: 14px; pointer-events: none; }
.error { grid-column: 1 / -1; margin: 0; padding: 14px 16px; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--down) 10%, var(--surface)); color: var(--down); font-weight: 550; }
.loading { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; margin: 0; color: var(--ink-2); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--s1); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Управление */
#report { padding: 28px 0 56px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
#report > * { min-width: 0; }
.controls { display: grid; gap: 14px; }
.controls__row { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: end; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 999px; border: 1px solid var(--line); }
.seg button {
  min-height: 40px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; color: var(--ink-2);
  font-size: 14px; font-weight: 600; cursor: pointer; transition: background-color .15s ease, color .15s ease, transform .1s ease;
}
.seg button:hover { color: var(--ink); background: color-mix(in srgb, var(--surface) 60%, transparent); }
.seg button:active { transform: scale(.97); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 0 0 1px var(--ring); }
.seg--sm button { min-height: 34px; padding: 0 12px; font-size: 13px; }
.custom { display: flex; gap: 12px; flex-wrap: wrap; }
.custom label { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 14px; }
.field { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); min-width: 160px; }
.field--wide { flex: 1; min-width: 240px; max-width: 520px; }
select, input[type="date"], input[type="search"] {
  min-height: 44px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface); font-size: 15px; font-weight: 450; color: var(--ink); width: 100%;
  transition: border-color .15s ease;
}
select:hover, input:hover { border-color: var(--axis); }
.range { margin: 0; color: var(--muted); font-size: 14px; }

/* Показатели */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
.kpi { background: var(--surface); border-radius: var(--radius); padding: 18px 20px 20px; box-shadow: 0 0 0 1px var(--ring); display: grid; align-content: start; gap: 4px; min-width: 0; }
.kpi__label { font-size: 14px; color: var(--ink-2); font-weight: 550; }
.kpi__value { font-size: clamp(30px, 3vw, 40px); font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; margin-top: 4px; }
.kpi__value small { font-size: .5em; font-weight: 600; color: var(--ink-2); letter-spacing: 0; margin-left: 4px; }
.kpi__sub { font-size: 13px; color: var(--muted); }
.delta { display: block; font-size: 13px; font-weight: 650; margin-top: 6px; line-height: 1.45; }
.delta--up { color: var(--up); }
.delta--down { color: var(--down); }
.delta--flat { color: var(--muted); }
.delta svg { width: 11px; height: 11px; margin-right: 3px; vertical-align: -1px; }
.delta span { color: var(--muted); font-weight: 500; }

/* Карточки */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.card { background: var(--surface); border-radius: var(--radius); padding: 22px 24px 24px; box-shadow: 0 0 0 1px var(--ring); min-width: 0; }
.card__head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 16px; margin-bottom: 18px; }
.card__head h2 { font-size: 18px; font-weight: 650; }
.card__head--sub { margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
.note { margin: 14px 0 0; font-size: 13px; color: var(--muted); }

/* Кольцевая диаграмма */
.donut { display: grid; grid-template-columns: 220px 1fr; gap: 28px; align-items: center; }
.donut svg { width: 220px; height: 220px; display: block; }
.donut__seg { transition: opacity .15s ease; cursor: default; }
.donut svg:hover .donut__seg { opacity: .45; }
.donut svg:hover .donut__seg:hover { opacity: 1; }
.donut__total { font-size: 28px; font-weight: 700; fill: var(--ink); }
.donut__cap { font-size: 12px; fill: var(--muted); }
.keys { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.keys li { display: grid; grid-template-columns: 12px 1fr auto auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; font-size: 15px; transition: background-color .15s ease; }
.keys li:hover, .keys li.is-hot { background: var(--surface-2); }
.keys i { width: 12px; height: 12px; border-radius: 3px; }
.keys .num { font-weight: 650; }
.keys .pct { color: var(--muted); font-size: 13px; min-width: 52px; text-align: right; }

/* Полоса-доля */
.meter { display: grid; gap: 10px; }
.meter__nums { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 20px; }
.meter__big { font-size: 36px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.meter__txt { color: var(--ink-2); font-size: 15px; }
.meter__bar { display: flex; height: 14px; border-radius: 4px; overflow: hidden; background: var(--track); gap: 2px; }
.meter__bar > span { height: 100%; transition: width .4s ease; }
.meter__rows { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px 20px; margin: 4px 0 0; }
.meter__rows div { display: grid; gap: 0; }
.meter__rows dt { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.meter__rows dt i { width: 10px; height: 10px; border-radius: 3px; }
.meter__rows dd { margin: 0; font-weight: 650; }
.prefs-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 2px; }
.prefs-list li { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 14px; color: var(--ink-2); }
.prefs-list b { color: var(--ink); }

/* Столбики по дням */
.bars { position: relative; }
.bars svg { width: 100%; height: 280px; display: block; overflow: visible; }
.bars .grid line { stroke: var(--line); }
.bars .axis { stroke: var(--axis); }
.bars text { font-size: 12px; fill: var(--muted); }
.bars .bar { fill: var(--s1); transition: opacity .12s ease; }
.bars .bar.is-prev { fill: var(--s-other); }
.bars .hit { fill: transparent; cursor: default; }
.bars .col:hover .bar { opacity: .75; }
.bars .col:hover .hit { fill: color-mix(in srgb, var(--ink) 5%, transparent); }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }

/* Таблицы */
.table-wrap { overflow-x: auto; margin: 0 -8px; padding: 0 8px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 720px; }
th, td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; white-space: normal; }
td:first-child { max-width: 420px; min-width: 180px; }
th { font-size: 12px; font-weight: 650; color: var(--muted); text-transform: none; position: relative; }
th button { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; padding: 4px 2px; border-radius: 4px; }
th button:hover { color: var(--ink); }
th button:focus-visible { outline: 2px solid var(--focus); }
th[aria-sort] button { color: var(--ink); }
th[aria-sort="descending"] button::after { content: "↓"; }
th[aria-sort="ascending"] button::after { content: "↑"; }
tbody tr { transition: background-color .12s ease; }
tbody tr:hover { background: var(--surface-2); }
tfoot td { font-weight: 650; border-bottom: 0; border-top: 1px solid var(--axis); }
.cell-bar { display: inline-flex; align-items: center; gap: 10px; justify-content: flex-end; }
.cell-bar__track { width: 80px; height: 8px; border-radius: 3px; background: var(--track); overflow: hidden; }
.cell-bar__fill { display: block; height: 100%; background: var(--s1); border-radius: 3px; }
.cell-bar b { font-weight: 600; min-width: 48px; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }
.search { min-width: 240px; flex: 0 1 320px; }
.more { margin-top: 16px; }

/* Текстовый отчёт */
.report-text { font-size: 17px; line-height: 1.65; max-width: 92ch; }
.report-text p { margin: 0 0 12px; }
.report-text p:last-child { margin-bottom: 0; }
.report-text .filter { color: var(--muted); font-size: 14px; }
.btn__icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; }
#copyReport.is-done { border-color: var(--up); color: var(--up); }

/* Подсказка */
.tip {
  position: fixed; z-index: 40; pointer-events: none; background: var(--ink); color: var(--bg);
  border-radius: 8px; padding: 8px 10px; font-size: 13px; line-height: 1.4; max-width: 280px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.tip b { font-weight: 650; }

.foot { border-top: 1px solid var(--line); padding: 24px 0 28px; color: var(--muted); font-size: 13px; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  :root { --gutter: 20px; }
  .intro { grid-template-columns: 1fr; gap: 32px; min-height: 0; padding-top: 36px; }
  .drop { min-height: 300px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  :root { --gutter: 16px; }
  .top__name { display: none; }
  .kpis { grid-template-columns: 1fr; }
  .donut { grid-template-columns: 1fr; justify-items: center; }
  .donut .keys { width: 100%; }
  .card { padding: 18px 16px 20px; }
  .field, .field--wide, .search { min-width: 0; flex: 1 1 100%; max-width: none; }
  .seg button { padding: 0 11px; }
  .drop__btn { width: 100%; }
  .top__file .btn { padding: 0 14px; font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
