:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface-soft: #edf3f1;
  --line: #d4dfdc;
  --line-strong: #bdcbc7;
  --text: #172522;
  --muted: #65736f;
  --green: #0f6b57;
  --green-dark: #0a5142;
  --blue: #315d96;
  --amber: #9a6815;
  --red: #a53c3c;
  --shadow: 0 12px 34px rgba(19, 43, 36, .08);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; color: var(--text); background: var(--bg); font-size: 14px; letter-spacing: 0; }
button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .52; }
[hidden] { display: none !important; }

.site-header { height: 64px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); position: sticky; top: 0; z-index: 20; }
.header-inner { width: min(1144px, calc(100% - 40px)); height: 100%; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; }
.brand { color: var(--text); text-decoration: none; display: inline-flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 750; }
.brand svg { width: 21px; color: var(--green); }
.user-menu { display: flex; align-items: center; gap: 10px; color: var(--muted); }

main { width: min(1144px, calc(100% - 40px)); margin: 0 auto; padding: 32px 0 64px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 25px; line-height: 1.25; }
h2 { margin: 0; font-size: 18px; }
h3 { font-size: 15px; }
.eyebrow { margin-bottom: 7px; color: var(--green); font-size: 11px; font-weight: 800; text-transform: uppercase; }

.auth-band { min-height: calc(100vh - 160px); display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 72px; align-items: center; }
.auth-copy { align-self: center; }
.auth-copy h1 { font-size: 36px; margin-bottom: 16px; }
.auth-copy p:last-child { color: var(--muted); font-size: 16px; }
.auth-band form { border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); padding: 28px; border-radius: 8px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 24px; border-bottom: 1px solid var(--line); }
.auth-tabs button { min-height: 42px; border: 0; border-bottom: 2px solid transparent; color: var(--muted); background: transparent; }
.auth-tabs button.selected { border-bottom-color: var(--green); color: var(--green); font-weight: 700; }

label { display: grid; gap: 7px; margin-bottom: 16px; color: #34423e; font-weight: 650; }
label small { color: var(--muted); font-weight: 400; line-height: 1.5; }
input, select { width: 100%; min-height: 42px; border: 1px solid var(--line-strong); border-radius: 6px; padding: 9px 11px; color: var(--text); background: var(--surface); outline: none; }
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(15,107,87,.12); }
.password-wrap { position: relative; display: block; }
.password-wrap input { padding-right: 46px; }
.password-wrap .icon-button { position: absolute; right: 4px; top: 4px; }

button.primary, button.secondary, button.danger, .link-button { min-height: 40px; border-radius: 6px; padding: 8px 13px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; white-space: nowrap; }
button svg { width: 17px; height: 17px; }
button.primary { border: 1px solid var(--green); color: #fff; background: var(--green); }
button.primary:hover:not(:disabled) { background: var(--green-dark); }
button.secondary { border: 1px solid var(--line-strong); color: var(--text); background: var(--surface); }
button.secondary:hover:not(:disabled) { border-color: var(--green); color: var(--green); }
button.danger { border: 1px solid #d8aaaa; color: var(--red); background: #fff7f7; }
.full { width: 100%; }
.icon-button { width: 40px; height: 40px; padding: 0; border: 1px solid transparent; border-radius: 6px; display: inline-grid; place-items: center; color: var(--muted); background: transparent; }
.icon-button:hover { color: var(--green); background: var(--surface-soft); }
.link-button { border: 0; padding: 4px 8px; min-height: 32px; color: var(--green); background: transparent; font-weight: 700; }

.workspace-heading { min-height: 74px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.heading-actions { display: flex; gap: 8px; }
.page-message, .form-message { margin: 14px 0 0; padding: 10px 12px; border: 1px solid #b8d9d0; border-radius: 6px; color: var(--green-dark); background: #f0faf7; }
.page-message.error, .form-message.error { border-color: #e3baba; color: var(--red); background: #fff5f5; }

.balances { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); margin: 22px 0; border-block: 1px solid var(--line); }
.balances > div { min-height: 105px; padding: 20px 26px; border-right: 1px solid var(--line); }
.balances > div:first-child { padding-left: 0; }
.balances > div:last-child { border-right: 0; }
.balances dt { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.balances dt svg { width: 15px; color: var(--green); }
.balances dd { margin: 8px 0 2px; color: var(--green); font-size: 30px; line-height: 1; font-weight: 780; font-variant-numeric: tabular-nums; }
.balances dd span { margin-left: 5px; color: var(--muted); font-size: 12px; font-weight: 500; }
.balances > div:nth-child(2) dd { color: var(--blue); }
.balances small { color: var(--muted); }

.service-tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); }
.service-tabs button { min-height: 48px; padding: 0 14px; border: 0; border-bottom: 2px solid transparent; display: inline-flex; align-items: center; gap: 7px; color: var(--muted); background: transparent; }
.service-tabs button.selected { border-bottom-color: var(--blue); color: var(--blue); font-weight: 750; }
.toolbar { padding: 20px 0 14px; display: grid; grid-template-columns: minmax(220px, 320px) 40px 1fr; gap: 8px; align-items: center; }
.toolbar > button:last-child { justify-self: end; }
.search { position: relative; margin: 0; }
.search svg { position: absolute; top: 12px; left: 11px; width: 17px; color: #81908c; }
.search input { padding-left: 36px; }

.data-section { border-top: 1px solid var(--line); padding-top: 14px; }
.section-heading { min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-heading h2 span { color: var(--muted); font-size: 12px; font-weight: 500; }
.section-heading select { width: 128px; min-height: 36px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th, td { padding: 13px 11px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); background: var(--surface-soft); font-size: 12px; font-weight: 650; }
th:first-child, td:first-child { width: 27%; }
th:last-child, td:last-child { width: 25%; }
.right { text-align: right; }
.account-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.account-icon { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; border-radius: 6px; color: var(--green); background: #e4f2ee; }
.account-icon.douyin { color: var(--blue); background: #e8eef7; }
.account-icon svg { width: 17px; }
.account-info strong, .account-info span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub { margin-top: 3px; color: var(--muted); font-size: 12px; }
.status { display: inline-flex; align-items: center; gap: 6px; color: var(--green); font-size: 12px; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.warn { color: var(--amber); }
.status.error { color: var(--red); }
.actions { display: flex; justify-content: flex-end; gap: 7px; flex-wrap: wrap; }
.actions button { min-height: 34px; padding: 6px 10px; }
.history-section { margin-top: 42px; }
.job-progress { min-width: 110px; }
.progress-bar { width: 100%; height: 5px; margin-top: 6px; overflow: hidden; border-radius: 3px; background: #dce5e2; }
.progress-bar span { display: block; height: 100%; background: var(--green); }
.empty { min-height: 190px; display: grid; place-items: center; align-content: center; gap: 8px; color: var(--muted); border-bottom: 1px solid var(--line); }
.empty svg { width: 30px; }
.empty h2 { font-size: 15px; }
.empty.compact { min-height: 90px; }

dialog { width: min(480px, calc(100% - 28px)); max-height: calc(100vh - 40px); overflow: auto; padding: 22px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); background: var(--surface); box-shadow: 0 24px 70px rgba(16,35,30,.22); }
dialog::backdrop { background: rgba(20,35,31,.38); }
.dialog-heading { min-height: 42px; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.dialog-heading .close { margin-top: -8px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.recharge-history { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 16px; }
.recharge-history ul { margin: 0; padding: 0; list-style: none; }
.recharge-history li { padding: 9px 0; display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); }
.recharge-history li small { display: block; color: var(--muted); }
.platform-choice { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.platform-choice label { position: relative; min-width: 0; margin: 0; }
.platform-choice input { position: absolute; width: 1px; height: 1px; min-height: 0; margin: 0; padding: 0; border: 0; clip-path: inset(50%); overflow: hidden; }
.platform-choice span { min-height: 48px; border: 1px solid var(--line-strong); border-radius: 6px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.platform-choice input:checked + span { border-color: var(--green); color: var(--green); background: #eef8f5; box-shadow: inset 0 0 0 1px var(--green); }
.platform-choice input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }
.qr-stage { width: min(240px, 100%); aspect-ratio: 1; margin: 20px auto 12px; display: grid; place-items: center; border: 1px solid var(--line); background: #fff; }
.qr-stage img { width: 100%; height: 100%; object-fit: contain; }
.qr-placeholder { padding: 20px; display: grid; place-items: center; gap: 10px; color: var(--muted); text-align: center; }
.qr-placeholder svg { width: 42px; height: 42px; }
.binding-status { min-height: 22px; overflow-wrap: anywhere; color: var(--muted); text-align: center; }
.verification-form { grid-template-columns: 1fr auto; align-items: end; gap: 8px; }
.verification-form label { margin: 0; }
.submit-summary { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 1px; margin: 0 0 18px; background: var(--line); }
.submit-summary div { padding: 12px; background: var(--surface-soft); }
.submit-summary dt { color: var(--muted); font-size: 11px; }
.submit-summary dd { margin: 5px 0 0; font-weight: 750; overflow-wrap: anywhere; }
.admin-dialog { width: min(840px, calc(100% - 28px)); }
.admin-form { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 10px; align-items: end; }
.admin-form label { margin: 0; }
.issued { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 12px; }
.issued pre { max-height: 220px; overflow: auto; padding: 12px; border: 1px solid var(--line); background: var(--surface-soft); user-select: all; }
.admin-cards { margin-top: 20px; max-height: 300px; }
.admin-cards th:first-child, .admin-cards td:first-child, .admin-cards th:last-child, .admin-cards td:last-child { width: auto; }
.admin-pending { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }
.admin-pending th:first-child, .admin-pending td:first-child, .admin-pending th:last-child, .admin-pending td:last-child { width: auto; }

@media (max-width: 760px) {
  .site-header { height: 56px; }
  .header-inner, main { width: min(100% - 24px, 1144px); }
  main { padding-top: 20px; }
  .auth-band { min-height: auto; grid-template-columns: 1fr; gap: 22px; padding: 24px 0; }
  .auth-copy h1 { font-size: 28px; }
  .auth-band form { padding: 20px; }
  .workspace-heading { align-items: flex-start; padding-bottom: 14px; }
  .heading-actions { flex-direction: column-reverse; align-items: stretch; }
  .balances { grid-template-columns: 1fr; }
  .balances > div { min-height: 86px; padding: 15px 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .balances > div:last-child { border-bottom: 0; }
  .balances dd { font-size: 25px; }
  .service-tabs button { flex: 1; justify-content: center; padding-inline: 8px; }
  .toolbar { grid-template-columns: minmax(0,1fr) 40px; }
  .toolbar > button:last-child { grid-column: 1 / -1; width: 100%; }
  table { min-width: 720px; }
  .history-section { margin-top: 30px; }
  .submit-summary { grid-template-columns: 1fr; }
  .admin-form { grid-template-columns: 1fr 1fr; }
  .admin-form button { grid-column: 1 / -1; }
}

@media (max-width: 430px) {
  .user-menu #username { display: none; }
  .workspace-heading { display: grid; }
  .heading-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .service-tabs button { font-size: 13px; }
  dialog { padding: 17px; }
  .qr-stage { width: min(220px, 100%); }
  .admin-form { grid-template-columns: 1fr; }
}
