:root {
  --bg: #0a0e14;
  --bg-soft: #0f1520;
  --panel: #111927;
  --panel-2: #16202f;
  --line: rgba(255, 255, 255, .07);
  --line-strong: rgba(255, 255, 255, .14);
  --text: #e7edf6;
  --text-dim: #8b9bb4;
  --text-mute: #5d6b80;
  --accent: #3f7bff;
  --accent-soft: rgba(63, 123, 255, .14);
  --ok: #34d399;
  --warn: #f59e0b;
  --danger: #f05252;
  --radius: 12px;
  --shadow: 0 12px 40px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: radial-gradient(1200px 600px at 15% -10%, #15203a 0%, transparent 55%),
              radial-gradient(900px 500px at 100% 0%, #102031 0%, transparent 50%),
              var(--bg);
  color: var(--text);
  font: 14px/1.55 "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #1d2a3d; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------- 登录 ---------------- */
#login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 380px;
  padding: 34px 30px 28px;
  background: linear-gradient(180deg, rgba(22, 32, 47, .95), rgba(14, 20, 30, .95));
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 46px; height: 46px;
  border-radius: 13px;
  display: grid; place-items: center;
  background: linear-gradient(140deg, #3f7bff, #7c4dff);
  font-weight: 800; letter-spacing: .5px;
  box-shadow: 0 8px 22px rgba(63, 123, 255, .35);
}

.login-card h1 { font-size: 20px; margin: 18px 0 4px; letter-spacing: .5px; }
.login-card p.sub { margin: 0 0 22px; color: var(--text-dim); font-size: 13px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }

input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%;
  padding: 10px 12px;
  background: #0c131d;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: #131c2a;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}

.btn:hover { background: #172334; border-color: rgba(255,255,255,.24); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, #3f7bff, #5a5bff); border-color: transparent; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: #ffd9d9; border-color: rgba(240, 82, 82, .4); background: rgba(240, 82, 82, .12); }
.btn.danger:hover { background: rgba(240, 82, 82, .2); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.hint { color: var(--text-mute); font-size: 12px; margin-top: 14px; line-height: 1.6; }

/* ---------------- 布局 ---------------- */
#app { display: none; grid-template-columns: 232px 1fr; min-height: 100vh; }
#app.on { display: grid; }

.sidebar {
  background: rgba(10, 15, 22, .82);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh;
  backdrop-filter: blur(14px);
}

.side-brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; }
.side-brand b { font-size: 15px; letter-spacing: .6px; }
.side-brand span { display: block; font-size: 11px; color: var(--text-mute); letter-spacing: .4px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-dim);
  cursor: pointer;
  border: 1px solid transparent;
  user-select: none;
}

.nav-item:hover { color: var(--text); background: rgba(255,255,255,.04); }
.nav-item.on { color: #fff; background: var(--accent-soft); border-color: rgba(63,123,255,.35); }
.nav-item svg { width: 17px; height: 17px; flex: none; opacity: .9; }

.side-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--text-mute); line-height: 1.7; }

.main { padding: 22px 26px 60px; min-width: 0; }

.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.topbar h2 { margin: 0; font-size: 19px; letter-spacing: .4px; }
.topbar .sp { flex: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: 999px;
  background: #101a28; border: 1px solid var(--line);
  color: var(--text-dim); font-size: 12.5px;
}
.chip b { color: var(--text); font-weight: 600; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); }

.avatar {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(140deg, #3f7bff, #7c4dff);
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}

/* ---------------- 卡片 ---------------- */
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); }
.card {
  background: linear-gradient(180deg, rgba(22, 32, 47, .72), rgba(14, 20, 30, .72));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.kpi .k-label { color: var(--text-dim); font-size: 12.5px; }
.kpi .k-value { font-size: 26px; font-weight: 700; margin: 6px 0 2px; letter-spacing: .5px; font-variant-numeric: tabular-nums; }
.kpi .k-sub { color: var(--text-mute); font-size: 12px; }
.kpi.accent { border-color: rgba(63,123,255,.35); background: linear-gradient(180deg, rgba(63,123,255,.16), rgba(14,20,30,.7)); }

.two-col { display: grid; grid-template-columns: 1.5fr 1fr; gap: 14px; margin-top: 14px; }
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }

.card h3 { margin: 0 0 3px; font-size: 14.5px; }
.card .cap { color: var(--text-mute); font-size: 12px; margin-bottom: 16px; }

/* 柱状图 */
.bars { display: flex; align-items: flex-end; gap: 14px; height: 168px; padding-top: 10px; }
.bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.bar {
  width: 100%; max-width: 44px; border-radius: 7px 7px 3px 3px;
  background: linear-gradient(180deg, #4f89ff, rgba(63,123,255,.25));
  min-height: 3px; transition: height .4s ease;
  position: relative;
}
.bar.gen { background: linear-gradient(180deg, #2b3a52, rgba(43,58,82,.3)); }
.bar span { position: absolute; top: -20px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.bar-wrap small { color: var(--text-mute); font-size: 11px; }

.kind-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.kind-row .nm { width: 58px; color: var(--text-dim); font-size: 12.5px; }
.kind-row .track { flex: 1; height: 7px; border-radius: 99px; background: #16202f; overflow: hidden; }
.kind-row .fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #3f7bff, #7c4dff); }
.kind-row .vl { width: 62px; text-align: right; font-size: 12.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* ---------------- 表格 ---------------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; min-width: 180px; }
.toolbar input[type=text] { min-width: 180px; }
.toolbar select { width: auto; min-width: 120px; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(12, 18, 27, .55); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  position: sticky; top: 0; z-index: 2;
  background: #101a28;
  text-align: left; font-weight: 600; color: var(--text-dim);
  padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
  font-size: 12.5px;
}
tbody td { padding: 10px 14px; border-bottom: 1px solid rgba(255,255,255,.045); vertical-align: middle; }
tbody tr:hover { background: rgba(63, 123, 255, .06); }
tbody tr:last-child td { border-bottom: 0; }
td.mono, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; letter-spacing: .3px; }
td .sub { color: var(--text-mute); font-size: 11.5px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; border: 1px solid transparent; }
.badge.unused { color: #9fb2cc; background: rgba(159, 178, 204, .1); border-color: rgba(159,178,204,.2); }
.badge.active { color: #5ee6b0; background: rgba(52, 211, 153, .12); border-color: rgba(52,211,153,.28); }
.badge.banned { color: #ff9b9b; background: rgba(240, 82, 82, .13); border-color: rgba(240,82,82,.3); }
.badge.expired { color: #ffc46b; background: rgba(245, 158, 11, .12); border-color: rgba(245,158,11,.3); }
.badge.online { color: #5ee6b0; background: rgba(52,211,153,.12); border-color: rgba(52,211,153,.28); }
.badge.offline { color: #8b9bb4; background: rgba(139,155,180,.08); border-color: rgba(139,155,180,.2); }

.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 12px; color: var(--text-dim); font-size: 12.5px; }

.copy { cursor: pointer; color: #9dc0ff; }
.copy:hover { text-decoration: underline; }

/* ---------------- 弹窗 ---------------- */
.mask {
  position: fixed; inset: 0; background: rgba(3, 6, 11, .72);
  display: none; align-items: center; justify-content: center; z-index: 50; padding: 20px;
  backdrop-filter: blur(3px);
}
.mask.on { display: flex; }
.modal {
  width: 560px; max-width: 100%; max-height: 86vh; overflow: auto;
  background: linear-gradient(180deg, #16202f, #0f1520);
  border: 1px solid var(--line-strong); border-radius: 16px; box-shadow: var(--shadow);
}
.modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-head .x { margin-left: auto; cursor: pointer; color: var(--text-dim); font-size: 20px; line-height: 1; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); }

.kind-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.kind-opt {
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 12px 8px; text-align: center; cursor: pointer;
  background: #0d141e;
}
.kind-opt:hover { border-color: rgba(255,255,255,.3); }
.kind-opt.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(63,123,255,.4); }
.kind-opt b { display: block; font-size: 13px; }
.kind-opt small { color: var(--text-mute); font-size: 11.5px; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

textarea.result { height: 190px; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; resize: vertical; }

/* ---------------- Toast ---------------- */
#toasts { position: fixed; top: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 99; }
.toast {
  padding: 10px 16px; border-radius: 10px; font-size: 13px;
  background: #16202f; border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  animation: slide .18s ease;
}
.toast.ok { border-color: rgba(52,211,153,.4); color: #a7f3d4; }
.toast.err { border-color: rgba(240,82,82,.45); color: #ffc0c0; }
@keyframes slide { from { opacity: 0; transform: translateY(-6px); } }

.empty { padding: 40px; text-align: center; color: var(--text-mute); font-size: 13px; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 6px; background: #182234; color: var(--text-dim); }
.nowrap { white-space: nowrap; }


/* 去掉数字输入框右侧的加减箭头（与页面风格不符，且容易误触） */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}
