:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e3e5ea;
  --text: #1f2329;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warn: #d97706;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }

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

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px; background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  font-size: 26px; color: var(--primary);
  background: #eff6ff; border-radius: 10px;
  width: 44px; height: 44px; display: grid; place-items: center;
}
.topbar h1 { margin: 0; font-size: 17px; font-weight: 600; }
.sub { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.token-box { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.token-box label { color: var(--muted); }

input, select, textarea {
  padding: 7px 10px; border: 1px solid var(--border);
  border-radius: 6px; font: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
textarea { width: 100%; min-height: 120px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

.btn {
  padding: 7px 14px; border: 1px solid var(--border); background: #fff;
  border-radius: 6px; cursor: pointer; font: inherit; color: var(--text);
  transition: background .15s, border-color .15s;
}
.btn:hover { background: #f3f4f6; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

.tabs { display: flex; gap: 4px; padding: 0 24px; background: var(--panel); border-bottom: 1px solid var(--border); }
.tab {
  padding: 11px 16px; border: none; background: none; cursor: pointer;
  font: inherit; color: var(--muted); border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

main { padding: 20px 24px 60px; max-width: 1400px; margin: 0 auto; }
.panel { display: none; }
.panel.active { display: block; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type=search] { min-width: 220px; }
.stat { color: var(--muted); font-size: 13px; }

.grid {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { background: #fafbfc; font-weight: 500; color: var(--muted); font-size: 12px; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafbfc; }
.table .empty { text-align: center; color: var(--muted); padding: 30px; }

code {
  background: #f3f4f6; padding: 1px 5px; border-radius: 4px;
  font-family: ui-monospace, Consolas, monospace; font-size: 12px;
}

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.badge-ok { background: #dcfce7; color: #15803d; }
.badge-wait { background: #fef3c7; color: #b45309; }
.badge-err { background: #fee2e2; color: #b91c1c; }
.badge-off { background: #f3f4f6; color: #6b7280; }

.modal { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 50; }
.modal.show { display: grid; place-items: center; }
.modal-box {
  background: #fff; border-radius: 10px; padding: 22px; width: min(560px, 92vw);
  max-height: 88vh; overflow: auto; box-shadow: 0 20px 50px rgba(0, 0, 0, .2);
}
.modal-box h3 { margin: 0 0 16px; font-size: 16px; }
.field { margin-bottom: 12px; }
.field label { display: block; margin-bottom: 4px; font-size: 13px; color: var(--muted); }
.field input, .field select { width: 100%; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-80px);
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 6px;
  opacity: 0; transition: all .25s; z-index: 100; pointer-events: none; max-width: 80vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }

/* 登录门禁：未验证令牌前盖住整个后台 */
.gate {
  position: fixed; inset: 0; background: var(--bg);
  display: grid; place-items: center; z-index: 200;
}
.gate.hide { display: none; }
.gate-box {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 30px 32px; width: min(420px, 92vw);
  box-shadow: 0 4px 16px rgba(16, 24, 40, .08);
}
.gate-box h2 { margin: 0 0 6px; font-size: 18px; }
.gate-sub { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.gate-box input { width: 100%; }
.gate-box button { width: 100%; margin-top: 14px; }
.gate-msg { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 20px; }
.gate-tip {
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border);
  color: var(--muted); font-size: 12px;
}

.doc { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px 28px; box-shadow: var(--shadow); }
.doc h2 { font-size: 15px; margin: 26px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.doc h2:first-child { margin-top: 0; }
.doc p { margin: 8px 0; }
.doc .hint { color: var(--muted); font-size: 13px; }
.code {
  background: #0f172a; color: #e2e8f0; padding: 12px 14px; border-radius: 6px;
  overflow-x: auto; font-size: 12px; font-family: ui-monospace, Consolas, monospace;
}
.doc .table { margin: 10px 0; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }