:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #1d4ed8;
  --primary-dark: #1e40af;
  --primary-soft: #eff4ff;
  --ok: #0f766e;
  --ok-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

code, .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: .92em;
}

.muted { color: var(--muted); }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }

/* ---------------- 登录页 ---------------- */
.page-login {
  background:
    radial-gradient(900px 500px at 15% 0%, #dbeafe 0%, transparent 60%),
    radial-gradient(700px 500px at 90% 100%, #e0f2fe 0%, transparent 55%),
    var(--bg);
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid rgba(226, 232, 240, .9);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 30px 30px 22px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8 60%, #1e3a8a);
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 1px;
  box-shadow: 0 6px 14px rgba(37, 99, 235, .32);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.brand-text strong { font-size: 16px; letter-spacing: .5px; }
.brand-text span { color: var(--muted); font-size: 12px; }

.app-block {
  margin: 28px 0 22px;
  padding: 18px 18px 16px;
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.app-label { font-size: 12px; color: var(--muted); letter-spacing: .08em; }
.app-name { margin: 4px 0 10px; font-size: 22px; line-height: 1.3; }
.app-cb { display: flex; gap: 8px; align-items: baseline; font-size: 12px; color: var(--muted); }
.app-cb span { flex: none; }
.app-cb code {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #475569;
}

/* ---------------- 按钮 / 表单 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform .04s ease, box-shadow .15s ease, background .15s ease;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(180deg, #2563eb, var(--primary));
  color: #fff;
  box-shadow: 0 6px 16px rgba(37, 99, 235, .28);
}
.btn-primary:hover { background: linear-gradient(180deg, #1d4ed8, var(--primary-dark)); }

.btn-wecom { min-height: 46px; font-size: 15px; }

.btn-ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}
.btn-ghost:hover { background: #f8fafc; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #991b1b; }

.btn-link {
  background: none;
  border: none;
  color: var(--muted);
  padding: 4px 6px;
  min-height: auto;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
}
.btn-link:hover { color: var(--text); text-decoration: underline; }

.btn-block { width: 100%; }
.btn-sm { min-height: 32px; padding: 4px 12px; font-size: 13px; }

.form { display: flex; flex-direction: column; gap: 6px; }
.form label { font-size: 13px; font-weight: 600; color: #334155; margin-top: 6px; }
.form input, .form textarea, .form select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font: inherit;
  color: var(--text);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form input:focus, .form textarea:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .15);
}
.form textarea { resize: vertical; min-height: 84px; }
.form .btn { margin-top: 16px; }

.hint { margin: 8px 0 0; color: var(--muted); font-size: 12px; }

.notice {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font-size: 13px;
  margin: 12px 0;
}
.notice-warn { background: var(--warn-soft); border-color: #fde68a; color: var(--warn); }
.notice-error { background: var(--danger-soft); border-color: #fecaca; color: var(--danger); }
.notice-ok { background: var(--ok-soft); border-color: #a7f3d0; color: var(--ok); }

.dev-box {
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  background: #fbfdff;
}
.dev-box summary {
  cursor: pointer;
  font-size: 13px;
  color: #475569;
  font-weight: 600;
}
.tag {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 11px;
  font-weight: 600;
}
.dev-box .form { margin-top: 10px; }

.login-foot {
  margin-top: 26px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}
.login-foot .dot { color: #cbd5e1; }

.mgr-title { font-size: 20px; margin: 26px 0 6px; }

/* ---------------- 错误页 ---------------- */
.page-center { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.center-card {
  max-width: 560px;
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 40px 36px;
  text-align: center;
}
.status-code {
  display: inline-block;
  padding: 2px 12px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .1em;
}
.center-card h1 { font-size: 22px; margin: 14px 0 8px; }
.center-msg { color: #475569; margin: 0 0 22px; word-break: break-word; }

/* ---------------- 管理后台 ---------------- */
.page-mgr { background: var(--bg); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 28px;
  height: 62px;
  padding: 0 28px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand-sm .brand-mark { width: 32px; height: 32px; border-radius: 9px; font-size: 16px; }
.brand-sm .brand-text strong { font-size: 14px; }
.brand-sm .brand-text span { font-size: 11px; }

.nav { display: flex; gap: 4px; }
.nav a {
  padding: 6px 12px;
  border-radius: 8px;
  color: #475569;
  font-size: 13px;
  font-weight: 500;
}
.nav a:hover { background: #f1f5f9; text-decoration: none; }
.nav a.on { background: var(--primary-soft); color: var(--primary); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.who { color: var(--muted); font-size: 13px; }
.topbar-right form { margin: 0; }

.container { max-width: 1120px; margin: 0 auto; padding: 26px 24px 60px; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-num { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.stat-label { color: var(--muted); font-size: 12px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
}
.card-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}
.card-head h2 { font-size: 16px; margin: 0; }
details.card > summary { list-style: none; cursor: pointer; margin-bottom: 0; }
details.card > summary::-webkit-details-marker { display: none; }
details.card[open] > summary { margin-bottom: 14px; }
details.card > summary h2 { display: inline; }

.grid-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 18px;
}
.grid-form .span-2 { grid-column: span 2; }
.span-2 { grid-column: span 2; }
.checks { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; margin-top: 8px; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: #334155; }
.check input { width: auto; }
.form-actions { display: flex; gap: 10px; align-items: center; }
.form-actions .btn { margin-top: 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td {
  padding: 12px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fbfdff; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.right, th.right { text-align: right; }

.strong-link { font-weight: 600; color: var(--text); }
.strong-link:hover { color: var(--primary); }

.badge {
  display: inline-block;
  padding: 1px 9px;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-on { background: var(--ok-soft); color: var(--ok); }
.badge-soft { background: var(--primary-soft); color: var(--primary); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }

.cb-cell { max-width: 330px; }
.cb-cell .mono { color: #475569; font-size: 12px; }

.empty { color: var(--muted); text-align: center; padding: 26px 0; margin: 0; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin: 4px 0 18px;
}
.page-head h1 { font-size: 22px; margin: 6px 0 4px; }
.back { font-size: 13px; color: var(--muted); }
.page-actions { padding-top: 6px; }

.kv-list { display: flex; flex-direction: column; }
.kv {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px dashed #eef2f7;
  align-items: baseline;
}
.kv:last-child { border-bottom: none; }
.kv > span { color: var(--muted); font-size: 13px; }
.kv code, .kv .mono { word-break: break-all; }

.card.danger { border-color: #fee2e2; }
.card.danger h2 { color: var(--danger); }
.card.danger .btn { margin-top: 6px; }

/* ---------------- 文档页 ---------------- */
.doc h2 { font-size: 17px; margin: 0 0 12px; }
.doc p { margin: 8px 0; }
.doc pre.code {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 12px;
  padding: 16px 18px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.65;
  margin: 12px 0;
  white-space: pre;
}
.doc-table { margin: 12px 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.doc-table td, .doc-table th { padding: 9px 12px; }
.doc-table tbody td { border-bottom: 1px solid #f1f5f9; }
.steps, .bullets { margin: 10px 0; padding-left: 22px; }
.steps li, .bullets li { margin: 6px 0; }

@media (max-width: 860px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-form { grid-template-columns: 1fr; }
  .grid-form .span-2, .span-2 { grid-column: span 1; }
  .topbar { gap: 12px; padding: 0 16px; }
  .nav { display: none; }
  .container { padding: 18px 14px 44px; }
  .kv { grid-template-columns: 1fr; gap: 4px; }
  .page-head { flex-direction: column; }
}
