:root {
  --primary: #1c6ef2;
  --primary-dark: #155ad1;
  --primary-light: #eaf1fe;
  --text: #1f2937;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --bg: #f4f6fa;
  --card: #ffffff;
  --border: #e6e9ef;
  --border-2: #d9dee7;
  --green: #16a34a;
  --green-bg: #e8f7ee;
  --red: #dc2626;
  --red-bg: #fdecec;
  --orange: #ea8a00;
  --orange-bg: #fff4e0;
  --gray-bg: #f3f4f6;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04);
  --font: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
.hidden { display: none !important; }
.mono { font-family: ui-monospace, Consolas, monospace; }
.muted { color: var(--text-2); }
.small-text { font-size: 12px; color: var(--text-2); }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow { flex: 1; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 80% -10%, #dfe9ff 0%, transparent 60%),
              linear-gradient(140deg, #f7f9ff 0%, #eef2fb 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.login-card {
  width: 400px; background: #fff; border: 1px solid var(--border);
  border-radius: 12px; padding: 34px 34px 26px;
  box-shadow: 0 20px 50px rgba(30, 58, 138, .12);
}
.login-brand { display: flex; gap: 14px; align-items: center; margin-bottom: 26px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 11px; background: linear-gradient(135deg, #2f80ff, #155ad1);
  color: #fff; font-weight: 800; font-size: 22px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(28, 110, 242, .3);
}
.login-brand h1 { font-size: 20px; letter-spacing: .5px; }
.login-brand p { margin: 3px 0 0; color: var(--text-2); font-size: 12px; }
.login-form label { display: block; margin-bottom: 16px; color: var(--text-2); font-size: 12px; }
.login-form input {
  display: block; width: 100%; margin-top: 6px; height: 40px; padding: 0 12px;
  border: 1px solid var(--border-2); border-radius: 6px; font-size: 13px; outline: none;
}
.login-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.login-form .btn { height: 40px; }
.form-error { color: var(--red); background: var(--red-bg); padding: 8px 10px; border-radius: 4px; margin-bottom: 14px; font-size: 12px; }
.login-tip { margin-top: 20px; font-size: 12px; color: var(--text-2); text-align: center; line-height: 1.8; }
.login-foot { margin-top: 28px; color: var(--text-3); font-size: 12px; }

/* ---------- 布局 ---------- */
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 208px; flex: 0 0 208px; background: #fff; border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.logo { display: flex; align-items: center; gap: 10px; padding: 16px 16px 14px; border-bottom: 1px solid var(--border); }
.brand-mark.small { width: 30px; height: 30px; border-radius: 8px; font-size: 15px; }
.logo-text strong { display: block; font-size: 15px; letter-spacing: .3px; }
.logo-text span { display: block; font-size: 10px; color: var(--text-3); margin-top: 1px; }
.nav { flex: 1; overflow-y: auto; padding: 8px 0 16px; }
.nav-group-title { padding: 14px 18px 6px; font-size: 11px; color: var(--text-3); letter-spacing: .5px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 18px;
  color: var(--text); cursor: pointer; border-left: 3px solid transparent; user-select: none;
}
.nav-item:hover { background: #f7f9fc; }
.nav-item.active { background: var(--primary-light); color: var(--primary); border-left-color: var(--primary); font-weight: 600; }
.nav-item .ico { width: 18px; text-align: center; font-size: 14px; opacity: .85; }
.sidebar-foot { padding: 12px 18px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-3); }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 50px; flex: 0 0 50px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 20px;
}
.crumbs { font-size: 13px; color: var(--text-2); }
.crumbs b { color: var(--text); font-weight: 600; }
.top-actions { display: flex; align-items: center; gap: 14px; }
.top-link { cursor: pointer; color: var(--text-2); font-size: 16px; }
.top-user { font-size: 12px; color: var(--text-2); }
.content { flex: 1; overflow-y: auto; padding: 16px 20px 40px; }

/* ---------- 通用 ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 14px;
}
.card-body { padding: 16px 18px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 18px; border-bottom: 1px solid var(--border);
}
.card-title { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-title::before { content: ""; width: 3px; height: 14px; border-radius: 2px; background: var(--primary); display: inline-block; }
.card-extra { display: flex; align-items: center; gap: 8px; font-size: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 30px; padding: 0 13px; border-radius: 4px; border: 1px solid var(--border-2);
  background: #fff; color: var(--text); font-size: 12px; cursor: pointer; white-space: nowrap;
  font-family: var(--font); transition: all .15s;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { color: var(--red); border-color: #f3c7c7; }
.btn.danger:hover { background: var(--red-bg); border-color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--gray-bg); color: var(--text); }
.btn.small { height: 26px; padding: 0 9px; font-size: 12px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px;
  border-radius: 3px; font-size: 11px; background: var(--gray-bg); color: var(--text-2);
}
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.blue { background: var(--primary-light); color: var(--primary); }
.badge.orange { background: var(--orange-bg); color: var(--orange); }
.badge.dot::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; display: inline-block; }

.kpis { display: grid; grid-template-columns: repeat(7, 1fr); background: #fff; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; }
.kpi { padding: 14px 18px; border-right: 1px solid var(--border); }
.kpi:last-child { border-right: 0; }
.kpi .k-label { color: var(--text-2); font-size: 12px; margin-bottom: 6px; }
.kpi .k-value { font-size: 22px; font-weight: 600; letter-spacing: .3px; }
.kpi .k-value small { font-size: 12px; font-weight: 400; color: var(--text-2); margin-left: 2px; }
.kpi .k-value.empty { color: var(--text-3); font-size: 16px; font-weight: 400; }

.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th {
  text-align: left; font-weight: 600; color: var(--text-2); font-size: 12px;
  background: #f8fafc; padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.tbl td { padding: 10px 12px; border-bottom: 1px solid #f0f2f6; vertical-align: middle; }
table.tbl tr:hover td { background: #fafbfe; }
table.tbl td.actions { white-space: nowrap; text-align: right; }
table.tbl .link { color: var(--primary); cursor: pointer; }
table.tbl .link.danger { color: var(--red); }
.empty-row { text-align: center; color: var(--text-3); padding: 34px 0 !important; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .grow { flex: 1; }
.input, .select, textarea.input {
  height: 30px; border: 1px solid var(--border-2); border-radius: 4px; padding: 0 9px;
  font-size: 12px; outline: none; background: #fff; color: var(--text); font-family: var(--font);
}
textarea.input { height: auto; padding: 8px 9px; line-height: 1.6; resize: vertical; }
.input:focus, .select:focus, textarea.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.select { cursor: pointer; }
.input.w160 { width: 160px; } .input.w220 { width: 220px; } .input.w100 { width: 100px; }

.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 10px 14px; font-size: 12px; color: var(--text-2); }
.pager .pg { cursor: pointer; padding: 3px 8px; border: 1px solid var(--border); border-radius: 3px; background: #fff; }
.pager .pg.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 18px; background: #fff; flex-wrap: wrap; }
.tab { padding: 12px 16px; cursor: pointer; color: var(--text-2); font-size: 13px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; }
.field .hint { font-size: 11px; color: var(--text-3); margin-top: 5px; line-height: 1.6; }
.switch-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.switch { position: relative; width: 38px; height: 20px; border-radius: 999px; background: #cfd5df; cursor: pointer; transition: .15s; flex: 0 0 auto; }
.switch::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch.on { background: var(--primary); }
.switch.on::after { left: 20px; }
.switch-row span { font-size: 12px; }

.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: flex-start;
  justify-content: center; z-index: 1000; padding: 60px 20px; overflow-y: auto;
}
.modal {
  width: 620px; max-width: 96vw; background: #fff; border-radius: 8px; box-shadow: 0 24px 60px rgba(0,0,0,.25);
  animation: pop .16s ease-out;
}
.modal.wide { width: 820px; }
@keyframes pop { from { transform: translateY(-6px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 15px; }
.modal-close { cursor: pointer; color: var(--text-3); font-size: 18px; line-height: 1; }
.modal-body { padding: 18px 20px; max-height: 66vh; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--border); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.toast-root { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 1200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #1f2937; color: #fff; padding: 9px 16px; border-radius: 4px; font-size: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: pop .15s; }
.toast.error { background: #b91c1c; }
.toast.success { background: #15803d; }

.code-box {
  background: #0f172a; color: #e2e8f0; border-radius: 5px; padding: 12px 14px;
  font-family: ui-monospace, Consolas, monospace; font-size: 12px; line-height: 1.7;
  word-break: break-all; white-space: pre-wrap; position: relative;
}
.code-box .copy { position: absolute; right: 8px; top: 6px; }

.section-title { font-size: 13px; font-weight: 600; margin: 6px 0 10px; color: var(--text); }

.stat-line { display: flex; gap: 26px; flex-wrap: wrap; }
.stat-line .item .v { font-size: 20px; font-weight: 600; }
.stat-line .item .l { font-size: 11px; color: var(--text-2); margin-top: 2px; }

.chart-wrap { position: relative; }
canvas.chart { width: 100%; display: block; }
.chart-legend { display: flex; gap: 18px; font-size: 12px; color: var(--text-2); align-items: center; }
.chart-legend i { width: 10px; height: 2px; display: inline-block; margin-right: 5px; vertical-align: middle; }

.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 70px; align-items: center; gap: 10px; font-size: 12px; }
.bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.bar-track { height: 8px; background: #eef1f6; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #5b9bff, #1c6ef2); border-radius: 4px; }
.bar-row .val { text-align: right; color: var(--text-2); }

.dot-cells { display: grid; gap: 6px; }
.dot-cell { display: flex; align-items: center; justify-content: space-between; font-size: 12px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 4px; }

.toggle-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }

.alert {
  border: 1px solid #f3e2b8; background: #fff9ec; color: #8a6100; border-radius: 4px;
  padding: 9px 12px; font-size: 12px; line-height: 1.7; margin-bottom: 12px;
}
.alert.info { border-color: #cfe0ff; background: #f2f7ff; color: #1e4fa3; }

.node-card { border: 1px solid var(--border); border-radius: 5px; padding: 14px; background: #fff; margin-bottom: 10px; }
.metric { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-2); margin-top: 8px; }
.metric .track { flex: 1; height: 6px; background: #eef1f6; border-radius: 3px; overflow: hidden; }
.metric .fill { height: 100%; background: var(--primary); }
.metric .fill.warn { background: var(--orange); }
.metric .fill.bad { background: var(--red); }

.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.plan-card { border: 1px solid var(--border); border-radius: 6px; padding: 18px; background: #fff; position: relative; }
.plan-card.featured { border-color: var(--primary); box-shadow: 0 6px 18px rgba(28,110,242,.12); }
.plan-card h4 { font-size: 16px; margin-bottom: 6px; }
.plan-price { font-size: 24px; font-weight: 700; color: var(--primary); }
.plan-price small { font-size: 12px; color: var(--text-2); font-weight: 400; }
.plan-features { margin: 12px 0 16px; padding: 0; list-style: none; color: var(--text-2); font-size: 12px; line-height: 2; }

.notice { font-size: 12px; color: var(--text-2); line-height: 1.7; }

@media (max-width: 980px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .kpi { border-bottom: 1px solid var(--border); }
  .form-grid { grid-template-columns: 1fr; }
  .plans { grid-template-columns: 1fr; }
  .sidebar { width: 180px; flex-basis: 180px; }
}
