/* ==========================================================================
   共享号池平台 · 设计系统
   --------------------------------------------------------------------------
   风格取向:Apple 式极简 —— 大留白、强层次、克制的色彩、
   圆角卡片 + 柔和阴影 + 毛玻璃导航。
   实现要点:
     · 颜色全部走 CSS 变量,深浅色自动切换,也支持手动覆盖
     · 系统字体栈优先 SF Pro / 苹方,保证中文与英文都有最佳字形
     · 过渡统一使用 Apple 常用的缓动曲线,避免生硬的线性动画
     · 移动端优先:所有栅格在窄屏自动降为单列
   ========================================================================== */

/* ---------- 设计令牌 ---------- */

:root {
  color-scheme: light dark;

  /* 字体:优先系统 UI 字体,中英文各自取最优字形 */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", ui-monospace, SFMono-Regular, Menlo, Consolas,
    "Liberation Mono", monospace;

  /* 圆角 */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-pill: 980px;

  /* 间距 */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;

  /* 层级 */
  --z-nav: 100;
  --z-dropdown: 200;
  --z-modal: 300;
  --z-toast: 400;

  /* 过渡 */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 140ms;
  --dur: 220ms;
  --dur-slow: 380ms;

  /* 尺寸 */
  --sidebar-w: 248px;
  --header-h: 56px;
  --content-max: 1180px;
}

/* 浅色(默认) */
:root,
[data-theme="light"] {
  --bg: #f5f5f7;
  --bg-elevated: #ffffff;
  --bg-sunken: #ececee;
  --bg-hover: rgba(0, 0, 0, 0.04);
  --bg-active: rgba(0, 0, 0, 0.07);
  --nav-bg: rgba(251, 251, 253, 0.78);

  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --text-inverse: #ffffff;

  --border: rgba(0, 0, 0, 0.09);
  --border-strong: rgba(0, 0, 0, 0.16);

  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-soft: rgba(0, 113, 227, 0.1);
  --accent-text: #0066cc;

  --success: #1d9b48;
  --success-soft: rgba(29, 155, 72, 0.12);
  --warning: #b25000;
  --warning-soft: rgba(255, 149, 0, 0.14);
  --danger: #d70015;
  --danger-soft: rgba(215, 0, 21, 0.1);
  --info: #0071e3;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);

  --skeleton: linear-gradient(90deg, #ececee 25%, #f5f5f7 50%, #ececee 75%);
}

/* 深色 — 跟随系统 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --bg-elevated: #1c1c1e;
    --bg-sunken: #141416;
    --bg-hover: rgba(255, 255, 255, 0.06);
    --bg-active: rgba(255, 255, 255, 0.1);
    --nav-bg: rgba(28, 28, 30, 0.72);

    --text: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-tertiary: #86868b;
    --text-inverse: #000000;

    --border: rgba(255, 255, 255, 0.12);
    --border-strong: rgba(255, 255, 255, 0.22);

    --accent: #0a84ff;
    --accent-hover: #409cff;
    --accent-soft: rgba(10, 132, 255, 0.16);
    --accent-text: #4da3ff;

    --success: #32d74b;
    --success-soft: rgba(50, 215, 75, 0.16);
    --warning: #ff9f0a;
    --warning-soft: rgba(255, 159, 10, 0.16);
    --danger: #ff453a;
    --danger-soft: rgba(255, 69, 58, 0.16);
    --info: #0a84ff;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);

    --skeleton: linear-gradient(90deg, #1c1c1e 25%, #2c2c2e 50%, #1c1c1e 75%);
  }
}

/* 深色 — 手动指定 */
[data-theme="dark"] {
  --bg: #000000;
  --bg-elevated: #1c1c1e;
  --bg-sunken: #141416;
  --bg-hover: rgba(255, 255, 255, 0.06);
  --bg-active: rgba(255, 255, 255, 0.1);
  --nav-bg: rgba(28, 28, 30, 0.72);

  --text: #f5f5f7;
  --text-secondary: #a1a1a6;
  --text-tertiary: #86868b;
  --text-inverse: #000000;

  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.22);

  --accent: #0a84ff;
  --accent-hover: #409cff;
  --accent-soft: rgba(10, 132, 255, 0.16);
  --accent-text: #4da3ff;

  --success: #32d74b;
  --success-soft: rgba(50, 215, 75, 0.16);
  --warning: #ff9f0a;
  --warning-soft: rgba(255, 159, 10, 0.16);
  --danger: #ff453a;
  --danger-soft: rgba(255, 69, 58, 0.16);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);

  --skeleton: linear-gradient(90deg, #1c1c1e 25%, #2c2c2e 50%, #1c1c1e 75%);
}

/* ---------- 基础重置 ---------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.006em;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.021em;
  line-height: 1.2;
}
h1 { font-size: 28px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
h4 { font-size: 15px; }

p { margin: 0; }

a {
  color: var(--accent-text);
  text-decoration: none;
  transition: opacity var(--dur-fast) var(--ease);
}
a:hover { opacity: 0.75; }

code, pre, kbd { font-family: var(--font-mono); font-size: 0.92em; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

::selection { background: var(--accent-soft); }

/* 滚动条:细、低对比,不打断视觉 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--text-tertiary); background-clip: content-box; }

/* ---------- 布局 ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: var(--z-nav);
  display: flex;
  flex-direction: column;
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-right: 1px solid var(--border);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  text-decoration: none;
  color: var(--text);
}
.sidebar-brand:hover { opacity: 1; }

.brand-mark {
  width: 34px; height: 34px;
  flex-shrink: 0;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--accent), #5856d6);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  box-shadow: var(--shadow-sm);
}

.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; color: var(--text-tertiary); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-2) var(--sp-3) var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-group-label {
  padding: var(--sp-4) var(--sp-3) var(--sp-2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 9px var(--sp-3);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.nav-link:hover { background: var(--bg-hover); color: var(--text); opacity: 1; }
.nav-link.is-active {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 590;
}
.nav-link svg { width: 17px; height: 17px; flex-shrink: 0; }

.sidebar-footer {
  padding: var(--sp-3);
  border-top: 1px solid var(--border);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background var(--dur-fast) var(--ease);
}
.user-chip:hover { background: var(--bg-hover); }

.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.user-meta { min-width: 0; flex: 1; }
.user-mail {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-balance { font-size: 11px; color: var(--text-tertiary); }

.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: calc(var(--z-nav) - 1);
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-5);
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}

.topbar-title { font-size: 17px; font-weight: 600; letter-spacing: -0.014em; }
.topbar-spacer { flex: 1; }

.mobile-toggle {
  display: none;
  width: 34px; height: 34px;
  align-items: center; justify-content: center;
  border: none; background: none; cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}
.mobile-toggle:hover { background: var(--bg-hover); }

.content {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--sp-6) var(--sp-5) var(--sp-8);
}

.page-head {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
  flex-wrap: wrap;
}
.page-head-text { flex: 1; min-width: 220px; }
.page-desc { margin-top: var(--sp-2); color: var(--text-secondary); font-size: 14px; max-width: 68ch; }

/* ---------- 卡片 ---------- */

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.card + .card { margin-top: var(--sp-4); }
.card.is-hoverable:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.card-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
}
.card-head-text { flex: 1; min-width: 0; }
.card-title { font-size: 15px; font-weight: 600; }
.card-sub { margin-top: 2px; font-size: 12.5px; color: var(--text-tertiary); }
.card-body { padding: var(--sp-5); }
.card-body.is-flush { padding: 0; }
.card-foot {
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border);
  background: var(--bg-sunken);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

/* ---------- 栅格 ---------- */

.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
}
.stat-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-tertiary);
  letter-spacing: 0.01em;
}
.stat-value {
  margin-top: var(--sp-2);
  font-size: 27px;
  font-weight: 600;
  letter-spacing: -0.028em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.stat-unit { font-size: 14px; font-weight: 500; color: var(--text-tertiary); margin-left: 3px; }
.stat-hint { margin-top: var(--sp-2); font-size: 12px; color: var(--text-tertiary); }
.stat-trend { margin-top: var(--sp-2); font-size: 12.5px; font-weight: 500; }

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--dur-fast) var(--ease);
  user-select: none;
}
.btn:hover { background: var(--bg-hover); }
.btn:active { transform: scale(0.975); }
.btn:disabled, .btn.is-loading {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.btn svg { width: 15px; height: 15px; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--bg-hover); }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }

.btn-pill { border-radius: var(--radius-pill); padding: 10px 22px; }
.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn-lg { padding: 12px 26px; font-size: 15px; }
.btn-block { width: 100%; }

.btn.is-loading::before {
  content: "";
  width: 13px; height: 13px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 表单 ---------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field + .field { margin-top: var(--sp-4); }

.label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}
.label .req { color: var(--danger); margin-left: 2px; }

.input, .select, .textarea {
  width: 100%;
  padding: 10px 13px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14.5px;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  -webkit-appearance: none;
  appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--text-tertiary); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px var(--accent-soft);
}
.input:disabled, .select:disabled, .textarea:disabled {
  background: var(--bg-sunken);
  color: var(--text-tertiary);
  cursor: not-allowed;
}
.textarea { min-height: 88px; resize: vertical; font-family: var(--font-mono); font-size: 13.5px; }
.input.is-mono { font-family: var(--font-mono); font-size: 13px; }

.select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%2386868b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 34px;
}

.hint { font-size: 12.5px; color: var(--text-tertiary); line-height: 1.5; }
.hint.is-error { color: var(--danger); }
.hint.is-success { color: var(--success); }

.field-row { display: flex; gap: var(--sp-3); }
.field-row > * { flex: 1; }
/* 并排布局中的字段是同级兄弟,不参与上下堆叠,清掉 .field + .field 的外边距,
   否则右列会比左列整体下坠 16px,看起来"歪了"。
   只匹配直接子级(>),不影响卡片/表单流里垂直堆叠的字段间距 */
.field-row > .field + .field,
.grid > .field + .field,
.grid-2 > .field + .field,
.grid-3 > .field + .field,
.grid-4 > .field + .field { margin-top: 0; }

/* number 输入框去掉浏览器自带的步进箭头,和文本框保持同一视觉规格 */
.input[type="number"]::-webkit-inner-spin-button,
.input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* 开关 */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  width: 44px;
  height: 26px;
  cursor: pointer;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 44px; height: 26px;
  border-radius: var(--radius-pill);
  background: var(--border-strong);
  transition: background var(--dur) var(--ease);
}
.switch-thumb {
  position: absolute;
  left: 2px; top: 2px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
  transition: transform var(--dur) var(--ease);
}
.switch input:checked + .switch-track { background: var(--success); }
.switch input:checked ~ .switch-thumb { transform: translateX(18px); }

.switch-row {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-3) 0;
}
.switch-row + .switch-row { border-top: 1px solid var(--border); }
.switch-row-text { flex: 1; min-width: 0; }
.switch-row-title { font-size: 14px; font-weight: 500; }
.switch-row-desc { margin-top: 2px; font-size: 12.5px; color: var(--text-tertiary); }

/* ---------- 徽标 ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 550;
  white-space: nowrap;
  background: var(--bg-sunken);
  color: var(--text-secondary);
}
.badge.is-success { background: var(--success-soft); color: var(--success); }
.badge.is-warning { background: var(--warning-soft); color: var(--warning); }
.badge.is-danger { background: var(--danger-soft); color: var(--danger); }
.badge.is-accent { background: var(--accent-soft); color: var(--accent-text); }

.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

/* ---------- 表格 ---------- */

.table-wrap { width: 100%; overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left;
  padding: 11px var(--sp-4);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
.table td {
  padding: 12px var(--sp-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr { transition: background var(--dur-fast) var(--ease); }
.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }

.mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: -0.01em;
}
.muted { color: var(--text-tertiary); }
.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; }

/* ---------- 空状态 / 骨架屏 ---------- */

.empty {
  padding: var(--sp-8) var(--sp-5);
  text-align: center;
  color: var(--text-tertiary);
}
.empty-icon {
  width: 46px; height: 46px;
  margin: 0 auto var(--sp-4);
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  background: var(--bg-sunken);
  color: var(--text-tertiary);
}
.empty-title { font-size: 15px; font-weight: 550; color: var(--text); }
.empty-desc { margin-top: var(--sp-2); font-size: 13.5px; max-width: 42ch; margin-inline: auto; line-height: 1.6; }

.skeleton {
  background: var(--skeleton);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: var(--radius-xs);
  height: 14px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- 提示条 ---------- */

.alert {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  line-height: 1.55;
  border: 1px solid transparent;
}
.alert + .alert { margin-top: var(--sp-3); }
.alert-info { background: var(--accent-soft); color: var(--accent-text); }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }
.alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert-title { font-weight: 600; }

/* ---------- 弹窗 ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: var(--sp-4);
  animation: fade-in var(--dur) var(--ease);
}
.modal {
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--bg-elevated);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  animation: modal-in var(--dur-slow) var(--ease);
}
.modal.is-wide { max-width: 720px; }
.modal-head {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
}
.modal-head-text { flex: 1; }
.modal-title { font-size: 18px; font-weight: 600; letter-spacing: -0.018em; }
.modal-desc { margin-top: var(--sp-2); font-size: 13.5px; color: var(--text-secondary); line-height: 1.55; }
.modal-body { padding: 0 var(--sp-5) var(--sp-5); }
.modal-foot {
  display: flex;
  gap: var(--sp-2);
  justify-content: flex-end;
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border);
  background: var(--bg-sunken);
  position: sticky;
  bottom: 0;
}

@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
}

/* ---------- Toast ---------- */

.toast-stack {
  position: fixed;
  top: var(--sp-5);
  right: var(--sp-5);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 240px;
  max-width: 400px;
  padding: 11px var(--sp-4);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  animation: toast-in var(--dur-slow) var(--ease);
  pointer-events: auto;
}
.toast.is-out { animation: toast-out var(--dur) var(--ease) forwards; }
.toast-mark { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.toast-success .toast-mark { background: var(--success); }
.toast-error .toast-mark { background: var(--danger); }
.toast-info .toast-mark { background: var(--accent); }
.toast-warn .toast-mark { background: var(--warning); }

@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }

/* ---------- 分页 ---------- */

.pager {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-secondary);
}
.pager-spacer { flex: 1; }

/* ---------- 标签页 ---------- */

.tabs {
  display: flex;
  gap: var(--sp-1);
  padding: var(--sp-1);
  background: var(--bg-sunken);
  border-radius: var(--radius-sm);
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
}
.tab {
  padding: 6px 14px;
  border: none;
  background: none;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--dur-fast) var(--ease);
}
.tab:hover { color: var(--text); }
.tab.is-active {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ---------- 代码块 ---------- */

.code-block {
  position: relative;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
  padding-right: 62px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.65;
  overflow-x: auto;
  white-space: pre;
  color: var(--text);
}
.code-copy {
  position: absolute;
  top: var(--sp-2);
  right: var(--sp-2);
  padding: 4px 9px;
  font-size: 11.5px;
  font-weight: 500;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all var(--dur-fast) var(--ease);
}
.code-copy:hover { color: var(--text); background: var(--bg-hover); }

/* ---------- 分段进度条 ---------- */

.meter {
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--bg-sunken);
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--accent);
  transition: width var(--dur-slow) var(--ease);
}
.meter-fill.is-success { background: var(--success); }
.meter-fill.is-warning { background: var(--warning); }
.meter-fill.is-danger { background: var(--danger); }

/* ---------- 迷你柱状图 ---------- */

.spark {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 64px;
}
.spark-bar {
  flex: 1;
  min-width: 4px;
  border-radius: 3px 3px 0 0;
  background: var(--accent);
  opacity: 0.85;
  transition: opacity var(--dur-fast) var(--ease);
  position: relative;
}
.spark-bar:hover { opacity: 1; }

/* ---------- 工具类 ---------- */

.stack { display: flex; flex-direction: column; }
.stack-2 { gap: var(--sp-2); }
.stack-3 { gap: var(--sp-3); }
.stack-4 { gap: var(--sp-4); }
.stack-5 { gap: var(--sp-5); }

.row { display: flex; align-items: center; }
.row-2 { gap: var(--sp-2); }
.row-3 { gap: var(--sp-3); }
.row-4 { gap: var(--sp-4); }
.row-wrap { flex-wrap: wrap; }
.row-between { justify-content: space-between; }
.flex-1 { flex: 1; min-width: 0; }

.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-5 { margin-top: var(--sp-5); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }

.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-accent { color: var(--accent-text); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.fw-600 { font-weight: 600; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.tabular { font-variant-numeric: tabular-nums; }

/* ---------- 认证页 / 独立页 ---------- */

.centered-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--sp-5);
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--accent-soft), transparent 70%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 412px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-7) var(--sp-6) var(--sp-6);
}
.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
}
.auth-brand .brand-mark { width: 46px; height: 46px; border-radius: 13px; font-size: 19px; }
.auth-title { font-size: 22px; font-weight: 600; letter-spacing: -0.022em; }
.auth-sub { font-size: 13.5px; color: var(--text-secondary); text-align: center; }
.auth-foot {
  margin-top: var(--sp-5);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 13.5px;
  color: var(--text-secondary);
}

/* ---------- 安装向导 ---------- */

.wizard {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1000px 500px at 50% -20%, var(--accent-soft), transparent 65%),
    var(--bg);
}

.wizard-head {
  padding: var(--sp-6) var(--sp-5) var(--sp-4);
  text-align: center;
}
.wizard-title { font-size: 26px; font-weight: 600; letter-spacing: -0.024em; }
.wizard-sub { margin-top: var(--sp-2); font-size: 14px; color: var(--text-secondary); }

.steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  padding: var(--sp-4) var(--sp-5) var(--sp-6);
  flex-wrap: wrap;
}
.step {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-tertiary);
  transition: all var(--dur) var(--ease);
}
.step-num {
  width: 19px; height: 19px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-sunken);
  color: var(--text-tertiary);
  transition: all var(--dur) var(--ease);
}
.step.is-active { color: var(--accent-text); background: var(--accent-soft); }
.step.is-active .step-num { background: var(--accent); color: #fff; }
.step.is-done { color: var(--success); }
.step.is-done .step-num { background: var(--success); color: #fff; }
.step-sep { width: 16px; height: 1px; background: var(--border-strong); }

.wizard-body {
  flex: 1;
  width: 100%;
  max-width: 660px;
  margin: 0 auto;
  padding: 0 var(--sp-5) var(--sp-6);
}
.wizard-panel { animation: panel-in var(--dur-slow) var(--ease); }
@keyframes panel-in { from { opacity: 0; transform: translateY(8px); } }

.wizard-foot {
  display: flex;
  gap: var(--sp-3);
  align-items: center;
  padding: var(--sp-5) var(--sp-6);
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}
.wizard-foot-spacer { flex: 1; }

.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-3);
}
.choice {
  position: relative;
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.choice:hover { border-color: var(--border-strong); }
.choice.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.choice-radio {
  width: 18px; height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  display: grid;
  place-items: center;
  transition: all var(--dur-fast) var(--ease);
}
.choice.is-selected .choice-radio { border-color: var(--accent); border-width: 5.5px; }
.choice-text { min-width: 0; }
.choice-title { font-size: 14.5px; font-weight: 550; }
.choice-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-text);
  margin-left: 6px;
}
.choice-desc { margin-top: 3px; font-size: 12.5px; color: var(--text-tertiary); line-height: 1.5; }

.check-list { display: flex; flex-direction: column; gap: 1px; }
.check-item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
}
.check-item + .check-item { border-top: 1px solid var(--border); }
.check-icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  margin-top: 1px;
}
.check-icon.is-ok { background: var(--success-soft); color: var(--success); }
.check-icon.is-fail { background: var(--danger-soft); color: var(--danger); }
.check-icon.is-warn { background: var(--warning-soft); color: var(--warning); }
.check-text { flex: 1; min-width: 0; }
.check-name { font-size: 14px; font-weight: 500; }
.check-detail {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--text-tertiary);
  word-break: break-all;
  line-height: 1.5;
}

/* ---------- 响应式 ---------- */

@media (max-width: 1000px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 780px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    width: 264px;
    transform: translateX(-100%);
    transition: transform var(--dur-slow) var(--ease);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.is-open { transform: translateX(0); }

  .main { margin-left: 0; }
  .mobile-toggle { display: inline-flex; }

  .content { padding: var(--sp-4) var(--sp-4) var(--sp-7); }
  .topbar { padding: 0 var(--sp-4); }

  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }

  h1 { font-size: 23px; }
  .stat-value { font-size: 23px; }

  .card-body { padding: var(--sp-4); }
  .card-head { padding: var(--sp-3) var(--sp-4); }
  .card-foot { padding: var(--sp-3) var(--sp-4); }
  .table th, .table td { padding: 10px var(--sp-3); }

  .page-head { flex-direction: column; }
  .auth-card { padding: var(--sp-5) var(--sp-4); }
  .modal { max-width: 100%; border-radius: var(--radius-lg); }
  .toast-stack { left: var(--sp-4); right: var(--sp-4); top: var(--sp-4); }
  .toast { max-width: none; }
  .wizard-foot { padding: var(--sp-4); flex-wrap: wrap; }
  .wizard-head { padding: var(--sp-5) var(--sp-4) var(--sp-3); }
  .wizard-body { padding: 0 var(--sp-4) var(--sp-5); }
  .steps { padding: var(--sp-3) var(--sp-4) var(--sp-5); }
  .step span:not(.step-num) { display: none; }
  .step.is-active span:not(.step-num) { display: inline; }
}

/* 侧边栏遮罩 */
.sidebar-scrim {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-nav) - 2);
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(2px);
  animation: fade-in var(--dur) var(--ease);
}

/* 尊重系统的"减少动效"偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   首页(home)
   ========================================================================== */

.home-body {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* 顶部导航:毛玻璃 */
.home-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}
.home-nav-inner {
  max-width: 1024px;
  margin: 0 auto;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.home-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}
.home-brand .brand-name { font-size: 15px; font-weight: 500; }
.home-nav-actions { display: flex; gap: 10px; align-items: center; }

.home-main {
  flex: 1;
  width: 100%;
  max-width: 1024px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Hero */
.hero {
  text-align: center;
  padding: 88px 0 56px;
}
.hero-title {
  font-size: clamp(34px, 6vw, 56px);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0 0 22px;
}
.hero-gradient {
  background: linear-gradient(92deg, #0071e3, #7d4bd0, #d6429a, #e8632c);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
[data-theme="dark"] .hero-gradient {
  background: linear-gradient(92deg, #409cff, #a58bff, #ff7ac2, #ff9f57);
  -webkit-background-clip: text;
  background-clip: text;
}
.hero-desc {
  max-width: 620px;
  margin: 0 auto 34px;
  font-size: 17px;
  line-height: 1.65;
  color: var(--text-secondary);
}
.hero-cta {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}
.hero-footnote {
  margin-top: 18px;
  font-size: 13px;
  color: var(--text-tertiary);
}

/* 实时统计条 */
.stat-strip-wrap { margin: 0 0 72px; }
.stat-strip {
  display: grid;
  grid-template-columns: auto repeat(4, minmax(0, 1fr));
  gap: 20px;
  align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 26px 30px;
}
.stat-live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--success);
  white-space: nowrap;
  padding-right: 20px;
  border-right: 1px solid var(--border);
}
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  animation: livePulse 2s ease-in-out infinite;
}
@keyframes livePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; }
}
.stat-item { text-align: center; }
.stat-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.stat-num {
  font-size: clamp(22px, 3.4vw, 30px);
  font-weight: 500;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat-sub { font-size: 12px; color: var(--text-tertiary); margin-top: 4px; }
@media (max-width: 760px) {
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 20px; }
  .stat-live { grid-column: 1 / -1; justify-content: center; border-right: none; padding-right: 0; }
}

/* 支持的模型 */
.home-models { padding-bottom: 72px; }
.home-section-title {
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}
.home-section-desc {
  font-size: 14.5px;
  color: var(--text-secondary);
  margin: 0 0 26px;
}
.home-model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.home-model-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.home-model-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.home-model-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.home-model-name {
  font-size: 16px;
  font-weight: 500;
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.home-model-ratio {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--accent-text);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
.home-model-stats {
  display: flex;
  gap: 22px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.home-model-stat-label { font-size: 12px; color: var(--text-tertiary); }
.home-model-stat-value {
  font-size: 14px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.home-model-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 20px;
  color: var(--text-tertiary);
  font-size: 14px;
  background: var(--bg-elevated);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}

/* 页脚 */
.home-footer {
  border-top: 1px solid var(--border);
  padding: 22px 20px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-tertiary);
}
.home-footer-sep { margin: 0 8px; }
