/* Payments (FB-S29) and Payments UI v2 (FB-S30, PMKT-278). Tokens from app.css only, so light and dark follow them. No inline
   styles or scripts (CSP): the Monthly | Yearly toggle is two radio inputs and :checked rules. */

/* ------------------------------------------------------------------ package picker (Plan & usage and /pricing) */
.picker { container-type: inline-size; }
.picker-head h2 { margin: 0 0 4px; }
.picker-head p { margin: 0; }
.picker-strip { display: flex; align-items: center; gap: 10px; margin: 16px 0 0; padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--text); font-weight: 600; }
.picker-strip .icon-svg { width: 18px; height: 18px; color: var(--accent); flex: none; }

/* the segmented toggle: a fieldset of real radios (keyboard: arrow keys), shown as up to four labels (wraps on a phone) */
.cycle-toggle { display: inline-flex; margin: 20px 0 4px; padding: 4px; gap: 4px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--border); max-width: 100%; min-width: 0; flex-wrap: wrap; }
@media (max-width: 560px) {
  .cycle-toggle { border-radius: 20px; }
  .cycle-toggle label { padding: 8px 12px; }
}
.cycle-toggle label { display: inline-flex; align-items: center; min-height: 40px; padding: 8px 18px; border-radius: 999px; cursor: pointer;
  font-weight: 600; color: var(--muted); white-space: nowrap; }
.cycle-toggle label:hover { color: var(--text); }
.cycle-save { color: var(--success); font-weight: 600; margin-left: 4px; }
.cycle-input:checked + label { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(20, 20, 18, 0.14); }
.cycle-input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 2px; }
/* the period toggle (plan_periods): each card shows the price of the checked period; the first one shows until another is checked */
.cyc-monthly, .cyc-quarterly, .cyc-half_yearly, .cyc-yearly { display: none; }
.pkg-grid .cyc-first { display: block; }
.picker:has(.cycle-input:checked:not(:first-of-type)) .pkg-grid .cyc-first { display: none; }
.picker:has(#cycle-monthly:checked) .pkg-grid .cyc-monthly,
.picker:has(#cycle-quarterly:checked) .pkg-grid .cyc-quarterly,
.picker:has(#cycle-half_yearly:checked) .pkg-grid .cyc-half_yearly,
.picker:has(#cycle-yearly:checked) .pkg-grid .cyc-yearly { display: block; }

/* 4 cards in a row when the section is wide, 2 x 2 on a tablet, stacked on a phone */
.pkg-grid { list-style: none; margin: 22px 0 0; padding: 0; display: grid; grid-template-columns: 1fr; gap: 16px; align-items: stretch; }
@container (min-width: 520px) { .pkg-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container (min-width: 900px) { .pkg-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.pkg { position: relative; display: flex; flex-direction: column; padding: 22px 18px 18px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); min-width: 0; }
.pkg.is-featured { border: 2px solid var(--accent); padding: 21px 17px 17px; box-shadow: 0 8px 28px rgba(11, 107, 102, 0.14); }
.pkg.is-current:not(.is-featured) { border-color: var(--border-strong); }
.pkg-ribbon { position: absolute; top: -12px; left: 16px; padding: 3px 10px; border-radius: 999px; font-size: 0.74rem; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase; background: var(--accent); color: var(--accent-ink); }
.pkg-ribbon-current { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); }
.pkg-name { margin: 0; font-size: 1.15rem; }
.pkg-prop { margin: 4px 0 0; color: var(--muted); font-size: 0.93rem; line-height: 1.4; min-height: 2.8em; }
.pkg-buy { margin: 14px 0 6px; }
.pkg-price { margin: 0; display: flex; align-items: baseline; gap: 4px; font-variant-numeric: tabular-nums; }
.pkg-amount { font-size: 2.15rem; font-weight: 750; line-height: 1.1; letter-spacing: -0.02em; }
.pkg-amount-na { color: var(--muted); }
.pkg-unit { font-size: 0.95rem; color: var(--muted); font-weight: 500; }
.pkg-tax { margin: -10px 0 14px; font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.pkg-note { margin: 3px 0 14px; font-size: 0.86rem; color: var(--muted); min-height: 1.3em; font-variant-numeric: tabular-nums; }
.pkg-hint { margin: 6px 0 0; font-size: 0.84rem; color: var(--muted); text-align: center; }
.pkg .btn-block { justify-content: center; text-align: center; }
.pkg .btn[disabled] { cursor: default; color: var(--muted); border-color: var(--border); background: var(--surface-2); }

.pkg-features { list-style: none; margin: 10px 0 0; padding: 16px 0 0; border-top: 1px solid var(--border); display: grid; gap: 10px; }
.feat { display: grid; grid-template-columns: 18px 1fr; gap: 9px; align-items: start; font-size: 0.93rem; line-height: 1.35; }
.feat .icon-svg { width: 18px; height: 18px; color: var(--success); margin-top: 1px; }
.feat-dash { display: inline-block; width: 18px; text-align: center; color: var(--muted); }
.feat.is-off { color: var(--muted); }
.feat.is-off s { text-decoration-color: var(--border-strong); }
.feat-sub { display: block; font-size: 0.82rem; color: var(--muted); }
.pkg-over { display: flex; gap: 6px; align-items: flex-start; margin: 12px 0 0; font-size: 0.86rem; color: var(--warn); }
.pkg-over .icon-svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.picker-free { margin: 18px 0 0; font-size: 0.9rem; text-align: center; }
.pkg .btn-block { white-space: normal; line-height: 1.25; padding-left: 12px; padding-right: 12px; }
/* the same rows line up across the cards of a row (name, value prop, price + button, features, warnings) */
@supports (grid-template-rows: subgrid) {
  .pkg { display: grid; grid-row: span 5; grid-template-rows: subgrid; row-gap: 0; align-content: start; }
  .pkg-name { grid-row: 1; }
  .pkg-prop { grid-row: 2; min-height: 0; }
  .pkg-buy { grid-row: 3; }
  .pkg-features { grid-row: 4; align-self: start; }
  .pkg-overs { grid-row: 5; }
}

/* ------------------------------------------------------------------ checkout confirm */
.co-page > .card { margin: 0; }
.co-page { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); grid-template-areas: "summary" "changes" "paybar"; align-items: start; }
.co-summary { grid-area: summary; }
.co-changes { grid-area: changes; }
.co-paybar { grid-area: paybar; }
@media (min-width: 960px) {
  .co-page { grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); grid-template-areas: "changes summary"; gap: 28px; }
  .co-summary { position: sticky; top: 20px; }
}
.co-changes h2, .co-summary h2 { margin: 0 0 16px; font-size: 1.1rem; }
.co-from-to { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 12px; align-items: stretch; margin: 0 0 20px; }
.co-plan { padding: 14px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); min-width: 0; }
.co-plan.is-new { border-color: var(--accent); background: var(--accent-soft); }
.co-plan-label { display: block; font-size: 0.76rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.co-plan-name { display: block; font-size: 1.15rem; font-weight: 700; margin: 2px 0; overflow-wrap: anywhere; }
.co-plan-when { display: block; font-size: 0.88rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.co-arrow { display: flex; align-items: center; color: var(--muted); }
.co-arrow .icon-svg { width: 22px; height: 22px; }
.co-gains-title { margin: 0 0 10px; font-size: 0.95rem; }
.co-gains { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.co-gains li { display: grid; grid-template-columns: 18px 1fr; gap: 9px; align-items: start; }
.co-gains .icon-svg { width: 18px; height: 18px; margin-top: 1px; }
.co-gains .gain .icon-svg { color: var(--success); }
.co-gains .loss { color: var(--warn); }
.co-note { margin: 18px 0 0; }

.co-lines { margin: 0; display: grid; gap: 10px; font-variant-numeric: tabular-nums; }
.co-line { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.co-line dt { margin: 0; min-width: 0; }
.co-line dd { margin: 0; white-space: nowrap; text-align: right; }
.co-line.is-credit dt, .co-line.is-credit dd { color: var(--success); }
.co-line.is-sub { padding-top: 10px; border-top: 1px solid var(--border); font-weight: 600; }
.co-line.is-small { font-size: 0.86rem; }
.co-line.is-small dt, .co-line.is-small dd { color: var(--muted); }
.co-line .co-sub { display: block; font-size: 0.84rem; color: var(--muted); font-weight: 400; }
.co-total { display: flex; justify-content: space-between; align-items: baseline; margin: 16px 0 18px; padding-top: 16px; border-top: 1px solid var(--border);
  font-size: 1.3rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.co-pay { justify-content: center; gap: 8px; }
.co-pay .icon-svg { width: 18px; height: 18px; }
.co-cancel { display: block; margin: 12px 0 0; text-align: center; color: var(--muted); }
.co-trust { display: flex; flex-direction: column; gap: 4px; align-items: center; margin: 16px 0 0; padding-top: 14px;
  border-top: 1px solid var(--border); font-size: 0.84rem; color: var(--muted); text-align: center; }
.co-trust-line { display: inline-flex; gap: 6px; align-items: center; }
.co-trust .icon-svg { width: 16px; height: 16px; }
/* phone: the summary first, then what changes, and a Pay bar that stays at the bottom of the screen */
.co-paybar { display: none; }
@media (max-width: 959px) {
  .co-summary .co-pay-wrap { display: none; }
  .co-paybar { display: block; position: sticky; bottom: 0; z-index: 5; margin: 0 -16px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(20, 20, 18, 0.08); }
  .co-paybar .co-paybar-total { display: flex; justify-content: space-between; margin: 0 0 8px; font-weight: 700; font-variant-numeric: tabular-nums; }
}

/* ------------------------------------------------------------------ receipts, pricing intro, checkout window */
.receipt { max-width: 760px; }
.receipt-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; }
.receipt-parties { display: grid; grid-template-columns: 1fr; gap: 12px; margin: 16px 0; }
@media (min-width: 600px) { .receipt-parties { grid-template-columns: 1fr 1fr; } }
.receipt-parties h2 { font-size: 0.95rem; color: var(--muted); margin: 0 0 4px; }
.receipt-parties p { margin: 0; }
.bill-lines { width: 100%; border-collapse: collapse; margin: 12px 0; font-variant-numeric: tabular-nums; }
.bill-lines th, .bill-lines td { padding: 8px 0; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.bill-lines .amt { text-align: right; white-space: nowrap; padding-left: 12px; }
.bill-lines tr.credit td { color: var(--success); }
.bill-lines tr.total th, .bill-lines tr.total td { font-weight: 650; font-size: 1.1rem; border-bottom: 0; }
/* invoice and receipt: two documents under two tabs, and the Share pop-up (billing_docs) */
.doc-page { max-width: 760px; }
.doc-page > .card, .doc-page > nav { margin-top: 16px; }
.doc-tabs a { display: inline-flex; align-items: center; gap: 6px; }
.doc-title { margin: 0; font-size: 1.6rem; }
.receipt-amount { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 8px 0 4px; padding: 12px 14px;
  border-radius: var(--radius-sm); background: var(--surface-2); font-variant-numeric: tabular-nums; }
.receipt-amount strong { font-size: 1.4rem; }
.receipt-rows th { font-weight: 500; color: var(--muted); }
.receipt-rows td.amt { white-space: normal; overflow-wrap: anywhere; }
.bill-share .public-main { margin: 0 auto; padding: 16px; }
.share-link-row { display: flex; gap: 8px; align-items: stretch; margin: 4px 0 12px; }
.share-link-row .input { flex: 1; min-width: 0; }
.share-actions { margin: 0; }
.doc-links { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.doc-links .share-form .btn { min-height: 36px; padding: 6px 10px; }
@media print {
  .app-nav, .app-header, .skip-link, .no-print, .site-footer, .public-header, .public-footer { display: none !important; }
  .doc-page { max-width: none; }
  .receipt { max-width: none; border: 0; box-shadow: none; }
  body { background: #fff; color: #000; }
}
.checkout-box { max-width: 560px; }
.pricing-intro { max-width: 760px; }
