:root {
  --bg: #f5f6fa;
  --bg-soft: #eef0f7;
  --card: #ffffff;
  --line: #e5e7ef;
  --line-strong: #d5d8e4;
  --ink: #171a23;
  --ink-2: #3d4353;
  --muted: #767d90;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --accent-2: #7c3aed;
  --green: #0f9d58;
  --green-soft: #e7f7ee;
  --amber: #b45309;
  --amber-soft: #fdf3e3;
  --red: #d23f3f;
  --red-soft: #fdecec;
  --blue: #2563eb;
  --blue-soft: #e9f0ff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(23, 26, 35, 0.04), 0 8px 24px -12px rgba(23, 26, 35, 0.12);
  --mono: "JetBrains Mono", "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -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(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
code, pre { font-family: var(--mono); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }

/* ---------------- 通用组件 ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink-2);
  font-weight: 550;
  font-size: 13px;
  cursor: pointer;
  transition: 0.16s ease;
  white-space: nowrap;
}
.btn:hover { border-color: #c3c7d6; background: #fbfbfe; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 16px -8px rgba(79, 70, 229, 0.8);
}
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--red); border-color: #f2c9c9; background: #fff7f7; }
.btn.danger:hover { background: var(--red-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--bg-soft); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn.icon { width: 32px; height: 32px; padding: 0; }

.input, .select, .textarea {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  outline: none;
  transition: 0.16s;
}
.textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 88px; line-height: 1.6; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
.input::placeholder { color: #9aa0b1; }
label.field { display: block; margin-bottom: 14px; }
label.field > span.label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
}
label.field > span.hint { display: block; font-size: 11.5px; color: var(--muted); margin-top: 5px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.02em;
  background: var(--bg-soft);
  color: var(--muted);
  white-space: nowrap;
}
.badge.free { background: var(--green-soft); color: var(--green); }
.badge.lv1 { background: var(--blue-soft); color: var(--blue); }
.badge.lv2 { background: #f3ecff; color: #7c3aed; }
.badge.warn { background: var(--amber-soft); color: var(--amber); }
.badge.err { background: var(--red-soft); color: var(--red); }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.cache { background: var(--accent-soft); color: var(--accent); }
.badge.env { background: #eef2ff; color: #4338ca; letter-spacing: .04em; font-family: var(--mono, ui-monospace, monospace); }

.field.is-managed .input,
.field.is-managed .textarea { background: var(--bg-soft, #f6f7f9); color: var(--text-muted, #6b7280); cursor: not-allowed; }
.field.is-managed .label, .switch.is-managed span { opacity: .85; }
.input:disabled, .textarea:disabled { cursor: not-allowed; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--ink-2);
  font-size: 11.5px;
}

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left;
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfbfd;
  white-space: nowrap;
}
table.data td { padding: 12px 14px; border-bottom: 1px solid #f0f1f6; vertical-align: middle; }
table.data tbody tr:hover { background: #fafaff; }
table.data tr:last-child td { border-bottom: none; }
table.data .empty { text-align: center; color: var(--muted); padding: 40px 0; }

.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}
.toast {
  min-width: 220px;
  max-width: 380px;
  padding: 11px 14px;
  border-radius: 10px;
  background: #1f2330;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.4);
  animation: slideIn 0.22s ease;
}
.toast.err { background: #b32d2d; }
.toast.ok { background: #157347; }
@keyframes slideIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------- 登录 / 初始化 ---------------- */

.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1000px 500px at 85% -10%, #e6e2ff 0%, transparent 60%),
    radial-gradient(800px 420px at 5% 100%, #e2f0ff 0%, transparent 55%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 20px;
  border: 1px solid var(--line);
  box-shadow: 0 30px 60px -30px rgba(23, 26, 35, 0.25);
  padding: 32px;
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.brand .mark {
  width: 38px; height: 38px;
  border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 800; font-size: 17px;
  box-shadow: 0 8px 18px -8px rgba(79, 70, 229, 0.8);
}
.brand .name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand .sub { font-size: 11.5px; color: var(--muted); }
.auth-card h1 { font-size: 21px; margin-bottom: 6px; }
.auth-card .lead { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.auth-card .btn { width: 100%; height: 40px; margin-top: 6px; }
.auth-foot { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; }
.form-error {
  display: none;
  margin-bottom: 12px;
  padding: 9px 12px;
  border-radius: 9px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 12.5px;
}
.form-error.show { display: block; }

/* ---------------- 后台框架 ---------------- */

.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand { padding: 0 6px; margin-bottom: 24px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.nav a:hover { background: var(--bg-soft); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.nav a .ico { width: 17px; height: 17px; opacity: 0.85; }
.sidebar .spacer { flex: 1; }
.sidebar .who { padding: 10px 12px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.sidebar .who b { display: block; color: var(--ink); font-size: 13px; font-weight: 600; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 26px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h2 { font-size: 16px; }
.topbar .desc { font-size: 12px; color: var(--muted); margin-top: 1px; }
.content { padding: 24px 26px 40px; max-width: 1320px; width: 100%; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 15px 16px;
}
.stat .k { font-size: 11.5px; color: var(--muted); font-weight: 600; letter-spacing: 0.02em; }
.stat .v { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin-top: 3px; }
.stat .v small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.stat .s { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; }
@media (max-width: 1080px) {
  .grid-2 { grid-template-columns: 1fr; }
  .sidebar { width: 200px; flex-basis: 200px; }
}
@media (max-width: 780px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex-basis: auto; height: auto; position: static; flex-direction: row; align-items: center; overflow-x: auto; padding: 10px 12px; }
  .sidebar .brand { display: none; }
  .nav { flex-direction: row; }
  .sidebar .spacer, .sidebar .who { display: none; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
}

.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.panel-head h3 { font-size: 14px; }
.panel-head .sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.panel-body { padding: 16px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; min-width: 140px; }
.toolbar .input, .toolbar .select { height: 34px; }

.bar-chart { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 10px; }
.bar-chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar-chart .bar {
  width: 100%; max-width: 46px; border-radius: 6px 6px 3px 3px;
  background: linear-gradient(180deg, #8f88f5, #4f46e5);
  min-height: 3px;
  transition: 0.3s;
  position: relative;
}
.bar-chart .bar:hover { filter: brightness(1.08); }
.bar-chart .lbl { font-size: 10.5px; color: var(--muted); }
.bar-chart .val { font-size: 10.5px; color: var(--ink-2); font-weight: 600; }

.key-cell { display: flex; align-items: center; gap: 6px; }
.key-cell code {
  font-size: 11.5px;
  background: var(--bg-soft);
  padding: 4px 7px;
  border-radius: 6px;
  color: var(--ink-2);
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.progress {
  height: 6px; border-radius: 999px; background: var(--bg-soft); overflow: hidden; min-width: 80px;
}
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, #6d63f0, #8b5cf6); border-radius: 999px; }
.progress.warn > i { background: linear-gradient(90deg, #f59e0b, #f97316); }
.progress.err > i { background: linear-gradient(90deg, #ef4444, #dc2626); }

.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state h4 { color: var(--ink); margin-bottom: 4px; font-size: 14px; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20, 22, 30, 0.42);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 60;
  animation: fade 0.16s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 520px; background: #fff; border-radius: 16px;
  box-shadow: 0 40px 80px -20px rgba(0, 0, 0, 0.35); overflow: hidden;
  animation: pop 0.18s ease;
}
@keyframes pop { from { transform: translateY(10px) scale(0.99); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { padding: 18px 20px 0; }
.modal-head h3 { font-size: 16px; }
.modal-head p { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.modal-body { padding: 18px 20px; max-height: 66vh; overflow-y: auto; }
.modal-foot { padding: 14px 20px; background: #fafafd; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

.drawer-mask { position: fixed; inset: 0; background: rgba(20, 22, 30, 0.35); z-index: 55; animation: fade 0.16s; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(560px, 100vw);
  background: #fff; z-index: 56; box-shadow: -20px 0 60px -30px rgba(0,0,0,0.4);
  display: flex; flex-direction: column; animation: slideLeft 0.22s ease;
}
@keyframes slideLeft { from { transform: translateX(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.drawer-head { padding: 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; }
.drawer-body { padding: 20px; overflow-y: auto; flex: 1; }

pre.code {
  background: #171a23; color: #d7dae6; padding: 12px 14px; border-radius: 10px;
  font-size: 12px; line-height: 1.65; overflow-x: auto; margin: 0; white-space: pre;
}
pre.code .k { color: #a5b4fc; }

/* 设置页 */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.section-title { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 650; margin-bottom: 14px; }
.section-title .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.switch { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 999px; background: #d8dae5; position: relative; cursor: pointer; transition: 0.18s; flex: 0 0 auto; }
.switch input:checked { background: var(--accent); }
.switch input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; transition: 0.18s; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.switch input:checked::after { left: 19px; }
.switch span { font-size: 13px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* 文档页 */
.site-nav {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,0.86); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.site-nav .inner {
  max-width: 1180px; margin: 0 auto; padding: 0 24px; height: 62px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.hero { max-width: 1180px; margin: 0 auto; padding: 56px 24px 26px; }
.hero .eyebrow { font-size: 12px; font-weight: 650; color: var(--accent); letter-spacing: 0.08em; text-transform: uppercase; }
.hero h1 { font-size: 34px; line-height: 1.2; margin: 10px 0 10px; letter-spacing: -0.03em; }
.hero .lead { color: var(--muted); font-size: 15px; max-width: 660px; }
.hero .pills { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px 64px; }
.section { margin-top: 26px; scroll-margin-top: 78px; }
.section > h2 { font-size: 18px; margin-bottom: 4px; }
.section > p.sub { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; }
.step { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.step .n { width: 24px; height: 24px; border-radius: 7px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 12px; font-weight: 700; margin-bottom: 10px; }
.step h3 { font-size: 13.5px; margin-bottom: 4px; }
.step p { font-size: 12.5px; color: var(--muted); }

.ep-group { margin-bottom: 18px; }
.ep-group-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.ep-group-head h3 { font-size: 14px; }
.ep-group-head .count { font-size: 11.5px; color: var(--muted); }
.ep-list { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.ep {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px;
  border-bottom: 1px solid #f0f1f6; cursor: pointer; transition: background 0.12s;
}
.ep:last-child { border-bottom: none; }
.ep:hover { background: #fafaff; }
.ep .method {
  font-family: var(--mono); font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em;
  padding: 3px 7px; border-radius: 5px; background: var(--bg-soft); color: var(--ink-2); min-width: 52px; text-align: center;
}
.ep .method.post { background: #eaf6ef; color: #0f9d58; }
.ep .path { font-family: var(--mono); font-size: 12.5px; color: var(--ink); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ep .name { font-size: 12.5px; color: var(--muted); }
.ep .meta { display: flex; align-items: center; gap: 6px; }
@media (max-width: 720px) {
  .ep .name { display: none; }
  .hero h1 { font-size: 26px; }
}
.search-box { position: relative; flex: 1; min-width: 200px; }
.search-box input { padding-left: 34px; }
.search-box svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); opacity: 0.45; }

.err-table { width: 100%; border-collapse: collapse; font-size: 12.5px; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.err-table th, .err-table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid #f0f1f6; }
.err-table th { background: #fbfbfd; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.err-table tr:last-child td { border-bottom: none; }

.footer { border-top: 1px solid var(--line); padding: 22px 24px; text-align: center; color: var(--muted); font-size: 12px; }

/* 细节 */
.copy-btn { opacity: 0.6; }
.copy-btn:hover { opacity: 1; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; font-size: 12.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.section-divider { height: 1px; background: var(--line); margin: 18px 0; }
.notice {
  display: flex; gap: 10px; padding: 10px 12px; border-radius: 10px;
  background: var(--accent-soft); color: #423bb5; font-size: 12.5px; line-height: 1.55;
}
.notice.warn { background: var(--amber-soft); color: var(--amber); }
.notice.err { background: var(--red-soft); color: var(--red); }
