:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* 顶部栏 */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 5;
}
.navbar .brand { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.navbar .brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.navbar nav a { color: var(--muted); margin-left: 20px; font-size: 14px; }
.navbar nav a.active { color: var(--primary); font-weight: 600; }
.navbar nav a:hover { color: var(--text); text-decoration: none; }

.container { max-width: 960px; margin: 28px auto; padding: 0 20px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.card + .card { margin-top: 20px; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: none; border-radius: 8px; padding: 9px 16px;
  font-size: 14px; font-weight: 500; cursor: pointer;
  background: var(--primary); color: #fff; transition: background .15s;
}
.btn:hover { background: var(--primary-hover); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover { background: #f9fafb; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b91c1c; }
.btn.sm { padding: 5px 11px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 表单 */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.input, textarea.input {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
}
.input:focus, textarea.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* 表格 */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 500; font-size: 13px; }
.table tbody tr:hover { background: #fafafa; }

/* 徽章 */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.badge.on { background: var(--success-soft); color: var(--success); }
.badge.off { background: var(--danger-soft); color: var(--danger); }
.badge.neutral { background: #f3f4f6; color: var(--muted); }

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* 登录页 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 380px; }
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 4px; }

/* 进度 */
.progress-track { height: 12px; background: #eef0f3; border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--primary), #7c3aed); border-radius: 999px; transition: width .3s ease; width: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.stat { background: #f9fafb; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 20px; font-weight: 600; margin-top: 4px; word-break: break-all; }

/* 日志 */
.log {
  background: #0f172a; color: #cbd5e1; border-radius: 8px; padding: 14px;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px;
  max-height: 280px; overflow-y: auto; white-space: pre-wrap; word-break: break-all;
}
.log .l { padding: 2px 0; }
.log .l.done { color: #4ade80; }
.log .l.error { color: #f87171; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; z-index: 20; }
.modal { background: #fff; border-radius: 12px; padding: 24px; width: 460px; max-width: 92vw; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.modal h3 { margin: 0 0 16px; font-size: 16px; }
.key-box { background: #f8fafc; border: 1px dashed var(--border); border-radius: 8px; padding: 12px; font-family: ui-monospace, Menlo, Consolas, monospace; word-break: break-all; }

.hidden { display: none !important; }
.toast { position: fixed; bottom: 24px; right: 24px; background: #111827; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 14px; opacity: 0; transition: opacity .2s; z-index: 30; }
.toast.show { opacity: 1; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.toolbar h2 { margin: 0; font-size: 16px; }
.actions { white-space: nowrap; }
.actions .btn { margin-left: 6px; }
.hint { font-size: 13px; color: var(--muted); }
