.payment-surface {
  display: grid;
  gap: 18px;
}
.payment-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}
.payment-main {
  display: grid;
  gap: 16px;
}
.payment-panel {
  background: var(--surface, #fff);
  border: 1px solid var(--line, #e4e7ec);
  border-radius: 10px;
  padding: 18px;
}
.payment-panel h2,
.payment-panel h3 {
  margin: 0 0 12px;
  font-size: 16px;
}
.payment-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.payment-kpi {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}
.payment-kpi span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.payment-kpi strong {
  display: block;
  margin-top: 5px;
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}
.payment-kpi small {
  color: var(--muted);
  font-size: 12px;
}
.payment-account {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}
.payment-account strong {
  font-size: 16px;
}
.payment-account small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}
.billing-switch {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.billing-switch button {
  border: 1px solid var(--line, #e4e7ec);
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
}
.billing-switch button.active {
  background: #111827;
  color: #fff;
  border-color: #111827;
}
.billing-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 16px;
}
.billing-hero.pay01-first { display: block; margin: 0 0 16px; }
.credit-hero strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 40px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.credit-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}
.credit-meta span {
  background: #f4f6f8;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
}
.plan-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.plan-card {
  border: 1px solid var(--line, #e4e7ec);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  text-align: left;
  cursor: pointer;
}
.plan-card.active {
  border-color: #111827;
  box-shadow: inset 0 0 0 1px #111827;
}
.plan-card b {
  display: block;
  margin-bottom: 6px;
}
.plan-card small {
  display: block;
  color: var(--muted);
  line-height: 1.45;
}
.ref-strip {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.finance-account-menu {
  position: relative;
  margin-left: auto;
}
.finance-account-trigger {
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--line-strong, #d0d5dd);
  border-radius: 8px;
  background: var(--surface, #fff);
  color: var(--text, #1d2939);
  font: inherit;
  cursor: pointer;
}
.finance-account-popover {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  right: 0;
  width: 286px;
  padding: 12px;
  border: 1px solid var(--line, #e4e7ec);
  border-radius: 10px;
  background: var(--surface, #fff);
  box-shadow: 0 12px 32px rgb(16 24 40 / 14%);
}
.finance-account-popover[hidden] { display: none; }
.finance-account-popover [role="menuitem"] {
  display: block;
  width: 100%;
  min-height: 36px;
  padding: 7px 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text, #1d2939);
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.finance-account-popover [role="menuitem"]:hover:not(:disabled) { background: var(--surface-soft, #f5f7fa); }
.finance-account-popover [role="menuitem"]:disabled { color: var(--muted, #667085); cursor: default; }
.finance-account-current { margin: 0 0 7px; padding: 4px 8px 9px; border-bottom: 1px solid var(--line, #e4e7ec); font-weight: 650; }
.finance-account-storage, .finance-account-message { margin: 7px 8px; color: var(--muted, #667085); font-size: 12px; line-height: 1.5; }
.finance-account-message:not(:empty) { color: var(--danger, #b42318); }
@media (max-width: 900px) {
  .billing-hero,
  .plan-row {
    grid-template-columns: 1fr;
  }
}
.payment-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.payment-tag {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-soft, #f5f7fa);
  color: #475467;
  font-size: 12px;
}
.payment-tag.good {
  background: #ecfdf3;
  color: #047857;
}
.payment-tag.warn {
  background: #fff7ed;
  color: #b45309;
}
.payment-tag.bad {
  background: #fff1f2;
  color: #be123c;
}
.payment-form {
  display: grid;
  gap: 14px;
}
.payment-form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.usd-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}
.usd-option {
  padding: 13px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  background: var(--surface);
}
.usd-option:has(input:checked) {
  border-color: var(--brand);
  background: #f1fbf8;
  color: var(--brand);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.1);
}
.usd-option input {
  position: absolute;
  opacity: 0;
}
.usd-option strong {
  display: block;
  font-size: 17px;
}
.usd-option span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 3px;
}
.payment-summary {
  display: grid;
  gap: 9px;
}
.payment-summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}
.payment-summary-row span {
  color: var(--muted);
}
.payment-summary-row strong {
  font-variant-numeric: tabular-nums;
}
.payment-summary-row.total strong {
  color: var(--brand);
  font-size: 20px;
}
.payment-actions {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}
.payment-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}
.payment-table th,
.payment-table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}
.payment-table th {
  font-size: 11px;
  color: var(--muted);
  font-weight: 800;
}
.payment-table td {
  font-size: 13px;
}
.payment-table-wrap {
  overflow: auto;
}
.payment-table tr[data-id] {
  cursor: pointer;
}
.payment-table tr[data-id]:hover {
  background: #fafdfc;
}
.payment-table .amount {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.payment-filter {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr auto;
  gap: 9px;
  align-items: end;
}
.payment-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.payment-detail dl {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.payment-detail dt {
  font-size: 11px;
  color: var(--muted);
}
.payment-detail dd {
  margin: 4px 0 0;
  font-weight: 700;
  word-break: break-word;
}
.payment-timeline {
  display: grid;
  gap: 0;
}
.payment-step {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 9px;
  position: relative;
  padding: 0 0 16px;
}
.payment-step:before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--brand);
  margin-top: 4px;
  z-index: 1;
}
.payment-step:not(:last-child):after {
  content: "";
  position: absolute;
  left: 4px;
  top: 13px;
  bottom: 0;
  border-left: 1px solid var(--line-strong);
}
.payment-step strong {
  font-size: 13px;
}
.payment-step span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}
.payment-notice {
  padding: 11px 13px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--line);
  color: #475467;
  line-height: 1.55;
  font-size: 13px;
}
.payment-notice.warn {
  background: #fffaf0;
  border-color: #fed7aa;
  color: #9a3412;
}
.payment-notice.good {
  background: #ecfdf3;
  border-color: #bbf7d0;
  color: #166534;
}
.payment-drawer {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.28);
  z-index: 20;
  display: none;
  justify-content: flex-end;
}
.payment-drawer.open {
  display: flex;
}
.payment-drawer-card {
  width: min(640px, 100%);
  height: 100%;
  background: var(--surface);
  overflow: auto;
  padding: 22px;
  box-shadow: -12px 0 32px rgba(16, 24, 40, 0.12);
}
.payment-drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 18px;
}
.payment-drawer-head h2 {
  margin: 0;
  font-size: 18px;
}
.payment-empty {
  padding: 32px 18px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: 9px;
  color: var(--muted);
  display: grid;
  gap: 8px;
}
.payment-empty strong {
  color: #344054;
}
.payment-hidden {
  display: none !important;
}
.payment-error {
  color: #be123c;
  font-size: 12px;
  min-height: 18px;
}
.payment-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.payment-small {
  font-size: 12px;
  color: var(--muted);
}
.payment-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}
.payment-admin-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.payment-hero {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.payment-status-icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #ecfdf3;
  color: #047857;
  font-size: 24px;
  font-weight: 800;
}
.payment-status-icon.warn {
  background: #fff7ed;
  color: #b45309;
}
.payment-status-icon.bad {
  background: #fff1f2;
  color: #be123c;
}
.payment-result-copy h2 {
  margin: 0 0 6px;
}
.payment-result-copy p {
  margin: 0;
  color: var(--muted);
}
@media (max-width: 1100px) {
  .payment-grid {
    grid-template-columns: 1fr;
  }
  .payment-filter {
    grid-template-columns: 1fr 1fr;
  }
  .payment-form-row,
  .payment-detail {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 720px) {
  .payment-kpis {
    grid-template-columns: 1fr;
  }
  .usd-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .payment-filter {
    grid-template-columns: 1fr;
  }
  .payment-panel {
    padding: 14px;
  }
}

.payment-cell-id {
  display: block;
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
}
.payment-panel h3 {
  margin-top: 20px;
}
.payment-panel + .payment-panel {
  margin-top: 16px;
}
.payment-surface > .payment-panel + .payment-panel,
.payment-main > .payment-panel + .payment-panel {
  margin-top: 0;
}
.payment-drawer {
  z-index: 1000;
}
.usd-option:has(input:focus-visible) {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
}
.payment-form textarea {
  resize: vertical;
}
.payment-panel summary {
  cursor: pointer;
  font-weight: 600;
}
.payment-table td {
  max-width: 260px;
}
.payment-grid > main {
  min-width: 0;
}

.payment-main,
.payment-panel,
.payment-table-wrap {
  min-width: 0;
  max-width: 100%;
}
.payment-grid {
  min-width: 0;
}
.payment-panel {
  box-sizing: border-box;
}
.payment-drawer-card {
  box-sizing: border-box;
}
body[data-payment-page] .page {
  min-width: 0;
}
body[data-payment-page="wallet"] .topbar .top-actions > a[href="wallet.html"] {
  display: none;
}

.payment-grid.payment-grid-single {
  grid-template-columns: minmax(0, 1fr);
}

/* Wide operational tables can opt in without inheriting the user detail rail. */
body[data-payment-wide="true"] .payment-grid,
.payment-wide .payment-grid {
  grid-template-columns: minmax(0, 1fr);
}
body[data-payment-wide="true"] .payment-grid > aside,
.payment-wide .payment-grid > aside {
  display: block;
  grid-column: 1;
}
body[data-payment-wide="true"] .payment-table-wrap,
.payment-wide .payment-table-wrap {
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}
body[data-payment-wide="true"] .payment-table,
.payment-wide .payment-table {
  min-width: 780px;
}
body[data-payment-wide="true"] .payment-table th,
.payment-wide .payment-table th {
  white-space: nowrap;
}
.payment-wide .payment-table td,
body[data-payment-wide="true"] .payment-table td {
  white-space: normal;
  vertical-align: top;
}
.link-button {
  border: 0;
  padding: 2px 0;
  background: transparent;
  color: var(--brand, #2563eb);
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.link-button:hover {
  text-decoration: underline;
}
.payment-inline { align-items: flex-start; gap: 16px; }
.payment-inline > div { min-width: 0; }
.payment-inline h2 { margin-bottom: 4px; }
.payment-filter { align-items: end; }
.payment-filter .field { min-width: 150px; }
.payment-table a:focus-visible,
.payment-actions .btn:focus-visible,
.payment-filter .control:focus-visible {
  outline: 2px solid var(--brand, #2563eb);
  outline-offset: 2px;
}

.finance-scope-select { min-width: 190px; }
.payment-admin-operation-fields { display: grid; gap: 12px; margin: 12px 0; }
.payment-admin-operation-fields:empty { display: none; }
.payment-admin-operation-fields .field { margin: 0; }

/* Finance workbench: one set of metrics, one modal operation flow. */
.finance-overview{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px}
.finance-overview-card{display:flex;flex-direction:column;gap:12px;border-top:3px solid var(--brand)}
.finance-overview-card>strong{font-size:28px;line-height:1.2}.finance-overview-card small{font-size:12px;color:var(--muted);font-weight:400}
.finance-filterbar{display:flex;flex-wrap:wrap;align-items:flex-end;gap:10px}.finance-filterbar .field{min-width:115px;flex:1;margin:0}.finance-filterbar .finance-search{flex:2;min-width:210px}
.finance-filterbar>.payment-actions{margin:0}.finance-filterbar .control{width:100%}
body[data-payment-page="finance"] .payment-table th{white-space:nowrap}body[data-payment-page="finance"] .payment-table td{font-size:13px;overflow-wrap:anywhere}
body[data-payment-page="finance"] .payment-table td .payment-actions{flex-wrap:nowrap}.finance-overview+.payment-panel{margin-top:0}
@media(max-width:1100px){.finance-overview{grid-template-columns:repeat(2,minmax(0,1fr))}}

.finance-overview>.payment-panel{margin:0}

/* A06 reconciliation and expanded A03 refund workbench: dense desktop operations. */
.recon-filters,.refund-filters{grid-template-columns:repeat(4,minmax(150px,1fr));gap:10px 12px}
.recon-filters .field,.refund-filters .field{min-width:0;margin:0}
.recon-filter-panel .payment-inline,.recon-table-head,.refund-table-head{align-items:center;justify-content:space-between}
.recon-page-size{min-width:110px;margin:0}
.recon-table,.refund-table{min-width:1060px}
.recon-table th,.refund-table th{white-space:nowrap}
.recon-table td,.refund-table td{min-width:96px;vertical-align:top}
.recon-table td:first-child,.refund-table td:first-child{min-width:155px}
.payment-pagination{display:flex;align-items:center;justify-content:flex-end;gap:12px;margin-top:14px;color:var(--muted);font-size:13px}
.payment-detail-links{display:flex;flex-wrap:wrap;gap:8px 18px;margin:8px 0 14px}
.refund-facts{margin-top:18px;padding-top:16px;border-top:1px solid var(--line,#e4e7ec)}
.refund-facts h3{margin:0 0 10px;font-size:15px}
.refund-facts p{font-size:13px;line-height:1.6}
.payment-backup{margin-top:12px}
.payment-backup textarea{width:100%;font:12px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre;overflow:auto}
.payment-backup .payment-actions{margin-top:8px}
@media(max-width:1100px){.recon-filters,.refund-filters{grid-template-columns:repeat(2,minmax(150px,1fr))}}

.payment-json-details{margin-top:8px}.payment-json-details summary{cursor:pointer;font-weight:600;color:var(--text-secondary,#475467)}.payment-json-details pre{max-height:320px;overflow:auto;padding:12px;border:1px solid var(--line,#e4e7ec);border-radius:8px;background:#f8fafc;font:12px/1.55 ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre-wrap;overflow-wrap:anywhere}
body[data-payment-page="recharge-reconciliation"] .recon-table th:last-child,
body[data-payment-page="recharge-reconciliation"] .recon-table td:last-child{position:sticky;right:0;width:128px;min-width:128px;max-width:128px;box-sizing:border-box;background:#fff;box-shadow:-1px 0 0 var(--line,#e4e7ec);}
body[data-payment-page="recharge-reconciliation"] .recon-table th:last-child{position:sticky;right:0;width:128px;min-width:128px;max-width:128px;box-sizing:border-box;z-index:4;background:#f7f8fa;box-shadow:-1px 0 0 var(--line,#e4e7ec);}
body[data-payment-page="recharge-reconciliation"] .recon-table th:nth-last-child(2),
body[data-payment-page="recharge-reconciliation"] .recon-table td:nth-last-child(2){position:sticky;right:var(--sticky-action-width,128px);width:164px;min-width:164px;max-width:164px;box-sizing:border-box;white-space:normal;background:#fff;box-shadow:-1px 0 0 var(--line,#e4e7ec);}
body[data-payment-page="recharge-reconciliation"] .recon-table th:nth-last-child(2){z-index:4;background:#f7f8fa;}
body[data-payment-page="recharge-reconciliation"] .recon-table td:nth-last-child(2){z-index:2;}
body[data-payment-page="recharge-reconciliation"] .recon-table .payment-tag{display:inline-block;max-width:100%;white-space:normal;}
body[data-payment-page="refunds"] .refund-list-table th:last-child,
body[data-payment-page="refunds"] .refund-list-table td:last-child{position:sticky;right:0;width:142px;min-width:142px;max-width:142px;box-sizing:border-box;background:#fff;box-shadow:-1px 0 0 var(--line,#e4e7ec);}
body[data-payment-page="refunds"] .refund-list-table th:last-child{z-index:4;background:#f7f8fa;}
body[data-payment-page="refunds"] .refund-list-table td:last-child{z-index:2;}
body[data-payment-page="refunds"] .refund-list-table th:nth-last-child(2),
body[data-payment-page="refunds"] .refund-list-table td:nth-last-child(2){position:sticky;right:var(--sticky-action-width,142px);width:156px;min-width:156px;max-width:156px;box-sizing:border-box;white-space:normal;background:#fff;box-shadow:-1px 0 0 var(--line,#e4e7ec);}
body[data-payment-page="refunds"] .refund-list-table th:nth-last-child(2){z-index:4;background:#f7f8fa;}
body[data-payment-page="refunds"] .refund-list-table td:nth-last-child(2){z-index:2;}
body[data-payment-page="refunds"] .refund-list-table td:nth-last-child(2) small{display:inline-block;max-width:100%;white-space:normal;overflow-wrap:anywhere;}
.table-scroll-hint{margin:4px 0 0;font-size:12px;}

/* Stage2b A03/A05 compact finance controls, tuned for 1920 x 1080. */
.refund-status-quick{display:flex;flex-wrap:wrap;gap:6px;margin:4px 0 14px}
.refund-status-quick .btn{font-size:12px;padding:6px 9px;white-space:nowrap}
.refund-money{text-align:right;font-variant-numeric:tabular-nums}
.refund-detail-columns{display:grid;grid-template-columns:minmax(0,1fr) 360px;gap:16px;align-items:start}
.refund-action-summary{position:sticky;top:18px;border:1px solid var(--line,#e4e7ec);border-radius:10px;background:#fff;padding:18px}
.refund-action-summary h2{font-size:18px;margin:0 0 10px}
.refund-action-summary dl{display:grid;grid-template-columns:110px minmax(0,1fr);gap:8px;margin:10px 0;font-size:13px}
.refund-action-summary dt{color:#667085}.refund-action-summary dd{margin:0;overflow-wrap:anywhere}
.refund-detail-header{align-items:flex-start}
.refund-detail-section{margin-top:14px}
body[data-payment-page="refunds"] .refund-list-table td:nth-child(6){text-align:right;font-variant-numeric:tabular-nums}
.package-config-layout{display:grid;grid-template-columns:minmax(0,1fr) minmax(300px,380px);gap:16px;align-items:start}
.package-preview-panel{position:sticky;top:16px}
.package-config-table input[type="number"]{width:120px;text-align:right}
@media(max-width:1100px){.refund-detail-columns,.package-config-layout{grid-template-columns:1fr}.refund-action-summary,.package-preview-panel{position:static}}
.refund-detail-columns{display:grid;grid-template-columns:minmax(0,1fr) 360px;gap:16px;align-items:start}
.refund-detail-main{display:grid;gap:14px;min-width:0}
.refund-detail-root .refund-action-summary{position:sticky;top:18px;align-self:start}
.refund-current-actions{display:grid;gap:10px;margin-top:14px}
.refund-current-actions .field{margin:0}
.refund-current-actions textarea{min-height:84px}
.refund-detail-main .payment-detail{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px 16px}
.package-history{margin-top:16px;border-top:1px solid var(--line,#e4e7ec);padding-top:12px}
.package-history summary{cursor:pointer;font-weight:650}
.package-history-entry{margin-top:12px;padding:12px;border:1px solid var(--line,#e4e7ec);border-radius:8px}
.package-history-entry ul{margin:8px 0 0;padding-left:20px;font-size:13px;line-height:1.6}
@media(max-width:1100px){.refund-detail-columns{grid-template-columns:1fr}.refund-detail-root .refund-action-summary{position:static}.refund-detail-main .payment-detail{grid-template-columns:1fr}}
