:root {
  --bg: #0b0b0b;
  --card: #161616;
  --card-2: #1d1d1d;
  --border: #2a2a2a;
  --border-soft: #222;
  --text: #f2f2f2;
  --text-dim: #9a9a9a;
  --text-faint: #6b6b6b;
  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;
  --blue: #60a5fa;
  --code-bg: #262626;
  --code-border: #2a2a2a;
  --pre-bg: #101010;
  --input-bg: #1d1d1d;
  --nav-active: #2e2e2e;
  --topbar-bg: rgba(11, 11, 11, .92);
  --shadow: rgba(0, 0, 0, .5);
}

/* 浅色主题（顶栏月亮/太阳按钮切换，持久化到 localStorage） */
html[data-theme="light"] {
  --bg: #f4f5f7;
  --card: #ffffff;
  --card-2: #f6f7f9;
  --border: #d9dde3;
  --border-soft: #e7e9ee;
  --text: #17181a;
  --text-dim: #5b6069;
  --text-faint: #9298a2;
  --green: #10b981;
  --red: #ef4444;
  --amber: #f59e0b;
  --blue: #3b82f6;
  --code-bg: #eef0f3;
  --code-border: #d9dde3;
  --pre-bg: #f6f7f9;
  --input-bg: #ffffff;
  --nav-active: #e4e7ec;
  --topbar-bg: rgba(255, 255, 255, .92);
  --shadow: rgba(15, 23, 42, .12);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  min-height: 100vh;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 32px;
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  background: var(--topbar-bg);
  backdrop-filter: blur(8px);
  z-index: 50;
}
.logo { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.logo small { color: var(--text-dim); font-weight: 400; font-size: 13px; }
.logo-mark { font-size: 22px; }

.nav {
  display: flex;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 4px;
}
.nav a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14px;
  padding: 6px 18px;
  border-radius: 999px;
  transition: all .15s;
}
.nav a:hover { color: var(--text); }
.nav a.active { background: var(--nav-active); color: var(--text); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--border-soft);
  cursor: pointer; font-size: 16px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .15s; color: var(--text);
}
.icon-btn:hover { border-color: var(--border); transform: translateY(-1px); }

.user-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--border-soft);
  border-radius: 999px; padding: 4px 10px 4px 4px;
  font-size: 13px; color: var(--text-dim);
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: #fff; font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
}
.user-chip.admin .avatar { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.logout-btn {
  border: none; background: transparent; cursor: pointer;
  color: var(--text-faint); font-size: 14px; padding: 2px 4px;
}
.logout-btn:hover { color: var(--red); }
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 5px 12px; background: var(--card);
}
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot.green { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot.red { background: var(--red); }
.dot.gray { background: #555; }

/* ---------- 布局 ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 32px 32px 80px; }
.section-title { font-size: 19px; font-weight: 700; margin: 30px 0 14px; }
.section-title:first-child { margin-top: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 20px;
}

/* ---------- 总览 ---------- */
.overview-head {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 14px 18px;
  background: var(--card-2);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  font-size: 13.5px; color: var(--text-dim);
}
.overview-head b { color: var(--text); font-weight: 600; }
.overview-head .right { margin-left: auto; color: var(--text-faint); font-family: ui-monospace, monospace; }

.quota-card {
  margin-top: 14px;
  background: var(--card-2);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 18px;
}
.quota-label { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.quota-label .tip { color: var(--text-faint); font-size: 12px; font-weight: 400; }
.bar { margin: 14px 0 10px; height: 6px; background: var(--code-border); border-radius: 999px; overflow: hidden; }
.bar > div { height: 100%; background: linear-gradient(90deg, #3b82f6, #60a5fa); border-radius: 999px; transition: width .4s; }
.bar > div.warn { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.bar > div.full { background: linear-gradient(90deg, #ef4444, #f87171); }
.quota-num { font-size: 13px; color: var(--text-dim); }
.quota-num b { color: var(--text); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-top: 14px; }
.stat {
  background: var(--card-2); border: 1px solid var(--border-soft);
  border-radius: 10px; padding: 14px 16px;
}
.stat .k { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.stat .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .v.green { color: var(--green); }
.stat .v.red { color: var(--red); }
.stat .v.blue { color: var(--blue); }

/* ---------- Token 表格 ---------- */
.card-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 6px; }
.card-head h3 { font-size: 16px; }
.card-head p { color: var(--text-dim); font-size: 13px; margin-top: 6px; line-height: 1.6; }
.btn {
  border: none; cursor: pointer; font-size: 13.5px;
  border-radius: 8px; padding: 9px 18px;
  transition: all .15s; white-space: nowrap;
}
.btn.primary { background: var(--text); color: var(--bg); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.15); }
.btn.ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn.ghost:hover { color: var(--text); border-color: #3a3a3a; }
.btn.danger-ghost { background: transparent; border: none; color: var(--red); cursor: pointer; font-size: 13px; padding: 4px 6px; }
.btn.plain { background: transparent; border: none; color: var(--text-dim); cursor: pointer; font-size: 13px; padding: 4px 6px; }
.btn.plain:hover, .btn.danger-ghost:hover { color: var(--text); }
.card-head .spacer { margin-left: auto; }

table { width: 100%; border-collapse: collapse; margin-top: 16px; font-size: 13.5px; }
th {
  text-align: left; color: var(--text-faint); font-weight: 500;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 12px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; color: var(--text-dim); }
.status-ok { color: var(--green); font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.dim { color: var(--text-faint); }

/* ---------- 登录 ---------- */
.login-wrap { display: flex; justify-content: center; padding-top: 10vh; }
.login-card { width: 420px; text-align: center; }
.login-card h2 { font-size: 20px; margin-bottom: 10px; }
.login-card p { color: var(--text-dim); font-size: 13.5px; line-height: 1.7; margin-bottom: 22px; }
.input {
  width: 100%; background: var(--input-bg); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 11px 14px; font-size: 14px;
  outline: none; font-family: ui-monospace, monospace;
}
.input:focus { border-color: var(--text-faint); }
.login-card .input { margin-bottom: 14px; }
.error-msg { color: var(--red); font-size: 13px; margin-bottom: 12px; min-height: 18px; }

/* ---------- 文档页 ---------- */
.docs { max-width: 920px; }
.docs h1 { font-size: 26px; margin-bottom: 8px; }
.docs .lead { color: var(--text-dim); font-size: 14.5px; line-height: 1.8; margin-bottom: 20px; }
.docs h2 { font-size: 19px; margin: 34px 0 14px; padding-top: 10px; }
.docs h3 { font-size: 15.5px; margin: 22px 0 10px; color: var(--text); }
.docs p { color: var(--text-dim); font-size: 13.5px; line-height: 1.8; margin: 8px 0; }
.docs ul { margin: 8px 0 8px 20px; color: var(--text-dim); font-size: 13.5px; line-height: 1.9; }
.docs code.inline {
  background: var(--code-bg); border: 1px solid var(--code-border); border-radius: 5px;
  padding: 1px 7px; font-size: 12.5px; font-family: ui-monospace, monospace; color: var(--text);
}
pre {
  background: var(--pre-bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px 18px; overflow-x: auto;
  font-size: 12.8px; line-height: 1.7; margin: 12px 0;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--text);
}
html[data-theme="light"] pre .c { color: #4a7c3f; }
html[data-theme="light"] pre .k { color: #1d6fb8; }
html[data-theme="light"] pre .s { color: #b0552e; }
pre .c { color: #6a9955; }
pre .k { color: #79b8ff; }
pre .s { color: #ce9178; }

.ep {
  display: inline-flex; align-items: center; gap: 10px; margin: 18px 0 6px;
}
.method {
  font-size: 11.5px; font-weight: 700; border-radius: 6px; padding: 3px 9px;
  font-family: ui-monospace, monospace; letter-spacing: .4px;
}
.method.get { background: #1d3a2f; color: #4ade80; }
.method.post { background: #1d3254; color: #60a5fa; }
.method.del { background: #452020; color: #f87171; }
.ep code { font-family: ui-monospace, monospace; font-size: 14px; font-weight: 600; }

table.doc { font-size: 13px; }
table.doc th { color: var(--text-dim); }
table.doc td { color: var(--text-dim); }
table.doc td:first-child { color: var(--text); font-family: ui-monospace, monospace; font-size: 12.5px; white-space: nowrap; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  backdrop-filter: blur(3px);
}
.modal {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 26px; width: 460px; max-width: 92vw;
  max-height: 84vh; overflow-y: auto;
}
.modal h3 { font-size: 16px; margin-bottom: 6px; }
.modal p.sub { color: var(--text-dim); font-size: 13px; line-height: 1.7; margin-bottom: 18px; }
.modal .row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.token-show {
  background: var(--pre-bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; font-family: ui-monospace, monospace; font-size: 13px;
  word-break: break-all; color: var(--text); margin: 10px 0;
}
.hidden { display: none !important; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 34px; left: 50%; transform: translateX(-50%);
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  font-size: 13.5px; padding: 10px 20px; border-radius: 999px; z-index: 200;
  box-shadow: 0 6px 24px var(--shadow);
}

.empty { text-align: center; color: var(--text-faint); font-size: 13.5px; padding: 34px 0; }
.refresh-note { color: var(--text-faint); font-size: 12px; margin-top: 10px; }
