/* ============================================================
   base.css — 设计系统（变量 / 重置 / 通用组件 / 响应式）
   所有页面共享；不承载页面私有样式。
   ============================================================ */

:root {
  /* 品牌 */
  --brand-1: #6366f1;
  --brand-2: #8b5cf6;
  --brand-grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

  /* 语义色 */
  --ok: #16a34a;
  --err: #dc2626;
  --warn: #d97706;
  --info: #2563eb;

  /* 中性色 */
  --bg: #f4f6fb;
  --surface: #ffffff;
  --border: #e5e9f2;
  --text: #1e293b;
  --text-2: #64748b;
  --text-3: #94a3b8;

  /* 尺寸 */
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, .12);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  line-height: 1.6;
  font-size: 15px;
}

a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { font-weight: 700; line-height: 1.3; }

/* ── 布局工具 ─────────────────────────────────────────────── */

.container { max-width: 1040px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--text-2); }
.mono { font-family: var(--mono); }
.hidden { display: none !important; }

/* ── 顶部导航 ─────────────────────────────────────────────── */

.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: 1040px; margin: 0 auto; padding: 0 20px;
  height: 60px; display: flex; align-items: center; gap: 16px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 17px; color: var(--text); letter-spacing: .2px;
}
.brand .logo {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: var(--brand-grad);
  display: grid; place-items: center; color: #fff;
  font-size: 15px; box-shadow: 0 4px 10px rgba(99, 102, 241, .35);
}
.nav-links { display: flex; gap: 6px; margin-left: 8px; }
.nav-link {
  padding: 7px 14px; border-radius: 10px; color: var(--text-2);
  font-size: 14px; font-weight: 500;
}
.nav-link:hover { background: rgba(99, 102, 241, .08); color: var(--brand-1); text-decoration: none; }
.nav-link.active { background: var(--brand-grad); color: #fff; box-shadow: 0 4px 12px rgba(99,102,241,.3); }
.nav-spacer { flex: 1; }
.nav-user { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 10px; }

/* ── 卡片 ────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 26px 28px;
}
.card + .card { margin-top: 18px; }
.card h2 { font-size: 16px; margin-bottom: 4px; }
.card .card-sub { font-size: 13px; color: var(--text-2); margin-bottom: 16px; }

/* ── 按钮 ────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 11px; cursor: pointer;
  padding: 10px 18px; font-size: 14px; font-weight: 600; font-family: inherit;
  transition: all .18s ease; white-space: nowrap; user-select: none;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand-grad); color: #fff; box-shadow: 0 4px 14px rgba(99,102,241,.3); }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(99,102,241,.4); }
.btn-ghost { background: #fff; color: var(--text); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { border-color: var(--brand-1); color: var(--brand-1); }
.btn-danger { background: #fff; color: var(--err); border-color: #f3cdcd; }
.btn-danger:hover:not(:disabled) { background: #fef2f2; border-color: var(--err); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 9px; }
.btn-lg { padding: 13px 22px; font-size: 15px; }

/* ── 表单 ────────────────────────────────────────────────── */

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 7px; }
.input, .textarea, .select {
  width: 100%; padding: 11px 14px; font-size: 14px; font-family: inherit;
  border: 1.5px solid var(--border); border-radius: 11px; outline: none;
  background: #fff; color: var(--text); transition: border-color .15s, box-shadow .15s;
}
.textarea { resize: vertical; min-height: 74px; font-family: var(--mono); font-size: 13px; }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--brand-1);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, .13);
}

/* ── 徽标 ────────────────────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.badge-admin { background: #fef3c7; color: #92400e; }
.badge-user { background: #e0e7ff; color: #3730a3; }
.badge-ok { background: #dcfce7; color: #15803d; }
.badge-off { background: #fee2e2; color: #b91c1c; }
.badge-muted { background: #f1f5f9; color: var(--text-2); }
.badge-warn { background: #fef3c7; color: #b45309; }
.badge-rej { background: #fee2e2; color: #b91c1c; }

/* 待审核横幅 */
.alert {
  display: flex; align-items: center; gap: 10px;
  border-radius: 12px; padding: 13px 16px; font-size: 14px; margin-bottom: 18px;
}
.alert-warn { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-err { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }
.alert-ok { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }

/* ── 表格 ────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { background: #f8fafc; color: var(--text-2); font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafbff; }
.table td.mono, .table td code { font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
.op-btn {
  border: 1px solid var(--border); background: #fff; border-radius: 8px;
  padding: 4px 10px; font-size: 12.5px; cursor: pointer; margin: 2px; transition: all .15s;
}
.op-btn:hover { border-color: var(--brand-1); color: var(--brand-1); }
.op-btn.danger { color: var(--err); }
.op-btn.danger:hover { border-color: var(--err); background: #fef2f2; }

/* ── Key 展示框 ──────────────────────────────────────────── */

.keybox {
  display: flex; align-items: center; gap: 10px;
  background: #f8fafc; border: 1.5px dashed var(--border); border-radius: 12px;
  padding: 14px 16px;
}
.keybox code { flex: 1; font-family: var(--mono); font-size: 14px; word-break: break-all; color: var(--brand-1); }
.copy-btn {
  background: var(--brand-grad); color: #fff; border: none; border-radius: 9px;
  padding: 8px 16px; font-size: 13px; font-weight: 600; cursor: pointer; flex: none;
  box-shadow: 0 3px 10px rgba(99,102,241,.3); transition: all .18s;
}
.copy-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(99,102,241,.4); }

/* ── Toast ───────────────────────────────────────────────── */

.toast {
  position: fixed; top: 22px; left: 50%; transform: translate(-50%, -16px);
  z-index: 999; padding: 11px 20px; border-radius: 12px; font-size: 14px;
  color: #fff; opacity: 0; pointer-events: none;
  box-shadow: var(--shadow-lg); transition: all .25s ease; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.success { background: var(--ok); }
.toast.error { background: var(--err); }
.toast.info { background: #334155; }

/* ── 加载态 / 空态 ───────────────────────────────────────── */

.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2.5px solid rgba(255,255,255,.35); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; color: var(--text-3); padding: 40px 0; font-size: 14px; }

/* ── 登录 / 注册页 ───────────────────────────────────────── */

.auth-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 12% -8%, rgba(99,102,241,.16), transparent 60%),
    radial-gradient(800px 480px at 105% 10%, rgba(139,92,246,.16), transparent 55%),
    linear-gradient(160deg, #f6f7ff 0%, #eef2ff 100%);
}
.auth-card {
  width: 100%; max-width: 430px; background: rgba(255,255,255,.9);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,.7); border-radius: 22px;
  box-shadow: var(--shadow-lg); padding: 36px 34px;
}
.auth-logo { display: flex; align-items: center; gap: 11px; margin-bottom: 6px; }
.auth-logo .logo {
  width: 42px; height: 42px; border-radius: 12px; background: var(--brand-grad);
  display: grid; place-items: center; color: #fff; font-size: 20px;
  box-shadow: 0 8px 20px rgba(99,102,241,.4);
}
.auth-title { font-size: 21px; font-weight: 800; }
.auth-sub { color: var(--text-2); font-size: 13.5px; margin-bottom: 22px; }
.auth-tabs { display: flex; gap: 8px; background: #f1f5f9; padding: 5px; border-radius: 12px; margin-bottom: 22px; }
.auth-tab {
  flex: 1; text-align: center; padding: 9px 0; border: none; background: transparent;
  border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--text-2); cursor: pointer; transition: all .2s;
}
.auth-tab.active { background: #fff; color: var(--brand-1); box-shadow: 0 2px 8px rgba(15,23,42,.08); }

/* ── 统计卡片（概览页） ──────────────────────────────────── */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 20px; box-shadow: var(--shadow);
}
.stat-card .num { font-size: 30px; font-weight: 800; letter-spacing: .3px; }
.stat-card .lbl { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.stat-card .icon { font-size: 22px; }

/* ── 折叠区（改密码等） ──────────────────────────────────── */

details.panel { margin-top: 18px; border: 1px solid var(--border); border-radius: 12px; background: #fbfcff; }
details.panel summary {
  cursor: pointer; padding: 13px 16px; font-size: 13.5px; font-weight: 600; color: var(--text-2); list-style: none;
}
details.panel summary::-webkit-details-marker { display: none; }
details.panel summary::before { content: '▸ '; color: var(--brand-1); }
details.panel[open] summary::before { content: '▾ '; }
details.panel .panel-body { padding: 4px 16px 18px; }

/* ── 结果表格（测试页） ──────────────────────────────────── */

.result-table td:first-child { white-space: nowrap; font-weight: 600; color: var(--text-2); width: 130px; }

/* ── 响应式 ──────────────────────────────────────────────── */

@media (max-width: 640px) {
  .container { padding: 0 14px; }
  .nav-inner { padding: 0 14px; }
  .card { padding: 20px 18px; border-radius: 16px; }
  .auth-card { padding: 28px 22px; }
  .keybox { flex-direction: column; align-items: stretch; }
  .copy-btn { width: 100%; }
  .nav-user .name { display: none; }
  .nav-link { padding: 6px 10px; font-size: 13px; }
  .btn { font-size: 13.5px; }
}
