/* Billing uses the semantic tokens defined by theme-global.css. */
#page-billing { min-width: 0; color: var(--th-text); font-size: 14px; letter-spacing: 0; }
#page-billing [hidden], #page-billing .hidden { display: none !important; }
#page-billing .billing-band { padding: 0 !important; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
#page-billing .billing-band h2, #page-billing .billing-band h3 { color: var(--th-text) !important; letter-spacing: 0 !important; font-size: 16px; }
#page-billing .billing-section-nav { position: static; display: flex; flex-wrap: nowrap; align-items: center; gap: 16px; overflow-x: auto; background: transparent; border-bottom: 1px solid var(--th-border); padding: 0; backdrop-filter: none; }
#page-billing .billing-section-nav .billing-section-tab { flex-shrink: 0; min-height: 44px; padding: 8px 4px; border: 0; border-bottom: 2px solid transparent; border-radius: 0 !important; color: var(--th-text-2); background: transparent; box-shadow: none; font-size: 14px; }
#page-billing .billing-section-tab:hover { color: var(--th-text); }
#page-billing .billing-section-tab[aria-selected="true"] { color: var(--th-accent); border-bottom-color: var(--th-accent); }
#page-billing :is(button, input, select, [role="tabpanel"]):focus-visible { outline: 2px solid var(--th-accent); outline-offset: 2px; }
#page-billing [role="tabpanel"] { min-width: 0; }
#page-billing #billing-balance-section { display: grid; gap: 28px; }
#page-billing #billing-ledger-section { border-top: 1px solid var(--th-border); padding-top: 24px !important; }
#page-billing .billing-recharge-method { display: flex; flex-wrap: wrap; gap: 12px; border: 0; padding: 0; margin: 0 0 24px; }
#page-billing .billing-recharge-method legend { font-size: 16px; font-weight: 600; color: var(--th-text); margin-bottom: 12px; }
#page-billing .billing-recharge-method label { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border: 1px solid var(--th-border); border-radius: 6px; cursor: pointer; }
#page-billing .billing-recharge-method label:has(:checked) { border-color: var(--th-accent); color: var(--th-text); background: color-mix(in srgb, var(--th-accent) 8%, transparent); }
#page-billing .billing-recharge-method input { min-height: 0; width: 16px; height: 16px; accent-color: var(--th-accent); }
#page-billing .billing-recharge-method svg { width: 18px; height: 18px; }
#page-billing #billing-summary-band { max-width: 1120px; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 28px 20px; }
#page-billing #billing-summary-band > div { padding: 0 16px 0 0; border: 0; border-radius: 0; background: transparent !important; min-width: 0; }
#page-billing #redeem-admin-panel, #page-billing #billing-overview-box { padding: 12px 0; background: transparent; border: 0; border-radius: 0; }
#page-billing #billing-overview-content { max-width: none; }
#page-billing #billing-redeem-section > div { max-width: 720px; }
#page-billing #online-payment-panel { max-width: 1120px; width: 100%; margin: 0 auto; }
#page-billing .payment-checkout-shell { align-self: stretch; }
#page-billing .payment-method-guide { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border: 1px solid var(--th-border); border-radius: 6px; background: var(--th-bg-2); color: var(--th-text-secondary); }
#page-billing .payment-method-guide svg { width: 18px; height: 18px; flex: 0 0 auto; color: var(--th-info); margin-top: 1px; }
#page-billing .payment-method-guide div { display: grid; gap: 4px; }
#page-billing .payment-method-guide strong { color: var(--th-text); font-size: 14px; }
#page-billing .payment-method-guide span { font-size: 13px; line-height: 1.5; }
#page-billing #payment-entry-fields { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; gap: 32px; }
#page-billing .payment-entry-grid { display: grid; grid-template-columns: minmax(0, 1fr); align-items: end; gap: 18px; }
#page-billing .payment-amount-field { display: grid; gap: 8px; min-width: 0; }
#page-billing #payment-amount-error { margin: 0; color: var(--th-danger); font-size: 13px; }
#page-billing #payment-amount-error:empty { display: none; }
#page-billing #payment-amount-yuan[aria-invalid="true"] { border-color: var(--th-danger); }
#page-billing .payment-quick-wrap { display: grid; gap: 8px; color: var(--th-text-secondary); font-size: 14px; }
#page-billing .payment-quick-amounts { display: flex; flex-wrap: wrap; gap: 6px; }
#page-billing .payment-quick-amount { min-height: 40px; min-width: 64px; padding: 8px 12px; border: 1px solid var(--th-border); border-radius: 6px !important; color: var(--th-text-secondary); background: transparent; font-size: 14px; }
#page-billing .payment-quick-amount:hover, #page-billing .payment-quick-amount.is-selected { color: var(--th-text); border-color: var(--th-accent); background: color-mix(in srgb, var(--th-accent) 14%, transparent); }
#page-billing .payment-quote-panel { min-width: 0; padding: 0 0 0 24px; border-left: 1px solid var(--th-border); }
#page-billing #payment-quote-title { margin: 0 0 8px; color: var(--th-text); font-size: 16px; font-weight: 600; }
#page-billing #payment-quote { margin: 0; padding: 0; min-width: 0; background: transparent; border: 0; border-radius: 0; }
#page-billing #payment-quote .payment-amounts { max-width: none; }
#page-billing #payment-quote .payment-amounts dd { text-align: right; }
#page-billing #payment-quote .payment-total dd { font-size: 20px; }
#page-billing #payment-quote[data-state="ready"] .payment-total dd { color: var(--th-accent); }
#page-billing #payment-quote:not([data-state="ready"]) dd { color: var(--th-text-secondary); font-size: 14px; font-weight: 400; }
#page-billing .payment-quote-status { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; min-height: 28px; margin: 4px 0 12px; }
#page-billing #payment-quote-message { color: var(--th-text-secondary); font-size: 13px; margin: 0; overflow-wrap: anywhere; }
#page-billing #payment-quote-message[data-error="true"] { color: var(--th-danger); }
#page-billing #payment-create-button { min-height: 44px; width: 100%; font-size: 14px; }
#page-billing #payment-create-button:disabled { cursor: not-allowed; }
#page-billing #payment-create-button[aria-busy="true"] { cursor: wait; }
#page-billing #redeem-admin-panel, #page-billing #redeem-codes-list { max-width: 1000px; }
#page-billing :is([class*="text-[10"], [class*="text-[11"], [class*="text-[12"], .text-xs) { font-size: 13px; letter-spacing: 0; }
#page-billing #redeem-generated-codes > div, #page-billing #redeem-codes-list > div { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 0; overflow-wrap: anywhere; }
#page-billing #redeem-generated-codes span:first-child, #page-billing #redeem-codes-list span:first-child { overflow-wrap: anywhere; }
#page-billing #redeem-admin-panel > .grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; }
#page-billing [class*="text-white/"] { color: var(--th-text-secondary) !important; }
#page-billing .text-white { color: var(--th-text) !important; }
#page-billing [class*="text-emerald-"] { color: var(--th-success) !important; }
#page-billing [class*="text-cyan-"] { color: var(--th-info) !important; }
#page-billing [class*="text-amber-"] { color: var(--th-warning) !important; }
#page-billing [class*="text-rose-"] { color: var(--th-danger) !important; }
#page-billing label { color: var(--th-text-secondary); min-width: 0; }
#page-billing input, #page-billing select { min-width: 0; min-height: 40px; max-width: 100%; color: var(--th-text); background: var(--th-input-bg); border-color: var(--th-border); border-radius: 6px; font-size: 14px; padding: 8px 10px; }
#page-billing button, #page-billing a.btn-glass { min-height: 34px; border-radius: 6px !important; letter-spacing: 0; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
#page-billing button:disabled { opacity: .5; cursor: wait; }
#page-billing button svg { width: 16px; height: 16px; flex-shrink: 0; }
#page-billing .billing-band > .rounded-xl { border-radius: 0 !important; border: 0; }
#page-billing table thead { background: var(--th-bg-2) !important; }
#page-billing table th, #page-billing table td { border-color: var(--th-border); }
#page-billing .max-h-64, #page-billing .max-h-80 { overflow-x: auto; }
#page-billing #billing-ledger-section, #page-billing #billing-orders-section { min-height: min(68dvh, 760px); display: flex; flex-direction: column; }
#page-billing #billing-ledger-section > .rounded-xl, #page-billing #billing-orders-section > .rounded-xl { display: flex; min-height: 0; flex: 1 1 auto; }
#page-billing #billing-ledger-section > .rounded-xl > .billing-ledger-table, #page-billing #billing-orders-section > .rounded-xl > .max-h-64 { max-height: none; min-height: 320px; width: 100%; overflow: auto; }
#page-billing #payment-order-result { overflow-wrap: anywhere; }
#page-billing .billing-fund-movements { margin-top: 6px; color: var(--th-text-secondary); }
#page-billing .billing-fund-movements summary { width: fit-content; cursor: pointer; color: var(--th-accent); font-size: 12px; }
#page-billing .billing-fund-movement { display: grid; grid-template-columns: minmax(6rem, auto) auto; gap: 2px 12px; margin-top: 7px; padding-left: 10px; border-left: 2px solid var(--th-border); font-size: 11px; }
#page-billing .billing-fund-movement strong { justify-self: end; font-variant-numeric: tabular-nums; }
#page-billing .billing-fund-movement strong.is-positive { color: var(--th-success); }
#page-billing .billing-fund-movement strong.is-negative { color: var(--th-danger); }
#page-billing .billing-fund-movement time, #page-billing .billing-fund-movement small { grid-column: 1 / -1; color: var(--th-text-2); font-size: 11px; }
#page-billing .payment-without-qr { grid-template-columns: minmax(0, 1fr); }
#page-billing .payment-without-qr .payment-amounts { max-width: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 40px; }
#page-billing .payment-without-qr .payment-total { font-size: 14px; border-top: 0; }
#page-billing #billing-summary-band > div > [id] { overflow-wrap: anywhere; font-size: 24px; }
@media (max-width: 767px) {
  #page-billing { padding: 20px 16px 32px; }
  #page-billing button, #page-billing input, #page-billing select { min-height: 44px; }
  #page-billing input, #page-billing select { font-size: 16px; }
  #page-billing .billing-section-nav { gap: 12px; }
  #page-billing #billing-summary-band { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #page-billing #redeem-admin-panel > .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #page-billing #redeem-code-input { width: 0; }
  #page-billing #billing-ledger-section label { flex: 1 1 100%; }
  #page-billing #billing-ledger-section label input, #page-billing #billing-ledger-section label select { width: 100%; }
  #page-billing #transactions-range-summary { margin-left: 0; }
  #page-billing .payment-entry-grid { grid-template-columns: 1fr; gap: 12px; }
  #page-billing #payment-entry-fields { grid-template-columns: 1fr; gap: 24px; }
  #page-billing .payment-quote-panel { padding: 20px 0 0; border-left: 0; border-top: 1px solid var(--th-border); }
  #page-billing .payment-without-qr .payment-amounts { grid-template-columns: 1fr; }
  #page-billing table, #page-billing table tbody { display: block; width: 100%; min-width: 0; }
  #page-billing table thead { display: none; }
  #page-billing table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-bottom: 1px solid var(--th-border); padding: 12px 0; gap: 10px; }
  #page-billing table td { padding: 0; white-space: normal; min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
  #page-billing table td::before { content: attr(data-label); display: block; font-size: 11px; color: var(--th-text-secondary); margin-bottom: 4px; }
  #page-billing table td:first-child, #page-billing table td:last-child { grid-column: 1 / -1; }
}
@media (max-width: 480px) {
  #page-billing #redeem-admin-panel > .grid { grid-template-columns: minmax(0, 1fr); }
}

/* ==========================================================================
   平台账务 (管理员): 指标卡 + 结构化表格
   此前全部是 `flex justify-between` 平铺行, 多个指标用 "/" 硬拼成一行 ——
   既读不出层级, 也无法两两对比。这里改为按语义分块: 指标卡 (KPI) / 数据表 / 状态磁贴。
   本区块刻意使用语义类名而非内联 tailwind: 上面 `[class*="text-white/"]` 会把所有
   灰阶压成同一个颜色、`[class*="text-[10"]` 会把所有字号抬到 13px, 层级会被抹平。
   ========================================================================== */
#page-billing #billing-platform-section { display: grid; gap: 22px; }
#page-billing .ledger-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; }
#page-billing .ledger-head h2 { font-size: 17px; font-weight: 600; color: var(--th-text); margin: 0; }
#page-billing .ledger-head p { margin: 5px 0 0; font-size: 13px; color: var(--th-text-2); }
#page-billing .ledger-refresh { flex: 0 0 auto; }

#page-billing .ledger-grid { display: grid; gap: 22px; }
#page-billing .ledger-block { display: grid; gap: 10px; min-width: 0; }
#page-billing .ledger-block > h3 { margin: 0; font-size: 13px; font-weight: 600; color: var(--th-text-2); }
#page-billing .ledger-block > h3 .ledger-hint { font-weight: 400; color: var(--th-text-2); opacity: .75; }

/* 指标卡 */
#page-billing .ledger-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(186px, 1fr)); gap: 12px; }
#page-billing .ledger-metric { display: grid; gap: 7px; align-content: start; min-width: 0; padding: 14px 16px; border: 1px solid var(--th-border); border-radius: 10px; background: var(--th-surface-subtle); }
#page-billing .ledger-metric-label { font-size: 12px; color: var(--th-text-2); }
#page-billing .ledger-metric-value { font-size: 21px; font-weight: 650; line-height: 1.15; color: var(--th-text); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
#page-billing .ledger-metric.is-revenue .ledger-metric-value { color: var(--th-accent); }
#page-billing .ledger-metric.is-profit .ledger-metric-value { color: var(--th-success); }
#page-billing .ledger-metric.is-loss .ledger-metric-value { color: var(--th-danger); }
#page-billing .ledger-metric-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; font-size: 12px; color: var(--th-text-2); font-variant-numeric: tabular-nums; }
#page-billing .ledger-coverage { display: grid; flex: 1 1 100%; gap: 2px; margin-top: 2px; padding-top: 7px; border-top: 1px solid var(--th-border); line-height: 1.35; }
#page-billing .ledger-coverage strong { font-weight: 600; color: var(--th-text); }
#page-billing .ledger-coverage.is-complete strong { color: var(--th-success); }
#page-billing .ledger-coverage.is-partial strong { color: var(--th-warning); }
#page-billing .ledger-coverage.is-unknown strong { color: var(--th-danger); }
#page-billing .ledger-delta { padding: 2px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
#page-billing .ledger-delta.is-up { color: var(--th-success); background: color-mix(in srgb, var(--th-success) 13%, transparent); }
#page-billing .ledger-delta.is-down { color: var(--th-danger); background: color-mix(in srgb, var(--th-danger) 13%, transparent); }

/* 统计条 */
#page-billing .ledger-chips { display: flex; flex-wrap: wrap; gap: 8px; }
#page-billing .ledger-chip { display: inline-flex; align-items: baseline; gap: 7px; padding: 7px 13px; border: 1px solid var(--th-border); border-radius: 999px; background: var(--th-surface-subtle); font-size: 13px; color: var(--th-text-2); }
#page-billing .ledger-chip strong { font-size: 14px; font-weight: 600; color: var(--th-text); font-variant-numeric: tabular-nums; }

/* 数据表 */
#page-billing .ledger-table-wrap { min-width: 0; overflow-x: auto; border: 1px solid var(--th-border); border-radius: 10px; }
#page-billing table.ledger-table { width: 100%; border-collapse: collapse; font-size: 13px; }
#page-billing table.ledger-table th { padding: 9px 14px; border-bottom: 1px solid var(--th-border); background: var(--th-surface-subtle); font-size: 12px; font-weight: 500; color: var(--th-text-2); text-align: right; white-space: nowrap; }
#page-billing table.ledger-table td { padding: 10px 14px; border-bottom: 1px solid var(--th-border); color: var(--th-text-secondary); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
#page-billing table.ledger-table th:first-child, #page-billing table.ledger-table td:first-child { text-align: left; }
#page-billing table.ledger-table tbody tr:last-child td { border-bottom: 0; }
#page-billing table.ledger-table tbody tr:hover td { background: var(--th-surface-subtle); }
#page-billing table.ledger-table .ledger-name { max-width: 280px; overflow: hidden; text-overflow: ellipsis; color: var(--th-text); font-weight: 550; }
#page-billing table.ledger-table .ledger-muted { color: var(--th-text-2); }
#page-billing .ledger-cost-cell { display: inline-grid; justify-items: end; gap: 2px; }
#page-billing .ledger-coverage-badge { color: var(--th-warning); font-size: 11px; font-weight: 600; line-height: 1.2; white-space: nowrap; }
/* 毛利着色不限定在表格内: 指标卡脚注里的毛利也用同一个类 (此前写成表格后代选择器, 卡内毛利没有颜色) */
#page-billing .ledger-profit { color: var(--th-success); font-weight: 600; }
#page-billing .ledger-profit.is-negative { color: var(--th-danger); }
#page-billing .ledger-empty { padding: 14px 2px; font-size: 13px; color: var(--th-text-2); }

/* 状态磁贴 */
#page-billing .ledger-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: 12px; }
#page-billing .ledger-tile { display: grid; gap: 5px; align-content: start; min-width: 0; padding: 13px 15px; border: 1px solid var(--th-border); border-radius: 10px; background: var(--th-surface-subtle); }
#page-billing .ledger-tile.is-alert { border-color: color-mix(in srgb, var(--th-danger) 45%, var(--th-border)); }
#page-billing .ledger-tile-label { font-size: 12px; color: var(--th-text-2); }
#page-billing .ledger-tile-value { font-size: 17px; font-weight: 600; color: var(--th-text); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
#page-billing .ledger-tile-value.is-warning { color: var(--th-warning); }
#page-billing .ledger-tile-value.is-danger { color: var(--th-danger); }
#page-billing .ledger-tile-value.is-ok { color: var(--th-success); }
#page-billing .ledger-tile-foot { font-size: 12px; color: var(--th-text-2); font-variant-numeric: tabular-nums; }

/* 窄屏: 指标卡与磁贴单列, 表格保留横向滚动 (上方通用 table 的卡片化规则不适用于账务表) */
@media (max-width: 767px) {
  #page-billing .ledger-metrics { grid-template-columns: minmax(0, 1fr); }
  #page-billing .ledger-tiles { grid-template-columns: minmax(0, 1fr); }
  #page-billing .ledger-metric-value { font-size: 19px; }
  #page-billing table.ledger-table tr { display: table-row; grid-template-columns: none; padding: 0; gap: 0; border-bottom: 0; }
  #page-billing table.ledger-table td { display: table-cell; max-width: none; padding: 9px 11px; white-space: nowrap; }
  #page-billing table.ledger-table td::before { content: none; }
  #page-billing table.ledger-table td:first-child, #page-billing table.ledger-table td:last-child { grid-column: auto; }
}
