/* ============================================================
   API 管理与充值系统 - Stylesheet
   Minimalist / Apple·Linear · Neutral Monochrome
   ============================================================ */

/* ============================================================
   1. Design Tokens
   ============================================================ */
:root {
  /* Colors - surfaces */
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-muted: #fafafa;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;

  /* Colors - text */
  --text: #18181b;
  --text-muted: #71717a;
  --text-light: #a1a1a1;

  /* Colors - brand */
  --brand: #18181b;
  --brand-subtle: #f4f4f5;
  --brand-border: #d4d4d8;

  /* Colors - primary */
  --primary: #18181b;
  --primary-fg: #fafafa;

  /* Colors - status */
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --success-text: #15803d;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-text: #b91c1c;
  --danger-subtle: #2a1416;
  --warning: #d97706;
  --warning-bg: #fffbeb;

  /* Radius - 整体比例缩小 */
  --r-xs: 5px;
  --r-sm: 7px;
  --r-md: 10px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-pill: 999px;

  /* Shadows */
  --shadow-xs: 0 1px 0px rgba(0,0,0,.04);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05), 0 1px 1px rgba(0,0,0,.03);
  --shadow: 0 2px 4px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.03);
  --shadow-md: 0 4px 8px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg: 0 12px 20px rgba(0,0,0,.08), 0 4px 8px rgba(0,0,0,.04);
  --shadow-xl: 0 24px 40px rgba(0,0,0,.10), 0 8px 16px rgba(0,0,0,.06);

  /* Layout - 整体比例缩小 */
  --maxw: 460px;
  --topbar-h: 46px;
  --tabbar-h: 54px;
  --ease: cubic-bezier(.4,0,.2,1);

  /* Font */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;

  /* ---- Backward-compatible aliases (legacy variable names) ---- */
  --card: var(--surface);
  --line: var(--border);
  --line-strong: var(--border-strong);
  --text-sub: var(--text-muted);
  --text-mute: var(--text-light);
  --accent: var(--brand);
  --accent-2: var(--brand-subtle);
  --warn: var(--warning);
}

/* ============================================================
   2. Reset & Base
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html, body {
  margin: 0;
  padding: 0;
  /* 锁定缩放：禁止双击放大（iOS Safari 10+ 忽略 user-scalable=no，需 touch-action 兜底） */
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  /* 适配 iPhone 6 - 17 Pro / 安卓全面屏：安全区 + 禁止横屏字体缩放 */
  text-rendering: optimizeLegibility;
  -webkit-touch-callout: none;
  overscroll-behavior-y: none; /* 禁止下拉刷新 */
  word-wrap: break-word;
  overflow-wrap: break-word;
}
/* 输入框/按钮不触发 iOS 放大（>=16px 字体不放大） */
input, button, select, textarea {
  font-family: inherit;
  font-size: 16px;
  color: inherit;
}
a {
  color: inherit;
  text-decoration: none;
}
img {
  max-width: 100%;
}

/* ============================================================
   3. Top Bar
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(245,245,247,.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0,0,0,.06);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  height: var(--topbar-h);
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.topbar .tb-title {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -.01em;
}
.topbar .tb-back {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  color: var(--brand);
  cursor: pointer;
  font-weight: 500;
  background: none;
  border: none;
  padding: 0;
}
.topbar .tb-back:active { opacity: .5; }

/* ============================================================
   4. Impersonate Bar
   ============================================================ */
.impersonate-bar {
  position: sticky;
  top: var(--topbar-h);
  z-index: 39;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--warning-bg);
  border-bottom: 1px solid rgba(217,119,6,.25);
  padding: 7px 14px;
  font-size: 12px;
  color: var(--warning);
  max-width: var(--maxw);
  margin: 0 auto;
}
.impersonate-bar .ib-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  line-height: 1.4;
}
.impersonate-bar .ib-info b { color: #9a5b06; }
.impersonate-bar .ib-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  flex-shrink: 0;
  animation: ibpulse 1.6s ease-in-out infinite;
}
@keyframes ibpulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}
.impersonate-bar .ib-btn {
  border: 1px solid rgba(217,119,6,.4);
  background: var(--warning);
  color: #fff;
  border-radius: var(--r-sm);
  padding: 6px 10px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: transform .08s var(--ease);
}
.impersonate-bar .ib-btn:active { transform: scale(.95); }

/* ============================================================
   5. Main Container
   ============================================================ */
.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 14px 14px 6px;
}

/* ============================================================
   6. Cards & Hero
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 13px 13px;
  margin-bottom: 11px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin: 0 0 11px;
}
.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-top: 1px solid var(--border);
}
.card-row:first-of-type { border-top: 0; }
.card-row .k {
  color: var(--text-muted);
  font-size: 13px;
}
.card-row .v {
  font-weight: 600;
  font-size: 13px;
  text-align: right;
  word-break: break-all;
}

/* Hero - large balance/overview card */
.hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 18px 16px;
  margin-bottom: 11px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.hero .hero-label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: .04em;
  font-weight: 500;
}
.hero .hero-val {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -.025em;
  margin-top: 5px;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.hero .hero-val .unit {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 5px;
}
.hero .hero-sub {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.hero .avatar {
  position: absolute;
  right: 16px;
  top: 16px;
  width: 38px;
  height: 38px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  object-fit: cover;
  background: #eee;
  box-shadow: var(--shadow-sm);
}
.hero-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}
.hero-grid .mini {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 10px;
  background: var(--surface);
}
.hero-grid .mini .k {
  font-size: 10px;
  color: var(--text-muted);
}
.hero-grid .mini .v {
  font-size: 17px;
  font-weight: 700;
  margin-top: 3px;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   7. Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  padding: 9px 13px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: transform .08s var(--ease), background .18s var(--ease),
              box-shadow .18s var(--ease), border-color .18s var(--ease);
  -webkit-appearance: none;
  appearance: none;
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: var(--primary-fg);
  border-color: var(--primary);
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
}
.btn-primary:active { background: #000; transform: scale(.97); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

.btn-danger {
  border-color: rgba(220,38,38,.3);
  color: var(--danger);
  background: var(--danger-bg);
}
.btn-danger:active { background: rgba(220,38,38,.12); }

.btn-sm { padding: 7px 10px; font-size: 12px; }
.btn-block { display: flex; width: 100%; }

/* ============================================================
   8. Quick Actions Grid
   ============================================================ */
.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 11px;
}
.action {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 13px 13px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: transform .08s var(--ease), box-shadow .18s var(--ease);
  box-shadow: var(--shadow);
}
.action:active { transform: scale(.98); box-shadow: var(--shadow-sm); }
.action .ic {
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  background: var(--brand-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}
.action .ic svg { width: 17px; height: 17px; }
.action .t { font-weight: 600; font-size: 13px; }
.action .d { font-size: 11px; color: var(--text-muted); }

/* ============================================================
   9. Forms
   ============================================================ */
.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.field .hint {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 5px;
}
/* 验证码行：输入框 + 获取按钮并排 */
.code-row { display: flex; gap: 7px; align-items: stretch; }
.code-row .input { flex: 1; }
.code-row .btn-code {
  flex-shrink: 0;
  min-width: 100px;
  padding: 0 10px;
  font-size: 12px;
  white-space: nowrap;
}
.code-row .btn-code:disabled { opacity: .55; cursor: not-allowed; }
.input, .select, .textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 10px 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease),
              background .18s var(--ease);
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(24,24,27,.08);
  background: var(--surface);
}
.textarea {
  resize: vertical;
  min-height: 78px;
  font-family: inherit;
}
.pwd-field { position: relative; }
.pwd-field .pwd-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-light);
  padding: 6px;
  display: flex;
  align-items: center;
}

/* ============================================================
   10. Amount Grid
   ============================================================ */
.amount-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}
.amount-grid .amt {
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 11px 4px;
  text-align: center;
  cursor: pointer;
  background: var(--surface);
  font-weight: 700;
  font-size: 14px;
  transition: transform .08s var(--ease), background .18s var(--ease),
              border-color .18s var(--ease), color .18s var(--ease);
  font-variant-numeric: tabular-nums;
}
.amount-grid .amt:active { transform: scale(.97); }
.amount-grid .amt.active {
  background: var(--brand);
  color: var(--primary-fg);
  border-color: var(--brand);
}

/* ============================================================
   11. Payment (pay-list, pay-row)
   ============================================================ */
.pay-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 11px;
}
.pay-grid .pay {
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 11px 4px;
  text-align: center;
  cursor: pointer;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  transition: transform .08s var(--ease), border-color .18s var(--ease),
              background .18s var(--ease);
}
.pay-grid .pay:active { transform: scale(.97); }
.pay-grid .pay.active {
  border-color: var(--brand);
  border-width: 2px;
  background: rgba(24,24,27,.03);
}
.pay-grid .pay .pn { font-size: 12px; color: var(--text-muted); }
.pay-grid .pay.active .pn { color: var(--text); font-weight: 600; }
.pay-grid .pay[disabled] { opacity: .4; cursor: not-allowed; }

/* Brand payment rows */
.pay-grid-2 { grid-template-columns: 1fr 1fr; gap: 8px; }
.pay-grid .pay-brand {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 11px 12px;
  text-align: left;
}
.pay-grid .pay-brand .pay-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.3;
}
.pay-grid .pay-brand .pn { font-size: 13px; font-weight: 600; color: var(--text); }
.pay-grid .pay-brand .pd { font-size: 10px; color: var(--text-light); }
.pay-grid .pay-brand svg { flex-shrink: 0; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.pay-grid .pay-brand.active {
  border-color: var(--brand);
  background: rgba(24,24,27,.03);
}

/* Full-width payment rows */
.pay-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 11px;
}
.pay-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  min-height: 50px;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r-md);
  cursor: pointer;
  user-select: none;
  transition: border-color .18s var(--ease), background .18s var(--ease),
              transform .08s var(--ease);
}
.pay-row:active { transform: scale(.99); }
.pay-row.active {
  border-color: var(--brand);
  background: rgba(24,24,27,.025);
}
.pay-logo-wrap {
  width: 34px;
  height: 34px;
  border-radius: var(--r-md);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pay-logo-alipay { background: rgba(22,119,255,.08); }
.pay-logo-wechat { background: rgba(7,193,96,.08); }
.pay-logo-wrap svg { width: 22px; height: 22px; display: block; }
.pay-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  line-height: 1.3;
  min-width: 0;
}
.pay-name { font-size: 14px; font-weight: 600; color: var(--text); }
.pay-desc { font-size: 10.5px; color: var(--text-light); }
.pay-check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid var(--border-strong);
  background: var(--surface);
  transition: background .18s var(--ease), border-color .18s var(--ease);
  position: relative;
}
.pay-row.active .pay-check {
  background: var(--brand);
  border-color: var(--brand);
}
.pay-row.active .pay-check::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid var(--primary-fg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ============================================================
   12. Tags
   ============================================================ */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 600;
  background: var(--brand-subtle);
  color: var(--text-muted);
}
.tag-success { background: var(--success-bg); color: var(--success-text); }
.tag-warn { background: var(--warning-bg); color: var(--warning); }
.tag-danger { background: var(--danger-bg); color: var(--danger-text); }
.tag-mute { background: var(--brand-subtle); color: var(--text-muted); }
.tag-fill { background: var(--brand); color: var(--primary-fg); }

/* ============================================================
   13. List Items
   ============================================================ */
.list-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 13px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .18s var(--ease);
}
.list-item:active { box-shadow: var(--shadow); }
.list-item .li-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}
.list-item .li-head .no {
  font-weight: 600;
  font-size: 13px;
  word-break: break-all;
}
.list-item .li-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
}
.list-item .li-meta .amt {
  font-weight: 700;
  color: var(--text);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.empty {
  text-align: center;
  padding: 40px 14px;
  color: var(--text-light);
  font-size: 13px;
}

/* ============================================================
   14. API Key Box & Key Card
   ============================================================ */
.key-box {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 9px 10px;
  background: var(--bg);
}
.key-box .kv {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 12px;
  word-break: break-all;
  color: var(--text);
}
.key-box .kv.empty { color: var(--text-light); font-family: inherit; }
.copy-btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--r-sm);
  padding: 6px 9px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  transition: transform .08s var(--ease), background .18s var(--ease);
}
.copy-btn:active { transform: scale(.94); background: var(--brand-subtle); }
.copy-btn.sm { padding: 4px 8px; font-size: 10px; }

/* Compact API Key card */
.key-card { padding: 11px 13px; }
.key-line { display: flex; align-items: center; gap: 9px; min-width: 0; }
.key-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
  letter-spacing: .02em;
}
.key-val {
  flex: 1;
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  min-width: 0;
}
.key-val.empty { color: var(--text-light); font-family: inherit; }
.key-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid var(--border);
}
.key-doc-link {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}
.key-doc-link:active { opacity: .5; }

/* Monospace utility */
.mono {
  font-family: var(--font-mono);
  font-size: 11px;
  word-break: break-all;
}

/* ============================================================
   15. Tab Bar
   ============================================================ */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  background: rgba(255,255,255,.82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--border);
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.tabbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  height: var(--tabbar-h);
}
.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-light);
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  transition: color .18s var(--ease);
}
.tabbar a.active { color: var(--text); font-weight: 600; }
.tabbar a svg { width: 20px; height: 20px; }

/* ============================================================
   16. Toast
   ============================================================ */
#toast-wrap {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
  pointer-events: none;
  width: 80%;
  max-width: 300px;
}
#toast-wrap .toast {
  background: rgba(24,24,27,.92);
  color: #fff;
  border-radius: var(--r-md);
  padding: 11px 15px;
  font-size: 13px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0,0,0,.25);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  animation: toastIn .2s var(--ease);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
#toast-wrap .toast.err { background: rgba(220,38,38,.95); }
#toast-wrap .toast.ok { background: rgba(22,163,74,.95); }
@keyframes toastIn {
  from { opacity: 0; transform: scale(.92); }
  to { opacity: 1; transform: scale(1); }
}

/* ============================================================
   17. Loading & Spinner
   ============================================================ */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
  padding: 30px 0;
}
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   18. Auth / Login
   ============================================================ */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 14px;
}
.auth-card { width: 100%; max-width: var(--maxw); }
.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.01em;
  margin: 0 0 5px;
}
.brand img {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  object-fit: cover;
  background: #eee;
  box-shadow: var(--shadow-sm);
}
.auth-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 18px;
}
.auth-tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 15px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 3px;
  background: var(--surface);
}
.auth-tabs button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px;
  border-radius: var(--r-pill);
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-muted);
  transition: background .18s var(--ease), color .18s var(--ease);
}
.auth-tabs button.active { background: var(--brand); color: var(--primary-fg); }
.auth-foot { text-align: center; margin-top: 14px; }
.auth-foot a { color: var(--text-muted); font-size: 12px; }
.opt-row { display: flex; gap: 14px; margin: 4px 0 11px; }
.opt-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
}

/* ============================================================
   19. Notes & Divider
   ============================================================ */
.note {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface);
  margin-bottom: 11px;
  line-height: 1.55;
  box-shadow: var(--shadow-sm);
}
.note b { color: var(--text); }
.divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

/* ============================================================
   20. Modal System
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: modalFadeIn .2s var(--ease);
}
.modal {
  position: relative;
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: modalScaleIn .25s var(--ease);
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
.modal-sm { max-width: 400px; }
.modal-md { max-width: 520px; }
.modal-lg { max-width: 680px; }
.modal-full { max-width: calc(100vw - 32px); width: calc(100vw - 32px); max-height: calc(100vh - 80px); }

/* JS-created modal-box alias */
.modal-box {
  position: relative;
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: modalScaleIn .25s var(--ease);
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 0;
  flex-shrink: 0;
}
.modal-head .modal-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--text);
}
.modal-body {
  padding: 14px 18px 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
}
.modal-close {
  width: 28px;
  height: 28px;
  border-radius: var(--r-xs);
  border: none;
  background: var(--bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  transition: background .15s var(--ease), transform .08s var(--ease);
}
.modal-close:hover { background: var(--border-strong); }
.modal-close:active { transform: scale(.92); }

/* Confirm dialog (styled modal variant) */
.confirm-dialog .modal-body { padding-bottom: 18px; }
.confirm-dialog .confirm-msg {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-muted);
  margin-bottom: 18px;
}
.confirm-dialog .confirm-btns {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(.92); }
  to { opacity: 1; transform: scale(1); }
}

/* Mobile: modal slides up as bottom sheet */
@media (max-width: 767px) {
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal, .modal-box {
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    max-width: 100%;
    width: 100%;
    max-height: 90vh;
    animation: modalSlideUp .25s var(--ease);
  }
}
@keyframes modalSlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* ============================================================
   21. Drawer System
   ============================================================ */
.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
}
.drawer-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.3);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: modalFadeIn .2s var(--ease);
}

/* Legacy full-screen drawer (used by admin.php / order.php inline drawers) */
.drawer {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: drawerIn .22s var(--ease);
}
@keyframes drawerIn {
  from { opacity: 0; transform: translateX(8px); }
  to { opacity: 1; transform: translateX(0); }
}
.drawer-head {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(245,245,247,.82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 14px;
  height: 46px;
}
.drawer-head .tb-back {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  color: var(--brand);
  cursor: pointer;
  font-weight: 500;
}
.drawer-head .tb-back:active { opacity: .5; }
.drawer-head .tb-title { font-weight: 600; font-size: 15px; }
.drawer-body {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 14px;
}

/* JS drawer panel (app.js openDrawer) */
.drawer-panel {
  position: relative;
  background: var(--surface);
  display: flex;
  flex-direction: column;
}

/* Drawer keyframe animations (used by app.js) */
@keyframes drawerSlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
@keyframes drawerSlideRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

/* ============================================================
   22. Segmented Control
   ============================================================ */
.seg {
  display: flex;
  gap: 4px;
  background: var(--brand-subtle);
  border-radius: var(--r-md);
  padding: 3px;
  margin-bottom: 12px;
}
.seg button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 9px 6px;
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-muted);
  transition: background .15s var(--ease), color .15s var(--ease);
}
.seg button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   23. Admin Backend
   ============================================================ */
.admin-wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 14px 16px calc(var(--tabbar-h) + 24px);
}

/* Stat grid */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.stat-cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 14px;
  box-shadow: var(--shadow-sm);
}
.stat-cell .sk {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}
.stat-cell .sv {
  font-size: 22px;
  font-weight: 700;
  margin-top: 4px;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
}
.stat-cell .sv.small { font-size: 17px; }
.stat-cell .ssub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.4;
}
.stat-cell .ssub b { color: var(--text); font-weight: 600; }

/* Admin table */
.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 560px;
}
.admin-table th, .admin-table td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.admin-table th {
  background: var(--bg);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  position: sticky;
  top: 0;
}
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table tr:active { background: var(--brand-subtle); }
.admin-table .mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

/* Row action buttons */
.row-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.row-btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--r-sm);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  transition: transform .08s var(--ease), background .18s var(--ease);
}
.row-btn:active { transform: scale(.94); background: var(--brand-subtle); }
.row-btn.danger { color: var(--danger); border-color: rgba(220,38,38,.3); }
.row-btn.primary { background: var(--brand); color: var(--primary-fg); border-color: var(--brand); }

/* Search bar */
.search-bar { display: flex; gap: 8px; margin-bottom: 12px; }
.search-bar .input { flex: 1; }

/* Pagination */
.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-muted);
}
.pager button {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--r-sm);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.pager button[disabled] { opacity: .4; cursor: not-allowed; }

/* ============================================================
   24. Switch (iOS-style toggle)
   ============================================================ */
.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border-strong);
  border-radius: var(--r-pill);
  transition: background .2s var(--ease);
}
.switch .slider::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s var(--ease);
  box-shadow: var(--shadow-sm);
}
.switch input:checked + .slider { background: var(--success); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ============================================================
   25. Settings
   ============================================================ */
.set-group { margin-bottom: 18px; }
.set-group-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 0 0 10px 4px;
}
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.switch-row:first-of-type { border-top: 0; }
.switch-row .sr-label { font-size: 14px; font-weight: 600; }
.switch-row .sr-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* 设置页：竖排表格填写样式（保底卡片已统一为白色） */
.set-card .card-title { margin-bottom: 8px; }
.set-table { display: flex; flex-direction: column; }
.set-tr {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.set-tr:first-of-type { border-top: 0; }
.set-td-label {
  flex: 0 0 230px;
  max-width: 230px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
}
.set-td-input { flex: 1; min-width: 0; }
.set-td-input .input { padding: 10px 12px; font-size: 14px; }
.set-td-input .switch { flex-shrink: 0; }
@media (max-width: 640px) {
  .set-tr { flex-direction: column; align-items: stretch; gap: 6px; padding: 10px 0; }
  .set-td-label { flex: none; max-width: none; font-size: 13px; }
}

/* 用户管理：头像 + 昵称单元格 */
.u-cell { display: flex; align-items: center; gap: 10px; }
.u-avatar {
  width: 34px; height: 34px; border-radius: var(--r-md);
  object-fit: cover; border: 1px solid var(--border); flex-shrink: 0;
}
.u-nick { font-weight: 600; font-size: 14px; color: var(--text); }
.u-nick-empty { color: var(--text-light); font-weight: 400; font-size: 13px; }

/* 用户编辑抽屉 / 个人页：头像 + 昵称头部 */
.u-profile-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 4px 0 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.u-profile-avatar {
  width: 60px; height: 60px; border-radius: var(--r-lg);
  object-fit: cover; border: 1.5px solid var(--border); flex-shrink: 0;
}
.u-profile-info { flex: 1; min-width: 0; }
.u-profile-nick { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.u-profile-qq { font-size: 13px; color: var(--text-muted); margin-bottom: 2px; }
.u-profile-meta { font-size: 12px; color: var(--text-light); }

/* Hero 昵称 */
.hero-nick {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}
.hero-nick:empty { display: none; }

/* API 调用分类统计条 */
.type-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}
.type-row:first-of-type { border-top: 0; }
.type-name { flex: 0 0 120px; font-size: 13px; font-weight: 600; color: var(--text); }
.type-bar-wrap { flex: 1; height: 8px; background: var(--surface-muted); border-radius: 999px; overflow: hidden; }
.type-bar { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s var(--ease); }
.type-count { flex: 0 0 70px; text-align: right; font-size: 13px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.type-rate { flex: 0 0 56px; text-align: right; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .type-name { flex: 0 0 90px; font-size: 12px; }
  .type-count { flex: 0 0 56px; font-size: 12px; }
  .type-rate { flex: 0 0 44px; }
}

/* ============================================================
   26. Filter Banner
   ============================================================ */
.filter-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--brand-subtle);
  border: 1px solid var(--brand-border);
  border-radius: var(--r-md);
  padding: 9px 14px;
  margin-bottom: 12px;
  font-size: 13px;
}
.filter-banner .fb-text { color: var(--text); }
.filter-banner .fb-text b { color: var(--brand); }
.filter-banner .fb-clear {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--r-md);
}
.filter-banner .fb-clear:hover { background: var(--danger-bg); }

/* ============================================================
   27. My Logs (responsive: mobile cards / desktop table)
   ============================================================ */
.mylogs-cards { display: flex; flex-direction: column; gap: 10px; }
.mylogs-table { display: block; }
.log-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}
.log-card .lc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.log-card .lc-type { font-weight: 600; font-size: 14px; }
.log-card .lc-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.log-card .lc-meta span { font-variant-numeric: tabular-nums; }

/* Desktop: show table, hide cards */
@media (min-width: 768px) {
  .mylogs-cards { display: none; }
}
/* Mobile: hide table, show cards */
@media (max-width: 767px) {
  .mylogs-table { display: none; }
}

/* ============================================================
   28. Code Block
   ============================================================ */
pre.code {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: #18181b;
  color: #e8e8e8;
  padding: 14px;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.6;
  font-family: var(--font-mono);
  box-shadow: var(--shadow);
}
pre.code .cmt { color: #7a7a7a; }
pre.code.code-ok { border-color: rgba(22,163,74,.4); background: #16261c; }
pre.code.code-err { border-color: rgba(220,38,38,.4); background: var(--danger-subtle); }

/* ============================================================
   29. Documentation
   ============================================================ */
.doc-head h1 { font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin-bottom: 4px; }
.doc-head p { font-size: 13px; color: var(--text-muted); margin: 0; }
.doc-h2 { font-size: 17px; font-weight: 700; margin: 22px 0 10px; letter-spacing: -.01em; }
.doc-p { color: var(--text-muted); font-size: 14px; margin: 8px 0; }
.doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 10px 0;
}
.doc-table th, .doc-table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
}
.doc-table th { background: var(--bg); font-weight: 600; }

/* API doc key bar */
.doc-keybar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin: 14px 0;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.doc-keybar .dk {
  display: inline-block;
  font-size: 11px;
  color: var(--text-light);
  margin-right: 8px;
  font-weight: 600;
}
.doc-keybar .copy-btn { position: absolute; right: 12px; bottom: 10px; }

/* Doc navigation */
.doc-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 18px;
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: 8px 0;
  z-index: 5;
}
.doc-nav a {
  font-size: 12px;
  padding: 5px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  color: var(--text-muted);
  background: var(--surface);
  white-space: nowrap;
}
.doc-nav a:active { transform: scale(.95); }

/* Doc sections */
.doc-sec { margin-bottom: 26px; scroll-margin-top: 54px; }
.doc-stitle {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.doc-stitle .tag { font-size: 11px; font-weight: 600; }
.doc-label { font-size: 13px; font-weight: 700; margin: 14px 0 6px; color: var(--text); }
.doc-label.ok { color: var(--success); }
.doc-label.err { color: var(--danger); }
.doc-sec p { font-size: 13px; color: var(--text-muted); margin: 0 0 8px; }
.doc-sec pre.code { margin: 6px 0; }

/* Doc params table */
.doc-params {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  margin: 8px 0;
  background: var(--surface);
}
.dp-row {
  display: grid;
  grid-template-columns: 1.1fr .6fr 2fr;
  gap: 6px;
  padding: 8px 12px;
  font-size: 12.5px;
  border-bottom: 1px solid var(--border);
  align-items: start;
}
.dp-row:last-child { border-bottom: none; }
.dp-row code {
  font-family: var(--font-mono);
  color: var(--brand);
  font-size: 12px;
  word-break: break-all;
}
.dp-head {
  background: var(--bg);
  font-weight: 700;
  font-size: 11px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.dp-head code { color: var(--text-light); }

/* Doc billing cards */
.doc-bill { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.doc-bill-card {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  background: var(--surface);
}
.dbc-h { font-weight: 700; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.dbc-b { font-size: 13px; color: var(--text-muted); line-height: 1.7; }
.doc-flow {
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: var(--r-md);
  padding: 10px 12px;
  line-height: 1.7;
}

/* ============================================================
   30. Probability Config
   ============================================================ */
.prob-card .note { font-size: 12.5px; line-height: 1.6; }
.weight-slots {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}
.weight-slots .ws { display: flex; flex-direction: column; gap: 4px; }
.weight-slots .ws-l { font-size: 11px; color: var(--text-muted); text-align: center; }
.weight-slots .weight-slot { text-align: center; padding: 9px 6px; }
.weight-presets { display: flex; gap: 6px; flex-wrap: wrap; }
.weight-presets .btn-sm { padding: 6px 12px; font-size: 12px; }
.prob-preview { display: flex; flex-direction: column; gap: 8px; }
.prob-row { display: flex; align-items: center; gap: 10px; }
.prob-row .pr-val {
  width: 84px;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.prob-row .pr-bar-wrap {
  flex: 1;
  height: 18px;
  background: var(--brand-subtle);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.prob-row .pr-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), #5a8def);
  border-radius: var(--r-pill);
  transition: width .3s var(--ease);
}
.prob-row .pr-pct {
  width: 48px;
  flex-shrink: 0;
  text-align: right;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Per-package weight grid */
.pkg-weight-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 4px;
}
.pkg-weight-slot { display: flex; flex-direction: column; gap: 5px; }
.pkg-weight-slot .pws-l {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: var(--brand-subtle);
  border-radius: var(--r-sm);
  padding: 7px 8px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}
.pkg-weight-slot .input {
  padding: 10px 8px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
}

/* ============================================================
   31. Package Price Table
   ============================================================ */
.pkg-price-table th, .pkg-price-table td { white-space: nowrap; }
.pkg-price-table .upp-1k, .pkg-price-table .upp-10k {
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
}
.pkg-price-table .upp-1k:focus, .pkg-price-table .upp-10k:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(24,24,27,.08);
}

/* ============================================================
   32. Order Page Layout (desktop 2-col)
   ============================================================ */
.order-cols {
  display: block;
}

/* ============================================================
   33. Responsive - Tablet (>=768px)
   ============================================================ */
@media (min-width: 768px) {
  :root { --maxw: 720px; }
  body { padding-bottom: calc(var(--tabbar-h) + 36px); }
  .topbar-inner, .wrap, .tabbar-inner, .drawer-body {
    max-width: var(--maxw);
  }
  .topbar-inner { height: 56px; }
  .impersonate-bar { top: 56px; }
  .wrap { padding: 22px 16px 10px; }
  .hero { padding: 28px 26px; }
  .hero .hero-val { font-size: 44px; }
  .hero-grid { grid-template-columns: repeat(3, 1fr); }
  .card { padding: 20px 18px; }

  /* Order page: desktop 2-col */
  .order-cols {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    gap: 18px;
    align-items: start;
  }
  .order-cols > .full { grid-column: 1 / -1; }

  /* Quick amount 6-col */
  .amount-grid { grid-template-columns: repeat(6, 1fr); }

  /* Payment list max width */
  .pay-list { max-width: 520px; }

  /* Doc params wider */
  .dp-row { grid-template-columns: 1fr .6fr 2.2fr; }
}

@media (min-width: 1024px) {
  :root { --maxw: 820px; }
  .hero .hero-val { font-size: 48px; }
}

/* ============================================================
   34. Responsive - Desktop Admin (>=900px)
   Left sidebar + wide content area
   ============================================================ */
@media (min-width: 900px) {
  .admin-body {
    padding-left: 220px;
    padding-bottom: 0;
    min-height: 100vh;
  }
  .admin-body .topbar-inner { max-width: none; }

  /* Bottom tabbar -> left fixed sidebar */
  .admin-body .tabbar.tabbar-admin {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    right: auto;
    width: 220px;
    height: 100vh;
    max-height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    border-top: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: 0;
    z-index: 60;
    display: flex;
    flex-direction: column;
  }
  /* Sidebar brand area */
  .admin-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 18px 16px 16px;
    border-bottom: 1px solid var(--border);
  }
  .admin-brand img {
    width: 38px;
    height: 38px;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    object-fit: cover;
    background: #eee;
    flex-shrink: 0;
  }
  .admin-brand .ab-text { min-width: 0; flex: 1; }
  .admin-brand .ab-t { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
  .admin-brand .ab-s { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

  /* Sidebar items: horizontal layout, full-width buttons — edge-to-edge fill */
  .admin-body .tabbar.tabbar-admin .tabbar-inner {
    max-width: none;
    flex-direction: column;
    justify-content: flex-start;
    flex: 1;
    height: auto;
    padding: 10px 10px 14px;
    gap: 2px;
    overflow-y: auto;
    width: 100%;
  }
  .admin-body .tabbar.tabbar-admin a {
    flex: none;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 10px;
    margin: 0;
    height: auto;
    width: 100%;
    box-sizing: border-box;
    transition: background .15s var(--ease), color .15s var(--ease);
    color: var(--text-muted);
  }
  .admin-body .tabbar.tabbar-admin a:hover {
    background: var(--brand-subtle);
    color: var(--text);
  }
  .admin-body .tabbar.tabbar-admin a.active {
    background: var(--brand);
    color: var(--primary-fg);
    font-weight: 600;
  }
  .admin-body .tabbar.tabbar-admin a svg { width: 20px; height: 20px; flex-shrink: 0; }

  /* Wide content area */
  .admin-wrap { max-width: none; padding: 24px 32px 40px; }

  /* Stat grid 4-col */
  .stat-grid { grid-template-columns: repeat(4, 1fr); gap: 14px; }
  .stat-cell { padding: 18px 18px; }
  .stat-cell .sv { font-size: 26px; }

  /* Table full width, no horizontal scroll */
  .admin-table-wrap { overflow-x: visible; }
  .admin-table { min-width: 0; font-size: 13.5px; }
  .admin-table th, .admin-table td { padding: 12px 14px; }

  /* Search bar wider */
  .search-bar { max-width: 560px; }

  /* Drawer: right panel, pushes content (margin-right) */
  .admin-body .admin-wrap { transition: margin-right .22s var(--ease); }
  .admin-body.drawer-open .admin-wrap { margin-right: 520px; }
  .admin-body .drawer {
    top: 0;
    bottom: 0;
    left: auto;
    right: 0;
    width: 520px;
    max-width: none;
    background: var(--bg);
    padding: 0;
    box-shadow: -10px 0 30px rgba(0,0,0,.07);
    border-left: 1px solid var(--border);
    animation: drawerInRight .24s var(--ease);
  }
  @keyframes drawerInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
  }
  .admin-body .drawer-head,
  .admin-body .drawer-body { max-width: none; margin-left: 0; margin-right: 0; }
  .admin-body .drawer-head { border-radius: 0; }
  .admin-body .drawer-body { padding: 20px; }

  /* Settings: full-width container, 2-col field layout inside */
  .admin-body #sec-settings {
    display: block;
    max-width: none;
  }
  .admin-body #sec-settings > .card,
  .admin-body #sec-settings > .btn-block { grid-column: auto; }
  /* 桌面端设置字段：双列（标签+说明 | 输入框） */
  .admin-body .set-field {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 24px;
    align-items: start;
    padding: 18px 0;
  }
  .admin-body .set-label { margin-bottom: 0; }
  .admin-body .set-hint { margin-top: 4px; }
  .admin-body .set-input-row .input { max-width: 560px; }
  .admin-body .set-save-bar { max-width: none; }

  /* My logs: right drawer panel */
  .mylogs-body .wrap { transition: margin-right .22s var(--ease); }
  .mylogs-body.drawer-open .wrap { margin-right: 520px; }
  .mylogs-body .drawer {
    top: 0;
    bottom: 0;
    left: auto;
    right: 0;
    width: 520px;
    max-width: none;
    background: var(--bg);
    padding: 0;
    box-shadow: -10px 0 30px rgba(0,0,0,.07);
    border-left: 1px solid var(--border);
    animation: drawerInRight .24s var(--ease);
  }
  .mylogs-body .drawer-head,
  .mylogs-body .drawer-body { max-width: none; margin: 0; }
  .mylogs-body .drawer-head { border-radius: 0; }
  .mylogs-body .drawer-body { padding: 20px; }
}

/* ============================================================
   35. Responsive - Large Desktop (>=1200px)
   ============================================================ */
@media (min-width: 1200px) {
  .stat-grid { grid-template-columns: repeat(6, 1fr); }
  .admin-wrap { max-width: none; }
}

/* Mobile: hide sidebar brand area */
@media (max-width: 899px) {
  .admin-brand { display: none; }
}

/* ============================================================
   36. Settings Redesign — Tab Navigation + Sensitive Fields + Sticky Save
   ============================================================ */

/* 侧边栏退出登录按钮 */
.ab-logout {
  margin-left: auto;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: background .15s var(--ease), color .15s var(--ease);
}
.ab-logout:hover { background: var(--danger-bg); color: var(--danger); }

/* Tab 导航条 */
.set-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.set-tabs::-webkit-scrollbar { height: 4px; }
.set-tabs::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }
.set-tab {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  text-decoration: none;
  color: var(--text-muted);
  transition: background .15s var(--ease), color .15s var(--ease);
  position: relative;
  white-space: nowrap;
}
.set-tab:hover { background: var(--brand-subtle); color: var(--text); }
.set-tab.active { background: var(--brand); color: var(--primary-fg); }
.set-tab svg { width: 20px; height: 20px; flex-shrink: 0; }
.set-tab span { font-size: 12px; font-weight: 500; }

/* 状态指示灯 */
.set-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: var(--r-pill);
  position: absolute;
  top: 8px;
  right: 10px;
}
.set-dot.dot-on  { background: var(--primary-fg); opacity: .4; }
.set-dot.dot-ok  { background: var(--success); }
.set-dot.dot-off { background: var(--border-strong); }
.set-tab.active .set-dot.dot-on { background: var(--primary-fg); opacity: .6; }

/* 内容面板 */
.set-panel {
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  padding: 24px 24px 8px;
  margin-bottom: 16px;
}
.set-panel-head { margin-bottom: 20px; }
.set-panel-title { font-size: 18px; font-weight: 700; letter-spacing: -.01em; color: var(--text); }
.set-panel-desc { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* 字段 */
.set-field {
  padding: 14px 0;
  border-top: 1px solid var(--border);
}
.set-field:first-of-type { border-top: 0; padding-top: 0; }
.set-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.set-input-row { position: relative; }
.set-input-row .input { width: 100%; }
.set-hint {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.45;
}

/* 粘性保存栏 */
.set-save-bar {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  z-index: 5;
  margin-bottom: 20px;
}
.set-save-status {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}
.set-save-status.dirty { color: var(--warning); }
.set-save-bar .btn {
  min-width: 120px;
  transition: box-shadow .2s var(--ease);
}
.set-save-bar .btn.has-change {
  box-shadow: 0 0 0 3px rgba(22, 163, 74, .18);
}

/* 移动端：Tab 改为横向滚动，面板去圆角全宽 */
@media (max-width: 640px) {
  .set-tabs { gap: 2px; padding: 3px; }
  .set-tab { min-width: 72px; padding: 10px 6px 8px; }
  .set-tab span { font-size: 11px; }
  .set-panel { padding: 16px 16px 4px; border-radius: var(--r-md); }
  .set-panel-title { font-size: 16px; }
  .set-field { padding: 12px 0; }
  .set-save-bar { padding: 12px 14px; border-radius: var(--r-sm); }
  .set-save-status { font-size: 12px; }
  .set-save-bar .btn { min-width: 100px; }
}
