/* Общие стили и компоненты (BRIEF §8.2, §8.4, §8.5) */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}
img, svg { max-width: 100%; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; line-height: 1.2; letter-spacing: -0.03em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
a.link, .prose a { color: var(--accent-text); text-decoration: underline; text-underline-offset: 2px; }
code, kbd, .mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.ink-2 { color: var(--ink-2); }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid #7B91FF; outline-offset: 3px; }
.skip-link {
  position: absolute; left: 16px; top: -100px; z-index: 100;
  background: var(--surface); color: var(--ink); padding: 12px 16px; border-radius: var(--radius-control);
  border: 1px solid var(--line-2);
}
.skip-link:focus { top: 12px; }

.container { max-width: var(--container); margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }
@media (max-width: 767px) { :root { --gutter: 16px; } }

/* Тестовый режим платежей (BRIEF §2.9) */
.test-banner {
  background: var(--test-banner-bg); color: var(--test-banner-ink);
  text-align: center; font-weight: 600; font-size: 14px; padding: 8px 16px;
}

/* Кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 44px; padding: 0 18px; border-radius: var(--radius-control);
  font: inherit; font-weight: 550; font-size: 14px; line-height: 1.2; text-align: center;
  border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .18s, transform .18s, color .18s, box-shadow .18s, border-color .18s;
}
.btn:hover { text-decoration: none; }
.btn svg { flex: none; }
.btn--lg { min-height: 47px; padding: 0 21px; font-size: 14px; }
.btn--xl { min-height: 50px; padding: 0 24px; font-size: 15px; }
.btn--block { display: flex; width: 100%; }
.btn--primary { background: var(--accent); color: #FFFFFF; box-shadow: 0 4px 7px rgba(68, 100, 237, .07); }
.btn--primary:hover { background: var(--accent-hover); box-shadow: 0 5px 15px rgba(68, 100, 237, .15); }
.btn--green { background: #1C7C5C; color: #FFFFFF; }
.btn--green:hover { filter: brightness(1.07); }
.btn--secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn--secondary:hover { border-color: #9BABEF; }
a.btn--primary:hover, a.btn--secondary:hover, a.btn--green:hover { transform: translateY(-2px); }
.btn--danger { background: transparent; color: var(--danger); border-color: transparent; }
.btn--danger-soft { background: var(--danger-soft); color: var(--danger); }
.btn--ghost { background: transparent; color: var(--accent-text); padding: 0 8px; }
.btn[disabled], .btn--disabled, .btn[aria-disabled="true"] {
  background: transparent; color: var(--ink-3); border: 1.5px dashed var(--line-2);
  cursor: not-allowed; filter: none;
}
.btn-icon {
  width: 40px; height: 40px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: var(--ink-3);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;
  transition: background .18s, color .18s;
}
.btn-icon:hover { background: var(--accent-soft); color: var(--accent-text); }
.btn-icon--sm { width: 36px; height: 36px; border-color: transparent; background: transparent; }

/* Поля */
.field { display: grid; gap: 6px; }
.field + .field { margin-top: 16px; }
.field label, .field .label { font-size: 13px; font-weight: 550; color: var(--ink); }
.field .hint { font-size: 13px; color: var(--ink-3); }
.field .error, .errorlist { font-size: 14px; color: var(--danger); margin: 0; padding: 0; list-style: none; }
.input, .field input[type="text"], .field input[type="email"], .field input[type="password"],
.field input[type="number"], .field input[type="date"], .field input[type="tel"], .field select, .field textarea {
  width: 100%; min-height: 46px; padding: 0 14px; border-radius: var(--radius-control);
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: inherit; font-size: 14px;
}
.field textarea { padding: 12px 14px; min-height: 120px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.field--invalid input, .field--invalid select, .field--invalid textarea { border-color: var(--danger); }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }

/* Метки статусов */
.pill {
  display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 6px;
  font-size: 12.5px; font-weight: 550; white-space: nowrap; background: var(--mute-soft); color: var(--mute);
}
.pill--ok { background: var(--ok-soft); color: var(--ok); }
.pill--warn { background: var(--warn-soft); color: var(--warn); }
.pill--danger { background: var(--danger-soft); color: var(--danger); }
.pill--accent { background: var(--accent-soft); color: var(--accent-text); }
.pill--sm { height: 24px; font-size: 12.5px; padding: 0 9px; }

/* Чипы фильтров */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border-radius: 7px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); font: inherit; font-size: 13px; font-weight: 550; cursor: pointer;
}
.chip:hover { text-decoration: none; border-color: #9BABEF; }
.chip[aria-pressed="true"], .chip[aria-current="true"], .chip--on { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-line); }
.chip .count { font-weight: 500; opacity: .75; }
.term-chips { list-style: none; padding: 0; margin: 10px 0; }
.term-chips form { display: contents; }
button.chip { cursor: pointer; }

/* Карточки и панели */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
.card--pad { padding: 28px; }
.empty {
  border: 1.5px dashed var(--line-2); border-radius: var(--radius-card); padding: 28px; color: var(--ink-2);
}
.empty__title { font-weight: 600; color: var(--ink); margin-bottom: 4px; }
.note {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 18px; border-radius: 8px;
  background: var(--accent-soft); color: var(--ink-2); font-size: 14px; line-height: 1.7; border: 1px solid var(--accent-line);
}
.note--warn { background: var(--warn-soft); color: var(--ink); border-color: transparent; }
.note--ok { background: var(--ok-soft); color: var(--ink); border-color: transparent; }
.note--danger { background: var(--danger-soft); color: var(--ink); border-color: transparent; }
.note--accent { background: var(--accent-soft); color: var(--ink); }
.note svg { flex: none; margin-top: 2px; }

.toast {
  padding: 14px 18px; border-radius: 9px; font-size: 14px; font-weight: 500;
  background: var(--ok-soft); color: var(--ink); border: 1px solid transparent;
}
.toast--error { background: var(--danger-soft); }
.toast--warning { background: var(--warn-soft); }
.toast--info { background: var(--accent-soft); }
.messages { display: grid; gap: 10px; margin-bottom: 24px; }

/* Знаки продуктов */
.mark {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 40px; height: 40px; border-radius: 10px; font-weight: 700; font-size: 14px;
}
.mark--doc { background: linear-gradient(135deg, #70A0FF, #2358CD); color: #FFFFFF; box-shadow: 0 5px 10px rgba(44, 85, 186, .14); }
.mark--sheet { background: linear-gradient(135deg, #5EC99B, #148355); color: #FFFFFF; box-shadow: 0 5px 10px rgba(33, 127, 80, .14); }
.mark--bundle { background: linear-gradient(135deg, #8EA2FF, #4464ED 55%, #2A9C78); color: #FFFFFF; box-shadow: 0 5px 10px rgba(44, 85, 186, .14); }
.mark--sm { width: 32px; height: 32px; border-radius: 8px; }
.mark--lg { width: 56px; height: 56px; border-radius: 12px; }
.mark--xl { width: 64px; height: 64px; border-radius: 14px; }
.dot { width: 10px; height: 10px; border-radius: 3px; flex: none; display: inline-block; }
.dot--doc { background: var(--doc); }
.dot--sheet { background: var(--sheet); }

/* Таблицы (BRIEF §8.4): шапка мелким ink-3, разделители, без зебры */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--ink-3); padding: 12px 16px; background: var(--surface-2); white-space: nowrap; }
.table td { padding: 14px 16px; border-top: 1px solid var(--line); vertical-align: top; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.is-warn td { background: var(--warn-row); }

/* Определения (dl) */
.deflist { margin: 0; border-top: 1px solid var(--line); }
.deflist > div { display: flex; flex-wrap: wrap; gap: 8px 24px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.deflist dt { flex: 0 0 240px; color: var(--ink-3); }
.deflist dd { margin: 0; flex: 1 1 240px; }

.prose { max-width: 760px; }
.prose h2 { font-size: 26px; margin: 32px 0 12px; }
.prose h3 { font-size: 20px; margin: 24px 0 8px; }
.prose p, .prose ul, .prose ol { margin: 0 0 14px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
.note--spaced { margin-top: 24px; }

/* Переключатель темы: показываем значок той темы, на которую переключимся */
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; letter-spacing: -0.04em; color: var(--ink); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img, .brand__logo { height: 32px; width: 32px; object-fit: contain; flex: none; }
.brand-mark { object-fit: contain; flex: none; }
