:root {
  --bg: #eef1f6;
  --card: #ffffff;
  --text: #16203a;
  --muted: #6b7a90;
  --line: #e6eaf2;
  --brand: #3b6ef5;
  --brand-2: #6a9bff;
  --ok: #12a150;
  --warn: #e08a00;
  --bad: #e5484d;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(22, 32, 58, .04), 0 8px 24px rgba(22, 32, 58, .06);
}

* { 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;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1120px; margin: 0 auto; padding: 20px 18px 56px; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px;
  box-shadow: 0 4px 12px rgba(59, 110, 245, .3);
}
.brand h1 { font-size: 17px; margin: 0; font-weight: 650; letter-spacing: .2px; }
.brand span { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.topbar .spacer { flex: 1; }
.userchip {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 6px 5px 14px; font-size: 13px; color: var(--muted);
  box-shadow: var(--shadow);
}
.userchip b { color: var(--text); font-weight: 600; }
.userchip a {
  color: var(--muted); text-decoration: none; font-size: 12px;
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px;
  transition: .15s;
}
.userchip a:hover { color: var(--bad); border-color: #f5c2c4; background: #fff5f5; }

/* ---------- 卡片 ---------- */
.grid { display: grid; gap: 14px; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g2 { grid-template-columns: 1.35fr 1fr; }

.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px;
  border: 1px solid rgba(255, 255, 255, .6);
}
.card h2 {
  margin: 0 0 14px; font-size: 13px; font-weight: 600; color: var(--muted);
  letter-spacing: .5px; display: flex; align-items: center; gap: 8px;
}
.card h2 .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); }

/* 小指标卡 */
.stat { display: flex; flex-direction: column; gap: 6px; }
.stat .label { font-size: 12px; color: var(--muted); }
.stat .value { font-size: 22px; font-weight: 680; letter-spacing: .3px; }
.stat .value.sm { font-size: 16px; font-weight: 620; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; border-radius: 999px;
  padding: 3px 10px; line-height: 18px;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; }
.pill.ok { color: var(--ok); background: #e8f7ef; }
.pill.ok .dot { background: var(--ok); box-shadow: 0 0 0 3px #cdeedd; }
.pill.bad { color: var(--bad); background: #fdecec; }
.pill.bad .dot { background: var(--bad); box-shadow: 0 0 0 3px #f8d4d5; }
.pill.warn { color: var(--warn); background: #fdf4e3; }
.pill.warn .dot { background: var(--warn); box-shadow: 0 0 0 3px #f8e6bf; }
.pill.idle { color: var(--muted); background: #f1f4f9; }
.pill.idle .dot { background: #9aa8bd; }

/* ---------- 流量进度 ---------- */
.usage-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.usage-num { font-size: 30px; font-weight: 700; letter-spacing: .5px; }
.usage-num small { font-size: 15px; color: var(--muted); font-weight: 500; margin-left: 4px; }
.usage-sub { font-size: 12px; color: var(--muted); margin-bottom: 14px; }

.bar {
  height: 12px; border-radius: 999px; background: #eef1f7; overflow: hidden;
  position: relative;
}
.bar > i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  border-radius: 999px; transition: width .6s cubic-bezier(.2, .8, .2, 1);
}
.bar > i.warn { background: linear-gradient(90deg, #f0a92b, #ffc85c); }
.bar > i.bad { background: linear-gradient(90deg, #e5484d, #ff7b7f); }

.bar-meta {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--muted); margin-top: 8px;
}

.spark { margin-top: 16px; }
.spark svg { display: block; width: 100%; height: 54px; }

/* ---------- 信息行 ---------- */
.rows { display: grid; gap: 0; }
.row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 13px;
}
.row:last-child { border-bottom: 0; }
.row .k { color: var(--muted); }
.row .v { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- 按钮 ---------- */
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.btn {
  appearance: none; border: 1px solid var(--line); background: #fff;
  color: var(--text); font-size: 13px; font-weight: 600;
  padding: 9px 16px; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  transition: .15s; font-family: inherit;
}
.btn:hover { border-color: #cfd8e8; box-shadow: 0 4px 12px rgba(22, 32, 58, .07); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border-color: transparent; color: #fff;
  box-shadow: 0 6px 16px rgba(59, 110, 245, .28);
}
.btn.primary:hover { box-shadow: 0 8px 20px rgba(59, 110, 245, .36); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: #f5c2c4; background: #fff7f7; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---------- 日志 ---------- */
.logs {
  font: 12px/1.75 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #475569; background: #f8fafc; border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; max-height: 208px; overflow: auto;
  white-space: pre-wrap; word-break: break-all; margin: 0;
}
.logs:empty::after { content: "暂无事件记录"; color: #9aa8bd; }

/* ---------- 协议标签 ---------- */
.protos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.proto {
  font-size: 12px; padding: 5px 10px; border-radius: 8px;
  background: #f1f5ff; color: #3a5da8; border: 1px solid #e2eafc;
  font-variant-numeric: tabular-nums;
}
.proto b { font-weight: 650; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  background: #16203a; color: #fff; padding: 11px 18px; border-radius: 10px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: .25s;
  max-width: 80vw; box-shadow: 0 12px 32px rgba(22, 32, 58, .3); z-index: 60;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: #b3261e; }

/* ---------- 确认弹窗 ---------- */
#mask {
  position: fixed; inset: 0; background: rgba(22, 32, 58, .38);
  display: none; place-items: center; z-index: 50; padding: 20px;
  backdrop-filter: blur(2px);
}
#mask.show { display: grid; }
.dialog {
  background: #fff; border-radius: 18px; width: 100%; max-width: 380px;
  padding: 22px 22px 18px; box-shadow: 0 24px 64px rgba(22, 32, 58, .26);
}
.dialog h3 { margin: 0 0 8px; font-size: 16px; }
.dialog p { margin: 0 0 18px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.dialog .btns { display: flex; gap: 10px; justify-content: flex-end; }

.foot {
  margin-top: 26px; text-align: center; font-size: 12px; color: #9aa8bd;
}
.foot b { color: var(--muted); font-weight: 600; }

/* ---------- 角色标识 ---------- */
.rol {
  font-size: 11px; font-weight: 600; line-height: 17px;
  padding: 1px 8px; border-radius: 999px; white-space: nowrap;
  background: #f1f4f9; color: var(--muted); border: 1px solid var(--line);
}
.rol[data-role="admin"] { color: #2f57c8; background: #eef3ff; border-color: #dfe8ff; }
.rol[data-role="viewer"] { color: #09806a; background: #e9f8f3; border-color: #d5efe8; }

/* ---------- 只读提示 ---------- */
.readonly { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.readonly p { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.7; }

/* ---------- 账号管理 ---------- */
.ulist { display: grid; gap: 8px; margin-bottom: 16px; }
.urow {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 12px;
  background: #f8fafc; border: 1px solid var(--line);
}
.urow .uname { font-weight: 600; font-size: 13px; }
.urow .me { margin-left: auto; font-size: 11.5px; color: #9aa8bd; }
.urow .btn.small { margin-left: auto; }
.uempty { font-size: 12.5px; color: #9aa8bd; padding: 4px 2px 12px; }

.uform { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.inp {
  font: inherit; font-size: 13px; color: var(--text);
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fbfcfe; outline: none; transition: .15s; min-width: 0;
}
.inp:focus {
  border-color: var(--brand); background: #fff;
  box-shadow: 0 0 0 3px rgba(59, 110, 245, .12);
}
#uName { flex: 1 1 150px; }
#uPass { flex: 1 1 170px; }
#uRole { flex: 0 0 108px; }
.hint { margin: 12px 0 0; font-size: 12px; color: #9aa8bd; line-height: 1.7; }

/* ---------- 续费 / 订单 ---------- */
.plans { display: grid; gap: 10px; margin-bottom: 14px; }
.plan {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 12px;
  background: #f8fafc; border: 1px solid var(--line);
  cursor: pointer; transition: .15s;
}
.plan:hover { border-color: #cfd8e8; background: #fff; box-shadow: 0 4px 12px rgba(22,32,58,.06); }
.plan .pname { font-weight: 600; font-size: 13px; }
.plan .pmeta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.plan .pprice { margin-left: auto; font-size: 16px; font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; }
.plan.off { opacity: .55; cursor: default; }

.orderbox {
  border: 1px dashed #cfd8e8; border-radius: 12px;
  padding: 14px; background: #fbfcfe; margin-bottom: 12px;
}
.ohead { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.ono { font: 12.5px/1 ui-monospace, Menlo, Consolas, monospace; color: var(--muted); letter-spacing: .4px; }
.otag { font-size: 11.5px; padding: 3px 9px; border-radius: 7px; background: #fdf4e3; color: var(--warn); font-weight: 600; }
.otag.ok { background: #e8f7ef; color: var(--ok); }
.otag.bad { background: #fdecec; color: var(--bad); }
.oamt { font-size: 26px; font-weight: 700; letter-spacing: .5px; font-variant-numeric: tabular-nums; }
.ohint { margin: 6px 0 10px; font-size: 12px; color: var(--muted); line-height: 1.7; }
.obtns { display: flex; gap: 8px; flex-wrap: wrap; }

.payqr { display: grid; place-items: center; padding: 6px 0; min-height: 60px; }
.payqr img { width: 100%; max-width: 190px; border-radius: 12px; border: 1px solid var(--line); }
.paynote { margin: 10px 0 0; font: inherit; font-size: 12.5px; line-height: 1.8; color: var(--muted); white-space: pre-wrap; word-break: break-word; text-align: center; }
.paynote:empty { display: none; }

.rev { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.revitem { flex: 1 1 132px; padding: 10px 14px; border-radius: 12px; background: #f8fafc; border: 1px solid var(--line); }
.revitem span { display: block; font-size: 11.5px; color: var(--muted); }
.revitem b { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }

.otabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.tab {
  appearance: none; border: 1px solid var(--line); background: #fff; color: var(--muted);
  font: 600 12px/1 inherit; padding: 7px 13px; border-radius: 8px; cursor: pointer; transition: .15s;
}
.tab:hover { border-color: #cfd8e8; }
.tab.on { background: #eef3ff; border-color: #dfe8ff; color: #2f57c8; }

.olist { display: grid; gap: 8px; max-height: 460px; overflow: auto; }
.orow {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; border-radius: 12px; background: #f8fafc; border: 1px solid var(--line);
}
.orow .oc { font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace; color: var(--muted); }
.orow .ou { font-weight: 600; font-size: 12.5px; }
.orow .og { font-size: 12px; color: var(--muted); }
.orow .oprice { font-weight: 700; font-variant-numeric: tabular-nums; }
.orow .opa { margin-left: auto; display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }

.plist { display: grid; gap: 8px; margin-bottom: 16px; }
.prow {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; border-radius: 12px; background: #f8fafc; border: 1px solid var(--line);
}
.prow.off { opacity: .55; }
.prow .pn { font-weight: 600; font-size: 13px; }
.prow .pm { font-size: 11.5px; color: var(--muted); }
.prow .pp { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.prow .opa { display: flex; gap: 7px; }

.btn.small { padding: 6px 11px; font-size: 12px; border-radius: 8px; font-weight: 600; }
.inp.num { flex: 0 0 96px; }
.inp.grow { flex: 1 1 280px; }

@media (max-width: 900px) {
  .g3 { grid-template-columns: 1fr 1fr; }
  .g2 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .g3 { grid-template-columns: 1fr; }
  .usage-num { font-size: 26px; }
  .wrap { padding: 16px 14px 40px; }
}
