/* ============================================================================
   /cp/ — simplified account cabinet. Loaded after brand.css.
   ========================================================================== */

/* The cabinet column is wider than the onboarding one: the sales card carries
   plan rows with the price on the right, and 640px squeezed the plans to a
   width where nothing read (three columns of ~170px). */
.page-col { max-width: 720px; }

/* Greeting */
.greeting { display: flex; flex-direction: column; gap: var(--bv-sp-1); }
.greeting h1 { font-size: clamp(22px, 18px + 1vw, 26px); }
.greeting__sub { font-size: var(--bv-fs-base); color: var(--bv-ink-faint); }

/* ---------------------------------------------------------------------------
   Subscription card — one card with four faces (trial / active / expiring /
   expired). Heading + status chip, a segmented meter, the plan selector and
   a single CTA.
   -------------------------------------------------------------------------- */
.sub-card { gap: var(--bv-sp-4); padding: var(--bv-card-pad-sm); }
.sub-card--warn   { border-color: var(--bv-warn-line); }
.sub-card--danger { border-color: var(--bv-danger-line); }

.sub-card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--bv-sp-3);
  flex-wrap: wrap;
}
.sub-card__title {
  flex: 1 1 auto;
  font-family: var(--bv-font-display);
  font-size: clamp(17px, 14px + 0.8vw, 20px);
  font-weight: 600;
  line-height: var(--bv-lh-tight);
  text-wrap: balance;
}
/* Price anchor to the right of the heading ("потом от 99 ₽/мес"). */
.sub-card__aside {
  flex: 0 0 auto;
  font-size: var(--bv-fs-sm);
  color: var(--bv-ink-faint);
  white-space: nowrap;
}
.sub-card__aside strong { color: var(--bv-ink); font-weight: 700; }
.sub-card__sub { font-size: var(--bv-fs-sm); color: var(--bv-ink-faint); }
.sub-card__body { font-size: var(--bv-fs-base); color: var(--bv-ink-soft); }
.sub-card__fine { font-size: var(--bv-fs-xs); color: var(--bv-ink-faint); text-align: center; }
.sub-card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--bv-sp-3);
  flex-wrap: wrap;
}

/* Status chip. Squared off like every other chip in the system — the
   rounded "pill" look was dropped brand-wide. */
.status-chip {
  flex-shrink: 0;
  align-self: flex-start;
  padding: 5px 10px;
  border-radius: var(--bv-r-chip);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  background: var(--bv-bg);
  border: 1px solid var(--bv-line);
  color: var(--bv-ink-mute);
}
.status-chip--accent { background: #FDEEE5; border-color: var(--bv-peach); color: var(--bv-accent-strong); }
.status-chip--ok     { background: var(--bv-ok-bg); border-color: var(--bv-ok-line); color: var(--bv-ok); }
.status-chip--warn   { background: var(--bv-warn-bg); border-color: var(--bv-warn-line); color: var(--bv-warn-ink); }
.status-chip--danger { background: var(--bv-danger-bg); border-color: var(--bv-danger-line); color: var(--bv-danger-ink); }

/* Progress: share of the period already spent. A <progress> keeps the value in
   an attribute, so the bar is fluid without an inline style. Both engines need
   their own pseudo-elements — hence the duplicated rules. */
/* Bar + deadline on one line: «прошло столько» рядом с «до какого числа». */
.meter-row { display: flex; align-items: center; gap: var(--bv-sp-3); }
.meter-row .meter { flex: 1 1 auto; margin: 0; }
.meter-row__date {
  flex: 0 0 auto;
  font-size: var(--bv-fs-xs);
  color: var(--bv-ink-faint);
  white-space: nowrap;
}

.meter {
  display: block;
  width: 100%;
  height: 8px;
  margin: calc(var(--bv-sp-1) * -1) 0 var(--bv-sp-1);
  border: none;
  border-radius: var(--bv-r-2xs);
  background: var(--bv-line);
  color: var(--bv-accent);          /* Firefox: fill colour */
  appearance: none;
  overflow: hidden;
}
.meter::-webkit-progress-bar { background: var(--bv-line); border-radius: var(--bv-r-2xs); }
.meter::-webkit-progress-value { background: var(--bv-accent); border-radius: var(--bv-r-2xs); }
.meter::-moz-progress-bar { background: var(--bv-accent); border-radius: var(--bv-r-2xs); }
.sub-card--warn .meter { color: var(--bv-warn-strong); }
.sub-card--warn .meter::-webkit-progress-value { background: var(--bv-warn-strong); }
.sub-card--warn .meter::-moz-progress-bar { background: var(--bv-warn-strong); }
.sub-card--danger .meter { color: var(--bv-danger); }
.sub-card--danger .meter::-webkit-progress-value { background: var(--bv-danger); }
.sub-card--danger .meter::-moz-progress-bar { background: var(--bv-danger); }

/* Plan selector on the card. Price per month is the anchor; the longest
   period comes first and is preselected. */
/* One plan per row, on every width. Three columns matched the mockup's 560px
   card, but inside our column they collapsed to ~170px each and the term, the
   price and the one-off sum fought for the same line. A row gives the price
   the right-hand side to itself — the shape the desktop app already uses. */
.plan-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--bv-sp-3);
}
.plan {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  text-align: left;
  cursor: pointer;
  background: var(--bv-surface);
  /* Transparent border + inset hairline: the unselected row reads as a thin
     outline and picking one does not shift the layout. */
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px var(--bv-line);
  border-radius: var(--bv-r-lg);
  font-family: inherit;
  color: inherit;
  transition:
    border-color var(--bv-dur) var(--bv-ease-out),
    box-shadow var(--bv-dur) var(--bv-ease-out),
    background var(--bv-dur) var(--bv-ease-out);
}
.plan:hover { box-shadow: inset 0 0 0 1px var(--bv-line-strong); }
.plan.is-active {
  border-color: var(--bv-accent);
  box-shadow: none;
  background: #FDEEE5;
}
/* The radio only appears on phones (owner's mockup); on desktop the
   highlighted row already says which plan is picked. */
.plan__radio { display: none; }
.plan__body { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-width: 0; }
.plan__head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.plan__save {
  padding: 2px 8px;
  border-radius: var(--bv-r-2xs);
  background: var(--bv-ok-bg);
  color: var(--bv-ok);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.plan__term { font-size: var(--bv-fs-base); font-weight: 700; color: var(--bv-ink); }
.plan__note { font-size: var(--bv-fs-xs); color: var(--bv-ink-faint); }
.plan__price {
  display: flex;
  align-items: baseline;
  gap: 4px;
  flex: 0 0 auto;
  white-space: nowrap;   /* never break "149 ₽/мес" mid-price */
}
.plan__num {
  font-family: var(--bv-font-display);
  font-size: var(--bv-fs-3xl);
  font-weight: 600;
  line-height: 1.15;
}
.plan__unit { font-size: var(--bv-fs-xs); color: var(--bv-ink-soft); }

/* Device count badge */
.count-pill {
  font-size: var(--bv-fs-sm);
  font-weight: 700;
  color: var(--bv-ink-soft);
  background: var(--bv-bg);
  border: 1px solid var(--bv-line);
  padding: 6px 14px;
  border-radius: var(--bv-r-chip);
  white-space: nowrap;
}

/* List rows: transaction history and devices */
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--bv-sp-3);
  background: var(--bv-bg);
  border: 1px solid var(--bv-line);
  border-radius: var(--bv-r-sm);
  padding: 14px 16px;
  transition: border-color var(--bv-dur-fast) ease;
}
.list-row:hover { border-color: var(--bv-line-strong); }
.list-row__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.list-row__title {
  font-size: var(--bv-fs-base);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-row__meta { font-size: var(--bv-fs-xs); color: var(--bv-ink-faint); }
.list-row__amount { flex-shrink: 0; font-size: var(--bv-fs-md); font-weight: 700; }
.list-row__amount.is-credit { color: var(--bv-ok); }

/* Devices slightly larger, with a bigger radius */
.device-row { border-radius: var(--bv-r-md); }
.device-row .list-row__title { font-size: var(--bv-fs-md); font-weight: 700; }
.device-row__actions { display: flex; align-items: center; gap: var(--bv-sp-2); flex-shrink: 0; }

/* Login blocks (.auth-box, .email-box, .tg-alt) live in brand.css —
   shared with the onboarding page. */

/* Renewal period chips: three equal columns; the discount badge is a
   floating pill on the top corner (otherwise it does not fit in the chip). */
/* Periods lay out as a grid so several plans wrap cleanly instead of
   overflowing a single row: 2-up on a phone-width sheet (2×2 for four plans),
   4-up once the sheet is wide enough. A plain flex row didn't shrink below the
   label width, so four plans ran off the edge on narrow WebViews (the app
   opens /cp/ in a phone-width WebView). Breakpoint is on the SHEET width
   (container query) so it's right regardless of viewport; a viewport media
   query is the fallback where container queries aren't supported. */
.period-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding-top: 10px;
}
@supports (container-type: inline-size) {
  .card.sheet { container-type: inline-size; }
  @container (min-width: 480px) {
    .period-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  }
}
@supports not (container-type: inline-size) {
  @media (min-width: 600px) {
    .period-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  }
}
.chip--period {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 14px 6px 12px;
}
.chip--period .chip__label { font-size: var(--bv-fs-base); font-weight: 700; white-space: nowrap; }
.chip--period .chip__price { font-size: var(--bv-fs-xs); color: var(--bv-ink-faint); white-space: nowrap; }
.chip--period.is-active .chip__price { color: var(--bv-accent-ink); opacity: 0.85; }
.chip__badge {
  position: absolute;
  top: -11px; right: 7px;
  font-size: 11px;
  font-weight: 700;
  color: var(--bv-surface);
  background: var(--bv-ok);
  padding: 2px 7px;
  border-radius: var(--bv-r-chip);
  border: 2px solid var(--bv-accent-ink);
  white-space: nowrap;
}


/* Payment method — chip row with a description */
.chip--method {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  padding: 14px 18px;
}
.chip--method .chip__name { font-size: var(--bv-fs-md); font-weight: 700; }
.chip--method .chip__desc { font-size: var(--bv-fs-xs); font-weight: 400; color: var(--bv-ink-faint); }
.chip--method.is-active { background: var(--bv-danger-bg); border-color: var(--bv-accent); color: var(--bv-ink); }

/* Label above a field group */
.field-label {
  display: block;
  font-size: var(--bv-fs-sm);
  font-weight: 600;
  color: var(--bv-ink-faint);
  margin-bottom: 10px;
}

/* "Connection link + Copy" row lives in brand.css (shared with onboarding) */

/* "Unlink all" confirmation strip */
.confirm-strip {
  display: flex;
  align-items: center;
  gap: var(--bv-sp-3);
  flex-wrap: wrap;
  background: var(--bv-danger-bg);
  border-radius: var(--bv-r-sm);
  padding: 12px 16px;
  font-size: var(--bv-fs-sm);
  color: var(--bv-danger-ink);
}

/* Mobile adjustments */
@media (max-width: 600px) {
  .page-header { padding: 14px; gap: 10px; }
}

/* --- Contextual refinements of brand.css components --- */

/* Header: "Log out" more prominent than a regular link-muted */
.page-header .link-muted { font-size: var(--bv-fs-base); font-weight: 600; color: var(--bv-ink-mute); }

/* Typography inside cards */
.card h1 { font-size: clamp(22px, 18px + 1vw, 26px); }
.card h2 { font-size: var(--bv-fs-panel); }
.card p { font-size: var(--bv-fs-md); color: var(--bv-ink-soft); }

/* Stat card footer: balance + history link */
.stat-card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: var(--bv-sp-2);
  flex-wrap: wrap;
  font-size: var(--bv-fs-xs);
}
.stat-card__more { margin-top: var(--bv-sp-2); }

/* Quick-amount chip row */
.chip-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* "Done" note in the renewal panel */
.done-note { font-weight: 600; color: var(--bv-ok); }

/* Device limit warning */
.limit-hint { font-size: var(--bv-fs-xs); color: var(--bv-warn-strong); }

/* Utility links under the page: transaction history + support, one quiet row. */
.page-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--bv-sp-5);
  flex-wrap: wrap;
}

/* Phones: three columns do not fit, and a lone third card looks broken. Each
   plan becomes a full-width row instead — term and price left, total right,
   the same shape as the renewal sheet. */
/* Phones: one plan per row — radio, term with the saving, the one-off sum
   underneath, price per month on the right. Three columns never fitted, and
   the row reads like a normal choice list. */
@media (max-width: 560px) {
  .plan { padding: 12px 14px; background: var(--bv-bg); }
  .plan.is-active { background: #FDEEE5; }
  .plan__radio {
    display: block;
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    border-radius: 50%;            /* a radio is round by convention */
    border: 2px solid var(--bv-line-strong);
    background: var(--bv-surface);
  }
  .plan.is-active .plan__radio {
    border-color: var(--bv-accent);
    background:
      radial-gradient(circle at 50% 50%, var(--bv-accent) 0 5px, var(--bv-surface) 5px);
  }
  /* Term and saving stay on one line — the badge belongs to the term. */
  .plan__head { flex-wrap: nowrap; gap: 6px; }
  .plan__term { font-size: var(--bv-fs-sm); white-space: nowrap; }
  .plan__note { font-size: 13px; }
  .plan__save { padding: 2px 7px; }
  .plan__num { font-size: var(--bv-fs-2xl); }
  /* The price anchor above the plans is desktop-only: on a phone every row
     already carries its price. */
  .sub-card__aside { display: none; }
}
@media (max-width: 560px) { .page-header__who { display: none; } }

/* Compact card: the devices block is a summary, not a section. */
.card--compact { gap: var(--bv-sp-3); padding: var(--bv-card-pad-sm); }
.card__title { display: flex; align-items: center; gap: var(--bv-sp-3); }
.link-accent {
  color: var(--bv-accent);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  /* Never wider than its row: on a narrow card the whole link moves to the
     next line instead of hanging over the edge. */
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.link-accent:hover { color: var(--bv-accent-strong); text-decoration: underline; }
/* Account deletion lives here now — reachable, deliberately not inviting. */
.link-faint {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  color: var(--bv-ink-faint);
  cursor: pointer;
}
.link-faint:hover { color: var(--bv-danger); text-decoration: underline; }

@media (max-width: 480px) {
  /* Unbounded is wide: at the fluid size the heading broke into two lines on a
     390 px phone, which pushed the price anchor under it and read as "shifted". */
  .sub-card__title { font-size: 16px; }
  .card__title h2 { font-size: 19px; }
}

/* ---------------------------------------------------------------------------
   Desktop: the dashboard must fit a 1080p viewport without a vertical
   scrollbar. The content itself fits — the scroll came from the shell's
   generous rhythm (115px header, 80px bottom padding, 22px gaps, 28px of
   vertical card padding). Tighten only the vertical spending; widths, the
   mobile layout and the horizontal paddings stay as designed. Kept LAST in
   the file so it wins over the base component rules above.
   -------------------------------------------------------------------------- */
@media (min-width: 601px) {
  .page-header { padding-top: var(--bv-sp-3); padding-bottom: var(--bv-sp-3); }
  .site-logo { height: clamp(44px, 36px + 0.8vw, 52px); }
  .page-main {
    padding-top: var(--bv-sp-4);
    padding-bottom: var(--bv-sp-5);
  }
  .page-col { gap: var(--bv-sp-4); }
  .sub-card {
    gap: var(--bv-sp-3);
    padding-top: var(--bv-sp-5);
    padding-bottom: var(--bv-sp-5);
  }
  /* The winback face carries two extra text lines; without this it was the
     only state still 20px taller than a 1080p viewport. */
  .sub-card__sub, .sub-card__body { margin-top: calc(var(--bv-sp-1) * -1); }
  .plan { padding: 9px 16px; }
  .card--compact { padding-top: var(--bv-sp-4); padding-bottom: var(--bv-sp-4); }
}
