:root {
  --bg: #f6f7f9;
  --card: #fff;
  --text: #1c2026;
  --muted: #6b7380;
  --line: #e4e7ec;
  --accent: #2f6feb;
  --accent-text: #fff;
  --danger: #d1343b;
  --ok: #1a8a4a;
  --warn: #b26b00;
  --code: #f1f3f6;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --card: #1a1e24;
    --text: #e6e9ee;
    --muted: #8d96a3;
    --line: #2b313a;
    --accent: #4c8bf5;
    --code: #232931;
    --danger: #f0565c;
    --ok: #3fbf74;
    --warn: #e09b2d;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
code { background: var(--code); padding: 1px 6px; border-radius: 5px; }
pre { background: var(--code); padding: 12px 14px; border-radius: 8px; overflow-x: auto; margin: 8px 0; }
pre code { background: none; padding: 0; }
h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 15px; margin: 0 0 12px; }
.boot { padding: 40px; color: var(--muted); text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.danger { color: var(--danger); }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* 布局 */
.layout { display: flex; min-height: 100vh; }
.side {
  width: 200px; flex-shrink: 0; background: var(--card); border-right: 1px solid var(--line);
  padding: 18px 12px; display: flex; flex-direction: column; gap: 2px;
}
.brand { font-weight: 700; font-size: 16px; padding: 0 10px 14px; display: flex; align-items: center; gap: 8px; }
.brand img { width: 22px; height: 22px; }
.side a { color: var(--text); padding: 7px 10px; border-radius: 7px; }
.side a:hover { background: var(--code); }
.side a.active { background: var(--accent); color: var(--accent-text); }
.side .group { font-size: 12px; color: var(--muted); padding: 14px 10px 4px; }
.side .spacer { flex: 1; }
.side .who { font-size: 12px; color: var(--muted); padding: 8px 10px; border-top: 1px solid var(--line); margin-top: 8px; }
.main { flex: 1; padding: 28px 32px; max-width: 1100px; min-width: 0; }
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .side { width: auto; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); padding: 10px; }
  .brand { width: 100%; padding-bottom: 6px; }
  .side .group, .side .spacer { display: none; }
  .side .who { border: 0; margin: 0; }
  .main { padding: 18px 14px; }
}

/* 卡片和数字 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 24px; font-weight: 600; margin-top: 2px; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tag { display: inline-block; font-size: 12px; padding: 0 8px; border-radius: 99px; background: var(--code); white-space: nowrap; }
.tag.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); }
.tag.danger { background: color-mix(in srgb, var(--danger) 15%, transparent); }
.tag.warn { background: color-mix(in srgb, var(--warn) 15%, transparent); }
.empty { color: var(--muted); padding: 20px 0; text-align: center; }

/* 表单 */
form { margin: 0; }
label { display: block; margin-bottom: 12px; }
label > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 7px;
  padding: 7px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
input[type=checkbox] { width: auto; margin-right: 6px; }
.check { display: flex; align-items: center; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > label { flex: 1; min-width: 140px; }
.row > .btn { margin-bottom: 12px; }
.btn {
  font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--card); color: var(--text);
  padding: 7px 14px; border-radius: 7px; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.small { padding: 2px 10px; font-size: 12px; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input { width: auto; flex: 1; max-width: 260px; }

/* 登录页 */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth .card { width: 100%; max-width: 360px; }
.auth .brand { justify-content: center; font-size: 20px; padding-bottom: 18px; }
.auth .btn { width: 100%; margin-top: 4px; }
.auth .switch { text-align: center; margin-top: 14px; font-size: 13px; }
.turnstile { margin-bottom: 12px; min-height: 0; }

/* 弹层和提示 */
.overlay { position: fixed; inset: 0; background: rgb(0 0 0 / .45); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 10; }
.dialog { background: var(--card); border-radius: var(--radius); padding: 22px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; }
.dialog .actions { justify-content: flex-end; margin-top: 16px; }
.secret { display: flex; gap: 8px; align-items: center; }
.secret code { flex: 1; padding: 8px 10px; word-break: break-all; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 8px 18px; border-radius: 8px; z-index: 20; max-width: 90vw;
}
.toast.error { background: var(--danger); color: #fff; }
textarea.codes { min-height: 140px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.err-detail { font-size: 12px; color: var(--muted); max-width: 360px; word-break: break-all; }
