/* Billing and subscription views */
    .subscription-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
      gap: 14px;
      margin: 16px 0;
    }
    .subscription-card {
      border: 1px solid var(--line);
      background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
      border-radius: 18px;
      padding: 16px;
      display: grid;
      gap: 10px;
    }
    .subscription-card.active {
      border-color: rgba(28,143,132,0.55);
      box-shadow: inset 0 0 0 1px rgba(28,143,132,0.12);
    }
    .subscription-head {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 12px;
    }
    .subscription-price {
      font-size: 28px;
      font-weight: 800;
      line-height: 1;
      color: var(--ink);
    }
    .subscription-name {
      margin-top: 6px;
      font-weight: 700;
      color: var(--ink);
    }
    .subscription-copy {
      color: var(--muted);
      line-height: 1.45;
    }
    .subscription-meta {
      color: var(--muted);
      font-size: 13px;
      line-height: 1.45;
      min-height: 18px;
    }
    .subscription-status {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      border-radius: 999px;
      padding: 6px 10px;
      font-size: 12px;
      font-weight: 700;
      background: rgba(176,58,46,0.14);
      color: #ffb3aa;
      border: 1px solid rgba(176,58,46,0.28);
      white-space: nowrap;
    }
    .subscription-status.active {
      background: rgba(28,143,132,0.16);
      border-color: rgba(28,143,132,0.35);
      color: #8be1d7;
    }
    .billing-summary-grid {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 14px;
      margin: 16px 0;
    }
    .billing-summary-card,
    .billing-surface,
    .billing-side-card,
    .billing-manager-plan {
      background: linear-gradient(180deg, #111417, #0d0f11);
      border: 1px solid #23282d;
      border-radius: 24px;
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
    }
    .billing-summary-card {
      padding: 18px;
    }
    .billing-summary-card .k {
      color: var(--muted);
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      margin-bottom: 10px;
    }
    .billing-summary-card .v {
      color: var(--ink);
      font-size: clamp(24px, 2.1vw, 42px);
      font-weight: 700;
      line-height: 1.1;
    }
    .billing-summary-card .sub {
      color: var(--muted);
      font-size: 13px;
      line-height: 1.45;
      margin-top: 10px;
    }
    .billing-shell {
      display: grid;
      grid-template-columns: minmax(0, 1fr);
      gap: 16px;
      align-items: start;
    }
    .billing-main,
    .billing-side {
      display: grid;
      gap: 16px;
    }
    .billing-priority-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 16px;
      min-width: 0;
    }
    .billing-priority-column {
      display: grid;
      gap: 16px;
      min-width: 0;
      align-content: start;
    }
    .billing-side {
      position: static;
    }
    .billing-main,
    .billing-side,
    .billing-surface,
    .billing-side-card {
      min-width: 0;
    }
    .billing-surface,
    .billing-side-card {
      padding: 18px;
    }
    .billing-surface-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 14px;
    }
    .billing-surface-title {
      margin: 0;
      display: inline-flex;
      align-items: center;
      gap: 10px;
      color: var(--ink);
      font-size: 20px;
    }
    .billing-surface-icon {
      width: 38px;
      height: 38px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      border-radius: 999px;
      background: rgba(28,143,132,0.12);
      border: 1px solid rgba(28,143,132,0.24);
      color: #49d8bf;
      font-size: 16px;
      flex: 0 0 auto;
    }
    .billing-table-wrap {
      border: 1px solid var(--line);
      border-radius: 18px;
      overflow: auto;
      background: rgba(255,255,255,0.01);
    }
    .billing-table {
      width: 100%;
      min-width: 760px;
      border-collapse: collapse;
    }
    .billing-table th,
    .billing-table td {
      padding: 16px 18px;
      text-align: left;
      border-bottom: 1px solid var(--line);
      vertical-align: middle;
    }
    .billing-table th {
      color: var(--muted);
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      white-space: nowrap;
      background: rgba(255,255,255,0.01);
    }
    .billing-table td {
      color: var(--text);
      background: transparent;
    }
    .billing-table tbody tr:last-child td {
      border-bottom: 0;
    }
    .billing-table tbody tr:hover td {
      background: rgba(255,255,255,0.02);
    }
    .billing-product-cell strong {
      display: block;
      color: var(--ink);
      font-size: 15px;
    }
    .billing-product-cell span {
      display: block;
      margin-top: 4px;
      color: var(--muted);
      font-size: 13px;
      line-height: 1.45;
    }
    .billing-invoice-table {
      min-width: 900px;
      border-collapse: separate;
      border-spacing: 0 10px;
    }
    .billing-invoice-table th {
      padding-bottom: 6px;
      border-bottom: 0;
      background: transparent;
      color: var(--muted);
      font-size: 13px;
      text-transform: none;
      letter-spacing: 0;
    }
    .billing-invoice-table td {
      padding: 16px 18px;
      border-bottom: 0;
      background: rgba(255,255,255,0.025);
      border-top: 1px solid rgba(255,255,255,0.04);
      border-bottom: 1px solid rgba(255,255,255,0.04);
      vertical-align: middle;
    }
    .billing-invoice-table tbody tr:hover td {
      background: rgba(28,143,132,0.08);
    }
    .billing-invoice-table tbody tr td:first-child {
      border-left: 1px solid rgba(255,255,255,0.04);
      border-radius: 16px 0 0 16px;
    }
    .billing-invoice-table tbody tr td:last-child {
      border-right: 1px solid rgba(255,255,255,0.04);
      border-radius: 0 16px 16px 0;
    }
    .billing-invoice-cell strong {
      display: block;
      color: var(--ink);
      font-size: 15px;
      letter-spacing: 0.02em;
    }
    .billing-invoice-period {
      color: var(--text);
      font-weight: 650;
      white-space: nowrap;
    }
    .billing-invoice-amount {
      color: var(--ink);
      font-weight: 800;
      white-space: nowrap;
    }
    .billing-invoice-amount.credit {
      color: #8be1d7;
    }
    .billing-invoice-amount.debit {
      color: #ffb3aa;
    }
    .billing-invoice-download {
      width: auto;
      padding: 0;
      color: #8be1d7;
      background: transparent;
      border: 0;
      border-radius: 0;
      font-size: 14px;
      font-weight: 800;
      text-align: left;
      white-space: nowrap;
      box-shadow: none;
    }
    .billing-invoice-download:hover,
    .billing-invoice-download:focus-visible {
      color: #b7f5ee;
      background: transparent;
      text-decoration: underline;
      outline: none;
    }
    .billing-invoice-pagination {
      display: flex;
      justify-content: flex-end;
      gap: 10px;
      margin-top: 16px;
    }
    .billing-invoice-page-button {
      width: auto;
      min-width: 78px;
      padding: 10px 18px;
      color: var(--text);
      background: rgba(255,255,255,0.03);
      border: 1px solid rgba(255,255,255,0.08);
      border-radius: 999px;
      font-weight: 750;
    }
    .billing-invoice-page-button:not(:disabled):hover {
      background: rgba(28,143,132,0.14);
      border-color: rgba(28,143,132,0.38);
    }
    .billing-invoice-page-button:disabled {
      color: var(--muted);
      cursor: not-allowed;
      opacity: 0.55;
    }
    .billing-pill {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      border-radius: 999px;
      padding: 6px 11px;
      font-size: 12px;
      font-weight: 700;
      border: 1px solid transparent;
      white-space: nowrap;
    }
    .billing-pill.active {
      color: #8be1d7;
      background: rgba(28,143,132,0.16);
      border-color: rgba(28,143,132,0.35);
    }
    .billing-pill.locked {
      color: #ffb3aa;
      background: rgba(176,58,46,0.14);
      border-color: rgba(176,58,46,0.28);
    }
    .billing-pill.scheduled {
      color: #f7d28d;
      background: rgba(216,154,58,0.14);
      border-color: rgba(216,154,58,0.3);
    }
    .billing-table .toolbar,
    .billing-manager-plan .toolbar {
      margin-top: 0;
    }
    .billing-table .toolbar button,
    .billing-manager-plan .toolbar button,
    #portal-subscription-manage-trigger {
      width: auto;
    }
    .portal-payment-actions,
    .billing-manager-plan .toolbar {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      align-items: center;
    }
    .portal-payment-actions button,
    .billing-manager-plan .toolbar button.portal-payment-alt-action {
      min-width: 112px;
    }
    .billing-side-card h4 {
      margin: 0 0 16px;
      color: var(--ink);
      font-size: 18px;
    }
    .billing-wallet-balance {
      color: var(--ink);
      font-size: 34px;
      font-weight: 800;
      line-height: 1;
      margin-bottom: 10px;
    }
    .billing-wallet-deposit-row {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 8px;
      align-items: center;
      margin: 14px 0 10px;
    }
    .billing-wallet-deposit-row input {
      min-width: 0;
      height: 42px;
    }
    .billing-wallet-deposit-row button {
      width: auto;
      height: 42px;
      white-space: nowrap;
    }
    .billing-side-meter {
      display: grid;
      gap: 10px;
      margin-bottom: 18px;
    }
    .billing-side-meter:last-child {
      margin-bottom: 0;
    }
    .billing-side-meter-head {
      display: flex;
      justify-content: space-between;
      gap: 12px;
      align-items: center;
    }
    .billing-side-meter-head span {
      color: var(--ink);
      font-weight: 700;
    }
    .billing-side-meter-head strong {
      color: var(--text);
      font-size: 15px;
    }
    .billing-progress,
    .billing-manager-plan-meter {
      height: 12px;
      border-radius: 999px;
      overflow: hidden;
      background: rgba(255,255,255,0.06);
      border: 1px solid rgba(28,143,132,0.2);
    }
    .billing-progress span,
    .billing-manager-plan-meter span {
      display: block;
      width: 0;
      height: 100%;
      border-radius: inherit;
      background: linear-gradient(90deg, rgba(28,143,132,0.55), rgba(28,143,132,0.95));
      transition: width 0.2s ease;
    }
    .billing-progress-premium,
    .billing-manager-plan-meter-premium {
      border-color: rgba(216,154,58,0.24);
    }
    .billing-progress-premium span,
    .billing-manager-plan-meter-premium span {
      background: linear-gradient(90deg, rgba(216,154,58,0.55), rgba(216,154,58,0.95));
    }
    .billing-side-note {
      color: var(--muted);
      font-size: 13px;
      line-height: 1.45;
    }
    .billing-transaction-list {
      display: grid;
      gap: 10px;
      max-height: 560px;
      overflow-y: auto;
      padding-right: 4px;
      overscroll-behavior: auto;
    }
    .billing-transaction-row {
      display: grid;
      gap: 4px;
      padding: 12px;
      border: 1px solid var(--line);
      border-radius: 16px;
      background: rgba(255,255,255,0.02);
    }
    .billing-transaction-main {
      display: flex;
      justify-content: space-between;
      gap: 12px;
      align-items: flex-start;
      color: var(--ink);
      font-weight: 700;
    }
    .billing-transaction-meta {
      color: var(--muted);
      font-size: 12px;
      line-height: 1.4;
    }
    .billing-transaction-amount.credit {
      color: #8be1d7;
    }
    .billing-transaction-amount.debit {
      color: #ffb3aa;
    }
    .billing-transaction-empty {
      color: var(--muted);
      border: 1px dashed var(--line);
      border-radius: 16px;
      padding: 12px;
      font-size: 13px;
      line-height: 1.45;
    }
    .billing-transaction-controls {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      margin-top: 12px;
      color: var(--muted);
      font-size: 12px;
      line-height: 1.4;
    }
    .billing-transaction-control-actions {
      display: inline-flex;
      align-items: center;
      gap: 8px;
    }
    .billing-transaction-page-button {
      border: 1px solid var(--line);
      border-radius: 999px;
      background: rgba(255,255,255,0.03);
      color: var(--text);
      padding: 7px 12px;
      font-size: 12px;
      font-weight: 700;
      cursor: pointer;
    }
    .billing-transaction-page-button:not(:disabled):hover {
      border-color: rgba(28,143,132,0.42);
      color: var(--ink);
    }
    .billing-transaction-page-button:disabled {
      cursor: not-allowed;
      opacity: 0.45;
    }
    .billing-manager-backdrop {
      position: fixed;
      inset: 0;
      background: rgba(5, 8, 12, 0.76);
      z-index: 90;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 24px;
      backdrop-filter: blur(6px);
    }
    .billing-manager-backdrop.show {
      display: flex;
    }
    .billing-manager-modal {
      width: min(1100px, 100%);
      max-height: calc(100vh - 48px);
      overflow: auto;
      padding: 24px;
      background: #101317;
      border: 1px solid #23282d;
      border-radius: 28px;
      box-shadow: 0 28px 90px rgba(0,0,0,0.45);
    }
    .billing-manager-head {
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      gap: 16px;
      margin-bottom: 18px;
    }
    .billing-manager-head h4 {
      margin: 0;
      color: var(--ink);
      font-size: clamp(28px, 3vw, 42px);
      line-height: 1.05;
    }
    .billing-manager-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
      gap: 16px;
    }
    .billing-manager-plan {
      padding: 20px;
      display: grid;
      gap: 12px;
    }
    .billing-manager-plan.active {
      border-color: rgba(28,143,132,0.36);
      box-shadow: inset 0 0 0 1px rgba(28,143,132,0.12);
    }
    .billing-manager-plan-premium.active {
      border-color: rgba(216,154,58,0.36);
      box-shadow: inset 0 0 0 1px rgba(216,154,58,0.12);
    }
    .billing-manager-plan-top {
      display: flex;
      justify-content: space-between;
      gap: 14px;
      align-items: flex-start;
    }
    .billing-manager-plan-label {
      color: var(--ink);
      font-size: 18px;
      font-weight: 700;
    }
    .billing-manager-plan-price {
      margin-top: 8px;
      color: var(--ink);
      font-size: clamp(28px, 3vw, 40px);
      font-weight: 800;
      line-height: 1;
    }
    .billing-manager-plan-price span {
      color: var(--muted);
      font-size: 15px;
      font-weight: 600;
      margin-left: 6px;
    }
    .billing-manager-plan-copy {
      color: var(--text);
      font-size: 15px;
      line-height: 1.5;
    }
    .billing-manager-plan-meta {
      color: var(--muted);
      font-size: 13px;
      line-height: 1.45;
      min-height: 18px;
    }
    @media (max-width: 1700px) {
      #billing-side-payment-history {
        order: 3;
      }
      #billing-side-notes {
        order: 4;
      }
    }
    @media (max-width: 980px) {
      .billing-priority-grid,
      .billing-side {
        grid-template-columns: 1fr;
      }
    }
    @media (max-width: 900px) {
      .billing-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }
      .billing-manager-grid {
        grid-template-columns: 1fr;
      }
    }
    @media (max-width: 640px) {
      .billing-summary-grid {
        grid-template-columns: 1fr;
      }
      .billing-summary-card,
      .billing-surface,
      .billing-side-card,
      .billing-manager-plan,
      .billing-manager-modal {
        border-radius: 20px;
      }
      .billing-manager-modal {
        padding: 18px;
      }
      .billing-surface-head,
      .billing-manager-head {
        flex-direction: column;
        align-items: stretch;
      }
      .billing-wallet-deposit-row {
        grid-template-columns: 1fr;
      }
    }

/* Light theme billing overrides */
    body.light-theme .subscription-card {
      background: linear-gradient(180deg, #ffffff, #f7fbff);
    }
    body.light-theme .subscription-status {
      color: #9b2c1e;
      background: rgba(176,58,46,0.08);
    }
    body.light-theme .subscription-status.active {
      color: #0d6b61;
      background: rgba(28,143,132,0.12);
    }
    body.light-theme .billing-summary-card,
    body.light-theme .billing-surface,
    body.light-theme .billing-side-card,
    body.light-theme .billing-manager-plan,
    body.light-theme .billing-manager-modal {
      background: linear-gradient(180deg, #ffffff, #f7fbff);
      border-color: var(--line);
      color: var(--text);
      box-shadow: 0 16px 34px rgba(31,60,92,0.08);
    }
    body.light-theme .billing-table th {
      background: rgba(13,59,102,0.03);
    }
    body.light-theme .billing-invoice-table th {
      background: transparent;
    }
    body.light-theme .billing-table tbody tr:hover td {
      background: rgba(13,59,102,0.03);
    }
    body.light-theme .billing-invoice-table td {
      background: #ffffff;
      border-color: rgba(13,59,102,0.08);
    }
    body.light-theme .billing-invoice-table tbody tr:hover td {
      background: rgba(13,59,102,0.04);
    }
    body.light-theme .billing-invoice-download {
      color: #0d766e;
    }
    body.light-theme .billing-invoice-page-button {
      background: #ffffff;
      border-color: var(--line);
    }
    body.light-theme .billing-progress,
    body.light-theme .billing-manager-plan-meter {
      background: rgba(13,59,102,0.06);
    }
    body.light-theme .billing-manager-backdrop {
      background: rgba(9, 20, 33, 0.4);
    }

@media (max-width: 860px) {
      .billing-shell,
      .billing-main,
      .billing-side,
      .billing-priority-grid,
      .billing-priority-column {
        gap: 12px;
      }
      .billing-shell {
        display: grid;
        grid-template-columns: 1fr;
      }
      .billing-main,
      .billing-side {
        display: grid;
      }
      #billing-subscriptions-surface {
        order: 1;
      }
      #billing-invoices-surface {
        order: 2;
      }
      #billing-side-wallet {
        order: 1;
      }
      #billing-side-payment-history {
        order: 3;
      }
      #billing-downloads-surface {
        order: 3;
      }
      #billing-side-available-access {
        order: 2;
      }
      #billing-side-notes {
        order: 4;
      }
      .billing-surface,
      .billing-side-card {
        padding: 16px;
      }
      .billing-surface-head {
        align-items: stretch;
      }
      .billing-surface-head > button,
      #portal-subscription-manage-trigger {
        width: 100%;
      }
      .billing-table-wrap {
        border: 0;
        border-radius: 0;
        overflow: visible;
        background: transparent;
      }
      .billing-table {
        min-width: 0;
        display: block;
      }
      .billing-table thead {
        display: none;
      }
      .billing-table tbody,
      .billing-table tr,
      .billing-table td {
        display: block;
        width: 100%;
      }
      .billing-table tbody {
        display: grid;
        gap: 12px;
      }
      .billing-table tbody tr {
        border: 1px solid var(--line);
        border-radius: 18px;
        overflow: hidden;
        background: rgba(255,255,255,0.02);
      }
      .billing-table tbody tr:hover td {
        background: transparent;
      }
      .billing-table td {
        padding: 12px 14px;
        border-bottom: 1px solid var(--line);
        white-space: normal;
      }
      .billing-table td:not(.billing-product-cell):not(.billing-table-action-cell) {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 14px;
      }
      .billing-table td:not(.billing-product-cell):not(.billing-table-action-cell)::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 11px;
        font-weight: 700;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        flex: 0 0 96px;
      }
      .billing-table td.billing-product-cell strong {
        margin-bottom: 6px;
      }
      .billing-table td.billing-product-cell span {
        margin-top: 0;
      }
      .billing-table td.billing-table-action-cell {
        padding: 14px;
      }
      .billing-table td.billing-table-action-cell button {
        width: 100%;
      }
      .billing-table tbody tr td:last-child {
        border-bottom: 0;
      }
      .billing-invoice-table {
        border-spacing: 0;
      }
      .billing-invoice-table td,
      .billing-invoice-table tbody tr td:first-child,
      .billing-invoice-table tbody tr td:last-child {
        border-left: 0;
        border-right: 0;
        border-radius: 0;
      }
      .billing-invoice-pagination {
        justify-content: stretch;
      }
      .billing-invoice-page-button {
        flex: 1;
      }
      .billing-table-empty-row td::before {
        content: none !important;
      }
      #portal-view-downloads .billing-surface .toolbar {
        display: grid;
        gap: 10px;
      }
      #portal-view-downloads .billing-surface .toolbar a,
      #portal-view-downloads .billing-surface .toolbar button {
        width: 100%;
      }
      #portal-view-downloads .billing-surface .toolbar a button {
        width: 100% !important;
      }
      #portal-view-downloads .billing-surface .analysis-meta-row,
      #portal-view-downloads .billing-side-card .analysis-meta-row,
      #portal-view-downloads .billing-side-meter-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
      }
      #portal-view-downloads .billing-surface .analysis-meta-row .v,
      #portal-view-downloads .billing-side-card .analysis-meta-row .v,
      #portal-view-downloads .billing-side-meter-head strong {
        width: 100%;
        text-align: left;
        white-space: normal;
        word-break: break-word;
      }
      #portal-view-downloads .notice,
      #portal-view-downloads .billing-side-note {
        overflow-wrap: anywhere;
      }
}
