:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --text: #1f2329;
  --muted: #86909c;
  --border: #e5e6eb;
  --bg: #f0f4ff;
  --error: #f53f3f;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.page { max-width: 420px; margin: 0 auto; padding: 48px 16px 32px; display: flex; flex-direction: column; min-height: 100vh; }
main { flex: 1; }
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.logo-img { width: 42px; height: 42px; object-fit: contain; }
.topbar-logo { width: 26px; height: 26px; object-fit: contain; vertical-align: -7px; margin-right: 4px; }
.brand-name { font-size: 17px; font-weight: 600; }
.card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 32px 28px; box-shadow: 0 4px 16px rgba(31,35,41,.06); }
.card.center { text-align: center; }
h1 { font-size: 20px; margin-bottom: 6px; }
.sub { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.app-desc { color: var(--muted); font-size: 13px; margin: -10px 0 14px; }
label { display: block; font-size: 13px; color: var(--text); margin-bottom: 14px; }
input[type="text"], input[type="password"] {
  width: 100%; margin-top: 6px; padding: 10px 12px; font-size: 14px;
  border: 1px solid var(--border); border-radius: 8px; outline: none; transition: border .15s;
}
input:focus { border-color: var(--primary); }
.btn {
  display: inline-block; width: 100%; padding: 11px 0; font-size: 15px; border-radius: 8px;
  border: 1px solid var(--border); background: #fff; color: var(--text); cursor: pointer;
  text-align: center; text-decoration: none; transition: all .15s;
}
.btn:hover { background: #f7f8fa; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; margin-top: 8px; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.feishu { background: #f5f6f8; color: #3370ff; border-color: #dfe1e6; }
.alert { padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.alert.error { background: #ffece8; color: var(--error); }
.divider { position: relative; text-align: center; margin: 20px 0 14px; }
.divider::before { content: ""; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: var(--border); }
.divider span { position: relative; background: #fff; color: var(--muted); font-size: 12px; padding: 0 10px; }
.scopes { background: #f7f8fa; border-radius: 8px; padding: 14px 16px; margin-bottom: 20px; }
.scopes-title { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.scopes ul { list-style: none; }
.scopes li { font-size: 13px; padding: 3px 0; }
.scopes li::before { content: "✓"; color: #00b42a; margin-right: 8px; }
.actions { display: flex; gap: 12px; }
.actions .btn { width: 50%; }
.code { font-size: 40px; font-weight: 700; color: var(--primary); margin-bottom: 8px; }
footer { text-align: center; color: var(--muted); font-size: 12px; margin-top: 28px; }

/* ============ 管理后台 ============ */
body.admin { background: var(--bg); }
.topbar {
  display: flex; align-items: center; gap: 18px; padding: 12px 24px;
  background: #1f2329; color: #fff; position: sticky; top: 0; z-index: 10;
}
.topbar-brand { font-weight: 600; font-size: 15px; }
.topbar-links { display: flex; gap: 4px; flex: 1; }
.topbar-links a { color: #c9cdd4; text-decoration: none; font-size: 14px; padding: 6px 12px; border-radius: 6px; }
.topbar-links a:hover { background: rgba(255,255,255,.1); color: #fff; }
.topbar-links a.active { background: var(--primary); color: #fff; }
.topbar-user { font-size: 13px; display: flex; gap: 12px; align-items: center; }
.topbar-user .muted { color: #86909c; }
.admin-main { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }
.page-title { font-size: 20px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.section-title { font-size: 15px; margin: 0 0 12px; }
.count { font-size: 13px; color: var(--muted); font-weight: 400; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 16px 0 26px; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 18px;
        text-decoration: none; color: var(--text); display: flex; flex-direction: column; gap: 4px; }
.stat b { font-size: 26px; color: var(--primary); }
.stat span { font-size: 13px; color: var(--muted); }
.panel { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; margin-bottom: 18px; }
.panel summary { cursor: pointer; font-size: 14px; font-weight: 500; }
table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--border);
        border-radius: 10px; overflow: hidden; font-size: 13px; }
table th, table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table th { background: #f7f8fa; font-weight: 500; color: var(--muted); }
table tr:last-child td { border-bottom: none; }
.row-disabled td { opacity: .55; }
code { background: #f2f3f5; padding: 1px 6px; border-radius: 4px; font-size: 12px; }
.badge { display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 999px;
         background: #f2f3f5; color: var(--muted); font-weight: 400; }
.badge.ok { background: #e8ffea; color: #00b42a; }
.badge.bad { background: #ffece8; color: var(--error); }
.badge.warn { background: #fff7e8; color: #ff7d00; }
.filter-bar { display: flex; gap: 10px; margin: 14px 0; }
.filter-bar input, .filter-bar select { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.grid-form { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 20px; margin-top: 12px; }
.grid-form label { font-size: 13px; margin: 0; }
.grid-form input, .grid-form select, .grid-form textarea {
  width: 100%; margin-top: 5px; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px; font-family: inherit;
}
.grid-form fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; grid-column: 1 / -1; }
.grid-form legend { font-size: 12px; color: var(--muted); padding: 0 6px; }
.check { display: inline-flex !important; align-items: center; gap: 6px; margin: 2px 14px 2px 0 !important; }
.check input { margin: 0 !important; width: auto !important; }
.form-actions { grid-column: 1 / -1; display: flex; gap: 10px; margin-top: 6px; }
.form-actions .btn { width: auto; padding: 9px 26px; margin: 0; }
.inline-form { display: flex; gap: 10px; margin: 8px 0; flex-wrap: wrap; }
.inline-form input { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.inline-form .btn { width: auto; padding: 8px 18px; margin: 0; font-size: 13px; }
.btn.gray { background: #f2f3f5; color: var(--text); border-color: var(--border); }
.link-btn { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 13px; padding: 0; }
.link-btn:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.alert.ok { background: #e8ffea; color: #00b42a; margin-bottom: 14px; }
.secret-box { background: #fff7e8; border: 1px solid #ffe4ba; border-radius: 8px; padding: 14px 18px; margin: 12px 0; }
.detail-cell { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
