:root {
  --brand: #2f6bff;
  --brand-dark: #2157d8;
  --brand-soft: #eaf1ff;
  --bg: #f4f6fb;
  --panel: #ffffff;
  --line: #e8ecf4;
  --line-strong: #dbe1ec;
  --text: #1b2333;
  --text-2: #55607a;
  --muted: #8a94a8;
  --green: #12b76a;
  --orange: #f79009;
  --red: #f04438;
  --shadow: 0 12px 30px rgba(27, 35, 51, .08);
  --radius: 12px;
}

* { box-sizing: border-box; }

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

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--brand); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon.sm { width: 16px; height: 16px; }
.icon.lg { width: 42px; height: 42px; stroke-width: 1.2; }

/* 通用按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 13px;
  transition: .16s ease;
  white-space: nowrap;
}
.btn.primary { background: var(--brand); color: #fff; box-shadow: 0 6px 14px rgba(47, 107, 255, .2); }
.btn.primary:hover { background: var(--brand-dark); }
.btn.ghost { border-color: var(--line-strong); background: #fff; color: var(--text-2); }
.btn.ghost:hover { color: var(--brand); border-color: #b9c9ea; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.danger { color: var(--red); }

.icon-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  color: var(--text-2);
}
.icon-btn:hover { background: #f0f3f9; color: var(--text); }

/* 登录 */
.login {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(900px 400px at 15% 15%, rgba(47, 107, 255, .14), transparent 60%),
    radial-gradient(700px 380px at 85% 80%, rgba(18, 183, 106, .1), transparent 60%),
    #f6f8fd;
  z-index: 50;
}
.login-panel {
  width: 400px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(14px);
  border: 1px solid #fff;
  border-radius: 18px;
  padding: 34px 36px 28px;
  box-shadow: var(--shadow);
}
.login-brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; letter-spacing: .2px; }
.logo-mark { color: var(--brand); font-size: 16px; }
.login-panel h1 { font-size: 22px; margin: 26px 0 6px; }
.login-sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; line-height: 1.6; }
.login-hint { text-align: center; font-size: 12px; color: var(--muted); margin: 16px 0 0; }
.form-error { color: var(--red); font-size: 12px; min-height: 18px; margin: 4px 0 8px; }

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; }
.field > span { font-size: 13px; color: var(--text-2); font-weight: 600; }
.field input, .field textarea, .field select, .search-box input {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 9px;
  padding: 10px 12px;
  outline: none;
  transition: .15s;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47, 107, 255, .12); }
.field input[type="color"] { padding: 4px; height: 40px; }
.field textarea { resize: vertical; line-height: 1.6; }
.field-note { font-size: 12px; color: var(--muted); margin: -6px 0 12px; }

/* 顶部 */
.app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.topbar {
  height: 48px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.brand-name { letter-spacing: .2px; }
.brand-tag { font-size: 11px; font-weight: 500; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; }
.top-right { display: flex; align-items: center; gap: 10px; }
.presence { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--green); background: #ecfdf3; border-radius: 20px; padding: 4px 10px; }
.presence i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.account { display: flex; align-items: center; gap: 7px; padding: 4px 8px; border-radius: 8px; font-size: 13px; color: var(--text-2); }
.account:hover { background: #f4f6fb; }

.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #6f9bff, #2f6bff);
  color: #fff; font-size: 13px; font-weight: 700; flex: none;
}
.avatar.xs { width: 26px; height: 26px; font-size: 11px; }

/* 布局 */
.shell { flex: 1; display: flex; min-height: 0; }
.rail {
  width: 56px;
  flex: none;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  position: relative;
  transition: width .18s ease;
}
.rail-icons { display: flex; flex-direction: column; gap: 4px; width: 100%; align-items: center; }
.rail-icon {
  width: 38px; height: 38px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
}
.rail-icon:hover { background: #f3f6fc; color: var(--brand); }
.rail-icon.active { background: var(--brand-soft); color: var(--brand); }
.rail-menu { display: none; }
.rail-toggle {
  margin-top: auto;
  width: 38px; height: 30px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 16px;
}
.rail-toggle:hover { background: #f4f6fb; }
.rail.expanded { width: 232px; align-items: stretch; padding: 14px 12px; }
.rail.expanded .rail-icons { display: none; }
.rail.expanded .rail-menu { display: flex; flex-direction: column; gap: 2px; width: 100%; }
.rail.expanded .rail-toggle { align-self: flex-start; margin-left: 2px; }
.menu-group { font-size: 11px; color: var(--muted); letter-spacing: .4px; padding: 12px 10px 5px; text-transform: uppercase; }
.menu-item, .submenu-item {
  text-align: left;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--text-2);
  font-size: 13px;
}
.menu-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.menu-item:hover, .submenu-item:hover { background: #f4f6fb; color: var(--text); }
.menu-item.active, .submenu-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.submenu { display: flex; flex-direction: column; padding-left: 14px; }
.submenu-item { font-size: 12.5px; color: var(--muted); }

.content { flex: 1; min-width: 0; min-height: 0; position: relative; }
.view { display: none; height: 100%; flex-direction: column; min-height: 0; overflow-y: auto; }
.view.active { display: flex; }
.page-head {
  flex: none;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 26px 14px;
}
.page-head h1 { font-size: 20px; margin: 0 0 4px; }
.page-head p { margin: 0; color: var(--muted); font-size: 13px; }

/* 收件箱 */
.banner {
  flex: none;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 18px;
  background: linear-gradient(90deg, #eef4ff, #f7faff);
  border-bottom: 1px solid #dfe9fb;
  color: #3d5a94;
  font-size: 12.5px;
}
.banner .icon { color: var(--brand); }
.banner a { margin-left: auto; font-weight: 600; }

.inbox-grid { flex: 1; display: flex; min-height: 0; background: #fff; border-top: 1px solid transparent; }

.conv-pane {
  width: 320px;
  flex: none;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #fff;
}
.pane-head { height: 50px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 14px 0 16px; }
.pane-title { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-size: 14px; }
.link { color: var(--brand); font-size: 12px; }
.link:hover { text-decoration: underline; }
.tabs { display: flex; gap: 4px; padding: 0 12px 10px; border-bottom: 1px solid var(--line); }
.tab {
  padding: 6px 9px;
  border-radius: 7px;
  font-size: 12px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.tab span { background: #f1f4fa; border-radius: 8px; padding: 0 5px; font-size: 11px; color: var(--text-2); }
.tab.active { color: var(--brand); background: var(--brand-soft); font-weight: 600; }
.tab.active span { background: #fff; color: var(--brand); }

.search-box {
  flex: none;
  margin: 10px 12px;
  height: 34px;
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 9px;
  background: #fbfcfe;
}
.search-box .icon { color: var(--muted); }
.search-box input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 0; height: 100%; font-size: 12.5px; }
.search-box input:focus { box-shadow: none; }
.search-box button {
  flex: none;
  height: 24px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand);
  background: var(--brand-soft);
  transition: .15s;
}
.search-box button:hover { background: #d9e6ff; }
.search-box:focus-within { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(47, 107, 255, .12); }

.conv-list { flex: 1; overflow-y: auto; padding: 0 8px 12px; }
.conv-item {
  display: flex;
  gap: 10px;
  padding: 10px;
  border-radius: 9px;
  cursor: pointer;
  position: relative;
}
.conv-item:hover { background: #f7f9fd; }
.conv-item.active { background: var(--brand-soft); }
.conv-item .avatar { width: 36px; height: 36px; }
.conv-item-main { flex: 1; min-width: 0; }
.conv-item-top { display: flex; align-items: center; gap: 6px; }
.conv-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { margin-left: auto; font-size: 11px; color: var(--muted); flex: none; }
.conv-preview {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-item-foot { display: flex; align-items: center; gap: 6px; margin-top: 5px; }
.mini-tag { font-size: 10.5px; border-radius: 4px; padding: 1px 5px; background: #f1f4fa; color: var(--muted); }
.mini-tag.ai { background: #eef4ff; color: var(--brand); }
.mini-tag.human { background: #ecfdf3; color: #0a9b5b; }
.mini-tag.pending { background: #fff4e5; color: #d9750a; }
.unread {
  margin-left: auto;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600;
}
.list-empty { padding: 60px 24px; text-align: center; color: var(--muted); }
.list-empty .icon { margin-bottom: 12px; color: #c3ccdc; }

/* 聊天区 */
.chat-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; background: #f7f9fc; overflow: hidden; }
.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px; }
.chat-empty h2 { font-size: 17px; margin: 18px 0 8px; }
.chat-empty p { color: var(--muted); margin: 0 0 20px; font-size: 13px; }
.empty-art { position: relative; width: 140px; height: 96px; }
.empty-art span { position: absolute; border-radius: 14px; background: #fff; box-shadow: 0 10px 24px rgba(36, 58, 99, .1); }
.empty-art span:nth-child(1) { width: 100px; height: 64px; left: 8px; top: 12px; background: #e9f0ff; transform: rotate(-6deg); }
.empty-art span:nth-child(2) { width: 100px; height: 64px; right: 4px; top: 6px; background: #fff; transform: rotate(5deg); }
.empty-art span:nth-child(3) { width: 44px; height: 8px; left: 48px; bottom: 2px; border-radius: 6px; background: #d6e2f8; box-shadow: none; }

.chat-main { flex: 1; display: flex; flex-direction: column; min-height: 0; background: #fff; }
.chat-head {
  flex: none;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  z-index: 3;
}
.chat-person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chat-person-info { min-width: 0; }
.chat-name-row { display: flex; align-items: center; gap: 7px; font-weight: 700; font-size: 14px; }
.chat-meta { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { font-size: 10.5px; border-radius: 4px; padding: 1px 5px; background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.badge.member { background: #ecfdf3; color: #0a9b5b; }
.state { font-size: 11px; color: var(--muted); }
.chat-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.chip {
  height: 28px;
  padding: 0 10px;
  border-radius: 7px;
  border: 1px solid var(--line-strong);
  background: #fff;
  font-size: 12px;
  color: var(--text-2);
}
.chip:hover { border-color: #b9c9ea; color: var(--brand); }
.chip.on { background: var(--brand-soft); border-color: #c9dbff; color: var(--brand); font-weight: 600; }
.chip.danger:hover { color: var(--red); border-color: #ffc9c4; }

.messages { flex: 1; overflow-y: auto; padding: 20px 22px 8px; background: #f7f9fc; }
.msg-row { display: flex; gap: 9px; margin-bottom: 14px; }
.msg-row.out { flex-direction: row-reverse; }
.msg-avatar { width: 30px; height: 30px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; background: #e6ecf8; color: #5b6b88; }
.msg-row.out .msg-avatar { background: linear-gradient(135deg, #7ba2ff, #2f6bff); color: #fff; }
.msg-body { max-width: min(560px, 72%); }
.msg-meta { font-size: 11px; color: var(--muted); margin-bottom: 4px; display: flex; gap: 6px; align-items: center; }
.msg-row.out .msg-meta { justify-content: flex-end; }
.bubble {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  border-top-left-radius: 4px;
  padding: 9px 12px;
  font-size: 13.5px;
  line-height: 1.65;
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: 0 2px 6px rgba(30, 45, 70, .04);
}
.msg-row.out .bubble {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  border-top-left-radius: 12px;
  border-top-right-radius: 4px;
}
.msg-row.ai .msg-avatar { background: #eef4ff; color: var(--brand); }
.msg-row.ai .bubble { background: #fff; border-color: #dbe7ff; }
.bubble img { max-width: 100%; border-radius: 8px; display: block; }
.bubble a.file { color: inherit; text-decoration: underline; }
.bubble a.msg-link { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }
.msg-row.out .bubble a.msg-link { color: #fff; }
.msg-system { text-align: center; color: var(--muted); font-size: 11.5px; margin: 10px 0 16px; }
.msg-system span { background: #eef1f7; border-radius: 10px; padding: 3px 10px; }
.typing-hint { height: 20px; flex: none; font-size: 11.5px; color: var(--muted); padding: 0 24px; background: #f7f9fc; }

.composer { flex: none; padding: 0 16px 14px; background: #fff; position: relative; }
.composer-box { border: 1px solid var(--line-strong); border-radius: 12px; padding: 8px 10px 8px; background: #fff; transition: .15s; }
.composer-box:focus-within { border-color: #b7caf5; box-shadow: 0 0 0 3px rgba(47, 107, 255, .08); }
.composer textarea {
  width: 100%;
  border: 0;
  outline: none;
  resize: none;
  min-height: 40px;
  max-height: 140px;
  font-size: 13.5px;
  line-height: 1.6;
  padding: 4px 2px;
}
.composer-actions { display: flex; align-items: center; gap: 4px; }
.composer-hint { margin-left: auto; font-size: 11px; color: var(--muted); margin-right: 8px; }
.quick-pop {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 96px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-height: 260px;
  overflow-y: auto;
  padding: 6px;
  z-index: 12;
}
.quick-item { padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.quick-item:hover { background: var(--brand-soft); }
.quick-item strong { display: block; font-size: 12.5px; margin-bottom: 3px; }
.quick-item span { font-size: 12px; color: var(--muted); }

/* 资料抽屉 */
.info-drawer {
  position: absolute;
  top: 62px;
  right: 0;
  bottom: 0;
  width: 320px;
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 28px rgba(30, 45, 70, .06);
  transform: translateX(102%);
  transition: transform .2s ease;
  z-index: 8;
  display: flex;
  flex-direction: column;
}
.info-drawer.open { transform: translateX(0); }
.drawer-head { height: 48px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; border-bottom: 1px solid var(--line); }
.drawer-body { padding: 16px; overflow-y: auto; }
.drawer-section { margin-bottom: 20px; }
.drawer-section h4 { font-size: 12px; color: var(--muted); margin: 0 0 8px; font-weight: 600; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed #eef1f7; font-size: 12.5px; }
.kv span:first-child { color: var(--muted); flex: none; }
.kv span:last-child { text-align: right; word-break: break-all; }
.drawer-person { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }

/* 通用卡片/页面 */
.two-col { display: grid; grid-template-columns: 1fr 380px; gap: 16px; padding: 0 26px 26px; }
.two-col.wide-left { grid-template-columns: 1fr 420px; }
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.card h2 { font-size: 15px; margin: 0 0 14px; }
.card h2:not(:first-child) { margin-top: 24px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.form-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.placeholder-card { padding: 30px; display: flex; flex-direction: column; gap: 16px; align-items: flex-start; max-width: 640px; margin: 0 26px 26px; }
.placeholder-card p { margin: 0; color: var(--text-2); }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.toggle-row:last-of-type { border-bottom: 0; }
.toggle-row strong { display: block; font-size: 13px; }
.toggle-row small { color: var(--muted); font-size: 12px; }
.toggle-row.compact { padding: 4px 0 14px; border: 0; }
.switch { appearance: none; width: 42px; height: 24px; border-radius: 12px; background: #d9e0ec; position: relative; transition: .18s; cursor: pointer; flex: none; }
.switch::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: #fff; top: 3px; left: 3px; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: .18s; }
.switch:checked { background: var(--brand); }
.switch:checked::after { transform: translateX(18px); }

.segmented { display: inline-flex; background: #eef1f7; border-radius: 9px; padding: 3px; gap: 2px; }
.segmented button { padding: 6px 12px; border-radius: 7px; font-size: 12.5px; color: var(--text-2); }
.segmented button.active { background: #fff; color: var(--brand); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.ai-panel { display: none; flex: 1; min-height: 0; overflow-y: auto; }
.ai-panel.active { display: block; }

.tips { margin: 0; padding-left: 18px; color: var(--text-2); font-size: 12.5px; line-height: 1.9; }
.test-result { font-size: 12px; color: var(--muted); }
.test-result.ok { color: var(--green); }
.test-result.err { color: var(--red); }
.field-note { font-size: 12px; color: var(--muted); margin: -4px 0 12px; }

/* 预览 */
.preview-card { background: #f9fbff; }
.widget-preview { width: 100%; max-width: 340px; height: 420px; margin: 0 auto; background: #fff; border-radius: 16px; border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.wp-head { padding: 16px; color: #fff; display: flex; align-items: center; gap: 10px; background: var(--brand); }
.wp-head small { display: block; font-size: 11px; opacity: .8; margin-top: 2px; }
.wp-avatar { width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.22); display: flex; align-items: center; justify-content: center; }
.wp-body { flex: 1; padding: 16px; background: #f6f8fc; }
.wp-bubble { background: #fff; border: 1px solid var(--line); border-radius: 10px; border-top-left-radius: 3px; padding: 9px 12px; font-size: 12.5px; line-height: 1.6; box-shadow: 0 2px 6px rgba(30,45,70,.05); }
.wp-input { padding: 10px 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; }
.wp-input i { font-style: normal; color: var(--brand); }

/* 知识库 */
.kb-list { display: flex; flex-direction: column; gap: 8px; max-height: 520px; overflow-y: auto; }
.kb-item { border: 1px solid var(--line); border-radius: 9px; padding: 12px; }
.kb-item-top { display: flex; align-items: center; gap: 8px; }
.kb-item strong { font-size: 13px; }
.kb-item p { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kb-actions { margin-left: auto; display: flex; gap: 4px; }
.kb-empty { color: var(--muted); font-size: 13px; padding: 20px 4px; }

/* 用量 */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; padding: 0 26px 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat small { color: var(--muted); font-size: 12px; display: block; margin-bottom: 6px; }
.stat strong { font-size: 20px; letter-spacing: -.3px; }
#ai-usage .card { margin: 0 26px 26px; }

.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 11px 8px; border-bottom: 1px solid #f1f4f9; }
.table tr:last-child td { border-bottom: 0; }
.empty-cell { text-align: center; color: var(--muted); padding: 26px 0 !important; }

/* 安装 */
.code-box { position: relative; background: #0f172a; border-radius: 10px; padding: 14px 16px; margin-bottom: 16px; }
.code-box pre { margin: 0; color: #d7e3ff; font-size: 12px; line-height: 1.7; white-space: pre-wrap; word-break: break-all; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.copy-btn { position: absolute; top: 8px; right: 8px; height: 26px; padding: 0 8px; border-radius: 6px; background: rgba(255,255,255,.12); color: #d7e3ff; font-size: 11px; display: inline-flex; align-items: center; gap: 4px; }
.copy-btn:hover { background: rgba(255,255,255,.22); }
.tag { font-size: 10.5px; background: #f1f4fa; color: var(--muted); border-radius: 4px; padding: 2px 6px; }

/* 通知渠道 */
.notify-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 0 26px 16px; }
.notify-card { display: flex; flex-direction: column; }
.notify-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.notify-head h2 { margin: 0 0 5px; font-size: 15px; }
.notify-head p { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.65; }
.notify-card .field { margin-top: 14px; margin-bottom: 0; }
.notify-card .form-actions { margin-top: 14px; }
.payload-preview {
  margin: 14px 0 0;
  background: #0f172a;
  color: #cfe0ff;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 11.5px;
  line-height: 1.65;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
.notify-local { margin: 0 26px 26px; }

/* 公众号绑定 */
.wx-qr-wrap {
  min-height: 270px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.wx-qr-wrap img {
  width: 220px;
  height: 220px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.wx-qr-wrap p { margin: 0; font-size: 12.5px; color: var(--muted); text-align: center; line-height: 1.7; }
.wx-binding { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px dashed var(--line); }
.wx-binding:last-child { border-bottom: 0; }
.wx-binding .grow { flex: 1; min-width: 0; }
.wx-binding strong { font-size: 12.5px; }
.wx-binding small { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.wx-empty { color: var(--muted); font-size: 13px; }

/* Telegram 绑定 */
.tg-bind {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafbff;
}
.tg-qr img {
  width: 168px;
  height: 168px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.tg-bind-info { flex: 1; min-width: 0; }
.tg-bind-info p { margin: 0 0 8px; font-size: 12.5px; color: var(--text-2); line-height: 1.65; }
.tg-bind-info code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  background: #eef2fb;
  border-radius: 5px;
  padding: 1px 6px;
  color: var(--text-2);
}
.tg-bind-info a { font-size: 12.5px; color: var(--brand); }
.tg-bindings { margin-top: 8px; }

/* 坐席 / 租户管理 */
.page-card { margin: 0 26px 26px; overflow-x: auto; }
.form-body { padding: 16px; max-height: 72vh; overflow-y: auto; }
.row-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.mini-btn {
  height: 26px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: #fff;
  font-size: 11.5px;
  color: var(--text-2);
}
.mini-btn:hover { color: var(--brand); border-color: #b9c9ea; }
.mini-btn.danger:hover { color: var(--red); border-color: #ffc9c4; }
.role-badge { font-size: 10.5px; border-radius: 4px; padding: 1px 6px; background: var(--brand-soft); color: var(--brand); }
.role-badge.agent { background: #f1f4fa; color: var(--muted); }
.status-on { color: var(--green); font-size: 12px; }
.status-off { color: var(--muted); font-size: 12px; }
.site-key { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11.5px; color: var(--muted); }
.self-tag { font-size: 10.5px; color: var(--muted); margin-left: 4px; }

/* 弹窗 / 提示 */
.modal { position: fixed; inset: 0; background: rgba(20, 28, 45, .38); display: flex; align-items: center; justify-content: center; z-index: 80; }
.modal-card { width: 380px; background: #fff; border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-body { padding: 10px; max-height: 300px; overflow-y: auto; }
.agent-option { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 8px; text-align: left; }
.agent-option:hover { background: var(--brand-soft); }
.agent-option small { margin-left: auto; font-size: 11px; color: var(--muted); }
.agent-option .dot { width: 7px; height: 7px; border-radius: 50%; background: #c7cfdd; }
.agent-option .dot.on { background: var(--green); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 36px;
  transform: translateX(-50%);
  background: rgba(23, 32, 51, .92);
  color: #fff;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 12.5px;
  z-index: 99;
  box-shadow: var(--shadow);
}

@media (max-width: 1200px) {
  .conv-pane { width: 280px; }
  .two-col, .two-col.wide-left { grid-template-columns: 1fr; }
  .info-drawer { width: 290px; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .conv-pane { width: 240px; }
  .chat-actions .chip:not(#aiToggleBtn) { display: none; }
  .inbox-grid { min-width: 720px; }
  .view { overflow-x: auto; }
  .notify-grid { grid-template-columns: 1fr; }
}
