:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --text: #17202a;
  --muted: #68737f;
  --line: #d8dde3;
  --brand: #147a5b;
  --brand-strong: #0e5d45;
  --accent: #b85c1e;
  --danger: #b42318;
  --warning: #a15c00;
  --success: #147a5b;
  --radius: 6px;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { font-size: 14px; line-height: 1.5; letter-spacing: 0; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
a { color: var(--brand-strong); }

.hidden { display: none !important; }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #e8edf0; }
.auth-box { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; background: #101820; color: white; border-radius: 5px; font-weight: 800; }
.auth-box h1 { margin: 24px 0 6px; font-size: 24px; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 22px; }
.success { color: var(--success); }

.field { display: grid; gap: 6px; margin: 14px 0; }
.field label { color: #3c4650; font-weight: 600; }
input, select, textarea { width: 100%; border: 1px solid #bfc7d0; border-radius: 5px; background: white; color: var(--text); padding: 9px 10px; min-height: 38px; }
textarea { min-height: 100px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(20, 122, 91, .18); border-color: var(--brand); }
.compact-text { margin: 6px 0; }
.register-methods { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; margin: 14px 0 4px; padding: 3px; border-radius: var(--radius); background: var(--surface-2); }
.register-methods .btn { border-color: transparent; background: transparent; }
.register-methods .btn[aria-selected="true"] { border-color: var(--line); background: var(--surface); color: var(--brand-strong); }
.sms-field { display: grid; grid-template-columns: minmax(0, 1fr) 128px; gap: 8px; }
.sms-field .btn { width: 128px; padding-left: 8px; padding-right: 8px; }
.captcha-host { min-height: 1px; }
.checkline { display: flex; align-items: flex-start; gap: 8px; margin: 12px 0; color: #3c4650; cursor: pointer; }
.checkline input { width: 17px; height: 17px; min-height: 17px; flex: 0 0 17px; margin: 2px 0 0; padding: 0; }

.btn { border: 1px solid #aeb7c1; border-radius: 5px; background: white; color: #25313c; padding: 8px 12px; min-height: 36px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-weight: 600; }
.btn:hover { background: #f2f4f6; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: white; }
.btn-primary:hover { background: var(--brand-strong); }
.btn-danger { color: var(--danger); border-color: #e3aaa5; }
.btn-small { padding: 5px 9px; min-height: 30px; font-size: 12px; }
.btn-block { width: 100%; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 224px minmax(0, 1fr); }
.sidebar { background: #17202a; color: white; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { padding: 2px 8px 22px; }
.sidebar .brand small { display: block; color: #aeb9c4; font-weight: 400; }
.nav { display: grid; gap: 3px; }
.nav button { width: 100%; border: 0; background: transparent; color: #cbd3dc; text-align: left; border-radius: 5px; padding: 10px 12px; cursor: pointer; }
.nav button:hover, .nav button.active { color: white; background: #2b3743; }
.sidebar-bottom { margin-top: 26px; border-top: 1px solid #35414d; padding-top: 14px; }

.main { min-width: 0; }
.topbar { height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 18px; margin: 0; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.content { padding: 22px 24px 40px; max-width: 1600px; margin: 0 auto; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.section-head h2 { margin: 0; font-size: 20px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin: 12px 0; }
.toolbar input, .toolbar select { width: auto; min-width: 150px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat strong { display: block; font-size: 25px; margin-top: 5px; }
.stat span { color: var(--muted); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin: 14px 0; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 15px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; font-size: 15px; }
.panel-body { padding: 15px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
.split table { min-width: 520px; }
th, td { padding: 10px 12px; border-bottom: 1px solid #e6e9ed; text-align: left; vertical-align: top; }
th { background: #f6f7f9; color: #4d5863; font-size: 12px; text-transform: none; white-space: nowrap; }
tbody tr:hover { background: #fafbfc; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 2px 8px; font-size: 12px; background: #e8edf1; color: #3f4a55; white-space: nowrap; }
.badge.active, .badge.paid, .badge.published, .badge.success { background: #dff3e9; color: #0b684a; }
.badge.pending, .badge.draft { background: #fff0d5; color: #865000; }
.badge.requested, .badge.processing { background: #e7eef8; color: #285687; }
.badge.disabled, .badge.failed, .badge.cancelled, .badge.archived, .badge.rejected, .badge.reversed { background: #fde7e5; color: #9b251c; }
.mono { font-family: Consolas, "SFMono-Regular", monospace; font-size: 12px; overflow-wrap: anywhere; }
.empty { padding: 32px; text-align: center; color: var(--muted); }

dialog { width: min(620px, calc(100% - 28px)); max-height: calc(100vh - 48px); overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); padding: 0; }
dialog::backdrop { background: rgba(14, 23, 31, .55); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font-size: 17px; }
.dialog-body { padding: 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 16px; border-top: 1px solid var(--line); }
.icon-button { width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 5px; background: white; cursor: pointer; font-size: 20px; }

.toast { position: fixed; right: 20px; bottom: 20px; max-width: min(420px, calc(100% - 40px)); background: #17202a; color: white; border-radius: 6px; padding: 12px 14px; z-index: 50; }
.toast.bad { background: #8d221a; }
.loading { opacity: .55; pointer-events: none; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.form-grid .wide { grid-column: 1 / -1; }
.note { border-left: 3px solid var(--brand); background: #edf6f2; padding: 10px 12px; color: #345148; }
.warning { border-left-color: var(--warning); background: #fff7e7; color: #6f4b15; }

.profile-summary { display: flex; align-items: center; gap: 16px; padding: 16px; }
.profile-copy { display: grid; gap: 3px; min-width: 0; }
.profile-copy strong { font-size: 17px; }
.profile-actions { margin-left: auto; }
.avatar { position: relative; display: grid; place-items: center; flex: 0 0 auto; overflow: hidden; border: 1px solid #cbd2d9; border-radius: 50%; background: #e7ecef; color: #36434e; font-weight: 800; }
.avatar img { width: 100%; height: 100%; display: block; object-fit: cover; }
.avatar-large { width: 72px; height: 72px; font-size: 20px; }
.avatar-small { width: 40px; height: 40px; font-size: 12px; }
.avatar-preview { width: min(320px, 100%); aspect-ratio: 1; margin: 0 auto; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.avatar-preview img { width: 100%; height: 100%; display: block; object-fit: contain; }
.user-identity { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.user-identity > div:last-child, .user-detail-profile > div:last-child { display: grid; gap: 2px; min-width: 0; }
.user-identity span { display: block; font-size: 12px; }
.user-detail-profile { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.user-detail-profile strong { font-size: 17px; }

.portal-shell { min-height: 100vh; }
.portal-header { background: #17202a; color: white; }
.portal-header-inner { min-height: 66px; max-width: 1180px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.portal-nav { display: flex; gap: 4px; min-width: 0; overflow-x: auto; }
.portal-nav button { border: 0; background: transparent; color: #cbd3dc; padding: 9px 11px; cursor: pointer; white-space: nowrap; }
.portal-nav button.active { color: white; border-bottom: 2px solid #4bc394; }
.portal-main { max-width: 1180px; margin: 0 auto; padding: 24px 20px 44px; }
.membership { display: grid; grid-template-columns: 1.3fr .7fr; gap: 14px; }
.progress { height: 8px; background: #e3e7eb; border-radius: 4px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--brand); }
.plan-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.note + .plan-grid { margin-top: 12px; }
.plan { border: 1px solid var(--line); border-radius: var(--radius); padding: 15px; }
.plan strong { display: block; font-size: 18px; }
.price { font-size: 24px; margin: 8px 0; }
.wechat-payment { display: grid; grid-template-columns: 280px minmax(0, 1fr); align-items: center; gap: 24px; }
.wechat-qr { width: 280px; height: 280px; max-width: 100%; aspect-ratio: 1; object-fit: contain; border: 1px solid var(--line); }
.wechat-payment-details { min-width: 0; }
.payment-amount { margin: 0 0 8px; color: var(--brand-strong); font-size: 28px; font-weight: 700; }
.payment-status { color: var(--warning); font-weight: 700; }
.announcement { border-bottom: 1px solid var(--line); padding: 14px 0; }
.announcement:last-child { border-bottom: 0; }
.announcement h3 { margin: 0 0 5px; font-size: 16px; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { height: auto; position: static; padding: 10px; }
  .sidebar .brand, .sidebar-bottom { display: none; }
  .nav { display: flex; overflow-x: auto; }
  .nav button { width: auto; white-space: nowrap; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .split, .membership { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .auth-shell { padding: 10px; }
  .auth-box { padding: 22px 14px; }
  .topbar { padding: 0 14px; }
  .content, .portal-main { padding: 16px 12px 32px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat { padding: 12px; }
  .stat strong { font-size: 20px; }
  .form-grid, .plan-grid { grid-template-columns: 1fr; }
  .wechat-payment { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .form-grid .wide { grid-column: auto; }
  .portal-header-inner { align-items: flex-start; flex-direction: column; padding: 12px; }
  .portal-nav { width: 100%; overflow-x: auto; }
  .section-head { flex-direction: column; }
  .sms-field { grid-template-columns: 1fr; }
  .sms-field .btn { width: 100%; }
  .profile-summary { align-items: flex-start; flex-wrap: wrap; }
  .profile-copy { flex: 1 1 calc(100% - 90px); }
  .profile-actions { width: 100%; margin-left: 0; }
}
