:root {
  --brand: #12b7f5;
  --brand-deep: #0a9ed8;
  --bg: #f2f5f9;
  --panel: #fff;
  --text: #1c2333;
  --text-2: #5f6b7a;
  --text-3: #98a2b3;
  --line: #e8edf4;
  --danger: #e5484d;
  --danger-soft: #fff1f1;
  --ok: #12a150;
  --ok-soft: #eafaf1;
  --warn: #b26a00;
  --warn-soft: #fff6e5;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(23, 43, 77, .06);
  --shadow-md: 0 10px 30px rgba(23, 43, 77, .1);
  --shadow-lg: 0 24px 70px rgba(23, 43, 77, .18);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; font-size: 14px; color: var(--text); outline: none; }
a { color: var(--brand-deep); text-decoration: none; }
svg { width: 100%; height: 100%; fill: currentColor; display: block; }
.hidden { display: none !important; }

/* ============ 登录 / 初始化 ============ */
.gate {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #e8f3ff 0%, #f7fafd 50%, #e9f9f4 100%);
}
.gate-bg .blob { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .5; }
.gate-bg .b1 { width: 420px; height: 420px; background: #9fd8ff; top: -120px; left: -60px; }
.gate-bg .b2 { width: 380px; height: 380px; background: #b6f0e2; bottom: -140px; right: -40px; }

.gate-card {
  position: relative; width: 420px; padding: 30px 32px 22px; border-radius: 20px;
  background: rgba(255, 255, 255, .94); border: 1px solid rgba(255, 255, 255, .8);
  box-shadow: var(--shadow-lg); backdrop-filter: blur(12px);
}
.gate-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.logo {
  width: 48px; height: 48px; border-radius: 14px; flex: none; color: #fff; font-weight: 800;
  font-size: 25px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #2fc9ff, #0a9ed8); box-shadow: 0 8px 18px rgba(18, 183, 245, .34);
}
.logo.sm { width: 34px; height: 34px; border-radius: 10px; font-size: 18px; }
.gate-brand h1 { margin: 0; font-size: 19px; }
.gate-brand p { margin: 3px 0 0; font-size: 12.5px; color: var(--text-3); }

.gate-form { display: flex; flex-direction: column; gap: 14px; }
.gate-tip {
  background: var(--warn-soft); color: #7a5000; font-size: 12.5px; line-height: 1.75;
  padding: 10px 12px; border-radius: 10px; border: 1px solid #ffe3ac;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12.5px; color: var(--text-2); display: flex; gap: 6px; align-items: center; }
.field > span em { font-style: normal; font-size: 11px; color: var(--text-3); }
.field input, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #f8fafc; transition: all .16s;
}
.field input:focus, .field textarea:focus {
  border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(18, 183, 245, .12);
}
.btn-primary {
  padding: 11px 18px; border-radius: 10px; color: #fff; font-weight: 600; font-size: 14.5px;
  background: linear-gradient(135deg, #21c1ff, #0a9ed8); box-shadow: 0 8px 18px rgba(18, 183, 245, .3);
  transition: transform .12s;
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-primary[disabled] { opacity: .55; cursor: not-allowed; transform: none; }
.gate-err { min-height: 16px; margin: 10px 0 0; color: var(--danger); font-size: 12.5px; text-align: center; }
.gate-back { text-align: center; margin: 10px 0 0; font-size: 12px; }
.gate-back a { color: var(--text-3); }

/* ============ 控制台框架 ============ */
.console { display: grid; grid-template-columns: 208px 1fr; height: 100vh; }

.side {
  background: #101728; color: #cfd8e6; display: flex; flex-direction: column;
  padding: 16px 12px 12px;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 18px; }
.side-brand b { display: block; font-size: 14.5px; color: #fff; letter-spacing: .3px; }
.side-brand span { font-size: 11px; color: #6d7a90; letter-spacing: .6px; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav button {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px;
  font-size: 13.5px; color: #a9b6c9; transition: all .15s; text-align: left;
}
.side-nav button svg { width: 17px; height: 17px; flex: none; }
.side-nav button:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side-nav button.active { background: linear-gradient(135deg, #12b7f5, #0a80c4); color: #fff; box-shadow: 0 6px 16px rgba(18, 183, 245, .3); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 0 6px; }
.side-foot a { font-size: 12.5px; color: #8fa0b8; }
.side-foot a:hover { color: #fff; }
.side-foot button {
  text-align: left; font-size: 12.5px; color: #8fa0b8; padding: 6px 0;
}
.side-foot button:hover { color: #ff8f8f; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 62px; flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; background: #fff; border-bottom: 1px solid var(--line);
}
.topbar h2 { margin: 0; font-size: 16px; }
.topbar-extra { font-size: 12.5px; color: var(--text-3); display: flex; gap: 14px; align-items: center; }
.view-wrap { flex: 1; overflow-y: auto; padding: 20px 24px 40px; }
.view-wrap::-webkit-scrollbar { width: 8px; }
.view-wrap::-webkit-scrollbar-thumb { background: #d6dde7; border-radius: 4px; }

/* ============ 概览 ============ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: 14px; }
.stat-card {
  background: #fff; border-radius: var(--radius); padding: 16px 18px;
  border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.stat-card .label { font-size: 12.5px; color: var(--text-3); }
.stat-card .value { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: .5px; }
.stat-card .value small { font-size: 12px; font-weight: 500; color: var(--text-3); margin-left: 4px; }
.stat-card.accent { background: linear-gradient(135deg, #12b7f5, #0a80c4); color: #fff; border: none; }
.stat-card.accent .label { color: rgba(255, 255, 255, .78); }
.stat-card.danger .value { color: var(--danger); }

.panel {
  background: #fff; border-radius: var(--radius); border: 1px solid var(--line);
  box-shadow: var(--shadow-sm); margin-top: 16px; overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.panel-head h3 { margin: 0; font-size: 14px; }
.panel-head p { margin: 3px 0 0; font-size: 12px; color: var(--text-3); }
.panel-body { padding: 8px 0 0; }

/* ============ 表格 ============ */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-weight: 500; color: var(--text-3); font-size: 12px;
  padding: 10px 14px; background: #fafbfd; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 11px 14px; border-bottom: 1px solid #f2f5f9; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafcff; }
.cell-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 34px; height: 34px; border-radius: 10px; flex: none; overflow: hidden;
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 14px;
  background: linear-gradient(135deg, #8ecdf7, #4aa8e8);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.group { background: linear-gradient(135deg, #9fd6ff, #5b9cf5); }
.avatar.official { background: linear-gradient(135deg, #ffd479, #f5a623); }
.uname { font-size: 13px; font-weight: 500; }
.usub { font-size: 11.5px; color: var(--text-3); }
.mono { font-family: "SFMono-Regular", Consolas, monospace; font-size: 12.5px; color: var(--text-2); }

.tag {
  display: inline-block; padding: 1px 7px; border-radius: 5px; font-size: 11px; line-height: 17px;
}
.tag.ok { color: var(--ok); background: var(--ok-soft); }
.tag.bad { color: var(--danger); background: var(--danger-soft); }
.tag.title { color: var(--warn); background: var(--warn-soft); }
.tag.role-owner { color: #8a5a00; background: #fff1d6; }
.tag.role-admin { color: #0a6c9e; background: #e7f5ff; }
.tag.official { color: #8a5a00; background: #fff1d6; }
.muted { color: var(--text-3); }

.btn {
  padding: 5px 11px; border-radius: 7px; font-size: 12.5px; border: 1px solid var(--line);
  background: #fff; color: var(--text-2); transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: #cfe3f5; background: #f6fbff; color: var(--brand-deep); }
.btn.danger { color: var(--danger); border-color: #f6d7d8; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ok { color: var(--ok); border-color: #cdeedb; }
.btn.ok:hover { background: var(--ok-soft); }
.btn.sm { padding: 3px 9px; font-size: 12px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.search {
  display: flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--line);
  border-radius: 9px; padding: 7px 11px; min-width: 260px;
}
.search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(18, 183, 245, .1); }
.search svg { width: 15px; height: 15px; color: var(--text-3); flex: none; }
.search input { border: none; background: none; width: 100%; font-size: 13px; }
.seg { display: flex; background: #fff; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { padding: 7px 14px; font-size: 12.5px; color: var(--text-2); }
.seg button.active { background: #eaf7ff; color: var(--brand-deep); font-weight: 600; }

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

.empty { text-align: center; color: var(--text-3); font-size: 13px; padding: 44px 16px; }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(16, 23, 40, .45); display: flex;
  align-items: center; justify-content: center; z-index: 60; padding: 24px; backdrop-filter: blur(2px);
}
.modal {
  position: relative; background: #fff; border-radius: 16px; width: 460px; max-width: 100%;
  max-height: 86vh; overflow-y: auto; padding: 22px; box-shadow: var(--shadow-lg);
  animation: pop .18s ease-out;
}
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }
.modal-close { position: absolute; right: 14px; top: 12px; width: 28px; height: 28px; border-radius: 8px; color: var(--text-3); font-size: 14px; }
.modal-close:hover { background: #f1f5fa; color: var(--text); }
.modal h3 { margin: 0 0 4px; font-size: 16px; }
.modal .sub { margin: 0 0 16px; font-size: 12.5px; color: var(--text-3); }
.modal .field { margin-bottom: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.modal.wide { width: 560px; }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chip {
  padding: 4px 10px; border-radius: 14px; font-size: 12px; background: #f2f6fb;
  color: var(--text-2); border: 1px solid var(--line);
}
.chip:hover { background: #e9f6ff; color: var(--brand-deep); border-color: #cfe9fb; }

.member-list { margin-top: 6px; max-height: 44vh; overflow-y: auto; }
.member-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 6px; border-bottom: 1px solid #f3f6fa;
}
.member-row:last-child { border-bottom: none; }
.member-row .grow { flex: 1; min-width: 0; }

.toast-stack { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: rgba(28, 35, 51, .93); color: #fff; font-size: 13px; padding: 9px 16px;
  border-radius: 10px; box-shadow: var(--shadow-md); animation: tin .2s ease-out;
}
.toast.err { background: rgba(220, 55, 70, .95); }
@keyframes tin { from { transform: translateY(-8px); opacity: 0; } }

@media (max-width: 820px) {
  .console { grid-template-columns: 64px 1fr; }
  .side-brand div:last-child, .side-nav span, .side-foot a, .side-foot button { display: none; }
  .side-nav button { justify-content: center; }
  .topbar { padding: 0 16px; }
  .view-wrap { padding: 16px; }
}
