:root {
  --bg: #f5f6f9;
  --panel: #ffffff;
  --line: #e7e9ef;
  --text: #1b1f27;
  --muted: #7a8397;
  --accent: #4f6ef7;
  --accent-d: #3d5be0;
  --ok: #18a058;
  --warn: #d98600;
  --bad: #d93a3a;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", -apple-system, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: 14px; }
a { color: var(--accent); text-decoration: none; }

/* ---------- 登录 ---------- */
#login {
  position: fixed; inset: 0; display: none;
  align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #e8ecff 0%, #f5f6f9 55%);
}
#login.show { display: flex; }
.login-card {
  width: 380px; background: #fff; border: 1px solid var(--line);
  border-radius: 16px; padding: 32px 30px 26px;
  box-shadow: 0 18px 48px rgba(27, 31, 39, .08);
}
.login-card h1 { font-size: 19px; margin: 14px 0 4px; }
.login-card p { color: var(--muted); font-size: 12.5px; margin: 0 0 22px; }
.brand {
  width: 40px; height: 40px; border-radius: 11px; color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #4f6ef7, #7b4ff7); font-size: 17px;
}

/* ---------- 布局 ---------- */
#app { display: none; height: 100%; }
#app.show { display: flex; }
.side {
  width: 208px; flex: 0 0 208px; background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 12px;
}
.side .brand-row { display: flex; align-items: center; gap: 10px; padding: 4px 6px 18px; }
.side .brand-row b { font-size: 14px; letter-spacing: .2px; }
.side .brand-row span { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 9px 11px; border: 0; border-radius: 9px; background: transparent;
  color: #4a5364; cursor: pointer; font-size: 13.5px;
}
.nav button:hover { background: #f3f5fb; }
.nav button.on { background: #edf1ff; color: var(--accent); font-weight: 600; }
.nav .badge {
  margin-left: auto; background: var(--warn); color: #fff; font-size: 10.5px;
  border-radius: 999px; padding: 1px 6px; font-weight: 600;
}
.side .foot { margin-top: auto; font-size: 11.5px; color: var(--muted); padding: 10px 8px 2px; border-top: 1px solid var(--line); }
.side .foot a { cursor: pointer; }

.main { flex: 1; overflow: auto; padding: 26px 30px 40px; }
.page { display: none; max-width: 1080px; }
.page.on { display: block; }
h2.title { font-size: 17px; margin: 0 0 4px; }
p.sub { color: var(--muted); font-size: 12.5px; margin: 0 0 20px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 16px;
}
.card h3 { font-size: 14px; margin: 0 0 14px; font-weight: 600; }
.card h3 small { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 6px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 16px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 24px; font-weight: 700; margin-top: 6px; letter-spacing: -.4px; }
.stat .v.warn { color: var(--warn); }
.stat .v.ok { color: var(--ok); }

/* ---------- 表单 ---------- */
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--muted); }
input[type=text], input[type=password], input[type=number], select, textarea {
  border: 1px solid #d9dee9; border-radius: 9px; padding: 8px 11px; outline: none;
  background: #fff; color: var(--text); min-width: 0;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 110, 247, .12); }
.btn {
  border: 1px solid #d9dee9; background: #fff; color: #38404f; cursor: pointer;
  border-radius: 9px; padding: 8px 14px; transition: .12s; white-space: nowrap;
}
.btn:hover { border-color: #bcc5d6; background: #fafbfd; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent-d); }
.btn.danger { color: var(--bad); border-color: #f2c9c9; }
.btn.danger:hover { background: #fdf3f3; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn:disabled { opacity: .55; cursor: default; }

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid #f0f2f6; font-size: 13px; vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; background: #fafbfd; }
tbody tr:hover { background: #fafbff; }
td.mono, .mono { font-family: Consolas, "SF Mono", Menlo, monospace; }
.code-cell { font-family: Consolas, monospace; font-weight: 600; letter-spacing: .5px; cursor: pointer; color: #2b3446; }
.code-cell:hover { color: var(--accent); }
.empty { text-align: center; color: var(--muted); padding: 28px 0; font-size: 13px; }

.tag { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; }
.tag.pending { background: #fff6e5; color: #9a6212; }
.tag.active { background: #e9f8ee; color: #157f3d; }
.tag.revoked { background: #fdecec; color: #b3261e; }
.tag i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.hint { font-size: 12px; color: var(--muted); line-height: 1.7; }
.alert { padding: 10px 13px; border-radius: 9px; font-size: 12.5px; margin-bottom: 14px; display: none; }
.alert.show { display: block; }
.alert.err { background: #fdf2f2; color: #b3261e; }
.alert.ok { background: #eefaf2; color: #157f3d; }

.drop {
  border: 1.5px dashed #cbd3e3; border-radius: var(--radius); padding: 26px; text-align: center;
  color: var(--muted); cursor: pointer; background: #fcfdff; transition: .15s;
}
.drop:hover, .drop.hot { border-color: var(--accent); background: #f6f8ff; color: var(--accent); }
.drop b { color: var(--text); }
.drop .fname { color: var(--accent); font-weight: 600; margin-top: 6px; }

.spin { display: inline-block; width: 13px; height: 13px; border: 2px solid #fff; border-top-color: transparent; border-radius: 50%; animation: sp .7s linear infinite; vertical-align: -2px; }
@keyframes sp { to { transform: rotate(360deg); } }

.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(10px);
  background: #23293a; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 99;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(20, 24, 34, .38); display: none;
  align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal.show { display: flex; }
.modal-card {
  width: 420px; max-width: 100%; background: #fff; border-radius: 14px; padding: 22px 24px 18px;
  box-shadow: 0 24px 60px rgba(20, 24, 34, .22);
}
.modal-card h3 { font-size: 15px; margin: 0 0 16px; }
.modal-card.wide { width: 780px; }
.modal-card .field { margin-bottom: 12px; }
.modal-card .field input { width: 100%; }
.modal-card .scroll { max-height: 340px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.modal-card .scroll table th { position: sticky; top: 0; z-index: 1; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ---------- 代理额度条 ---------- */
.qbar { height: 6px; border-radius: 3px; background: #eef0f6; overflow: hidden; margin-top: 6px; width: 120px; }
.qbar i { display: block; height: 100%; background: var(--accent); }
.qbar.low i { background: var(--bad); }
.qbar.mid i { background: var(--warn); }
.badge.gray { background: #f1f3f8; color: #6b7488; }
.badge.warn { background: #fff6e5; color: #9a6212; }
.agent-tip {
  display: flex; gap: 10px; align-items: flex-start; background: #f6f8ff; border: 1px solid #dfe6ff;
  border-radius: 10px; padding: 12px 14px; font-size: 12.5px; color: #4a5364; line-height: 1.7;
  margin-bottom: 16px;
}
