/* ============================================================
   设计系统 token
   主色调：蓝石（oklch 约 56% 0.2 250）
   中性色：冷灰（oklch，色调偏蓝）
   ============================================================ */
:root {
  /* ── 中性色阶（冷灰，微蓝调） ── */
  --n-0:   oklch(99%   0.004 260);
  --n-50:  oklch(97%   0.006 260);
  --n-100: oklch(94%   0.008 260);
  --n-200: oklch(89%   0.010 260);
  --n-300: oklch(80%   0.012 260);
  --n-400: oklch(68%   0.013 260);
  --n-500: oklch(55%   0.014 260);
  --n-600: oklch(43%   0.015 260);
  --n-700: oklch(32%   0.016 260);
  --n-800: oklch(22%   0.018 260);
  --n-900: oklch(14%   0.020 260);
  --n-950: oklch(10%   0.022 260);

  /* ── 主色（蓝石） ── */
  --a-50:  oklch(96%   0.040 252);
  --a-100: oklch(92%   0.070 252);
  --a-200: oklch(85%   0.110 252);
  --a-300: oklch(75%   0.150 252);
  --a-400: oklch(64%   0.190 252);
  --a-500: oklch(54%   0.210 252);   /* 主色 */
  --a-600: oklch(46%   0.210 252);
  --a-700: oklch(38%   0.200 252);
  --a-800: oklch(30%   0.180 252);
  --a-900: oklch(22%   0.150 252);

  /* ── 语义色 ── */
  --success-bg:  oklch(95% 0.05 155);
  --success-border: oklch(80% 0.12 155);
  --success-text:oklch(35% 0.13 155);
  --success:     oklch(52% 0.17 155);

  --warn-bg:     oklch(97% 0.04 80);
  --warn-border: oklch(85% 0.10 80);
  --warn-text:   oklch(40% 0.12 80);
  --warn:        oklch(68% 0.17 80);

  --danger-bg:   oklch(96% 0.04 20);
  --danger-border:oklch(83% 0.10 20);
  --danger-text: oklch(38% 0.13 20);
  --danger:      oklch(53% 0.19 20);

  --info-bg:     oklch(95% 0.04 252);
  --info-border: oklch(80% 0.10 252);
  --info-text:   oklch(36% 0.14 252);

  /* ── 角色语义 ── */
  --bg:           var(--n-50);
  --surface:      var(--n-0);
  --surface-raised: var(--n-0);
  --border:       var(--n-200);
  --border-strong:var(--n-300);
  --text:         var(--n-900);
  --text-secondary:var(--n-600);
  --muted:        var(--n-400);
  --primary:      var(--a-500);
  --primary-hover:var(--a-600);
  --primary-light:var(--a-50);
  --sidebar-bg:   var(--n-950);
  --sidebar-text: var(--n-300);
  --sidebar-active:var(--n-0);
  --sidebar-hover: oklch(18% 0.022 260);

  /* ── 间距节奏（8px base） ── */
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-5:  20px;
  --sp-6:  24px;
  --sp-8:  32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* ── 圆角 ── */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-full: 9999px;

  /* ── 阴影 ── */
  --shadow-xs: 0 1px 2px oklch(0% 0 0 / .05);
  --shadow-sm: 0 1px 3px oklch(0% 0 0 / .08), 0 1px 2px oklch(0% 0 0 / .06);
  --shadow-md: 0 4px 12px oklch(0% 0 0 / .08), 0 2px 4px oklch(0% 0 0 / .05);
  --shadow-lg: 0 12px 32px oklch(0% 0 0 / .10), 0 4px 8px oklch(0% 0 0 / .06);
  --shadow-focus: 0 0 0 3px var(--a-200);

  /* ── 字体 ── */
  --font-sans: 'Inter', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;

  /* ── 过渡 ── */
  --ease: cubic-bezier(.4,0,.2,1);
  --duration: 160ms;

  /* ── 布局 ── */
  --sidebar-w: 228px;
  --topbar-h:  60px;
}

/* ── 暗色主题 ── */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:           var(--n-950);
    --surface:      oklch(13% 0.020 260);
    --surface-raised: oklch(17% 0.022 260);
    --border:       oklch(22% 0.022 260);
    --border-strong:oklch(30% 0.024 260);
    --text:         var(--n-50);
    --text-secondary:var(--n-400);
    --muted:        var(--n-500);
    --primary:      var(--a-400);
    --primary-hover:var(--a-300);
    --primary-light: oklch(20% 0.04 252);
    --sidebar-bg:   oklch(9%  0.020 260);
    --sidebar-hover: oklch(16% 0.022 260);
  }
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  font-size: .9375rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
ul, ol { list-style: none; }

/* ============================================================
   App Shell（已登录布局）
   ============================================================ */
.app-shell {
  display: flex;
  min-height: 100dvh;
}

/* ── 侧边栏 ── */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform var(--duration) var(--ease);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-6) var(--sp-5);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--n-0);
  letter-spacing: -.01em;
  text-decoration: none !important;
  flex-shrink: 0;
}
.brand-dot {
  width: 8px; height: 8px;
  border-radius: var(--r-full);
  background: var(--a-400);
  flex-shrink: 0;
  box-shadow: 0 0 8px var(--a-400);
}

.side-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-2) var(--sp-3) var(--sp-4);
  scrollbar-width: thin;
  scrollbar-color: oklch(25% .02 260) transparent;
}
.side-nav a {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  color: var(--sidebar-text);
  font-size: .875rem;
  font-weight: 500;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
  text-decoration: none !important;
  position: relative;
  margin-bottom: 2px;
}
.side-nav a:hover  { background: var(--sidebar-hover); color: var(--n-0); }
.side-nav a.active { background: var(--a-500); color: #fff; }
.nav-icon { width: 18px; font-size: 1rem; flex-shrink: 0; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  line-height: 1;
  padding: 2px 6px;
  border-radius: var(--r-full);
  min-width: 18px;
  text-align: center;
}
.nav-divider {
  height: 1px;
  background: oklch(22% .022 260);
  margin: var(--sp-3) var(--sp-2);
}
.nav-section-label {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: oklch(40% .015 260);
  padding: var(--sp-4) var(--sp-3) var(--sp-1);
}

/* 侧边栏底部用户区 */
.side-user {
  padding: var(--sp-4) var(--sp-4);
  border-top: 1px solid oklch(18% .022 260);
  flex-shrink: 0;
}
.side-user-info {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.side-avatar {
  width: 36px; height: 36px;
  border-radius: var(--r-full);
  background: var(--a-600);
  color: #fff;
  font-size: .875rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.side-user-name {
  font-size: .8rem;
  font-weight: 600;
  color: var(--n-100);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-user-role {
  font-size: .72rem;
  color: oklch(52% .018 260);
  margin-top: 1px;
}
.side-balance {
  background: oklch(16% .022 260);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-3);
  margin-bottom: var(--sp-3);
}
.side-balance .lbl {
  font-size: .72rem;
  color: oklch(48% .018 260);
  margin-bottom: 2px;
}
.side-balance .val {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--n-100);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}
.side-balance .member-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .7rem;
  font-weight: 600;
  color: oklch(78% .13 80);
  background: oklch(22% .06 80 / .4);
  border: 1px solid oklch(45% .10 80 / .5);
  border-radius: var(--r-full);
  padding: 1px 8px;
  margin-top: 4px;
}

/* ── 主内容区 ── */
.main-wrap {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100dvh;
}

/* ── Topbar ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-6);
  box-shadow: var(--shadow-xs);
}
.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 1.3rem;
  line-height: 1;
  padding: var(--sp-2);
  border-radius: var(--r-sm);
  transition: background var(--duration);
}
.hamburger:hover { background: var(--n-100); }
.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  flex: 1;
  color: var(--text);
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.balance-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--a-200);
  border-radius: var(--r-full);
  padding: var(--sp-1) var(--sp-3);
  font-size: .8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}
.icon-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--r-full);
  color: var(--text-secondary);
  font-size: 1.1rem;
  transition: background var(--duration);
  text-decoration: none !important;
}
.icon-btn:hover { background: var(--n-100); color: var(--text); }
.icon-btn .dot {
  position: absolute;
  top: 7px; right: 7px;
  width: 7px; height: 7px;
  background: var(--danger);
  border-radius: var(--r-full);
  border: 2px solid var(--surface);
}

/* 遮罩层 */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: oklch(0% 0 0 / .45);
  z-index: 150;
  backdrop-filter: blur(2px);
}

/* ── 内容区 ── */
.content {
  flex: 1;
  padding: var(--sp-6);
}
.container { max-width: 1160px; margin: 0 auto; }

/* ── 页脚 ── */
.footer {
  padding: var(--sp-5) var(--sp-6);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .8rem;
  text-align: center;
}

/* ============================================================
   未登录布局（auth）
   ============================================================ */
.auth-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.auth-topbar {
  padding: var(--sp-5) var(--sp-8);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.auth-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-8) var(--sp-4);
}
.auth-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-10) var(--sp-10);
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.auth-box h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: var(--sp-2);
  color: var(--text);
}
.auth-box .subtitle {
  color: var(--text-secondary);
  font-size: .875rem;
  margin-bottom: var(--sp-8);
}

/* ============================================================
   卡片
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  margin-bottom: var(--sp-5);
  box-shadow: var(--shadow-xs);
}
.card h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--sp-5);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.card h2 .card-icon {
  width: 32px; height: 32px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.card h3 {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--sp-3);
}

/* ── 栅格 ── */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-4); }

/* ── 统计卡 ── */
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5) var(--sp-5);
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
}
.stat::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--stat-color, var(--primary));
  border-radius: 0 2px 2px 0;
}
.stat .label {
  font-size: .78rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: var(--sp-2);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.stat .value {
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}
.stat .sub {
  font-size: .78rem;
  color: var(--muted);
  margin-top: var(--sp-1);
}
.stat-icon {
  position: absolute;
  top: var(--sp-4); right: var(--sp-4);
  font-size: 1.5rem;
  opacity: .18;
}

/* ============================================================
   表格
   ============================================================ */
.table-wrap { overflow-x: auto; border-radius: var(--r-md); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead { position: sticky; top: 0; z-index: 1; }
th {
  background: var(--n-50);
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--duration); }
tbody tr:hover { background: var(--n-50); }
.num { font-variant-numeric: tabular-nums; font-family: var(--font-mono); }

/* 直接在卡片内无 table-wrap 的 table */
.card > table, .card > .table-wrap { margin: 0 calc(-1 * var(--sp-6)); width: calc(100% + var(--sp-6) * 2); }
.card > table th:first-child,
.card > .table-wrap table th:first-child { padding-left: var(--sp-6); }
.card > table th:last-child,
.card > .table-wrap table th:last-child { padding-right: var(--sp-6); }
.card > table td:first-child,
.card > .table-wrap table td:first-child { padding-left: var(--sp-6); }
.card > table td:last-child,
.card > .table-wrap table td:last-child { padding-right: var(--sp-6); }

/* ============================================================
   表单
   ============================================================ */
.form-group { margin-bottom: var(--sp-5); }
.form-group label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--sp-2);
  letter-spacing: .01em;
}
.form-row { display: flex; gap: var(--sp-4); }
.form-row .form-group { flex: 1; }

/* ── 图形验证码 ── */
.captcha-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.captcha-row input { flex: 1; min-width: 0; }
.captcha-row img {
  height: 46px;
  width: 150px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  cursor: pointer;
  flex-shrink: 0;
}

input[type=text], input[type=email], input[type=password],
input[type=number], input[type=search], input[type=url],
select, textarea {
  display: block;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  color: var(--text);
  transition: border-color var(--duration), box-shadow var(--duration);
  appearance: none;
  -webkit-appearance: none;
}
input:hover, select:hover, textarea:hover { border-color: var(--n-400); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--shadow-focus);
}
input:disabled, select:disabled, textarea:disabled {
  background: var(--n-100);
  color: var(--muted);
  cursor: not-allowed;
}
input[type=number] { font-variant-numeric: tabular-nums; }
textarea { resize: vertical; min-height: 100px; line-height: 1.6; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%23888' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  padding-right: 36px;
}
.input-hint { font-size: .78rem; color: var(--muted); margin-top: var(--sp-1); }
.input-error { font-size: .78rem; color: var(--danger); margin-top: var(--sp-1); }
.form-check { display: flex; align-items: center; gap: var(--sp-2); cursor: pointer; }
.form-check input[type=checkbox], .form-check input[type=radio] {
  width: 16px; height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ============================================================
   按钮
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-md);
  font-size: .875rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background var(--duration), box-shadow var(--duration), transform 80ms;
  border: 1px solid transparent;
  white-space: nowrap;
  text-decoration: none !important;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px oklch(0% 0 0 / .12);
}
.btn:hover  { background: var(--primary-hover); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-sm  { padding: 6px var(--sp-3); font-size: .8rem; }
.btn-lg  { padding: var(--sp-4) var(--sp-6); font-size: 1rem; border-radius: var(--r-lg); }
.btn-block { width: 100%; }
.btn-icon { padding: var(--sp-2); }

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-strong);
  box-shadow: none;
}
.btn-outline:hover { background: var(--n-100); color: var(--text); border-color: var(--n-300); }

.btn-ghost {
  background: transparent;
  color: var(--primary);
  border-color: transparent;
  box-shadow: none;
}
.btn-ghost:hover { background: var(--primary-light); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: oklch(45% .20 20); }

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-group { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

/* ============================================================
   标签 / 徽章
   ============================================================ */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: .73rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}
.tag-green  { background: var(--success-bg);  color: var(--success-text);  border: 1px solid var(--success-border); }
.tag-red    { background: var(--danger-bg);   color: var(--danger-text);   border: 1px solid var(--danger-border); }
.tag-amber  { background: var(--warn-bg);     color: var(--warn-text);     border: 1px solid var(--warn-border); }
.tag-blue   { background: var(--info-bg);     color: var(--info-text);     border: 1px solid var(--info-border); }
.tag-gray   { background: var(--n-100);       color: var(--n-600);         border: 1px solid var(--n-200); }
.tag-purple { background: oklch(94% .04 295); color: oklch(38% .14 295);   border: 1px solid oklch(82% .08 295); }
.tag-gold   { background: oklch(96% .06 80);  color: oklch(38% .14 80);    border: 1px solid oklch(82% .10 80); }

/* ============================================================
   提示横幅
   ============================================================ */
.notice {
  border-radius: var(--r-md);
  padding: var(--sp-4) var(--sp-5);
  font-size: .875rem;
  line-height: 1.6;
  margin-bottom: var(--sp-5);
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
}
.notice::before { font-size: 1rem; flex-shrink: 0; margin-top: 2px; }
.notice-green  { background: var(--success-bg); color: var(--success-text); border: 1px solid var(--success-border); }
.notice-green::before  { content: '✓'; color: var(--success); }
.notice-red    { background: var(--danger-bg);  color: var(--danger-text);  border: 1px solid var(--danger-border); }
.notice-red::before    { content: '✕'; color: var(--danger); }
.notice-blue   { background: var(--info-bg);    color: var(--info-text);    border: 1px solid var(--info-border); }
.notice-blue::before   { content: 'ℹ'; color: var(--primary); }
.notice-amber  { background: var(--warn-bg);    color: var(--warn-text);    border: 1px solid var(--warn-border); }
.notice-amber::before  { content: '⚠'; color: var(--warn); }

/* 顶部 flash 提示 */
.alert {
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-5);
  font-size: .875rem;
  font-weight: 500;
  margin-bottom: var(--sp-5);
  transition: opacity .4s, transform .4s;
}
.alert-success { background: var(--success-bg); color: var(--success-text); border: 1px solid var(--success-border); }
.alert-error   { background: var(--danger-bg);  color: var(--danger-text);  border: 1px solid var(--danger-border); }
.alert.fade-out { opacity: 0; transform: translateY(-4px); }

/* ============================================================
   Mono / 代码
   ============================================================ */
.mono { font-family: var(--font-mono); font-size: .85em; }
code, pre {
  font-family: var(--font-mono);
  font-size: .85em;
}
pre {
  background: var(--n-950);
  color: var(--n-100);
  border-radius: var(--r-md);
  padding: var(--sp-5);
  overflow-x: auto;
  line-height: 1.65;
  margin: var(--sp-4) 0;
  font-size: .825rem;
}
code:not(pre code) {
  background: var(--n-100);
  color: var(--a-700);
  padding: 1px 6px;
  border-radius: var(--r-sm);
}

/* ============================================================
   个人中心 / 用户信息面板
   ============================================================ */
.profile-header {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-5);
  padding: var(--sp-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: var(--sp-5);
  box-shadow: var(--shadow-xs);
}
.profile-avatar {
  width: 68px; height: 68px;
  border-radius: var(--r-full);
  background: var(--a-500);
  color: #fff;
  font-size: 1.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px var(--a-100);
}
.profile-info { flex: 1; min-width: 0; }
.profile-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.profile-meta {
  font-size: .8rem;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
}
.profile-meta span { display: flex; align-items: center; gap: 5px; }
.profile-actions { display: flex; gap: var(--sp-3); align-items: center; flex-shrink: 0; }

/* ============================================================
   模型广场
   ============================================================ */
.model-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: var(--sp-5);
  align-items: start;
}
.model-vendor-nav {
  position: sticky;
  top: calc(var(--topbar-h) + var(--sp-5));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.model-vendor-nav .nav-header {
  padding: var(--sp-3) var(--sp-4);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.model-vendor-nav button {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  background: none;
  border: none;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: left;
  transition: background var(--duration), color var(--duration);
  border-bottom: 1px solid var(--border);
}
.model-vendor-nav button:last-child { border-bottom: none; }
.model-vendor-nav button:hover { background: var(--n-50); color: var(--text); }
.model-vendor-nav button.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.model-count { margin-left: auto; font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.model-toolbar {
  display: flex;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.model-toolbar input { flex: 1; }
.model-toolbar select { width: 140px; flex-shrink: 0; }

.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--sp-4);
}
.model-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  transition: box-shadow var(--duration), border-color var(--duration);
  box-shadow: var(--shadow-xs);
}
.model-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.model-card-header { display: flex; align-items: flex-start; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.model-icon {
  width: 38px; height: 38px;
  border-radius: var(--r-md);
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.model-name {
  font-size: .825rem;
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-mono);
  line-height: 1.3;
  word-break: break-all;
}
.model-provider { font-size: .75rem; color: var(--muted); margin-top: 2px; }
.model-tags { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.price-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2);
  background: var(--n-50);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  margin-bottom: var(--sp-3);
  font-size: .78rem;
}
.price-box .price-item .price-lbl { color: var(--muted); margin-bottom: 2px; }
.price-box .price-item .price-val {
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  font-size: .8rem;
}
.price-box.fixed { grid-template-columns: 1fr; }

/* 接入文档折叠 */
details.doc-toggle { margin-top: var(--sp-2); }
details.doc-toggle summary {
  cursor: pointer;
  font-size: .8rem;
  font-weight: 600;
  color: var(--primary);
  padding: var(--sp-2) 0;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
details.doc-toggle summary::before {
  content: '▶';
  font-size: .6rem;
  transition: transform var(--duration);
}
details[open].doc-toggle summary::before { transform: rotate(90deg); }
.doc-tabs { display: flex; gap: var(--sp-1); margin-bottom: var(--sp-2); margin-top: var(--sp-3); border-bottom: 1px solid var(--border); }
.doc-tab-btn {
  padding: var(--sp-2) var(--sp-3);
  background: none;
  border: none;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--duration), border-color var(--duration);
}
.doc-tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.doc-panel { display: none; }
.doc-panel.active { display: block; }
.doc-panel pre { font-size: .78rem; max-height: 240px; margin: 0; }

/* ============================================================
   Playground（聊天 UI）
   ============================================================ */
.chat-wrap {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--topbar-h) - var(--sp-6) * 2 - 70px);
  min-height: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  scrollbar-width: thin;
}
.msg { display: flex; gap: var(--sp-3); max-width: 85%; }
.msg.user { flex-direction: row-reverse; align-self: flex-end; }
.msg.assistant { align-self: flex-start; }
.msg-avatar {
  width: 32px; height: 32px;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  flex-shrink: 0;
}
.msg.user .msg-avatar { background: var(--a-500); color: #fff; }
.msg.assistant .msg-avatar { background: var(--n-100); color: var(--text-secondary); }
.msg-bubble {
  border-radius: var(--r-lg);
  padding: var(--sp-3) var(--sp-4);
  font-size: .875rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.user .msg-bubble { background: var(--a-500); color: #fff; border-bottom-right-radius: var(--r-sm); }
.msg.assistant .msg-bubble { background: var(--n-100); color: var(--text); border-bottom-left-radius: var(--r-sm); }
.msg.error .msg-bubble { background: var(--danger-bg); color: var(--danger-text); border: 1px solid var(--danger-border); }
.chat-input-bar {
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  gap: var(--sp-3);
  align-items: flex-end;
}
.chat-input-bar textarea {
  flex: 1;
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  min-height: 44px;
  max-height: 140px;
  resize: none;
  font-size: .875rem;
}
.chat-toolbar { display: flex; gap: var(--sp-3); margin-bottom: var(--sp-3); flex-wrap: wrap; align-items: center; }
.chat-toolbar select { width: auto; flex-shrink: 0; font-size: .8rem; }

/* ============================================================
   分页
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-5) 0;
  flex-wrap: wrap;
}
.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-md);
  font-size: .875rem;
  font-weight: 500;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  text-decoration: none !important;
  transition: background var(--duration), color var(--duration), border-color var(--duration);
}
.pagination a:hover { background: var(--primary-light); color: var(--primary); border-color: var(--a-200); }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .disabled { opacity: .4; pointer-events: none; }

/* ============================================================
   空状态
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-16) var(--sp-8);
  text-align: center;
  color: var(--muted);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: var(--sp-4); opacity: .5; }
.empty-state h3 { font-size: .9rem; font-weight: 600; color: var(--text-secondary); margin-bottom: var(--sp-2); }
.empty-state p  { font-size: .8rem; }

/* ============================================================
   快速接入代码块
   ============================================================ */
.quickstart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: var(--sp-5);
  box-shadow: var(--shadow-xs);
}
.quickstart-card .qs-header {
  padding: var(--sp-4) var(--sp-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--n-50);
}
.quickstart-card .qs-title { font-size: .875rem; font-weight: 600; color: var(--text); }
.copy-field {
  display: flex;
  gap: var(--sp-3);
  align-items: center;
  background: var(--n-50);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
}
.copy-field .copy-value {
  flex: 1;
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   充值/会员价格卡
   ============================================================ */
.price-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-8) var(--sp-6);
  text-align: center;
  transition: border-color var(--duration), box-shadow var(--duration);
}
.price-card.featured {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--a-100);
  position: relative;
}
.price-card.featured::before {
  content: '推荐';
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  padding: 3px 14px;
  border-radius: var(--r-full);
}
.price-amount {
  font-size: 2.8rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}
.price-unit { font-size: 1rem; font-weight: 500; color: var(--muted); margin-left: 4px; }
.price-period { font-size: .8rem; color: var(--muted); margin-top: 4px; margin-bottom: var(--sp-5); }
.price-features {
  list-style: none;
  text-align: left;
  font-size: .85rem;
  line-height: 2;
  color: var(--text-secondary);
  margin-bottom: var(--sp-6);
}
.price-features li::before { content: '✓ '; color: var(--success); font-weight: 700; }

/* ============================================================
   帮助提示文本
   ============================================================ */
.help-text { font-size: .78rem; color: var(--muted); margin-top: var(--sp-3); line-height: 1.6; }
.section-title {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: var(--sp-4);
  margin-top: var(--sp-8);
}
.section-title:first-child { margin-top: 0; }

/* 分割线 */
hr { border: none; border-top: 1px solid var(--border); margin: var(--sp-6) 0; }

/* ============================================================
   后台 admin 样式扩展
   ============================================================ */
.admin-nav-tabs {
  display: flex;
  gap: 2px;
  background: var(--n-100);
  border-radius: var(--r-lg);
  padding: 4px;
  margin-bottom: var(--sp-6);
  flex-wrap: wrap;
}
.admin-nav-tabs a {
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-md);
  font-size: .825rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none !important;
  transition: background var(--duration), color var(--duration);
}
.admin-nav-tabs a:hover { background: var(--surface); color: var(--text); }
.admin-nav-tabs a.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-xs); }

/* details 操作折叠 */
details > summary { cursor: pointer; user-select: none; }
details > summary::-webkit-details-marker { display: none; }

/* ============================================================
   数据看板 charts
   ============================================================ */
.chart-container {
  position: relative;
  width: 100%;
  height: 280px;
}
.chart-tabs { display: flex; gap: var(--sp-1); margin-bottom: var(--sp-4); }
.chart-tab {
  padding: var(--sp-1) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  background: none;
  color: var(--text-secondary);
  transition: background var(--duration), color var(--duration), border-color var(--duration);
}
.chart-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 960px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .sidebar-overlay.open { display: block; }
  .main-wrap { margin-left: 0; }
  .hamburger { display: flex; }
  .model-layout { grid-template-columns: 1fr; }
  .model-vendor-nav { position: static; display: flex; overflow-x: auto; border-radius: var(--r-md); gap: 0; }
  .model-vendor-nav button { border-bottom: none; border-right: 1px solid var(--border); white-space: nowrap; flex-shrink: 0; }
  .model-vendor-nav button:last-child { border-right: none; }
  .model-vendor-nav .nav-header { display: none; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .content { padding: var(--sp-4); }
  .card { padding: var(--sp-4); border-radius: var(--r-md); }
  .auth-box { padding: var(--sp-6); border-radius: var(--r-lg); }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; }
  .profile-header { flex-direction: column; gap: var(--sp-4); }
  .profile-actions { width: 100%; }
  .topbar { padding: 0 var(--sp-4); }
  .topbar-right .balance-chip { display: none; }
  .model-grid { grid-template-columns: 1fr; }
  .chat-wrap { height: calc(100dvh - var(--topbar-h) - var(--sp-4) * 2 - 60px); }
}

/* ── 减少动画（无障碍） ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
}
