:root {
  --bg: #0b0f14;
  --bg-soft: #0f151d;
  --panel: #131b25;
  --panel-2: #17202c;
  --border: #22303f;
  --border-soft: #1a2531;
  --text: #e6edf3;
  --muted: #8b9aab;
  --accent: #3b82f6;
  --accent-hover: #2f6fd6;
  --green: #2dd4a7;
  --red: #f0656b;
  --amber: #e8b04b;
  --radius: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
p { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.req { color: var(--red); }

/* ---------- 通用控件 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: .15s;
  white-space: nowrap;
}
.btn:hover { border-color: #33465c; background: #1c2735; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: #3a1d22; border-color: #5a2a31; color: #ff9ba0; }
.btn-danger:hover { background: #4a2229; }
.btn-ghost { background: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.icon-btn {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; color: var(--muted);
  border-radius: 6px; cursor: pointer; font-size: 14px;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

.input {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  background: #0d141c;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; padding: 9px 11px; resize: vertical; line-height: 1.5; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59, 130, 246, .12); }
.input::placeholder { color: #5a6b7d; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #6b7d90 50%), linear-gradient(135deg, #6b7d90 50%, transparent 50%); background-position: calc(100% - 16px) 15px, calc(100% - 11px) 15px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
.input-row { display: flex; gap: 8px; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(59, 130, 246, .16), transparent 60%),
    radial-gradient(700px 400px at 100% 100%, rgba(45, 212, 167, .10), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 390px;
  background: linear-gradient(180deg, var(--panel), #111923);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.brand-mark {
  width: 44px; height: 44px; flex: 0 0 44px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #3b82f6, #2dd4a7);
  color: #061019; font-weight: 800; font-size: 15px; letter-spacing: .5px;
  border-radius: 12px;
}
.brand h1 { font-size: 17px; }
.brand p { font-size: 11px; color: var(--muted); letter-spacing: .6px; text-transform: uppercase; margin-top: 2px; }
.brand-sm { margin-bottom: 22px; padding: 0 4px; }
.brand-sm .brand-mark { width: 36px; height: 36px; flex-basis: 36px; font-size: 13px; border-radius: 10px; }
.brand-sm h1 { font-size: 15px; }

.login-card label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 7px; }
.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-right: 44px; }
.input-group .icon-btn { position: absolute; right: 4px; }
.login-card .btn-primary { margin-top: 6px; height: 40px; }
.form-error { color: var(--red); font-size: 12px; min-height: 18px; margin: 8px 0 4px; }
.login-foot { margin-top: 24px; font-size: 11px; color: #5c6b7c; text-align: center; line-height: 1.6; }

/* ---------- 布局 ---------- */
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 220px; flex: 0 0 220px;
  background: var(--bg-soft);
  border-right: 1px solid var(--border-soft);
  padding: 20px 14px;
  display: flex; flex-direction: column;
}
.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  height: 38px; padding: 0 12px; border-radius: 8px;
  color: var(--muted); font-size: 13px; transition: .15s;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: rgba(59, 130, 246, .12); color: #8fb8ff; }
.nav-ico { width: 16px; text-align: center; font-size: 13px; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.server-state { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--muted); padding: 0 4px; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot-ok { background: var(--green); box-shadow: 0 0 0 3px rgba(45, 212, 167, .15); }

.main { flex: 1; overflow-y: auto; padding: 28px 32px 40px; }
.page { max-width: 1180px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head h2 { font-size: 20px; margin-bottom: 4px; }
.page-head p { font-size: 12.5px; }
.head-actions { display: flex; gap: 8px; }

/* ---------- 概览 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stat-card {
  background: var(--panel); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 16px 18px;
  display: flex; flex-direction: column; gap: 8px;
}
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: .5px; }
.accent-green { color: var(--green); }

.panel-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--border-soft); border-radius: var(--radius); }
.card-head { padding: 15px 18px; border-bottom: 1px solid var(--border-soft); }
.card-head h3 { font-size: 13.5px; }
.recent-list, .group-list { padding: 8px 10px 12px; }
.recent-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 8px; border-radius: 8px; font-size: 13px;
}
.recent-item:hover { background: var(--panel-2); }
.recent-item .meta { color: var(--muted); font-size: 11.5px; }
.group-row { display: flex; align-items: center; gap: 10px; padding: 9px 8px; }
.group-name { width: 110px; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-bar { flex: 1; height: 6px; background: #0d141c; border-radius: 4px; overflow: hidden; }
.group-bar span { display: block; height: 100%; background: linear-gradient(90deg, #3b82f6, #2dd4a7); border-radius: 4px; }
.group-count { font-size: 12px; color: var(--text); width: 26px; text-align: right; }

/* ---------- 工具栏与表格 ---------- */
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; }
.toolbar .input { width: 260px; }
.toolbar .select { width: 150px; }

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
}
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11.5px; font-weight: 500; color: var(--muted);
  padding: 12px 16px; background: #101822; border-bottom: 1px solid var(--border-soft);
  text-transform: uppercase; letter-spacing: .4px;
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border-soft); font-size: 13px; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #151e29; }
.cell-name { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 8px;
  background: linear-gradient(135deg, rgba(59, 130, 246, .25), rgba(45, 212, 167, .18));
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: #9dc0ff;
}
.cell-name strong { display: block; font-weight: 500; }
.cell-name small { color: var(--muted); font-size: 11.5px; }
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 11.5px; background: #16212d; color: #93a7bb; border: 1px solid #1f2c3a;
}
.tag-green { background: rgba(45, 212, 167, .1); color: var(--green); border-color: rgba(45, 212, 167, .25); }
.tag-blue { background: rgba(59, 130, 246, .1); color: #86b4ff; border-color: rgba(59, 130, 246, .25); }
.tag-red { background: rgba(240, 101, 107, .1); color: #ff9ba0; border-color: rgba(240, 101, 107, .25); }
.tag-amber { background: rgba(232, 176, 75, .1); color: var(--amber); border-color: rgba(232, 176, 75, .25); }
.row-actions { display: flex; gap: 4px; flex-wrap: nowrap; }
.link-btn { background: none; border: none; color: #7ea6d8; font-size: 12.5px; cursor: pointer; padding: 4px 6px; border-radius: 5px; white-space: nowrap; }
.link-btn:hover { background: var(--panel-2); color: #a9c8f0; }
.link-btn.danger { color: #d9858a; }
.link-btn.danger:hover { color: #ff9ba0; background: #2a1a1e; }
.empty { padding: 60px 20px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 14px; align-items: center; }
.empty p { font-size: 13px; }

/* ---------- 弹窗 ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(3, 7, 11, .72);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 50;
}
.modal {
  width: 100%; max-width: 720px; max-height: 90vh;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-sm { max-width: 560px; }
.modal-xs { max-width: 400px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border-soft);
}
.modal-head h3 { font-size: 15px; }
.tabs { display: flex; gap: 4px; padding: 12px 20px 0; border-bottom: 1px solid var(--border-soft); }
.tab {
  background: none; border: none; color: var(--muted);
  padding: 8px 14px 12px; font-size: 13px; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: #8fb8ff; border-bottom-color: var(--accent); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--border-soft); background: #101822;
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field-full { grid-column: 1 / -1; }
.field-inline { flex-direction: row; align-items: center; gap: 18px; }
.field label { font-size: 12px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 7px; cursor: pointer; font-size: 12.5px; color: var(--text); }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }
.hint { font-size: 11.5px; color: #64768a; line-height: 1.6; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: #1b2634; border: 1px solid #2c3d50; color: var(--text);
  padding: 11px 18px; border-radius: 9px; font-size: 13px;
  box-shadow: var(--shadow); z-index: 100; max-width: 80vw;
}
.toast.error { border-color: #5a2a31; background: #2a1a1e; color: #ffb4b8; }
.toast.success { border-color: #1d4d3e; background: #13251f; color: #8be8c8; }

/* ---------- 响应式 ---------- */
@media (max-width: 980px) {
  .panel-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .sidebar { width: 64px; flex-basis: 64px; padding: 16px 8px; }
  .sidebar .brand > div:last-child, .nav-item span:last-child, .server-state span:last-child, .sidebar-foot .btn { display: none; }
  .nav-item { justify-content: center; padding: 0; }
  .main { padding: 20px 16px 32px; }
  .form-grid { grid-template-columns: 1fr; }
  .toolbar { flex-wrap: wrap; }
  .toolbar .input, .toolbar .select { width: 100%; }
  .table th:nth-child(2), .table td:nth-child(2),
  .table th:nth-child(5), .table td:nth-child(5) { display: none; }
}
