:root {
  --bg: #0a0d14;
  --bg-soft: #0f1420;
  --panel: #121826;
  --panel-2: #161d2e;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e8ecf6;
  --muted: #8b95ad;
  --accent: #7c6bff;
  --accent-2: #40c4ff;
  --green: #34d399;
  --red: #fb5d72;
  --amber: #f5b544;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 600px at 10% -10%, rgba(124, 107, 255, 0.16), transparent 60%),
    radial-gradient(900px 500px at 95% 0%, rgba(64, 196, 255, 0.10), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.shell { max-width: 1200px; margin: 0 auto; padding: 26px 22px 60px; }

/* ---------------------------------------------------------------- 顶栏 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-mark {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 12px;
  font-weight: 800; font-size: 20px; letter-spacing: -1px;
  color: #fff;
  background: linear-gradient(135deg, #635bff, #a855f7 60%, #40c4ff);
  box-shadow: 0 8px 24px rgba(99, 91, 255, 0.35);
}

.brand-title { font-size: 18px; font-weight: 700; letter-spacing: .3px; }
.brand-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }

.top-actions { display: flex; align-items: center; gap: 10px; }

.mode-badge {
  font-size: 11px; font-weight: 700; letter-spacing: 1px;
  padding: 5px 10px; border-radius: 999px;
  border: 1px solid rgba(52, 211, 153, .4);
  color: var(--green);
  background: rgba(52, 211, 153, .10);
}
.mode-badge.test {
  border-color: rgba(245, 181, 68, .45);
  color: var(--amber);
  background: rgba(245, 181, 68, .10);
}

/* ---------------------------------------------------------------- 标签页 */
.tabs {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin: 18px 0 22px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 6px;
  border-radius: 12px;
  width: fit-content;
}

.tab {
  appearance: none; border: 0; cursor: pointer;
  background: transparent;
  color: var(--muted);
  font-size: 13px; font-weight: 600;
  padding: 9px 16px;
  border-radius: 9px;
  transition: all .18s ease;
}
.tab:hover { color: var(--text); background: rgba(255, 255, 255, .04); }
.tab.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(99, 91, 255, .95), rgba(168, 85, 247, .85));
  box-shadow: 0 6px 18px rgba(99, 91, 255, .3);
}

/* ---------------------------------------------------------------- 通用 */
.view-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}
.view-title { margin: 0; font-size: 17px; font-weight: 700; }

.card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.card + .card, .card + .muted { margin-top: 16px; }

.card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.card-title { font-size: 14px; font-weight: 700; }
.card-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 16px;
  margin: 16px 0;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.stat {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent 70%);
  opacity: .7;
}
.stat-label { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.stat-value {
  font-size: 26px; font-weight: 700; letter-spacing: -.4px;
  margin: 8px 0 6px; font-variant-numeric: tabular-nums;
}
.stat-foot { color: var(--muted); font-size: 12px; }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot-amber { background: var(--amber); box-shadow: 0 0 8px var(--amber); }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; margin-top: 14px; }
.row-gap { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- 按钮 */
.btn {
  appearance: none; cursor: pointer;
  border-radius: 10px; border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, .05);
  color: var(--text);
  font-size: 13px; font-weight: 600;
  padding: 9px 14px;
  transition: all .16s ease;
  white-space: nowrap;
}
.btn:hover { background: rgba(255, 255, 255, .10); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
  border: 0; color: #fff;
  background: linear-gradient(135deg, #635bff, #8b5cf6);
  box-shadow: 0 8px 22px rgba(99, 91, 255, .35);
}
.btn-primary:hover { filter: brightness(1.06); }

.btn-ghost { background: transparent; }
.btn-block { width: 100%; padding: 12px; font-size: 14px; }
.btn-mini { padding: 5px 9px; font-size: 12px; border-radius: 8px; }
.btn-danger { border-color: rgba(251, 93, 114, .5); color: var(--red); }

.icon-btn {
  border: 0; background: transparent; color: var(--muted);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 2px 6px;
  border-radius: 8px;
}
.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, .06); }

/* ---------------------------------------------------------------- 表单 */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 7px; }

.input {
  width: 100%;
  background: #0c111b;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  color: var(--text);
  font-size: 13px;
  padding: 10px 12px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus {
  border-color: rgba(124, 107, 255, .8);
  box-shadow: 0 0 0 3px rgba(124, 107, 255, .18);
}
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }

/* 可搜索的子账户列表 */
select.input.input-list {
  appearance: auto; background-image: none;
  padding: 5px; height: auto; min-height: 138px;
  line-height: 1.5; overflow-y: auto;
}
select.input.input-list option {
  padding: 6px 8px; border-radius: 6px; font-size: 12.5px;
}
select.input.input-list option:checked {
  background: rgba(124, 107, 255, .35) linear-gradient(0deg, rgba(124, 107, 255, .35), rgba(124, 107, 255, .35));
  color: #fff;
}

.form { display: block; }

.seg {
  display: inline-flex; gap: 4px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  padding: 4px; border-radius: 10px;
}
.seg button {
  border: 0; background: transparent; color: var(--muted);
  font-size: 12px; font-weight: 600; padding: 7px 13px; border-radius: 7px; cursor: pointer;
}
.seg button.active { background: rgba(124, 107, 255, .2); color: #cfc9ff; }

/* ---------------------------------------------------------------- 表格 */
.table-card { padding: 6px 0 0; overflow: hidden; }

.table-wrap { overflow-x: auto; }

table.data {
  width: 100%; border-collapse: collapse; font-size: 13px;
  min-width: 720px;
}
table.data th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky; top: 0;
  background: var(--panel);
}
table.data td {
  padding: 13px 16px; border-bottom: 1px solid rgba(255, 255, 255, .045);
  vertical-align: middle;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: rgba(255, 255, 255, .025); }

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: #b9c2d8;
  letter-spacing: .1px;
}

.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--green); }
.neg { color: var(--red); }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600;
  padding: 4px 8px; border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  white-space: nowrap;
}
.badge.ok { color: var(--green); border-color: rgba(52, 211, 153, .35); background: rgba(52, 211, 153, .09); }
.badge.warn { color: var(--amber); border-color: rgba(245, 181, 68, .35); background: rgba(245, 181, 68, .09); }
.badge.bad { color: var(--red); border-color: rgba(251, 93, 114, .35); background: rgba(251, 93, 114, .09); }
.badge.info { color: #a9b6ff; border-color: rgba(124, 107, 255, .35); background: rgba(124, 107, 255, .1); }

.empty {
  padding: 42px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.empty strong { display: block; color: var(--text); font-size: 14px; margin-bottom: 6px; font-weight: 600; }
.empty .btn { margin-top: 14px; }

/* ---------------------------------------------------------------- 图表 */
.chart { width: 100%; height: 240px; position: relative; }
.chart svg { width: 100%; height: 100%; display: block; }

.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: center; }
.donut { width: 180px; height: 180px; flex: 0 0 auto; }
.donut-legend { display: flex; flex-direction: column; gap: 8px; font-size: 12px; min-width: 140px; }
.donut-legend .item { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); }
.donut-legend .item b { color: var(--text); font-weight: 600; }
.donut-legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 7px; }

.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 5px; }
.sw-green { background: var(--green); }
.sw-red { background: var(--red); }

/* ---------------------------------------------------------------- 快捷操作 */
.quick {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.quick-item {
  text-align: left; cursor: pointer;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, .03);
  border-radius: 12px;
  padding: 15px 16px;
  color: var(--text);
  transition: all .16s ease;
}
.quick-item:hover {
  border-color: rgba(124, 107, 255, .5);
  background: rgba(124, 107, 255, .08);
  transform: translateY(-2px);
}
.quick-title { font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.quick-sub { font-size: 11.5px; color: var(--muted); line-height: 1.5; }

.mini-list { display: flex; flex-direction: column; }
.mini-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 11px 0;
  border-bottom: 1px solid rgba(255, 255, 255, .05);
  font-size: 13px;
}
.mini-row:last-child { border-bottom: 0; }
.mini-row span { color: var(--muted); }
.mini-row strong { font-variant-numeric: tabular-nums; }

.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0 28px;
}
.kv { display: flex; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px solid rgba(255, 255, 255, .05); font-size: 13px; }
.kv span { color: var(--muted); }
.kv b { font-weight: 600; text-align: right; word-break: break-all; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.check-row {
  display: flex; align-items: flex-start; gap: 9px;
  margin: 4px 0 16px;
  font-size: 13px; color: var(--muted);
  line-height: 1.5;
}
.check-row input { margin-top: 2px; accent-color: var(--accent); }

/* ---------------------------------------------------------------- 弹窗 */
.modal-layer {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(4, 6, 12, .72);
  backdrop-filter: blur(6px);
  display: grid; place-items: center;
  padding: 20px;
}
.modal {
  width: min(560px, 100%);
  max-height: 88vh; overflow: auto;
  background: linear-gradient(180deg, #141a29, #101520);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  box-shadow: var(--shadow);
  animation: pop .18s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 15px; font-weight: 700; }
.modal-body { padding: 20px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--border);
}

.note {
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 12px;
  line-height: 1.6;
  border: 1px solid rgba(245, 181, 68, .28);
  background: rgba(245, 181, 68, .07);
  color: #f0d7a4;
  margin-bottom: 16px;
}
.note.info { border-color: rgba(124, 107, 255, .3); background: rgba(124, 107, 255, .09); color: #cdc7ff; }
.note.err { border-color: rgba(251, 93, 114, .35); background: rgba(251, 93, 114, .08); color: #ffb3be; }

.link-box {
  display: flex; gap: 8px; align-items: center;
  background: #0b101a; border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 9px 10px;
}
.link-box input { flex: 1; background: transparent; border: 0; color: var(--text); font-size: 12px; outline: none; font-family: ui-monospace, monospace; }

/* ---------------------------------------------------------------- 登录 */
.login-layer {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background:
    radial-gradient(700px 420px at 50% 10%, rgba(124, 107, 255, .22), transparent 65%),
    rgba(6, 9, 16, .92);
  backdrop-filter: blur(10px);
  padding: 20px;
}
.login-card {
  width: min(400px, 100%);
  background: linear-gradient(180deg, #141a29, #0f1420);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-card .brand-mark { margin: 0 auto 16px; width: 52px; height: 52px; font-size: 24px; }
.login-card h1 { font-size: 19px; margin: 0 0 8px; }
.login-card p { font-size: 12.5px; margin: 0 0 22px; }
.login-card form { text-align: left; }
.login-error { color: var(--red); font-size: 12px; min-height: 16px; margin-bottom: 10px; }

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  z-index: 60;
  background: rgba(20, 26, 41, .96);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 13px;
  box-shadow: var(--shadow);
  max-width: min(720px, calc(100% - 40px));
  line-height: 1.5;
}
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .25);
  border-top-color: #fff;
  display: inline-block; vertical-align: -3px;
  animation: spin .7s linear infinite;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 980px) {
  .grid-2 { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .quick { grid-template-columns: repeat(2, 1fr); }
  .kv-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .shell { padding: 18px 14px 50px; }
  .brand-sub { display: none; }
  .tabs { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .tab { padding: 9px 12px; }
  .stat-row { grid-template-columns: 1fr; }
  .quick { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
}

