/* ------------------------------------------------------------------ */
/* tokens                                                              */
/* ------------------------------------------------------------------ */

:root {
  --bg: #fbfbfa;
  --surface: #ffffff;
  --surface-sunken: #f4f4f2;
  --ink: #15161a;
  --ink-soft: #4a4c55;
  --ink-muted: #86888f;
  --line: rgba(21, 22, 26, 0.1);
  --line-strong: rgba(21, 22, 26, 0.18);
  --accent: #15161a;
  --accent-ink: #ffffff;
  --warn: #a3421f;
  --warn-bg: rgba(163, 66, 31, 0.08);
  --ok: #2f6b46;
  --focus: rgba(21, 22, 26, 0.28);
  --shadow: 0 1px 2px rgba(21, 22, 26, 0.04), 0 8px 24px -12px rgba(21, 22, 26, 0.16);
  --radius: 10px;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0f11;
    --surface: #16181b;
    --surface-sunken: #1b1e21;
    --ink: #f0f0ee;
    --ink-soft: #b6b8be;
    --ink-muted: #7e8189;
    --line: rgba(240, 240, 238, 0.11);
    --line-strong: rgba(240, 240, 238, 0.2);
    --accent: #f0f0ee;
    --accent-ink: #0e0f11;
    --warn: #e3936f;
    --warn-bg: rgba(227, 147, 111, 0.1);
    --ok: #7fbf9a;
    --focus: rgba(240, 240, 238, 0.34);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.7);
  }
}

* {
  box-sizing: border-box;
}

/*
 * Любой явный display в наших правилах перебивает display:none, который
 * браузер вешает на [hidden]. Мы прячем через .hidden = true повсюду,
 * поэтому фиксируем приоритет один раз здесь.
 */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ------------------------------------------------------------------ */
/* shell                                                               */
/* ------------------------------------------------------------------ */

.page {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 24px 96px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.masthead {
  padding: 32px 0 56px;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.wordmark__mark {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  position: relative;
}

.wordmark__mark::after {
  content: "";
  position: absolute;
  inset: -1.5px -7px -1.5px auto;
  left: 5px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  border-left-color: transparent;
  border-bottom-color: transparent;
  transform: rotate(45deg);
  opacity: 0.35;
}

main {
  flex: 1;
}

.footer {
  padding-top: 48px;
  color: var(--ink-muted);
  font-size: 12.5px;
  border-top: 1px solid var(--line);
  margin-top: 56px;
}

/* ------------------------------------------------------------------ */
/* intro                                                               */
/* ------------------------------------------------------------------ */

h1 {
  margin: 0 0 14px;
  font-size: clamp(30px, 6vw, 40px);
  line-height: 1.12;
  font-weight: 560;
  letter-spacing: -0.025em;
}

h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 560;
  letter-spacing: -0.01em;
}

.lede {
  margin: 0 0 32px;
  max-width: 46ch;
  color: var(--ink-soft);
  font-size: 16px;
}

.search {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.field {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field:focus-within {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent);
}

.field__at {
  padding: 0 2px 0 14px;
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 15px;
}

.field input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-family: var(--mono);
  font-size: 15px;
  padding: 13px 14px 13px 4px;
  outline: none;
}

.field input::placeholder {
  color: var(--ink-muted);
  font-family: var(--sans);
}

/* ------------------------------------------------------------------ */
/* buttons                                                             */
/* ------------------------------------------------------------------ */

.btn {
  font: inherit;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0 22px;
}

.btn--primary:hover:not(:disabled) {
  opacity: 0.86;
}

.btn--primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn--ghost {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink-soft);
  padding: 7px 13px;
  font-size: 13px;
}

.btn--ghost:hover {
  color: var(--ink);
  border-color: var(--focus);
}

.linkish {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink-muted);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}

.linkish:hover {
  color: var(--ink);
}

.switch {
  margin: 22px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.note {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--ink-muted);
}

.note:empty {
  display: none;
}

/* ------------------------------------------------------------------ */
/* panels                                                              */
/* ------------------------------------------------------------------ */

.panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  padding: 22px;
  box-shadow: var(--shadow);
}

.panel__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 18px;
}

.page--narrow {
  max-width: 520px;
}

/* ---- условия обслуживания на первом экране ------------------------ */

.terms {
  list-style: none;
  margin: 28px 0 0;
  padding: 0;
  display: grid;
  gap: 14px;
}

.terms li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-soft);
}

.terms b {
  color: var(--ink);
  font-weight: 560;
}

.terms__icon svg {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: var(--ink-muted);
  stroke-width: 1.7;
  stroke-linecap: round;
  margin-top: 2px;
}

/* ---- карточка профиля -------------------------------------------- */

.profile {
  display: flex;
  align-items: center;
  gap: 14px;
}

.profile__avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  flex: none;
}

.profile__name {
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 500;
}

.profile__full {
  font-size: 13.5px;
  color: var(--ink-muted);
}

.profile__counts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin-top: 20px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.count {
  background: var(--surface);
  padding: 14px;
}

.count__value {
  font-size: 19px;
  font-weight: 560;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.count--warn .count__value {
  color: var(--warn);
}

.count__label {
  font-size: 11.5px;
  color: var(--ink-muted);
  margin-top: 2px;
}

/* ---- отказ (закрытый / слишком большой) --------------------------- */

.gate {
  margin-top: 22px;
  padding: 18px;
  border-radius: 12px;
  background: var(--warn-bg);
  border: 1px solid color-mix(in srgb, var(--warn) 26%, transparent);
}

.gate h2 {
  color: var(--warn);
  margin-bottom: 8px;
}

.gate p {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-soft);
}

/* ---- оплата ------------------------------------------------------- */

.pay {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.pay__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.pay__amount {
  font-size: 26px;
  font-weight: 560;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.pay__hint {
  font-size: 13px;
  color: var(--ink-muted);
  margin-top: 2px;
}

.pay__row .btn--primary {
  padding: 12px 26px;
}

.pay__why {
  margin: 14px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-muted);
  max-width: 52ch;
}

.terms__tiers {
  display: block;
  margin-top: 5px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-muted);
}

.pay__wait {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 0;
  font-size: 13.5px;
  color: var(--ink-soft);
}

/* ---- статус свежести данных над сводкой --------------------------- */

.freshness {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-sunken);
  font-size: 13px;
  color: var(--ink-soft);
}

.freshness__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  flex: none;
}

.freshness .btn {
  margin-left: auto;
}

.btn--sm {
  padding: 5px 11px;
  font-size: 12.5px;
}

/* ------------------------------------------------------------------ */
/* progress                                                            */
/* ------------------------------------------------------------------ */

.progress__row {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 14px;
}

.progress__row .linkish {
  margin-left: auto;
}

.spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  border-top-color: var(--ink);
  animation: spin 0.7s linear infinite;
  flex: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.meter {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--ink-muted);
}

.meter__track {
  height: 3px;
  border-radius: 2px;
  background: var(--surface-sunken);
  overflow: hidden;
}

.meter__fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--ink);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.meter__value {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

/* ------------------------------------------------------------------ */
/* alerts                                                              */
/* ------------------------------------------------------------------ */

.panel,
.alert,
.results {
  margin-top: 40px;
}

.alert,
.banner {
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.5;
  border: 1px solid;
}

.alert {
  color: var(--warn);
  background: var(--warn-bg);
  border-color: color-mix(in srgb, var(--warn) 26%, transparent);
}

.alert #error-retry {
  margin-top: 10px;
}

.banner {
  color: var(--ink-soft);
  background: var(--surface-sunken);
  border-color: var(--line);
  margin-bottom: 22px;
  font-size: 13px;
}

/* ------------------------------------------------------------------ */
/* results                                                             */
/* ------------------------------------------------------------------ */

.account {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}

.account__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  flex: none;
}

.account__name {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 500;
}

.account__full {
  font-size: 13px;
  color: var(--ink-muted);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface);
}

.stat {
  padding: 16px 14px;
  border-right: 1px solid var(--line);
}

.stat:last-child {
  border-right: 0;
}

.stat__value {
  font-size: 22px;
  font-weight: 560;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.stat--accent .stat__value {
  color: var(--warn);
}

.stat__label {
  font-size: 11.5px;
  color: var(--ink-muted);
  letter-spacing: 0.01em;
  margin-top: 3px;
}

@media (max-width: 560px) {
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .stat:nth-child(2) {
    border-right: 0;
  }
  .stat:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin: 32px 0 4px;
}

.segmented {
  display: inline-flex;
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 2px;
}

.segmented button {
  font: inherit;
  font-size: 13px;
  border: 0;
  background: none;
  color: var(--ink-muted);
  padding: 6px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.segmented button[aria-selected="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.toolbar__actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.filter {
  font: inherit;
  font-size: 13px;
  width: 150px;
  padding: 7px 11px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

.filter:focus {
  border-color: var(--focus);
}

@media (max-width: 560px) {
  .toolbar__actions {
    width: 100%;
  }
  .filter {
    flex: 1;
    width: auto;
  }
}

.copybox {
  margin-top: 16px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface-sunken);
  padding: 14px;
}

.copybox__hint {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--ink-soft);
}

.copybox textarea {
  width: 100%;
  resize: vertical;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}

.list {
  list-style: none;
  margin: 20px 0 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--line);
}

.row__index {
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-muted);
  min-width: 26px;
  text-align: right;
  flex: none;
}

.row__body {
  min-width: 0;
  flex: 1;
}

.row__name {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.row__name:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.row__full {
  font-size: 12.5px;
  color: var(--ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 1px 5px;
  flex: none;
}

.tick {
  width: 13px;
  height: 13px;
  flex: none;
  fill: var(--ink-muted);
}

.empty {
  padding: 40px 0;
  text-align: center;
  color: var(--ink-muted);
  font-size: 14px;
  border-bottom: 1px solid var(--line);
  margin: 20px 0 0;
}

/* ------------------------------------------------------------------ */
/* toast                                                               */
/* ------------------------------------------------------------------ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  z-index: 10;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---- ключ доступа вместо оплаты ----------------------------------- */

.pay__key-toggle {
  margin: 16px 0 0;
}

.keyform {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.keyform__input {
  font: inherit;
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  flex: 1;
  min-width: 180px;
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

.keyform__input:focus {
  border-color: var(--focus);
}

/* ---- подвал: реквизиты и документы -------------------------------- */

.footer__claim {
  margin: 0 0 20px;
  max-width: 62ch;
}

.footer__info {
  display: flex;
  gap: 28px;
  justify-content: space-between;
  flex-wrap: wrap;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.footer__req {
  line-height: 1.7;
}

.footer__req a {
  color: var(--ink-soft);
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
}

.footer__req a:hover {
  color: var(--ink);
}

.footer__docs {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  max-width: 34ch;
}

.footer__docs .linkish {
  font-size: 12.5px;
  text-align: left;
}

/* ---- окно с документом -------------------------------------------- */

.docdialog {
  width: min(760px, calc(100vw - 32px));
  max-height: min(86vh, 900px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  overflow: hidden;
}

.docdialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.docdialog__bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
}

.docdialog__title {
  font-size: 13.5px;
  font-weight: 560;
  line-height: 1.35;
}

.docdialog__bar .linkish {
  margin-left: auto;
  flex: none;
}

.docdialog__body {
  padding: 20px 24px 28px;
  overflow-y: auto;
  max-height: calc(min(86vh, 900px) - 56px);
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink-soft);
}

.docdialog__body h2 {
  font-size: 13.5px;
  margin: 22px 0 8px;
  color: var(--ink);
}

.docdialog__body p {
  margin: 0 0 9px;
}

.doc__loading,
.doc__meta {
  color: var(--ink-muted);
}

/* ---- отдельная страница документа --------------------------------- */

.page--doc {
  max-width: 760px;
}

.doc h1 {
  font-size: clamp(22px, 4vw, 28px);
  margin-bottom: 6px;
}

.doc__meta {
  font-size: 13px;
  margin: 0 0 28px;
}

.doc h2 {
  font-size: 15px;
  margin: 28px 0 10px;
  letter-spacing: -0.01em;
}

.doc p {
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink-soft);
  margin: 0 0 10px;
}

/* ---- чек: галочка и почта, всегда видимы, под кнопкой оплаты -------- */

.receipt {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}

.receipt__check {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
}

.receipt__check input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  flex: none;
}

.receipt__email {
  font: inherit;
  font-size: 14px;
  width: 100%;
  max-width: 320px;
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

.receipt__email:focus {
  border-color: var(--focus);
}

.receipt__email.is-invalid {
  border-color: var(--warn);
}
