/*
 * Страница «Тарифы и оплата» (/billing/).
 * Построена на токенах и компонентах styles/home.css (masthead, brand,
 * eyebrow, button, site-footer), как prices.html и support.html.
 * Здесь — только то, чего нет на главной. Inline-стилей нет: на /billing/
 * действует CSP style-src 'self'.
 */

.billing-page main {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.billing-page main > * {
  min-width: 0;
}

.billing-page button {
  font: inherit;
  cursor: pointer;
}

.billing-page a:not(.button):not(.brand):not(.header-action):not(.footer-cta):not(.footer-brand) {
  transition: color 0.18s ease;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid rgba(47, 107, 255, 0.3);
  outline-offset: 3px;
}

/* ---------- Hero ---------- */

.billing-hero {
  --masthead-pad-x: clamp(22px, 5vw, 72px);
  position: relative;
  display: grid;
  justify-items: center;
  padding: 14px clamp(22px, 5vw, 72px) clamp(34px, 4vw, 52px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.92);
  border-radius: 38px;
  background:
    radial-gradient(circle at 92% 6%, rgba(47, 107, 255, 0.11), transparent 24rem),
    radial-gradient(circle at 6% 96%, rgba(255, 207, 74, 0.15), transparent 22rem),
    rgba(251, 250, 246, 0.92);
  box-shadow: var(--shadow);
  text-align: center;
}

.billing-hero::after {
  position: absolute;
  right: -140px;
  bottom: -200px;
  width: 380px;
  height: 380px;
  border: 1px solid rgba(47, 107, 255, 0.08);
  border-radius: 50%;
  box-shadow:
    0 0 0 52px rgba(47, 107, 255, 0.025),
    0 0 0 104px rgba(47, 107, 255, 0.016);
  content: "";
  pointer-events: none;
}

.billing-hero > * {
  position: relative;
  z-index: 1;
}

.billing-hero .masthead--in-hero {
  margin-bottom: clamp(12px, 2.4vw, 34px);
}

.billing-hero h1 {
  max-width: 900px;
  margin: 22px 0 16px;
}

.billing-lead {
  max-width: 600px;
  margin: 0;
  color: var(--muted);
  font-size: clamp(15px, 1.4vw, 18px);
  line-height: 1.62;
}

/* Статус. billing.js перезаписывает className целиком ('' | 'error'),
   поэтому стилизуем по id. */
#message {
  max-width: 640px;
  margin: 22px 0 0;
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

#message:empty {
  display: none;
}

#message.error {
  border-color: rgba(200, 52, 72, 0.22);
  background: #fff1f2;
  color: #a4243a;
}

/* ---------- Cards ---------- */

.billing-card {
  min-width: 0;
  padding: clamp(26px, 3.4vw, 44px);
  border: 1px solid var(--line);
  border-radius: 32px;
  background: rgba(251, 250, 246, 0.86);
  box-shadow: 0 18px 54px rgba(28, 39, 70, 0.07);
}

.billing-card h2 {
  margin: 0;
  font-family: "Onest", "Inter", sans-serif;
  font-size: clamp(22px, 2.2vw, 28px);
  font-weight: 680;
  letter-spacing: -0.04em;
  line-height: 1.15;
}

.billing-card p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

/* ---------- Login ---------- */

.billing-login {
  display: grid;
  justify-items: center;
  width: min(100%, 640px);
  margin: 0 auto;
  text-align: center;
}

.billing-login p {
  max-width: 460px;
  margin: 10px 0 24px;
}

/* ---------- Checkout layout ---------- */

.billing-layout {
  display: grid;
  grid-template-columns: minmax(0, 450px) minmax(0, 520px);
  justify-content: center;
  align-items: start;
  gap: 18px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Карточка «Тариф семьи» ----------
 * 1-в-1 с lib/widgets/family_tariff_card.dart и
 * lib/widgets/family_card/family_page_style.dart (Airy frost).
 * Токены продублированы здесь, чтобы карточка не зависела от палитры сайта.
 */

.tariff-card {
  --tc-ink: #1f3155;
  --tc-muted: #60708f;
  --tc-link: #2f6bff;
  --tc-card: #f9fbff;
  --tc-card-border: #d9e5fa;
  --tc-icon-surface: #eaf2ff;
  --tc-primary: #2f6bff;
  --tc-primary-border: #6e98f6;
  width: 100%;
  max-width: 450px;
  justify-self: center;
  overflow: hidden;
  border: 1px solid var(--tc-card-border);
  border-radius: 28px;
  background: rgba(249, 251, 255, 0.98);
  box-shadow: 0 8px 18px rgba(49, 86, 151, 0.07);
  color: var(--tc-ink);
  font-family: "Inter", system-ui, sans-serif;
  text-align: left;
}

/* Пустая карточка (владелец не вы, оплата скрыта) не показывается. */
.tariff-card:not(:has(> :not([hidden]))) {
  display: none;
}

.tariff-muted {
  margin: 0;
  color: var(--tc-muted);
  font-size: 13px;
  line-height: 1.4;
}

/* Обложка */

.tariff-cover {
  padding: 22px 24px 14px;
  background: linear-gradient(to bottom right, var(--tc-icon-surface), var(--tc-card));
}

.tariff-cover__top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
}

.tariff-cover__top .tariff-muted {
  flex: 1;
}

.tariff-chip {
  padding: 5px 9px;
  border-radius: 20px;
  background: var(--tc-icon-surface);
  color: var(--tc-link);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
}

.tariff-cover__main {
  display: flex;
  align-items: center;
  gap: 15px;
}

.tariff-cover__copy {
  flex: 1;
  min-width: 0;
}

.tariff-name {
  margin: 0 0 8px;
  color: var(--tc-ink);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.65px;
  line-height: 1.2;
}

.tariff-art {
  flex: none;
  width: 155px;
  height: 155px;
  object-fit: contain;
}

/* Тело */

.tariff-body {
  display: flex;
  flex-direction: column;
  padding: 24px;
}

.tariff-body fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.tariff-info {
  margin: 0 0 20px;
  padding: 15px;
  border-radius: 14px;
  background: var(--tc-icon-surface);
  color: var(--tc-muted);
  font-size: 13px;
  line-height: 1.4;
}

.tariff-info strong {
  display: block;
  margin-bottom: 4px;
  color: var(--tc-ink);
  font-weight: 600;
}

.tariff-info p {
  margin: 0;
  color: var(--tc-muted);
  font-size: 13px;
  line-height: 1.4;
}

/* CupertinoSlidingSegmentedControl */
.tariff-segmented {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  padding: 2px;
  border-radius: 9px;
  background: var(--tc-icon-surface);
}

.tariff-segment {
  min-height: 32px;
  padding: 8px 6px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--tc-ink);
  font: 400 12px/1.2 "Inter", system-ui, sans-serif !important;
  cursor: pointer;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.tariff-segment[aria-checked="true"] {
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 3px 1px rgba(0, 0, 0, 0.04);
  font-weight: 500 !important;
}

.tariff-price-row {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-top: 20px;
}

.tariff-price-row .tariff-muted {
  flex: 1;
}

.tariff-price {
  color: var(--tc-ink);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.4px;
  text-align: right;
  white-space: nowrap;
}

.tariff-price span {
  color: var(--tc-muted);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0;
}

.tariff-price .tariff-unavailable {
  font-size: 13px;
  white-space: normal;
}

.tariff-savings {
  margin: 6px 0 0;
  color: var(--tc-link);
  font-size: 13px;
}

.tariff-features {
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
}

.tariff-features li {
  position: relative;
  margin-bottom: 10px;
  padding-left: 24px;
  color: var(--tc-ink);
  font-size: 13px;
  line-height: 1.45;
}

/* CupertinoIcons.check_mark, 15px, primary */
.tariff-features li::before {
  position: absolute;
  top: 3px;
  left: 1px;
  width: 12px;
  height: 7px;
  border-bottom: 1.6px solid var(--tc-primary);
  border-left: 1.6px solid var(--tc-primary);
  content: "";
  transform: rotate(-45deg) translate(1px, 2px);
}

.tariff-choices {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: 8px;
  margin-top: 10px;
}

.tariff-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 8px 2px;
  border: 1px solid var(--tc-card-border);
  border-radius: 14px;
  background: var(--tc-card);
  color: var(--tc-ink);
  font: 400 11px/1.2 "Inter", system-ui, sans-serif !important;
  text-align: center;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, opacity 0.18s ease;
}

.tariff-choice:active {
  opacity: 0.6;
}

.tariff-choice[aria-checked="true"] {
  border-color: var(--tc-primary-border);
  background: var(--tc-icon-surface);
}

.tariff-choice img {
  width: 55px;
  height: 55px;
  object-fit: contain;
}

.tariff-choice span {
  overflow-wrap: anywhere;
}

.tariff-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  margin-top: 20px;
  padding: 14px 12px;
  border: 0;
  border-radius: 14px;
  background: var(--tc-primary);
  color: #fff;
  font: 600 14px/1.2 "Inter", system-ui, sans-serif !important;
  text-align: center;
  cursor: pointer;
  transition: opacity 0.18s ease;
}

.tariff-button:active {
  opacity: 0.6;
}

.tariff-button:disabled {
  background: var(--tc-primary);
  opacity: 0.4;
  cursor: not-allowed;
}

#create-family .tariff-info {
  margin-bottom: 0;
}

.tariff-footnote {
  margin: 14px 0 0;
  color: var(--tc-muted);
  font-size: 11px;
  line-height: 1.45;
  text-align: center;
}

.tariff-footnote + .tariff-footnote {
  margin-top: 6px;
}

#summary:empty {
  display: none;
}

/* Условия и согласие — в языке карточки */

.tariff-card .terms {
  margin-top: 20px;
  border: 1px solid var(--tc-card-border);
  border-radius: 14px;
  background: #fff;
}

.tariff-card .terms summary {
  padding: 13px 15px;
  color: var(--tc-link);
  font-size: 13px;
  font-weight: 600;
}

.tariff-card .terms[open] summary {
  border-bottom: 1px solid var(--tc-card-border);
}

.tariff-card .terms pre {
  padding: 13px 15px 15px;
  color: var(--tc-muted);
  font-size: 12px;
}

.tariff-card .accept {
  margin: 16px 0 0;
  color: var(--tc-ink);
  font-size: 13px;
}

.tariff-card .accept input {
  accent-color: var(--tc-primary);
}

/* ---------- Terms & consent (база) ---------- */

.terms summary {
  cursor: pointer;
  list-style-position: inside;
}

.terms pre {
  max-height: 420px;
  margin: 0;
  overflow: auto;
  font: inherit;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.accept {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  line-height: 1.5;
  cursor: pointer;
}

.accept input {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 0;
  cursor: pointer;
}

/* ---------- History ---------- */

.billing-history {
  display: grid;
  gap: 8px;
  position: sticky;
  top: 18px;
}

.billing-history__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.billing-history__head h2 {
  font-size: clamp(20px, 2vw, 24px);
}

#refresh {
  min-height: 42px;
  padding: 0 16px;
  font-size: 12px;
}

#orders {
  color: var(--muted);
  font-size: 14px;
}

.order {
  display: grid;
  gap: 4px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.order:first-child {
  padding-top: 4px;
}

.order:last-child {
  border-bottom: 0;
}

.order strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.order p {
  margin: 0;
  font-size: 13px;
}

.billing-help a {
  color: var(--blue-700);
  font-weight: 600;
}

.billing-help a:hover {
  color: var(--blue-600);
}

.billing-help {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

/* ---------- Responsive ---------- */

@media (max-width: 1040px) {
  .billing-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .billing-history {
    width: 100%;
    max-width: 450px;
    justify-self: center;
  }

  .billing-history {
    position: static;
  }

}

@media (max-width: 820px) {
  .billing-hero {
    padding-top: 8px;
    border-radius: 29px;
  }

  .billing-card {
    border-radius: 26px;
  }
}

@media (max-width: 640px) {
  .billing-card {
    padding: 24px 18px;
  }

}

/* LayoutBuilder compact (< 352px ширины обложки) */
@media (max-width: 420px) {
  .tariff-name {
    font-size: 23px;
  }

  .tariff-art {
    width: 110px;
    height: 110px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tariff-segment,
  .tariff-choice,
  .tariff-button {
    transition: none;
  }
}
