/* QR-партнёры — стили кабинета. Светлая и тёмная тема, телефон и компьютер. */

:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --sidebar: #eceff3;
  --text: #15171b;
  --muted: #5a616e;
  --border: #dfe3ea;
  --accent: #1f5fd6;
  --accent-hover: #194fb4;
  --accent-soft: #e6eefc;
  --on-accent: #ffffff;
  --danger: #c4302b;
  --danger-soft: #fbe9e8;
  --on-danger: #ffffff;
  --ok: #136c33;
  --ok-soft: #e5f4ea;
  --on-ok: #ffffff;
  --field-border: #7d8697;
  --warn: #9a5b00;
  --warn-soft: #fdf1dc;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --grid: #e7e9ee;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 6%);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --tabbar-h: 64px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #16181c;
    --surface: #1f2228;
    --surface-2: #272b32;
    --sidebar: #1b1e23;
    --text: #eef0f3;
    --muted: #a9b0bc;
    --border: #343842;
    --accent: #6b9bff;
    --accent-hover: #8cb2ff;
    --accent-soft: #24324d;
    --on-accent: #0d1424;
    --danger: #ff7b72;
    --danger-soft: #3d2222;
    --on-danger: #2a0b09;
    --ok: #5fd08a;
    --ok-soft: #1c3527;
    --on-ok: #0b1f12;
    --field-border: #6b7280;
    --warn: #f0b45a;
    --warn-soft: #3a2e1a;
    --series-1: #3987e5;
    --series-2: #d95926;
    --grid: #2c3038;
    --shadow: none;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-block: 72px calc(var(--tabbar-h) + 96px); }
@media (min-width: 900px) { html { scroll-padding-block: 24px 96px; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
img, svg { max-inline-size: 100%; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
h1, h2, h3 { line-height: 1.25; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(1.4rem, 1.1rem + 1.2vw, 1.85rem); letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; margin-block-end: 12px; }
h3 { font-size: 1rem; }
p { margin: 0 0 12px; text-wrap: pretty; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
/* Очень длинные слова и названия без пробелов не должны раздвигать страницу */
h1, h2, h3, p, li, summary, .page-title, .brand-name, .sub, .note, .r-name, .group-title, .sticker p, .preview-banner, .result, .kpi-label, .kpi-hint { overflow-wrap: anywhere; }
.cell-main > span { min-inline-size: 0; }
td, th { overflow-wrap: break-word; }
tbody th a { overflow-wrap: anywhere; }
p code, li code { overflow-wrap: anywhere; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute; inline-size: 1px; block-size: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.92rem; }
.center { text-align: center; }
.mt { margin-block-start: 20px; }
.print-only { display: none; }

/* ---------- Загрузка ---------- */
.boot, .loading { min-block-size: 50dvh; display: grid; place-items: center; }
.boot::after, .loading::after {
  content: ""; inline-size: 28px; block-size: 28px; border-radius: 50%;
  border: 3px solid var(--border); border-block-start-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(1turn); } }
@media (prefers-reduced-motion: reduce) { .boot::after, .loading::after { animation-duration: 2.4s; } }
.view[aria-busy="true"] > :not(.loading) { opacity: 0.6; transition: opacity 0.2s 0.15s; }

/* ---------- Оболочка ---------- */
.topbar {
  position: sticky; inset-block-start: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-block-end: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; min-inline-size: 0; }
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; inline-size: 34px; block-size: 34px; border-radius: 10px; background: var(--accent); color: var(--on-accent); flex: none; }
.brand-mark svg { inline-size: 20px; block-size: 20px; }

.sidenav { display: none; }
.sidenav ul, .tabbar ul { list-style: none; margin: 0; padding: 0; }

.tabbar {
  position: fixed; inset-inline: 0; inset-block-end: 0; z-index: 30;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(10px);
  border-block-start: 1px solid var(--border);
  padding-block-end: env(safe-area-inset-bottom);
}
.tabbar ul { display: grid; grid-template-columns: repeat(5, 1fr); }
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-block-size: var(--tabbar-h); padding: 6px 2px; color: var(--muted); text-decoration: none; font-size: 0.72rem;
}
.tabbar a[aria-current="page"] { color: var(--accent); font-weight: 600; }
.tabbar svg { inline-size: 24px; block-size: 24px; }

.view {
  inline-size: 100%;
  max-inline-size: 1240px;
  margin-inline: auto;
  padding: 16px max(16px, env(safe-area-inset-right)) calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  outline: none;
}
.view.bare, .shell-partner .view { padding-block-end: 40px; }

@media (min-width: 900px) {
  .shell:not(.shell-partner) {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    grid-template-areas: "brand main" "nav main";
    min-block-size: 100dvh;
    background: linear-gradient(to right, var(--sidebar) 248px, var(--bg) 248px);
  }
  .shell:not(.shell-partner) .topbar {
    grid-area: brand; position: relative; background: transparent; backdrop-filter: none; border: 0; padding: 20px 20px 12px;
  }
  .shell:not(.shell-partner) .topbar-logout { display: none; }
  .shell:not(.shell-partner) .brand-name { white-space: normal; line-height: 1.25; }
  .sidenav {
    grid-area: nav; display: flex; flex-direction: column; justify-content: space-between;
    position: sticky; inset-block-start: 0; align-self: start; block-size: calc(100dvh - 70px); padding: 4px 12px 20px;
  }
  .sidenav a, .sidenav-logout {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
    color: var(--text); text-decoration: none; font: inherit; font-weight: 500;
  }
  .sidenav a:hover, .sidenav-logout:hover { background: var(--surface-2); color: var(--text); }
  .sidenav a[aria-current="page"] { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); font-weight: 600; }
  .sidenav li + li { margin-block-start: 2px; }
  .sidenav-logout { background: none; border: 0; cursor: pointer; color: var(--muted); inline-size: 100%; }
  .tabbar { display: none; }
  .shell:not(.shell-partner) .view { grid-area: main; padding: 28px 36px 48px; }
}

/* ---------- Заголовок страницы ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; margin-block-end: 18px; }
.page-title { min-inline-size: 0; flex: 1 1 320px; }
.page-sub { color: var(--muted); margin: 6px 0 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.back { display: inline-block; margin-block-end: 6px; font-size: 0.92rem; text-decoration: none; }

/* ---------- Карточки и сетки ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-block-end: 16px; }
.card.center { text-align: center; }
.card.narrow { max-inline-size: 520px; margin: 10dvh auto 0; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); margin-block-end: 16px; }
.grid-2 > .card { margin: 0; }
.grid-2.top { align-items: start; }
.stack > * + * { margin-block-start: 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-block-end: 12px; }
.section-head h2 { margin: 0; }
.link-more { font-size: 0.92rem; }
.empty { color: var(--muted); padding: 16px 0; margin: 0; }
.empty.small { padding: 8px 0; }
.empty-state { text-align: center; padding: 36px 20px; }
.empty-state p { max-inline-size: 52ch; margin-inline: auto; color: var(--muted); }
.empty-state .btn-row { justify-content: center; }
.note { white-space: pre-wrap; background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 0.8rem; font-weight: 600; vertical-align: middle; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-block-size: 42px; padding: 8px 16px; border-radius: 10px;
  border: 1px solid var(--field-border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; font-size: 0.95rem; text-decoration: none; cursor: pointer;
  white-space: nowrap; touch-action: manipulation;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn svg { inline-size: 18px; block-size: 18px; flex: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { min-block-size: 36px; padding: 6px 12px; font-size: 0.9rem; }
.btn.block { inline-size: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn[data-copied] { border-color: var(--ok); color: var(--ok); }
.btn.primary[data-copied] { background: var(--ok); border-color: var(--ok); color: var(--on-ok); }
::placeholder { color: var(--muted); opacity: 1; }
.btn[data-failed] { border-color: var(--danger); color: var(--danger); }
.danger-text { color: var(--danger); }
.icon-btn { display: grid; place-items: center; min-inline-size: 40px; min-block-size: 40px; border: 0; background: transparent; color: var(--muted); border-radius: 10px; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row.center { justify-content: center; }

@media (max-width: 599px) {
  .page-actions { inline-size: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
}

/* ---------- Поля ---------- */
.field { display: block; margin-block-end: 14px; min-inline-size: 0; }
.field > * + * { margin-block-start: 6px; }
.field > label, .field > textarea, .field > input:not([type="checkbox"], [type="radio"]) { display: block; }
/* WebKit: a block-level <select> leaks the width of its longest option into the page scroll width */
.field > select { display: inline-block; vertical-align: top; }
.field label, .field legend, .period-label { font-weight: 600; font-size: 0.9rem; }
.field-row { display: grid; gap: 0 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.field-hint { color: var(--muted); font-size: 0.85rem; margin: 0; }
.field.inline { display: flex; flex-direction: row; align-items: center; gap: 8px; margin: 0; }
.field.inline > * + * { margin-block-start: 0; }
.req { color: var(--danger); }
fieldset.field { border: 0; padding: 0; margin-inline: 0; }
input, select, textarea {
  font: inherit; font-size: 16px; color: var(--text);
  background: var(--surface); border: 1px solid var(--field-border); border-radius: 10px;
  min-block-size: 42px; padding: 8px 12px; inline-size: 100%; min-inline-size: 0;
  accent-color: var(--accent);
}
textarea { resize: vertical; min-block-size: 70px; }
input[type="checkbox"], input[type="radio"] { inline-size: 24px; min-inline-size: 24px; block-size: 24px; min-block-size: 24px; padding: 0; margin: 0; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input[readonly] { background: var(--surface-2); }
.touched :user-invalid, form.touched :invalid { border-color: var(--danger); }
:user-invalid { border-color: var(--danger); }
.form-error { color: var(--danger); background: var(--danger-soft); border-radius: var(--radius-sm); padding: 10px 12px; margin: 0 0 12px; }
.radio-row { display: flex; gap: 16px; flex-wrap: wrap; min-block-size: 42px; align-items: center; }
.radio-row label, .inline-check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.copy-field { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; }
.copy-field input { flex: 1 1 12rem; min-inline-size: 0; font-family: var(--mono); font-size: 0.9rem; }
.link-more-row { margin: 12px 0 0; }
.password { display: flex; gap: 8px; }
.password input { flex: 1; }
.sticky-actions { position: sticky; inset-block-end: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); z-index: 5; display: flex; justify-content: flex-end; margin-block-end: 16px; }
@media (min-width: 900px) { .sticky-actions { inset-block-end: 16px; } }

/* ---------- Панель фильтров и период ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-end; padding: 14px 16px; }
.toolbar .field { margin: 0; }
.period { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.period select { inline-size: auto; min-inline-size: 200px; }
.period-custom { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.period-custom input { inline-size: auto; }
.period-range { color: var(--muted); font-size: 0.92rem; }
.page-actions .period { justify-content: flex-end; }
.filters-box { flex: 1 1 100%; }
.filters-box > summary { cursor: pointer; font-weight: 600; min-block-size: 40px; display: flex; align-items: center; color: var(--accent); }
.filters-box[open] > summary { margin-block-end: 10px; }
@media (min-width: 900px) { .filters-box > summary { display: none; } }
.filters { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); flex: 1 1 100%; }
.filters .grow { grid-column: span 2; }
@media (max-width: 599px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .grow { grid-column: 1 / -1; }
  .period { inline-size: 100%; }
  .period select { flex: 1; min-inline-size: 0; }
  .period-label { inline-size: 100%; }
}
/* Самые узкие телефоны: по одному полю в строке, чтобы выбранное значение в списке читалось целиком */
@media (max-width: 400px) {
  .filters { grid-template-columns: 1fr; }
  .filters .grow { grid-column: auto; }
}

/* ---------- Показатели ---------- */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); margin-block-end: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; min-inline-size: 0; }
.kpi-label { color: var(--muted); font-size: 0.88rem; }
.kpi-value { font-size: clamp(1.45rem, 1.2rem + 1vw, 1.9rem); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.kpi-hint { color: var(--muted); font-size: 0.82rem; }
.kpi.accent { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); background: linear-gradient(var(--accent-soft), var(--surface)); }
@media (max-width: 599px) { .kpis { grid-template-columns: 1fr 1fr; } }

/* ---------- Таблицы (на узком контейнере — карточки) ---------- */
.table-wrap { overflow: auto; max-inline-size: 100%; container-type: inline-size; border-radius: var(--radius-sm); }
.table-wrap:focus-visible { outline-offset: 2px; }
table { border-collapse: separate; border-spacing: 0; inline-size: 100%; font-variant-numeric: tabular-nums; }
caption { text-align: start; font-weight: 600; padding-block-end: 8px; }
th, td { padding: 10px 12px; text-align: start; vertical-align: top; border-block-end: 1px solid var(--border); }
thead th { position: sticky; inset-block-start: 0; z-index: 1; background: var(--surface); color: var(--muted); font-size: 0.82rem; font-weight: 600; white-space: nowrap; }
tbody th { font-weight: 500; }
tbody tr:hover > * { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
tfoot th, tfoot td { font-weight: 700; border-block-end: 0; border-block-start: 2px solid var(--border); }
.num { text-align: end; white-space: nowrap; }
.sub { display: block; color: var(--muted); font-size: 0.82rem; font-weight: 400; }
.cell-main { display: flex; gap: 10px; align-items: flex-start; }
.row-check-wrap { display: inline-grid; place-items: center; margin: -8px 0 -8px -8px; padding: 8px; cursor: pointer; flex: none; }
.row-check { flex: none; }
.muted-row > * { color: var(--muted); }
.table-wrap.compact th, .table-wrap.compact td { padding: 7px 10px; }

@container (width < 840px) {
  .table-wrap.wide table, .table-wrap.wide thead, .table-wrap.wide tbody, .table-wrap.wide tfoot, .table-wrap.wide tr, .table-wrap.wide th, .table-wrap.wide td { display: block; }
  .table-wrap.wide thead { display: none; }
  .table-wrap.wide tr { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin-block-end: 10px; background: var(--surface); }
  .table-wrap.wide tbody tr:hover > * { background: none; }
  .table-wrap.wide th, .table-wrap.wide td { border: 0; padding: 3px 0; }
  .table-wrap.wide tbody th { font-weight: 600; padding-block-end: 6px; margin-block-end: 4px; border-block-end: 1px solid var(--border); }
  .table-wrap.wide td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; text-align: end; }
  .table-wrap.wide td::before { content: attr(data-label); color: var(--muted); font-size: 0.88rem; text-align: start; font-weight: 400; }
  .table-wrap.wide td[data-label=""]::before { content: none; }
  .table-wrap.wide td:empty { display: none; }
  .table-wrap.wide tfoot tr { background: var(--surface-2); }
  .table-wrap.wide tfoot th { border: 0; }
  .table-wrap.wide tfoot td:empty { display: none; }
  .table-wrap.wide caption { padding-block-end: 6px; }
}
@container (width < 460px) {
  .table-wrap.fit table, .table-wrap.fit thead, .table-wrap.fit tbody, .table-wrap.fit tfoot, .table-wrap.fit tr, .table-wrap.fit th, .table-wrap.fit td { display: block; }
  .table-wrap.fit thead { display: none; }
  .table-wrap.fit tr { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin-block-end: 10px; background: var(--surface); }
  .table-wrap.fit tbody tr:hover > * { background: none; }
  .table-wrap.fit th, .table-wrap.fit td { border: 0; padding: 3px 0; }
  .table-wrap.fit tbody th { font-weight: 600; padding-block-end: 6px; margin-block-end: 4px; border-block-end: 1px solid var(--border); }
  .table-wrap.fit td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; text-align: end; }
  .table-wrap.fit td::before { content: attr(data-label); color: var(--muted); font-size: 0.88rem; text-align: start; font-weight: 400; }
  .table-wrap.fit td[data-label=""]::before { content: none; }
  .table-wrap.fit td:empty { display: none; }
  .table-wrap.fit tfoot tr { background: var(--surface-2); }
  .table-wrap.fit tfoot th { border: 0; }
  .table-wrap.fit tfoot td:empty { display: none; }
  .table-wrap.fit caption { padding-block-end: 6px; }
}
@container (width < 360px) {
  .table-wrap.fit-sm table, .table-wrap.fit-sm thead, .table-wrap.fit-sm tbody, .table-wrap.fit-sm tfoot, .table-wrap.fit-sm tr, .table-wrap.fit-sm th, .table-wrap.fit-sm td { display: block; }
  .table-wrap.fit-sm thead { display: none; }
  .table-wrap.fit-sm tr { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin-block-end: 10px; background: var(--surface); }
  .table-wrap.fit-sm tbody tr:hover > * { background: none; }
  .table-wrap.fit-sm th, .table-wrap.fit-sm td { border: 0; padding: 3px 0; }
  .table-wrap.fit-sm tbody th { font-weight: 600; padding-block-end: 6px; margin-block-end: 4px; border-block-end: 1px solid var(--border); }
  .table-wrap.fit-sm td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; text-align: end; }
  .table-wrap.fit-sm td::before { content: attr(data-label); color: var(--muted); font-size: 0.88rem; text-align: start; font-weight: 400; }
  .table-wrap.fit-sm td[data-label=""]::before { content: none; }
  .table-wrap.fit-sm td:empty { display: none; }
  .table-wrap.fit-sm tfoot tr { background: var(--surface-2); }
  .table-wrap.fit-sm tfoot th { border: 0; }
  .table-wrap.fit-sm tfoot td:empty { display: none; }
  .table-wrap.fit-sm caption { padding-block-end: 6px; }
}

@media (min-width: 600px) {
  .codes-body > .table-wrap, .group > .table-wrap { background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
}

/* ---------- Выбор строк ---------- */
.select-all { margin: 0 0 8px 4px; }
.select-all label { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; color: var(--muted); }
.selection-bar {
  position: sticky; inset-block-end: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 10px); z-index: 25;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  background: var(--text); color: var(--bg); border-radius: var(--radius); padding: 10px 14px; margin-block-start: 12px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 20%);
}
.selection-bar .btn:not(.primary) { background: transparent; color: inherit; border-color: color-mix(in srgb, var(--bg) 40%, transparent); }
.selection-count { font-weight: 600; margin-inline-end: auto; }
@media (min-width: 900px) { .selection-bar { inset-block-end: 16px; } }

.group { margin-block-end: 22px; }
.group-title { font-size: 1.05rem; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-block-end: 8px; }
.group-stats { color: var(--muted); font-size: 0.9rem; font-weight: 400; }
.group-stats strong { color: var(--text); }

/* ---------- Обзор ---------- */
.setup { border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); background: linear-gradient(var(--warn-soft), var(--surface)); }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.checklist li { display: flex; align-items: center; gap: 10px; }
.check-icon { display: grid; place-items: center; inline-size: 24px; block-size: 24px; border-radius: 50%; border: 2px solid var(--border); flex: none; }
.checklist li.done .check-icon { background: var(--ok); border-color: var(--ok); color: #fff; }
.checklist li.done .check-icon svg { inline-size: 14px; block-size: 14px; }
.checklist li.done span:not(.check-icon) { color: var(--muted); text-decoration: line-through; }
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.bars li { display: grid; grid-template-columns: minmax(90px, 9rem) 1fr auto; gap: 10px; align-items: center; }
.bar-track { block-size: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-fill { display: block; block-size: 100%; inline-size: 0; background: var(--series-1); border-radius: 999px; }
.bar-value { color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-block-end: 1px solid var(--border); }
.plain-list li:last-child { border: 0; }

/* ---------- График ---------- */
.chart { position: relative; overflow: hidden; }
.chart-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px 16px; margin-block-end: 8px; }
.chart-title { font-size: 1rem; }
.legend { display: flex; gap: 16px; list-style: none; margin: 0; padding: 0; font-size: 0.9rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; inline-size: 12px; block-size: 3px; border-radius: 2px; background: var(--series-1); }
.swatch.s2 { background: var(--series-2); }
.chart-plot { position: relative; inline-size: 100%; }
.chart-plot svg { display: block; overflow: visible; touch-action: pan-y; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.s1, .chart .dot.s1 { stroke: var(--series-1); }
.chart .line.s2, .chart .dot.s2 { stroke: var(--series-2); }
.chart .dot { fill: var(--surface); stroke-width: 2; }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-tip {
  position: absolute; inset-block-start: 36px; z-index: 3; pointer-events: none; opacity: 0;
  display: grid; gap: 2px; padding: 8px 10px; border-radius: 10px; font-size: 0.85rem; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--border); box-shadow: 0 6px 18px rgb(0 0 0 / 14%);
  transition: opacity 0.12s, visibility 0.12s; visibility: hidden;
}
.chart-tip.show { opacity: 1; visibility: visible; }
.chart-tip span { display: flex; align-items: center; gap: 6px; }
.chart-tip .swatch { inline-size: 10px; block-size: 10px; border-radius: 50%; }

/* ---------- Карточка кода ---------- */
.code-layout { display: grid; gap: 16px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 1000px) { .code-layout { grid-template-columns: 300px minmax(0, 1fr); } }
.qr-card { text-align: center; }
.qr-img { inline-size: min(100%, 240px); block-size: auto; aspect-ratio: 1; background: #fff; border-radius: 12px; padding: 6px; border: 1px solid var(--border); }
.code-slug { margin: 12px 0; }
.code-slug strong { font-size: 1.1rem; letter-spacing: 0.08em; }
.qr-card .copy-field { margin-block-end: 12px; }
.qr-card .btn-row { justify-content: center; }
.qr-dialog { text-align: center; }

/* ---------- Сверка ---------- */
.report { padding: 6px 0; }
.report-head, .report-row summary, .report-total {
  display: grid; grid-template-columns: minmax(0, 1fr) 80px 110px 120px; gap: 12px; align-items: center; padding: 12px 18px;
}
.report-head { color: var(--muted); font-size: 0.82rem; font-weight: 600; border-block-end: 1px solid var(--border); }
.report-row { border-block-end: 1px solid var(--border); }
.report-row summary { cursor: pointer; list-style: none; }
.report-row summary::-webkit-details-marker { display: none; }
.report-row summary .r-name { display: flex; flex-direction: column; padding-inline-start: 20px; position: relative; }
.report-row summary .r-name::before { content: "▸"; position: absolute; inset-inline-start: 0; color: var(--muted); transition: rotate 0.15s; }
.report-row[open] summary .r-name::before { rotate: 90deg; }
.report-row summary:hover { background: var(--surface-2); }
.report-detail { padding: 4px 18px 14px; }
.r-regs { font-weight: 700; font-size: 1.1rem; }
.report-total { background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.report-row.own summary .r-name strong { color: var(--muted); }
@media (max-width: 640px) {
  .report-head { display: none; }
  .report-row summary, .report-total { grid-template-columns: 1fr 1fr 1fr; padding: 12px 14px; }
  .report-row summary .r-name, .report-total .r-name { grid-column: 1 / -1; }
  .report-row summary .num, .report-total .num { text-align: start; display: flex; flex-direction: column; }
  .report-row summary .num::before, .report-total .num::before { content: attr(data-label); color: var(--muted); font-size: 0.78rem; font-weight: 400; }
  .report-total .num:empty::before { content: ""; }
  .report-detail { padding: 4px 12px 12px; }
}

/* ---------- Интеграция ---------- */
.steps { padding-inline-start: 22px; margin: 0 0 12px; }
.steps li { margin-block-end: 8px; }
pre.code { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; overflow: auto; max-inline-size: 100%; font-size: 0.85rem; line-height: 1.45; margin: 0 0 12px; }
.grid-2 > *, .card, details { min-inline-size: 0; }
.sim { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-end; }
.sim .field { margin: 0; }
.sim .grow { flex: 1 1 260px; min-inline-size: 0; }
.sim select { max-inline-size: 100%; text-overflow: ellipsis; }
.sim-result:not(:empty) { margin-block-start: 14px; }
.result { display: grid; gap: 4px; padding: 12px 14px; border-radius: var(--radius-sm); margin-block-end: 8px; }
.result.ok { background: var(--ok-soft); color: var(--ok); }
.result.warn { background: var(--warn-soft); color: var(--warn); }
.result span { color: var(--text); }

/* ---------- Меню «Ещё» ---------- */
.menu-list { padding: 6px; }
.menu-list a, .menu-list button {
  display: flex; align-items: center; gap: 12px; inline-size: 100%; min-block-size: 52px; padding: 10px 12px;
  border: 0; background: none; color: var(--text); font: inherit; text-decoration: none; border-radius: 10px; cursor: pointer;
}
.menu-list a:hover, .menu-list button:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Кабинет партнёра ---------- */
.preview-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: var(--accent-soft); color: var(--text); border-radius: var(--radius-sm); padding: 10px 14px; margin-block-end: 16px; }

/* ---------- Вход ---------- */
.login { min-block-size: 90dvh; display: grid; place-items: center; }
.login-card { inline-size: min(100%, 400px); padding: 28px 24px; }
.login-card h1 { font-size: 1.3rem; margin-block-end: 18px; }
.login-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-block-end: 20px; }
.login-card .hint { margin: 14px 0 0; text-align: center; }

/* ---------- Диалоги ---------- */
dialog.dialog {
  inline-size: min(560px, calc(100vw - 24px)); max-block-size: calc(100dvh - 24px);
  padding: 0; border: 0; border-radius: 18px; background: var(--surface); color: var(--text);
  box-shadow: 0 20px 60px rgb(0 0 0 / 30%);
}
dialog.dialog.wide { inline-size: min(680px, calc(100vw - 24px)); }
dialog:modal { overscroll-behavior: contain; }
dialog::backdrop { background: rgb(10 14 22 / 50%); overflow: hidden; overscroll-behavior: contain; }
.dialog-form { display: flex; flex-direction: column; max-block-size: inherit; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 8px 20px; }
.dialog-head h2 { margin: 0; font-size: 1.15rem; }
.dialog-body { padding: 8px 20px; overflow: auto; }
.dialog-form .form-error { margin: 0 20px 8px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; border-block-start: 1px solid var(--border); }
.preview { color: var(--muted); font-size: 0.9rem; min-block-size: 1.5em; }
@media (max-width: 599px) {
  dialog.dialog, dialog.dialog.wide { inline-size: 100vw; max-inline-size: 100vw; margin: auto 0 0; border-radius: 18px 18px 0 0; max-block-size: 92dvh; }
  .dialog-foot { padding-block-end: max(18px, env(safe-area-inset-bottom)); }
  .dialog-foot .btn { flex: 1; }
}

/* ---------- Уведомления ---------- */
.toast {
  position: fixed; z-index: 1000; inset-inline: 16px; inset-block-end: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom));
  margin-inline: auto; inline-size: fit-content; max-inline-size: min(520px, calc(100vw - 32px));
  padding: 12px 16px; border-radius: 12px; background: var(--text); color: var(--bg); font-weight: 500;
  box-shadow: 0 10px 30px rgb(0 0 0 / 25%); opacity: 0; translate: 0 8px; pointer-events: none;
  transition: opacity 0.18s, translate 0.18s;
}
.toast.show { opacity: 1; translate: 0 0; }
.toast[data-kind="error"] { background: var(--danger); color: var(--on-danger); }
.toast:empty { padding: 0; }
@media (min-width: 900px) { .toast { inset-block-end: 24px; } }
@media (prefers-reduced-motion: reduce) { .toast { transition: opacity 0.18s; translate: 0 0; } }
.noscript { padding: 24px; text-align: center; }

/* ---------- Печать наклеек ---------- */
.print-mode .view { max-inline-size: none; padding-block-end: 40px; }
.print-toolbar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-block-end: 12px; }
.print-toolbar .field.inline select { inline-size: auto; }
.sheet { display: grid; gap: 12px; margin-inline: auto; max-inline-size: 760px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.sheet.size-s { grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.sheet.size-l { max-inline-size: 560px; grid-template-columns: 1fr; }
.sheet.size-l .sticker-title { font-size: 1.6rem; }
.sheet.size-s .sticker-title { font-size: 0.95rem; }
.sticker {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center;
  background: #fff; color: #111; border: 1px dashed #b9bec8; border-radius: 8px; padding: 14px 10px; break-inside: avoid;
}
.sticker p { margin: 0; }
.sticker-title { font-weight: 800; font-size: 1.05rem; line-height: 1.2; }
.sticker-qr { inline-size: 70%; aspect-ratio: 1; block-size: auto; }
.sticker-sub { font-size: 0.82rem; color: #333; }
.sticker-code { font-size: 0.8rem; color: #333; }
.sticker-code strong { font-family: var(--mono); letter-spacing: 0.06em; }
.sticker-name { font-size: 0.7rem; color: #666; }

@page { size: A4; margin: 10mm; }
@media print {
  :root { color-scheme: light; --bg: #fff; --surface: #fff; --text: #000; --muted: #444; --border: #ccc; --shadow: none; }
  body { background: #fff; }
  .no-print, .topbar, .sidenav, .tabbar, .toolbar, .page-actions, .selection-bar, .select-all, #toast, .back, .preview-banner { display: none !important; }
  .print-only { display: block; }
  .shell:not(.shell-partner) { display: block; background: none; }
  .view, .shell:not(.shell-partner) .view, .print-mode .view { padding: 0 !important; max-inline-size: none; }
  .card { border: 0; box-shadow: none; padding: 0; }
  .kpis, .report-row { break-inside: avoid; }
  .kpi { box-shadow: none; }
  .report-row summary .r-name::before { content: none; }
  a { color: inherit; text-decoration: none; }

  .sheet { gap: 0; justify-content: center; }
  .sheet.size-s { grid-template-columns: repeat(3, 63mm); grid-auto-rows: 66mm; }
  .sheet.size-m { grid-template-columns: repeat(2, 95mm); grid-auto-rows: 90mm; }
  .sheet.size-l { grid-template-columns: 150mm; grid-auto-rows: 135mm; }
  .sticker { border-radius: 0; padding: 4mm; overflow: hidden; justify-content: center; }
  /* Текст не сжимается, при нехватке места уменьшается QR-код (сохраняя квадрат) */
  .sticker p { flex-shrink: 0; }
  .sticker-qr { flex: 0 1 auto; min-block-size: 18mm; inline-size: auto !important; aspect-ratio: 1; object-fit: contain; }
  .sticker-title, .sticker-sub, .sticker-name { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
  .size-s .sticker-title { -webkit-line-clamp: 2; }
  .size-s .sticker-title { font-size: 9pt; }
  .size-s .sticker-qr { block-size: 34mm; }
  .size-s .sticker-sub, .size-s .sticker-code { font-size: 7pt; }
  .size-s .sticker-name { font-size: 6pt; }
  .size-m .sticker-title { font-size: 15pt; }
  .size-m .sticker-qr { block-size: 55mm; }
  .size-m .sticker-sub, .size-m .sticker-code { font-size: 9pt; }
  .size-m .sticker-name { font-size: 7pt; }
  .size-l .sticker-title { font-size: 26pt; }
  .size-l .sticker-qr { block-size: 85mm; }
  .size-l .sticker-sub, .size-l .sticker-code { font-size: 13pt; }
  .size-l .sticker-name { font-size: 9pt; }
}

/* ---------- Ссылки-плитки, строки-ссылки, мелкие элементы ---------- */
a.kpi-link { color: inherit; text-decoration: none; transition: border-color 0.15s, box-shadow 0.15s; }
a.kpi-link:hover { border-color: var(--accent); color: inherit; }
a.kpi-link .kpi-label::after { content: " →"; color: var(--accent); }
tr.row-link { cursor: pointer; }
.link-btn { background: none; border: 0; padding: 4px 0; font: inherit; font-weight: 600; color: var(--accent); text-align: start; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link-btn:hover { color: var(--accent-hover); }
.slug-copy { background: var(--surface-2); border: 1px dashed var(--field-border); border-radius: 8px; padding: 4px 10px; font-size: 1.05rem; font-weight: 700; letter-spacing: 0.08em; color: var(--text); cursor: copy; }
.slug-copy[data-copied] { border-color: var(--ok); color: var(--ok); }
.back, .link-more { display: inline-flex; align-items: center; min-block-size: 32px; }
tbody th a, td a { display: inline-block; padding-block: 3px; }
.skip-link { position: absolute; inset-inline-start: 8px; inset-block-start: -60px; z-index: 100; background: var(--accent); color: var(--on-accent); padding: 10px 14px; border-radius: 10px; font-weight: 600; text-decoration: none; }
.skip-link:focus { inset-block-start: 8px; color: var(--on-accent); }
@media print { .skip-link { display: none; } }
