/* Billing view — v3, layered on /styles.css (tokens, .card, .section-label, .btn, .badge, .pill, .table, .skel, .empty-state).
   Flat cards and hairlines, mono section labels, light headings, the off-white primary for the one action that matters in
   each state; quiet line art instead of glass. Static: no entrance motion, only the shared hover/press feedback. The layout
   follows the view's own width (container queries), so the sidebar breakpoints never squeeze a card. */

.bill { container: bill / inline-size; max-width: 1600px; }

/* ── Header: label · title · copy, Support on the right ── */
.bill-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.bill-head-copy { min-width: 0; }
.bill-head .page-title { margin-top: 2px; overflow-wrap: anywhere; }
.bill-lede { max-width: 960px; margin-top: 4px; text-wrap: balance; }
.bill-support { display: flex; align-items: center; gap: 12px; flex: none; min-width: 0; max-width: 340px; min-height: 52px; margin-top: 4px; padding: 9px 14px 9px 10px; border: 1px solid var(--line-strong); border-radius: var(--r-2); background: var(--card); transition: border-color var(--dur-2) var(--ease-out), background-color var(--dur-2) var(--ease-out); }
.bill-support:hover { border-color: var(--line-hover); background: var(--card-hover); }
.bill-support-ico { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border: 1px solid var(--line); border-radius: var(--r-2); background: var(--raised-2); color: var(--text-2); }
.bill-support-ico .icon { width: 15px; height: 15px; }
.bill-support-text { display: grid; flex: 1 1 auto; gap: 4px; min-width: 0; }
.bill-support-text .label { color: var(--text-4); line-height: 1.2; }
/* A long SUPPORT_EMAIL ellipsizes; the full address stays in the title and the mailto link. */
.bill-support-mail { overflow: hidden; color: var(--text); font-size: var(--fs-base); line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.bill-support-go { width: 14px; height: 14px; margin-left: 2px; color: var(--text-3); transition: translate var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out); }
.bill-support:hover .bill-support-go { translate: 1px -1px; color: var(--text); }

/* ── Shared pieces ── */
.bill-card { display: flex; flex-direction: column; min-width: 0; }
.bill-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; min-height: 14px; }
.bill-card-titles { min-width: 0; }
.bill-card-titles .card-sub { margin-top: 8px; }
.bill-label { margin: 0; }
.bill-label:focus:not(:focus-visible) { outline: none; }
.bill .badge .icon { width: 12px; height: 12px; stroke-width: 2; }
.bill .bill-btn { --h: 40px; padding: 0 18px; font-size: 13px; }
.bill .bill-btn .icon { width: 14px; height: 14px; }
.bill .bill-btn.btn-lg { --h: 42px; padding: 0 24px; font-size: 13.5px; }
.bill-btn[aria-busy="true"] { cursor: progress; opacity: .72; }
/* Demo-disabled actions stay focusable (a click explains why): dim the ink, not the element, so the focus ring stays clear. */
.bill .btn[aria-disabled="true"] { border-color: var(--line); color: var(--text-4); opacity: 1; }
.bill .btn[aria-disabled="true"]:hover { background: transparent; }
/* "Current plan": a settled state, not a broken button. */
.bill .bill-btn-current:disabled { border-color: var(--line); color: var(--text-2); opacity: 1; cursor: default; }
.bill-btn-current .icon { color: var(--accent); stroke-width: 2.2; }
.bill-reason { margin-top: 8px; color: var(--text-3); font-size: var(--fs-sm); line-height: 1.45; }
.bill-reason a, .bill-note a, .bill-plan-note a, .bill .empty-text a, .bill-unavail a, .bill-pay-sub a { color: var(--text); text-decoration: underline; text-decoration-color: var(--line-hover); text-underline-offset: 3px; transition: text-decoration-color var(--dur-2) var(--ease-out); }
.bill-reason a, .bill-note a, .bill-plan-note a, .bill .empty-text a, .bill-unavail a, .bill-pay-sub a { display: inline-block; padding: 3px 0; margin: -3px 0; }
.bill-reason a:hover, .bill-note a:hover, .bill-plan-note a:hover, .bill .empty-text a:hover, .bill-unavail a:hover, .bill-pay-sub a:hover { text-decoration-color: currentColor; }
/* Link-style buttons ("Invoices →", "View all 12"): the shared .card-link with a 40px hit area. */
.bill .card-link { min-height: 40px; padding: 0; border: 0; background: none; font-family: var(--font); }
.bill .card-link:disabled, .bill .card-link[aria-disabled="true"] { color: var(--text-4); cursor: not-allowed; }
.bill .card-link:disabled .icon, .bill .card-link[aria-disabled="true"] .icon { translate: none; }

/* Loading shapes only; the shared .skel goes static under reduced motion. */
.bill .skel { max-width: 100%; }
.bill .skel + .skel { margin-top: 9px; }
.bill .skel-title { height: 18px; }
.bill .skel-label { height: 10px; }
.bill .skel-btn { height: 40px; }
.bill .skel-lg { height: 42px; }
.bill .skel-block { width: 100% !important; }
.bill .skel-pill { height: 20px; }
.bill .skel-brand { flex: none; height: 32px; }

/* ── Banner (payment trouble, paused, billing-only access) ── */
.bill-banner { display: flex; align-items: center; gap: 14px; margin-top: 20px; padding: 12px 14px 12px 16px; border: 1px solid var(--line-strong); border-radius: var(--r-2); background: var(--card); }
.bill-banner.is-danger { border-color: rgb(var(--danger-rgb) / .32); background: rgb(var(--danger-rgb) / .04); }
.bill-banner.is-warn { border-color: rgb(var(--warn-rgb) / .3); background: rgb(var(--warn-rgb) / .035); }
.bill-banner-ico { display: grid; flex: none; color: var(--text-3); }
.bill-banner-ico .icon { width: 16px; height: 16px; }
.bill-banner.is-danger .bill-banner-ico { color: var(--danger); }
.bill-banner.is-warn .bill-banner-ico { color: var(--warn); }
.bill-banner-text { display: grid; gap: 2px; flex: 1; min-width: 0; }
.bill-banner-text strong { color: var(--text); font-size: var(--fs-md); font-weight: 500; line-height: 1.4; }
.bill-banner-text > span { color: var(--text-2); font-size: var(--fs-base); line-height: 1.5; }
.bill-banner-text .bill-reason { margin-top: 2px; }
.bill-banner-action { flex: none; }

/* ── Stale details (a background refresh failed): persistent, with the time of the details shown ── */
.bill-stale { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 16px; padding: 8px 12px; border: 1px solid rgb(var(--warn-rgb) / .28); border-radius: var(--r-2); color: var(--text-2); font-size: var(--fs-base); line-height: 1.45; }
.bill-stale > .icon { width: 15px; height: 15px; color: var(--warn); }
.bill-stale > span { flex: 1 1 auto; min-width: 0; }
.bill-stale-retry { min-height: 32px !important; }

/* ── Current plan + payment method ── */
.bill-top { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 16px; margin-top: 20px; }
.bill-current { container: billcur / inline-size; }
.bill-flag { margin: -4px 0; }
.bill-flag:empty { display: none; }
/* One line while the real strings fit, wrapping only as much as they need: plan · date · action, then the action on the
   next line (right), then date and action together on it. Content-driven (flex-wrap), so "Past due" (≈500px) stays on one
   line where "Canceling" + "Access until" (≈585px) already wraps; phones stack. */
.bill-current-body { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 28px; min-height: 52px; margin: 12px -4px 14px; padding: 4px; overflow: hidden; }
.bill-id { display: grid; flex: 1 1 auto; gap: 6px; min-width: 0; }
.bill-id-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-width: 0; }
.bill-plan-label { overflow: hidden; color: var(--text); font-size: var(--fs-title); font-weight: 400; line-height: 1.25; letter-spacing: -.005em; text-overflow: ellipsis; white-space: nowrap; }
.bill-plan-price { color: var(--text-3); font-size: var(--fs-base); line-height: 1.4; }
.bill-meta { position: relative; display: grid; flex: none; align-content: center; gap: 7px; min-height: 44px; }
/* Hairline between the plan and its date while they share a line; when the date wraps to the start of the next line the
   rule falls outside the row (overflow: hidden) and disappears. The 4px padding keeps focus rings unclipped. */
.bill-meta::before { content: ""; position: absolute; top: 4px; bottom: 4px; left: -15px; width: 1px; background: var(--line); }
.bill-meta .label { color: var(--text-4); line-height: 1.2; white-space: nowrap; }
.bill-date { color: var(--text); font-size: var(--fs-lg); line-height: 1.3; white-space: nowrap; }
.bill-action { flex: none; margin-left: auto; }
.bill-unavail { display: flex; flex: 1 1 auto; align-items: center; gap: 14px; min-width: 0; }
.bill-current-body:has(> .bill-unavail) { flex: 1; margin-bottom: 0; }
.bill-unavail-ico { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: var(--r-2); color: var(--text-4); }
.bill-unavail-ico .icon { width: 16px; height: 16px; }
.bill-unavail-text { display: grid; gap: 3px; min-width: 0; }
.bill-unavail-text strong { color: var(--text); font-size: var(--fs-lg); font-weight: 400; line-height: 1.35; }
.bill-unavail-text span { color: var(--text-3); font-size: var(--fs-base); line-height: 1.45; }
.bill-note { display: flex; align-items: flex-start; gap: 9px; margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line-faint); color: var(--text-3); font-size: var(--fs-base); line-height: 1.5; }
.bill-note:empty { display: none; }
.bill-note > .icon { width: 14px; height: 14px; margin-top: 2px; color: var(--text-4); }
.bill-note.is-warn > .icon { color: var(--warn); }
.bill-note.is-danger > .icon { color: var(--danger); }
.bill-note.is-warn, .bill-note.is-danger { color: var(--text-2); }
.bill-note .skel { width: min(300px, 80%) !important; }
@container billcur (max-width: 400px) {
  .bill-action { flex: 1 1 100%; }
  .bill-action .btn { width: 100%; }
  .bill-plan-label { white-space: normal; }
}

.bill-pay-body { display: flex; flex: 1; flex-direction: column; gap: 20px; margin-top: 16px; }
.bill-pay-row { display: flex; align-items: center; gap: 14px; min-width: 0; }
.bill-brand { display: grid; place-items: center; flex: none; width: 46px; height: 32px; border: 1px solid var(--line-strong); border-radius: var(--r-2); background: var(--raised); color: var(--text); font-family: var(--mono); font-size: 9.5px; font-weight: 500; letter-spacing: .06em; line-height: 1; }
.bill-brand .icon { width: 16px; height: 16px; color: var(--text-3); }
.bill-brand.is-empty { border-style: dashed; background: transparent; }
.bill-brand.is-error .icon { color: var(--text-4); }
.bill-brand .bill-mc { width: 26px; height: 16px; }
.bill-pay-text { display: grid; gap: 5px; min-width: 0; }
.bill-pay-title { overflow: hidden; color: var(--text); font-size: 18px; font-weight: 400; line-height: 1.3; letter-spacing: -.005em; text-overflow: ellipsis; white-space: nowrap; }
.bill-pay-title.is-empty { font-size: var(--fs-lg); white-space: normal; }
.bill-dots { color: var(--text-2); font-size: .72em; letter-spacing: .1em; vertical-align: .12em; }
.bill-pay-sub { color: var(--text-3); font-size: var(--fs-base); line-height: 1.45; }
.bill-pay-sub + .bill-pay-sub { margin-top: -2px; }
.bill-pay { container: billpay / inline-size; }
@container billpay (max-width: 300px) { .bill-pay-row { flex-direction: column; align-items: flex-start; gap: 10px; } .bill-pay-title { white-space: normal; } }
.bill-pay-action { margin-top: auto; }
.bill-pay-action.has-retry { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.bill-pay-action .bill-grow { flex: 1 1 auto; }
.bill-pay-action.has-retry .bill-reason { flex-basis: 100%; margin-top: 0; }

/* ── Billing history ── */
.bill-history { margin-top: 16px; }
.bill-head-btn { flex: none; margin: -13px 0 -13px; }
.bill-table-wrap { margin: 14px -20px 0; }
.bill-table { table-layout: fixed; }
.bill-table th { padding: 9px 12px; }
.bill-table td { height: 48px; padding: 0 12px; white-space: nowrap; }
.bill-table :is(th, td):first-child { padding-left: 20px; }
.bill-table :is(th, td):last-child { padding-right: 20px; }
.bill-table .c-date { width: 18%; }
.bill-table .c-amt { width: 14%; }
.bill-table .c-status { width: 15%; }
.bill-table .c-inv { width: 13%; text-align: right; }
.bill-table td.c-date, .bill-table td.c-amt { color: var(--text); }
.bill-table td.c-amt { font-variant-numeric: tabular-nums; }
.bill-table td.c-desc > span { display: block; overflow: hidden; text-overflow: ellipsis; }
.bill-table tbody tr.bill-skel-row:hover { background: none; }
.bill-pill.is-success { border-color: rgb(var(--ok-rgb) / .3); color: var(--ok); }
.bill-pill.is-warn { border-color: rgb(var(--warn-rgb) / .32); color: var(--warn); }
.bill-pill.is-danger { border-color: rgb(var(--danger-rgb) / .32); color: var(--danger); }
.bill-pill.is-muted { color: var(--text-4); }
.bill-inv { display: inline-flex; align-items: center; justify-content: flex-end; gap: 6px; min-height: 40px; color: var(--text-2); transition: color var(--dur-2) var(--ease-out); }
.bill-inv .icon { width: 12px; height: 12px; transition: translate var(--dur-2) var(--ease-out); }
.bill-inv:hover { color: var(--text); }
.bill-inv:hover .icon { translate: 1px -1px; }
.bill-inv-none { color: var(--text-5); }
.bill-history-state .empty-state { padding: 30px 16px 14px; }
.bill-history-state .empty-text { max-width: 380px; text-wrap: balance; }
.bill-history-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 0 16px; margin: 6px 0 -10px; padding-top: 4px; border-top: 1px solid var(--line-faint); }
.bill-history-state:not([hidden]) + .bill-history-foot { justify-content: center; margin-top: 0; padding-top: 0; border-top: 0; text-align: center; }
.bill-more .icon { translate: none !important; }
/* Scrolled into view (collapse, focus) below the sticky top bar: 51px, 56px when the sidebar is off-canvas. */
.bill-history, .bill-more { scroll-margin-top: calc(var(--topbar-h) + 12px); }
@media (max-width: 960px) { .bill-history, .bill-more { scroll-margin-top: 68px; } }
.bill-older { min-height: 32px; margin-left: 4px; vertical-align: baseline; }
.bill-older .icon { translate: none !important; }
.bill-inv-reason { margin-top: 6px; }
.bill-history-note { color: var(--text-3); font-size: var(--fs-sm); line-height: 1.45; }

/* ── Plan information ── */
.bill-plans { display: grid; grid-template-columns: minmax(0, 1.62fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; }
.bill-plan { display: flex; flex-direction: column; min-width: 0; padding: 16px 20px 20px; overflow: hidden; isolation: isolate; }
.bill-pro { container: billpro / inline-size; }
.bill-plan-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 10px; }
.bill-plan-name { color: var(--text); font-size: var(--fs-h2); font-weight: 400; line-height: 1.2; letter-spacing: -.01em; }
.bill-plan-name-sm { font-size: var(--fs-title); line-height: 1.25; }
.bill-plan-badge:empty { display: none; }
.bill-price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-top: 18px; }
.bill-price-num { color: var(--text); font-size: var(--fs-display); font-weight: 300; line-height: 1; letter-spacing: -.035em; }
.bill-price-per { color: var(--text-2); font-size: var(--fs-lg); }
.bill-per { margin-top: 9px; color: var(--text-3); font-size: var(--fs-md); }
.bill-price-sm { margin-top: 16px; }
.bill-price-sm .bill-price-num { font-size: 40px; letter-spacing: -.03em; }
.bill-features { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px 28px; margin: 24px 0 0; padding: 20px 0 0; border-top: 1px solid var(--line-faint); list-style: none; }
.bill-features li { display: flex; align-items: flex-start; gap: 11px; min-width: 0; color: var(--text-2); font-size: var(--fs-md); line-height: 1.4; }
.bill-features .icon { width: 14px; height: 14px; margin-top: 1.5px; color: var(--accent); stroke-width: 2; }
.bill-plan-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-top: auto; padding-top: 24px; }
.bill-pro-cta { min-width: 0; }
.bill-pro-cta .btn { min-width: 236px; }
.bill-pro-off { display: inline-flex; align-items: center; gap: 9px; min-height: 42px; color: var(--text-3); font-size: var(--fs-md); }
.bill-pro-off .icon { width: 15px; height: 15px; color: var(--text-4); }
.bill-plan-note { min-width: 0; padding-left: 20px; border-left: 1px solid var(--line); color: var(--text-3); font-size: var(--fs-base); line-height: 1.45; }
/* Line art sits in the top-right corner behind the copy and fades out before the feature list. */
.bill-art-wrap { position: absolute; inset: 0; z-index: -1; overflow: hidden; border-radius: inherit; pointer-events: none; }
.bill-art { position: absolute; top: 0; right: 0; width: min(420px, 62%); height: auto; -webkit-mask-image: linear-gradient(90deg, transparent, #000 40%), linear-gradient(180deg, #000 50%, transparent 94%); mask-image: linear-gradient(90deg, transparent, #000 40%), linear-gradient(180deg, #000 50%, transparent 94%); -webkit-mask-composite: source-in; mask-composite: intersect; }
.bill-extra { container: billextra / inline-size; }
.bill-extra-body { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.bill-extra-side { display: flex; flex: 1; flex-direction: column; min-width: 0; }
@container billextra (min-width: 600px) {
  .bill-extra-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 40px; }
  .bill-extra-side .bill-facts { margin-top: 2px; }
  .bill-extra-side .bill-plan-foot { padding-top: 20px; }
}
.bill-desc { max-width: 46ch; margin-top: 16px; color: var(--text-2); font-size: var(--fs-md); line-height: 1.55; }
.bill-facts { margin: 18px 0 0; border-top: 1px solid var(--line-faint); }
.bill-facts > div { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line-faint); }
.bill-facts dt { flex: none; color: var(--text-4); font-family: var(--mono); font-size: var(--fs-label); letter-spacing: var(--ls-label); line-height: 1.4; text-transform: uppercase; }
.bill-facts dd { min-width: 0; margin: 0; color: var(--text-2); font-size: var(--fs-base); line-height: 1.45; text-align: right; }
@container billpro (max-width: 540px) { .bill-features { grid-template-columns: minmax(0, 1fr); } }
/* Narrow card: the art would crowd the title (its framed square reads like a checkbox), so it steps aside. */
@container billpro (max-width: 460px) { .bill-art-wrap { display: none; } }

/* ── Responsive: the view's own width ── */
/* Current plan + Payment method stay side by side (Current plan wraps its row when narrow) until the pair gets cramped. */
@container bill (max-width: 740px) {
  .bill-top { grid-template-columns: minmax(0, 1fr); }
  .bill-pay-body { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; }
  .bill-pay-action { margin-top: 0; }
  .bill-pay-action .btn-block { width: auto; }
}
/* The title would wrap beside the Support card: Support moves under the copy. */
@container bill (max-width: 900px) {
  .bill-head { flex-direction: column; gap: 16px; }
  .bill-support { max-width: 100%; margin-top: 0; }
}
@container bill (max-width: 880px) {
  .bill-plans { grid-template-columns: minmax(0, 1fr); }
}
/* Phones: invoices become stacked rows (date · amount / description / status · document); the header row stays for AT. */
@container bill (max-width: 600px) {
  .bill-table, .bill-table tbody, .bill-table tr, .bill-table td { display: block; }
  .bill-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
  .bill-table tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "date amt" "desc desc" "status inv"; gap: 3px 12px; padding: 13px 20px 8px; border-bottom: 1px solid var(--line-faint); }
  .bill-table tbody tr:last-child { border-bottom: 0; }
  .bill-table tbody td { width: auto; height: auto; padding: 0 !important; border: 0; }
  .bill-table .c-date { grid-area: date; }
  .bill-table .c-amt { grid-area: amt; text-align: right; }
  .bill-table .c-desc { grid-area: desc; color: var(--text-3); white-space: normal; }
  .bill-table td.c-desc > span { white-space: normal; overflow-wrap: anywhere; }
  .bill-table .c-status { grid-area: status; align-self: center; margin-top: 6px; }
  .bill-table .c-inv { grid-area: inv; align-self: center; margin-top: 2px; }
  .bill-table .bill-skel-row td { min-height: 12px; }
  .bill-banner { flex-wrap: wrap; }
  .bill-banner-action { flex: 1 0 100%; }
  .bill-banner-action .btn { width: 100%; }
  .bill-price-num { font-size: 52px; }
  .bill-pro-cta, .bill-pro-cta .btn { width: 100%; min-width: 0; }
  .bill-plan-note { padding-left: 0; border-left: 0; }
}
@media (max-width: 560px) {
  .bill-head .page-title { font-size: 28px; }
  .bill .card-pad, .bill-plan { padding: 16px 16px 18px; }
  .bill-table-wrap { margin: 12px -16px 0; }
  .bill-table :is(th, td):first-child { padding-left: 16px; }
  .bill-table :is(th, td):last-child { padding-right: 16px; }
  .bill-table tbody tr { padding: 13px 16px 8px; }
  .bill-pay-body { flex-direction: column; align-items: stretch; }
  .bill-pay-action .btn { width: 100%; }
  .bill-extra-cta { width: 100%; }
  .bill-support { align-self: stretch; }
  .bill-support-mail { overflow-wrap: anywhere; white-space: normal; }
}
