:root {
  --bg: #08090a;
  --panel: #0f1011;
  --raised: #151618;
  --hover: #1a1b1e;
  --active: #1f2023;
  --border: #212225;
  --border-strong: #2c2d31;
  --text: #f7f8f8;
  --text-2: #d0d6e0;
  --text-3: #8a8f98;
  --text-4: #62666d;
  --accent: #5e6ad2;
  --accent-hover: #6f7ae0;
  --green: #4cb782;
  --yellow: #f2c94c;
  --red: #eb5757;
  --gray: #6b6f76;
  --font: "Inter", "Inter Variable", "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text-2);
  font: 13px/1.5 var(--font);
  font-feature-settings: "cv01", "ss03";
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- 基础控件 ---------- */

input {
  width: 100%;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--raised);
  color: var(--text);
  outline: none;
  transition: border-color .12s;
}
input::placeholder { color: var(--text-4); }
input:focus { border-color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: 6px;
  font-weight: 500;
  white-space: nowrap;
  transition: background .12s, color .12s;
}
.btn.sm { height: 26px; padding: 0 8px; font-size: 12px; }
.btn.block { width: 100%; height: 36px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.secondary { background: var(--raised); border: 1px solid var(--border-strong); color: var(--text-2); }
.btn.secondary:hover { background: var(--hover); color: var(--text); }
.btn.ghost { color: var(--text-3); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.danger:hover { color: var(--red); }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 14px; height: 14px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 26px; height: 26px;
  border-radius: 6px;
  color: var(--text-3);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 17px; height: 17px;
  padding: 0 4px;
  border-radius: 4px;
  background: rgba(255,255,255,.14);
  font: 500 11px/1 var(--font);
  color: rgba(255,255,255,.85);
}

.error { margin: 0; color: var(--red); font-size: 12px; }
.error:empty { display: none; }

.logo {
  display: inline-block;
  width: 20px; height: 20px;
  border-radius: 6px;
  background: var(--accent) radial-gradient(circle at 50% 44%, #fff 0 32%, transparent 33%);
}
.logo.lg { width: 44px; height: 44px; border-radius: 12px; }
.logo.xs { width: 14px; height: 14px; border-radius: 4px; }

/* ---------- 管理员登录 ---------- */

.signin { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.signin-card { width: min(320px, 100%); display: grid; gap: 10px; }
.signin-card .logo { margin: 0 auto 6px; }
.signin-card h1 { margin: 0 0 14px; text-align: center; color: var(--text); font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.signin-card input { height: 38px; }
.signin-card .btn { margin-top: 4px; }

/* ---------- 框架 ---------- */

.app { display: grid; grid-template-columns: 220px 1fr; height: 100%; }

.sidebar { display: flex; flex-direction: column; padding: 10px 8px; min-height: 0; }
.workspace { display: flex; align-items: center; gap: 8px; padding: 6px 8px 14px; }
.workspace-name { color: var(--text); font-weight: 600; }
.nav { display: grid; gap: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 8px;
  height: 28px; padding: 0 8px;
  border-radius: 6px;
  color: var(--text-2);
  text-decoration: none;
  font-weight: 500;
}
.nav-item svg { color: var(--text-3); }
.nav-item:hover { background: var(--hover); }
.nav-item[aria-current="page"] { background: var(--active); color: var(--text); }
.nav-item .count { margin-left: auto; color: var(--text-4); font-size: 12px; font-variant-numeric: tabular-nums; }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; padding: 0 2px 0 8px; }
.me { color: var(--text-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }

.panel {
  margin: 8px 8px 8px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.topbar {
  display: flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 12px 0 20px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.topbar .title { color: var(--text); font-weight: 500; }
.spacer { flex: 1; }
.crumb { color: var(--text-3); text-decoration: none; font-weight: 500; }
.crumb:hover { color: var(--text); }
.crumb-sep { width: 12px; height: 12px; color: var(--text-4); }

.scroll { flex: 1; overflow-y: auto; min-height: 0; }

/* ---------- 状态图标 ---------- */

.status { width: 14px; height: 14px; stroke-width: 1.6; }
.status.online { color: var(--green); }
.status.connecting, .status.reconnecting { color: var(--yellow); }
.status.relogin_required { color: var(--red); }
.status.stopped { color: var(--gray); }

.avatar {
  display: inline-grid; place-items: center;
  width: 20px; height: 20px;
  border-radius: 50%;
  object-fit: cover;
  background: #2a2d4a;
  color: #c9cdf7;
  font-size: 11px;
  font-weight: 600;
  flex: none;
}
.avatar.lg { width: 40px; height: 40px; font-size: 17px; }

/* ---------- 账号列表 ---------- */

.group-head {
  display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 20px;
  background: var(--raised);
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  font-weight: 500;
}
.group-head .n { color: var(--text-4); font-variant-numeric: tabular-nums; }

.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid;
  grid-template-columns: 14px minmax(140px, 1.2fr) minmax(120px, 1fr) 110px 90px;
  align-items: center;
  gap: 14px;
  height: 44px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  color: var(--text-3);
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}
.row:hover { background: var(--hover); }
.row .who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.row .name { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .cell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .when { text-align: right; color: var(--text-4); }

.empty {
  flex: 1;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  padding: 40px 16px;
  text-align: center;
}
.empty-art { width: 64px; height: 64px; color: var(--text-4); stroke-width: 1; }
.empty p { margin: 0; color: var(--text-3); }

/* ---------- 群聊 ---------- */

.row.group { grid-template-columns: 20px minmax(160px, 1fr) 120px 80px 132px; }
.row.group:hover { background: transparent; }
.gavatar {
  display: inline-grid; place-items: center;
  width: 20px; height: 20px;
  border-radius: 5px;
  background: #24343a;
  color: #9fd3c7;
  font-size: 11px;
  font-weight: 600;
}
.row .members { text-align: right; }
.stack { display: flex; justify-content: flex-end; }
.stack .avatar { box-shadow: 0 0 0 2px var(--panel); }
.stack .avatar + .avatar { margin-left: -5px; }
.avatar.more { background: var(--active); color: var(--text-3); font-size: 10px; width: auto; min-width: 20px; padding: 0 5px; border-radius: 10px; }
.group-note {
  display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 20px;
  border-bottom: 1px solid var(--border);
  color: var(--text-3);
}

/* ---------- 账号详情 ---------- */

.detail { flex: 1; display: grid; grid-template-columns: 1fr 260px; min-height: 0; }
.detail-main { overflow-y: auto; padding: 36px clamp(20px, 5vw, 56px) 48px; }
.detail-inner { max-width: 680px; margin: 0 auto; }

.identity-head { display: flex; align-items: center; gap: 14px; }
.identity-head h1 { margin: 0; color: var(--text); font-size: 22px; font-weight: 600; letter-spacing: -.012em; line-height: 1.3; }

.wallet {
  margin-top: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--raised);
}
.wallet-head {
  display: flex; align-items: center;
  height: 38px; padding: 0 8px 0 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-3);
  font-weight: 500;
}
.wallet-body { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; padding: 18px 16px 20px; }
.amount {
  color: var(--text);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.amount.dim { color: var(--text-4); }
.frozen { color: var(--text-3); font-variant-numeric: tabular-nums; }
.wallet-note { color: var(--text-3); }
.spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.props {
  border-left: 1px solid var(--border);
  padding: 14px 10px;
  overflow-y: auto;
}
.prop {
  display: flex; align-items: center; gap: 10px;
  min-height: 32px; padding: 0 10px;
  border-radius: 6px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.prop > svg { color: var(--text-3); }
.prop .muted { color: var(--text-4); }
.prop-sep { height: 1px; margin: 10px; background: var(--border); }
.props .btn { width: 100%; justify-content: flex-start; height: 32px; padding: 0 10px; font-weight: 400; }

/* ---------- 弹窗 ---------- */

.modal {
  width: min(560px, calc(100vw - 32px));
  margin-top: 12vh;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--raised);
  color: var(--text-2);
  box-shadow: 0 16px 70px rgba(0,0,0,.55);
}
.modal::backdrop { background: rgba(0,0,0,.5); }
.modal-head { display: flex; align-items: center; gap: 6px; padding: 12px 12px 4px 16px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--text-2);
  font-size: 12px; font-weight: 500;
}
.modal-title { color: var(--text-2); font-size: 12px; font-weight: 500; }
.modal-head .close { margin-left: auto; }
.modal-body { padding: 10px 16px 14px; display: grid; gap: 8px; }
.step { display: grid; gap: 4px; }
.identity { display: flex; align-items: center; gap: 2px; }

input.bare { height: 34px; padding: 0; border: 0; background: transparent; border-radius: 0; }
input.bare:focus, input.bare:focus-visible { border: 0; outline: none; box-shadow: none; }
input.bare.big { height: 40px; font-size: 18px; font-weight: 500; }
input.bare.country { width: 52px; flex: none; height: 40px; font-size: 18px; font-weight: 500; color: var(--text-3); }
input.bare.code { letter-spacing: .2em; font-variant-numeric: tabular-nums; }
.lead { margin: 6px 0 8px; color: var(--text-2); font-size: 15px; font-weight: 500; }
.captcha-box { min-height: 44px; }

.modal-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}

/* ---------- 窄屏 ---------- */

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { flex-direction: row; align-items: center; padding: 6px 8px; }
  .workspace { padding: 0 8px; }
  .nav { display: none; }
  .sidebar-foot { margin: 0 0 0 auto; }
  .panel { margin: 0 8px 8px; }
  .row { grid-template-columns: 14px 1fr 64px; }
  .row .ident, .row .uid { display: none; }
  .row.group { grid-template-columns: 20px 1fr auto; }
  .row.group .gid, .row.group .members { display: none; }
  .nav { display: flex; gap: 2px; }
  .nav-item .count { display: none; }
  .detail { grid-template-columns: 1fr; overflow-y: auto; }
  .detail-main { overflow: visible; padding-top: 24px; padding-bottom: 8px; }
  .props { border-left: 0; border-top: 1px solid var(--border); }
}

@media (prefers-reduced-motion: reduce) {
  .spin { animation: none; }
  * { transition: none !important; }
}
