:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1c2126;
  --muted: #6b7480;
  --accent: #0f766e;
  --accent-soft: #e6f4f2;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #b54708;
  --ok: #067647;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.55;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* ---------------------------------------------------------------- 登录页 */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
  font-size: 18px;
  font-weight: 600;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
}

.auth-sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }

/* ------------------------------------------------------------------ 布局 */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar .brand { display: flex; align-items: center; gap: 9px; font-weight: 600; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: 13px; }

.tabs {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  gap: 4px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.tab {
  appearance: none;
  border: 0;
  background: none;
  padding: 11px 14px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-family: inherit;
}

.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 500; }
.tab:hover { color: var(--text); }

.container { max-width: 1120px; margin: 0 auto; padding: 22px 20px 60px; }

/* ------------------------------------------------------------------ 组件 */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.stat .value { font-size: 18px; font-weight: 600; word-break: break-all; }
.stat .hint { color: var(--muted); font-size: 12px; margin-top: 2px; }

.btn {
  appearance: none;
  font-family: inherit;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 7px 12px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: #f2f4f6; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #0b5f59; }
.btn-danger { color: var(--danger); border-color: #f3c4c1; background: var(--danger-soft); }
.btn-danger:hover { background: #fbdcd9; }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-link { border: 0; background: none; color: var(--accent); padding: 0; cursor: pointer; font-family: inherit; font-size: 13px; }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.toolbar h2 { font-size: 16px; margin: 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; background: #fafbfc; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num { font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 8px; border-radius: 999px; }
.badge-ok { background: #e7f6ee; color: var(--ok); }
.badge-off { background: #f1f2f4; color: var(--muted); }
.badge-warn { background: #fef3e6; color: var(--warn); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.mono { font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty { text-align: center; color: var(--muted); padding: 44px 12px; }

/* ------------------------------------------------------------------ 表单 */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; margin-bottom: 6px; color: #3c444d; }
.field .hint { color: var(--muted); font-size: 12px; margin-top: 5px; }
input[type="text"], input[type="email"], input[type="password"], select, textarea {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid #cfd4da;
  border-radius: 8px;
  padding: 9px 11px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { resize: vertical; min-height: 160px; }
.form-error { background: var(--danger-soft); color: var(--danger); border-radius: 8px; padding: 9px 11px; font-size: 13px; margin-bottom: 14px; }
.form-ok { background: var(--accent-soft); color: var(--accent); border-radius: 8px; padding: 9px 11px; font-size: 13px; margin-bottom: 14px; }

/* ------------------------------------------------------------------ 弹窗 */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 32, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal {
  background: var(--surface);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 12px 40px rgba(16, 24, 40, 0.24);
}
.modal-lg { max-width: 640px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-head .spacer { flex: 1; }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }
.icon-btn { border: 0; background: none; font-size: 18px; color: var(--muted); cursor: pointer; line-height: 1; padding: 2px 6px; }

.qr-box { display: flex; justify-content: center; padding: 10px 0 4px; }
.qr-box svg { width: 220px; height: 220px; }
.secret-box {
  background: #f7f8fa;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  word-break: break-all;
}

pre.config {
  background: #0f1720;
  color: #e6edf3;
  padding: 14px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.5;
  overflow: auto;
  max-height: 320px;
  white-space: pre;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

.banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}
.banner-warn { background: #fff7e8; color: #7a4a08; border: 1px solid #f3ddb8; }
.banner-info { background: var(--accent-soft); color: #0b5f59; border: 1px solid #cfe8e4; }

.section-title { font-size: 14px; font-weight: 600; margin: 0 0 12px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) {
  .row-2 { grid-template-columns: 1fr; }
  .topbar-inner { padding: 0 14px; }
  .tabs { padding: 0 14px; overflow-x: auto; }
  .container { padding: 16px 14px 48px; }
  .truncate { max-width: 140px; }
}

/* 工具类（CSP 禁止行内样式，统一用类） */
.btn-block { width: 100%; padding: 10px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-0 { margin-bottom: 0; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.flex-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.spacer { flex: 1; }
