:root {
  --bg: #0f0f23;
  --panel: #1a1a3e;
  --panel2: #22224a;
  --line: #2a2a4e;
  --primary: #6366f1;
  --primary2: #8b5cf6;
  --text: #f2f3ff;
  --sub: #9aa0c7;
  --muted: #8b90b8;
  --green: #34d399;
  --orange: #fb923c;
  --red: #f87171;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  min-height: 100vh;
}
.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login-mask {
  position: fixed; inset: 0; background: linear-gradient(160deg, #1a1a3e, #0f0f23);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.login-box {
  width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 24px;
  padding: 40px 32px; text-align: center;
}
.login-logo {
  width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 20px;
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  display: flex; align-items: center; justify-content: center; font-size: 32px; font-weight: 700; color: #fff;
}
.login-box h1 { font-size: 22px; margin-bottom: 8px; }
.login-sub { font-size: 13px; color: var(--sub); margin-bottom: 28px; }
.field { display: block; text-align: left; margin-bottom: 18px; }
.field span { display: block; font-size: 13px; color: var(--sub); margin-bottom: 8px; }
.field input {
  width: 100%; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 16px; color: #fff; font-size: 15px; outline: none;
}
.field input:focus { border-color: var(--primary); }
.btn-primary {
  width: 100%; padding: 14px; border: none; border-radius: 12px; cursor: pointer;
  background: linear-gradient(135deg, var(--primary), var(--primary2)); color: #fff;
  font-size: 15px; font-weight: 600;
}
.login-err { color: var(--red); font-size: 13px; margin-top: 14px; min-height: 18px; }

/* ---------- 框架 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; background: #111128; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 24px 0; flex-shrink: 0;
}
.brand { display: flex; gap: 14px; align-items: center; padding: 0 24px 28px; }
.brand-logo {
  width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(135deg, var(--primary), var(--primary2));
  display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; color: #fff;
}
.brand-name { font-size: 17px; font-weight: 700; }
.brand-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.menu { flex: 1; }
.menu-item {
  padding: 14px 24px; font-size: 14px; color: #b9bde6; cursor: pointer; border-left: 3px solid transparent;
}
.menu-item:hover { background: var(--panel); color: #fff; }
.menu-item.active { background: #1c1c44; color: #c3ccff; border-left-color: var(--primary); }
.sidebar-foot { padding: 20px 24px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
#adminName { font-size: 13px; color: var(--sub); }
.btn-ghost-sm {
  background: var(--panel2); color: #c3ccff; border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 14px; font-size: 12px; cursor: pointer;
}

.main { flex: 1; padding: 28px 32px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 26px; }
.topbar-title { font-size: 22px; font-weight: 700; }
.topbar-meta { font-size: 12px; color: var(--muted); }

/* ---------- 统计卡 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 18px; margin-bottom: 24px; }
.stat-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 22px;
}
.stat-card .num { font-size: 30px; font-weight: 700; color: #fff; }
.stat-card .label { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---------- 面板 / 表格 ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 24px; margin-bottom: 22px; }
.panel-title { font-size: 16px; font-weight: 600; margin-bottom: 18px; }
.panel-desc { font-size: 13px; color: var(--sub); line-height: 1.7; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 13px 14px; text-align: left; font-size: 13px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 500; font-size: 12px; }
.table td { color: #e6e8ff; }
.tag { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; }
.tag-green { background: rgba(52,211,153,.15); color: var(--green); }
.tag-orange { background: rgba(251,146,60,.15); color: var(--orange); }
.tag-blue { background: rgba(99,102,241,.15); color: #c3ccff; }
.tag-red { background: rgba(248,113,113,.15); color: var(--red); }
.tag-muted { background: rgba(154,160,199,.15); color: var(--muted); }

/* ---------- 内容库 ---------- */
.content-list { display: flex; flex-direction: column; gap: 16px; }
.content-item { background: var(--panel2); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.content-item .ci-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.content-item .ci-title { font-size: 15px; font-weight: 600; }
.content-item textarea {
  width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; color: #fff;
  padding: 12px; font-size: 13px; min-height: 64px; resize: vertical; outline: none;
}
.content-item .ci-actions { margin-top: 12px; display: flex; gap: 10px; justify-content: flex-end; }
.btn-sm { background: var(--primary); color: #fff; border: none; border-radius: 8px; padding: 8px 16px; font-size: 12px; cursor: pointer; }
.btn-sm.ghost { background: var(--panel); border: 1px solid var(--line); color: #c3ccff; }
.muted { color: var(--muted); font-size: 12px; }

/* ---------- 菜单分组 ---------- */
.menu-group { padding: 16px 24px 6px; font-size: 11px; color: var(--muted); letter-spacing: 1px; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-item { display: block; text-align: left; }
.form-item.form-full { grid-column: 1 / -1; }
.form-item span { display: block; font-size: 13px; color: var(--sub); margin-bottom: 8px; }
.form-item input, .form-item textarea {
  width: 100%; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; color: #fff; font-size: 14px; outline: none; resize: vertical;
}
.form-item input:focus, .form-item textarea:focus { border-color: var(--primary); }

.group-checks { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.group-check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: #e6e8ff; cursor: pointer; }
.group-check input { width: 16px; height: 16px; padding: 0; margin: 0; background: none; border: none; accent-color: var(--primary); }

/* ---------- 开关 ---------- */
.switch-grid { display: flex; flex-wrap: wrap; gap: 24px; }
.switch-item { display: flex; align-items: center; gap: 10px; font-size: 14px; color: #e6e8ff; cursor: pointer; }
.switch-item input { width: 16px; height: 16px; accent-color: var(--primary); }

/* ---------- 会话管理 ---------- */
.toolbar { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar-input {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; color: #fff; font-size: 13px; outline: none;
}
.toolbar-input:focus { border-color: var(--primary); }
#sessSearch { flex: 1; min-width: 200px; }
.sess-cell-main { font-size: 13px; }
.sess-cell-sub { font-size: 11px; color: var(--muted); margin-top: 3px; }
.sess-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.detail-meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--sub); margin-bottom: 16px; }
.detail-meta b { color: #fff; font-weight: 600; }
.detail-list { display: flex; flex-direction: column; gap: 12px; max-height: 52vh; overflow-y: auto; padding-right: 4px; }
.detail-hints { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; }
.detail-hints-title { font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.hint-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 6px 0; font-size: 12px; }
.msg { display: flex; gap: 10px; }
.msg.user { flex-direction: row-reverse; }
.msg-bubble { max-width: 72%; background: var(--panel2); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; }
.msg.user .msg-bubble { background: rgba(99,102,241,.18); }
.msg-text { font-size: 13px; line-height: 1.6; }
.msg-meta { font-size: 11px; color: var(--muted); margin-top: 5px; }

/* ---------- 权益 ---------- */
.benefit-list { display: flex; flex-direction: column; gap: 12px; }
.benefit-item { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: center; }
.benefit-item input {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 13px; color: #fff; font-size: 13px; outline: none;
}
.btn-danger { background: rgba(248,113,113,.15); color: var(--red); border: 1px solid rgba(248,113,113,.3); border-radius: 8px; padding: 8px 14px; font-size: 12px; cursor: pointer; }

/* ---------- 弹窗 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(8,8,20,.7); display: flex; align-items: center; justify-content: center; z-index: 200; }
.modal-box { width: 460px; max-width: 92vw; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 26px; }
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.modal-box .form-item { margin-bottom: 14px; }

/* ---------- 表格操作 ---------- */
.op-link { color: #c3ccff; cursor: pointer; font-size: 12px; }
.op-link:hover { color: #fff; }
.ci-actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; }

/* ---------- 内容库内联输入 ---------- */
.ci-title-input {
  background: transparent; border: none; color: #fff; font-size: 15px; font-weight: 600; outline: none; min-width: 160px;
}
.ci-line {
  width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; color: #fff;
  padding: 10px 12px; font-size: 13px; outline: none; margin: 8px 0;
}
.modal-box select, .form-item select {
  width: 100%; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; color: #fff; font-size: 14px; outline: none;
}
