/* ============================================================
   智能客服 Agent · 全站样式（浅色主题 · v2）
   设计系统：蓝色主色 #3b6cff / 青绿辅色 / slate 中性色
   ============================================================ */
:root {
  --primary: #3b6cff;
  --primary-deep: #2b54d6;
  --primary-soft: #edf2ff;
  --primary-glow: rgba(59, 108, 255, .18);
  --teal: #0ea5a5;
  --teal-soft: #e6f7f7;

  --bg: #f4f6fb;
  --bg-decor: #eef2fb;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --border: #e5eaf3;
  --border-strong: #d5dcec;

  --text: #0f172a;
  --text-2: #5b6b85;
  --text-3: #94a3b8;

  --green: #15a34a;
  --green-soft: #e6f7ec;
  --red: #e5484d;
  --red-soft: #fdecec;
  --orange: #d97706;
  --orange-soft: #fdf3e3;
  --amber: #f5a623;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 20px rgba(15, 23, 42, .06);
  --shadow-lg: 0 2px 6px rgba(15, 23, 42, .05), 0 16px 44px rgba(15, 23, 42, .12);
  --ring: 0 0 0 3px var(--primary-glow);

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 20px;

  --ease: cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: rgba(59, 108, 255, .18); }

/* 细滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #a8b6cc; background-clip: content-box; border: 2px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: 14px; color: var(--text); }
input::placeholder, textarea::placeholder { color: var(--text-3); }
.hidden { display: none !important; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 18px; border-radius: var(--r-sm);
  font-size: 14px; font-weight: 500; letter-spacing: .2px;
  background: linear-gradient(135deg, var(--primary), #5a86ff);
  color: #fff;
  box-shadow: 0 1px 2px rgba(59, 108, 255, .25), 0 4px 12px rgba(59, 108, 255, .18);
  transition: transform .12s var(--ease), box-shadow .15s, filter .15s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); box-shadow: 0 2px 4px rgba(59, 108, 255, .28), 0 8px 20px rgba(59, 108, 255, .24); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.98); box-shadow: var(--shadow-sm); }
.btn:disabled { background: #c3cddf; color: #fff; box-shadow: none; cursor: not-allowed; transform: none; filter: none; }
.btn-outline { background: #fff; color: var(--primary); border: 1px solid var(--border-strong); box-shadow: var(--shadow-sm); }
.btn-outline:hover { border-color: var(--primary); background: var(--primary-soft); filter: none; }
.btn-ghost { background: transparent; color: var(--text-2); box-shadow: none; }
.btn-ghost:hover { background: #edf0f7; color: var(--text); }
.btn-danger { background: linear-gradient(135deg, var(--red), #f06b6f); box-shadow: 0 1px 2px rgba(229, 72, 77, .25), 0 4px 12px rgba(229, 72, 77, .18); }
.btn-danger:hover { box-shadow: 0 2px 4px rgba(229, 72, 77, .3), 0 8px 20px rgba(229, 72, 77, .22); }
.btn-sm { padding: 5px 12px; font-size: 13px; border-radius: 7px; }

/* ============ 徽标 ============ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500; line-height: 1.5;
  background: #edf0f7; color: var(--text-2);
  white-space: nowrap;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .75; }
.badge-intent { background: var(--primary-soft); color: var(--primary-deep); }
.badge-ok { background: var(--green-soft); color: var(--green); }
.badge-warn { background: var(--orange-soft); color: var(--orange); }
.badge-danger { background: var(--red-soft); color: var(--red); }

/* ============ 品牌 ============ */
.brand { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 10px; letter-spacing: .2px; }
.brand .logo {
  width: 32px; height: 32px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #22c3c3);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 16px;
  box-shadow: 0 2px 6px rgba(59, 108, 255, .3), inset 0 1px 0 rgba(255, 255, 255, .25);
}

/* ============================================================
   客服聊天页
   ============================================================ */
.chat-header {
  height: 58px;
  background: rgba(255, 255, 255, .82);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; position: sticky; top: 0; z-index: 20;
}
.header-right { display: flex; align-items: center; gap: 10px; }

.chat-layout { display: flex; height: calc(100vh - 58px); }

/* ---- 侧边会话栏 ---- */
.sidebar {
  width: 264px; background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
  background: linear-gradient(180deg, #fbfcfe, #f7f9fd);
}
.sidebar-title {
  padding: 16px 18px 10px; font-size: 12px; color: var(--text-3);
  font-weight: 600; letter-spacing: .5px; text-transform: uppercase;
  display: flex; justify-content: space-between; align-items: center;
}
.sidebar-title span { text-transform: none; letter-spacing: 0; font-weight: 500; }
.conv-list { flex: 1; overflow-y: auto; padding: 0 10px 14px; }
.conv-item {
  position: relative;
  padding: 11px 13px; border-radius: var(--r); cursor: pointer; margin-bottom: 4px;
  display: flex; flex-direction: column; gap: 3px;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, transform .15s var(--ease);
}
.conv-item:hover { background: #fff; border-color: var(--border); transform: translateX(2px); box-shadow: var(--shadow-sm); }
.conv-item.active { background: #fff; border-color: #cfdbff; box-shadow: 0 0 0 3px var(--primary-glow); }
.conv-item.active::before {
  content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px;
  border-radius: 3px; background: linear-gradient(180deg, var(--primary), #22c3c3);
}
.conv-item .t { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.conv-item .d { font-size: 11.5px; color: var(--text-3); display: flex; gap: 6px; align-items: center; }
.conv-item .d .badge { font-size: 10.5px; padding: 0 8px; }

/* ---- 消息区 ---- */
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.messages {
  flex: 1; overflow-y: auto; padding: 26px 28px 12px;
  background:
    radial-gradient(circle at 18% 12%, rgba(59, 108, 255, .045), transparent 42%),
    radial-gradient(circle at 85% 88%, rgba(14, 165, 165, .05), transparent 40%),
    var(--bg);
}
.msg-row { display: flex; margin-bottom: 20px; gap: 12px; align-items: flex-start; animation: msgIn .28s var(--ease) both; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.msg-row.user { flex-direction: row-reverse; }
/* 消息包裹层：承载宽度上限（百分比放这里，避免与 bubble 内容尺寸形成循环依赖
   导致短消息被压到一字宽竖排） */
.msg-box {
  min-width: 0; max-width: min(78%, 620px);
  display: flex; flex-direction: column; align-items: flex-start;
}
.msg-row.user .msg-box { align-items: flex-end; }
.avatar {
  width: 36px; height: 36px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 17px;
  box-shadow: var(--shadow-sm);
}
.msg-row.bot .avatar { background: linear-gradient(135deg, var(--primary), #22c3c3); color: #fff; box-shadow: 0 2px 8px rgba(59, 108, 255, .28); }
.msg-row.user .avatar { background: linear-gradient(135deg, #e2e8f4, #cdd8ec); color: #5b6b85; }
.msg-row.system .avatar { background: var(--orange-soft); }

.bubble {
  width: fit-content; max-width: 100%;
  padding: 11px 16px; border-radius: var(--r-lg); font-size: 14.5px;
  word-break: break-word; white-space: pre-wrap; position: relative;
}
.msg-row.bot .bubble {
  background: var(--panel); border: 1px solid var(--border);
  border-top-left-radius: 5px; box-shadow: var(--shadow);
}
.msg-row.user .bubble {
  background: linear-gradient(135deg, var(--primary), #5a86ff); color: #fff;
  border-top-right-radius: 5px;
  box-shadow: 0 2px 6px rgba(59, 108, 255, .25), 0 8px 20px rgba(59, 108, 255, .16);
}
.msg-row.system .bubble { background: var(--orange-soft); color: #92590a; border: 1px solid #f3dcae; font-size: 13px; }
.msg-meta { font-size: 11px; color: var(--text-3); margin-top: 6px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.msg-row.user .msg-meta { justify-content: flex-end; }

.fb-btn {
  font-size: 12px; padding: 2px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: #fff; color: var(--text-2);
  transition: all .15s;
}
.fb-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.fb-btn.on-good { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.fb-btn.on-bad { background: var(--red-soft); border-color: var(--red); color: var(--red); }

/* 正在输入动画 */
.typing { display: inline-flex; gap: 5px; padding: 5px 2px; align-items: center; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: #b6c2d9; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }

/* 转人工横幅 */
.escalate-banner {
  margin: 0 28px 12px; padding: 11px 16px; border-radius: var(--r);
  background: linear-gradient(135deg, #fff7e8, #fdf3e3);
  border: 1px solid #f3dcae; color: #92590a;
  font-size: 13px; display: flex; align-items: center; gap: 8px;
  box-shadow: var(--shadow-sm);
  animation: msgIn .3s var(--ease) both;
}
.escalate-banner.agent-in {
  background: linear-gradient(135deg, #eefaf4, #e6f7ee);
  border-color: #bfe8d2; color: #1c7c4d;
}

/* 人工客服消息（用户端）：紫色头像 + 左侧强调边 */
.msg-row.agent .avatar {
  background: linear-gradient(135deg, #8b5cf6, #6d5df6);
  color: #fff; box-shadow: 0 2px 8px rgba(139, 92, 246, .3);
}
.msg-row.agent .bubble {
  background: #fff; border: 1px solid var(--border);
  border-left: 3px solid #8b5cf6;
}

/* 结束确认评价卡片（用户端内嵌消息流） */
.resolve-card {
  margin: 4px 0 18px 48px; max-width: min(78%, 620px);
  background: linear-gradient(135deg, #f7f9ff, #eef3ff);
  border: 1px solid #d5e0f8; border-radius: var(--r-lg);
  padding: 16px 18px; box-shadow: var(--shadow-sm);
  animation: msgIn .3s var(--ease) both;
}
.resolve-card .rc-title { font-size: 14px; font-weight: 700; color: var(--text-1); margin-bottom: 10px; }
.resolve-card .rc-q { font-size: 13.5px; color: var(--text-2); margin-bottom: 12px; }
.resolve-card .rc-hint { font-size: 12px; color: var(--text-3); margin-top: 10px; }
.resolve-card .rc-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.rc-btn {
  border: 1px solid var(--border); background: #fff; color: var(--text-1);
  border-radius: var(--r); padding: 9px 18px; font-size: 13.5px; cursor: pointer;
  transition: all .16s var(--ease); font-family: inherit;
}
.rc-btn:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
.rc-btn.rc-yes { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.rc-btn.rc-yes:hover { background: #2f5cf0; }
.rc-btn.rc-no:hover { border-color: var(--orange); color: var(--orange); }
.rc-btn.rc-ghost { background: transparent; color: var(--text-2); }
.rc-stars { display: flex; gap: 6px; margin-bottom: 12px; }
.rc-stars span {
  font-size: 30px; color: #d3dbe8; cursor: pointer; transition: transform .12s var(--ease), color .12s;
  user-select: none;
}
.rc-stars span:hover { transform: scale(1.15); }
.rc-stars span.on { color: #ffb020; }
.rc-comment {
  width: 100%; min-height: 64px; border: 1px solid var(--border); border-radius: var(--r);
  padding: 9px 12px; font-size: 13px; font-family: inherit; resize: vertical;
  margin-bottom: 12px; background: #fff; color: var(--text-1);
}
.rc-comment:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,108,255,.12); }
.resolve-card.resolve-done {
  background: linear-gradient(135deg, #f0fbf5, #e9f8ef);
  border-color: #bfe8d2;
}
.resolve-card .rc-hint a { color: var(--primary); font-weight: 600; text-decoration: underline; cursor: pointer; }

/* 客服工作台：我的满意度 mini 条 */
.my-sat { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.my-sat-item { background: var(--surface, #fff); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.my-sat-label { font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.my-sat-value { font-size: 22px; font-weight: 700; line-height: 1.1; }
.my-sat-sub { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.my-sat-value.v-green { color: #16a34a; }
.my-sat-value.v-amber { color: #d97706; }
.my-sat-value.v-red { color: #dc2626; }
.my-sat-value.v-blue { color: #2563eb; }
.tbl .my-sat-value { font-size: 15px; }

/* ---- 底部输入区 ---- */
.composer {
  display: flex; gap: 10px; padding: 14px 28px 12px;
  background: rgba(255, 255, 255, .9);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
}
.composer input {
  flex: 1; height: 44px; border: 1px solid var(--border-strong); border-radius: var(--r);
  padding: 0 16px; outline: none; background: #fff;
  transition: border-color .15s, box-shadow .15s;
  font-size: 14.5px;
}
.composer input:focus { border-color: var(--primary); box-shadow: var(--ring); }
.composer .btn { height: 44px; padding: 0 22px; border-radius: var(--r); }
.quick-chips { display: flex; gap: 8px; padding: 12px 28px 0; flex-wrap: wrap; background: rgba(255, 255, 255, .9); }
.chip {
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border);
  font-size: 12.5px; color: var(--text-2); background: #fff;
  transition: all .15s var(--ease);
}
.chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.chat-actions { display: flex; justify-content: space-between; align-items: center; padding: 10px 28px 14px; background: rgba(255, 255, 255, .9); }

/* ---- 弹层（评分） ---- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .42);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  animation: fadeIn .2s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  background: #fff; border-radius: var(--r-xl);
  width: 420px; max-width: calc(100vw - 40px); padding: 28px;
  box-shadow: var(--shadow-lg);
  animation: popIn .28s var(--ease);
}
@keyframes popIn { from { opacity: 0; transform: scale(.94) translateY(10px); } }
.modal h3 { font-size: 17px; margin-bottom: 6px; }
.modal .stars { display: flex; gap: 8px; font-size: 30px; margin: 14px 0 16px; }
.stars span { cursor: pointer; color: #dde3ee; transition: transform .15s var(--ease), color .15s; }
.stars span:hover, .stars span.on { color: var(--amber); transform: scale(1.18); text-shadow: 0 2px 10px rgba(245, 166, 35, .4); }
.modal textarea {
  width: 100%; border: 1px solid var(--border-strong); border-radius: var(--r);
  padding: 10px 12px; min-height: 80px; resize: vertical; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.modal textarea:focus { border-color: var(--primary); box-shadow: var(--ring); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ============================================================
   管理后台
   ============================================================ */
.admin-header {
  height: 58px;
  background: rgba(255, 255, 255, .82);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; position: sticky; top: 0; z-index: 20;
}
.admin-layout { display: flex; min-height: calc(100vh - 58px); }

/* ---- 侧边导航 ---- */
.admin-nav {
  width: 200px; background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; flex-shrink: 0;
  background: linear-gradient(180deg, #fbfcfe, #f7f9fd);
  position: sticky; top: 58px; height: calc(100vh - 58px);
}
.nav-item {
  position: relative;
  text-align: left; padding: 10px 14px; border-radius: var(--r);
  font-size: 14px; color: var(--text-2); font-weight: 500;
  display: flex; align-items: center; gap: 10px;
  transition: background .15s, color .15s;
}
.nav-item .ico { font-size: 16px; width: 22px; text-align: center; }
.nav-item:hover { background: #eef1f8; color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary-deep); font-weight: 600; }
.nav-item.active::before {
  content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px;
  border-radius: 3px; background: linear-gradient(180deg, var(--primary), #22c3c3);
}

.admin-content { flex: 1; padding: 26px 30px; overflow-x: auto; min-width: 0; }
.view-title { font-size: 19px; font-weight: 700; margin-bottom: 18px; letter-spacing: .2px; }
.view-title::after { content: ""; display: block; width: 34px; height: 3px; border-radius: 3px; margin-top: 7px; background: linear-gradient(90deg, var(--primary), #22c3c3); }

/* ---- 统计卡片 ---- */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card {
  position: relative; overflow: hidden;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 18px;
  box-shadow: var(--shadow);
  transition: transform .18s var(--ease), box-shadow .18s;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-card::after {
  content: ""; position: absolute; right: -18px; top: -18px; width: 84px; height: 84px;
  border-radius: 50%; background: radial-gradient(circle, var(--primary-glow), transparent 68%);
  pointer-events: none;
}
.stat-card .stat-head { display: flex; align-items: center; gap: 8px; }
.stat-icon {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; font-size: 14px;
  background: var(--primary-soft); color: var(--primary-deep);
}
.stat-icon.green { background: var(--green-soft); color: var(--green); }
.stat-icon.orange { background: var(--orange-soft); color: var(--orange); }
.stat-icon.red { background: var(--red-soft); color: var(--red); }
.stat-card .label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.stat-card .value { font-size: 27px; font-weight: 750; margin-top: 8px; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.stat-card .value.blue { color: var(--primary); }
.stat-card .value.green { color: var(--green); }
.stat-card .value.orange { color: var(--orange); }
.stat-card .value.red { color: var(--red); }
.stat-card .sub { font-size: 12px; color: var(--text-3); margin-top: 3px; }

/* ---- 面板与图表 ---- */
.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 20px; margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.panel h4 { font-size: 14.5px; font-weight: 600; margin-bottom: 16px; display: flex; align-items: center; gap: 7px; }
.panel h4::before { content: ""; width: 4px; height: 14px; border-radius: 2px; background: linear-gradient(180deg, var(--primary), #22c3c3); }
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .charts-row { grid-template-columns: 1fr; } }

.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.bar-row:last-child { margin-bottom: 0; }
.bar-row .name { width: 110px; font-size: 12.5px; color: var(--text-2); text-align: right; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { flex: 1; height: 16px; background: #eef1f7; border-radius: 6px; overflow: hidden; }
.bar-fill {
  height: 100%; border-radius: 6px;
  background: linear-gradient(90deg, var(--primary), #7ba3ff);
  min-width: 2px;
  transform-origin: left center;
  animation: barGrow .55s var(--ease) both;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25);
}
@keyframes barGrow { from { transform: scaleX(0); } }
.bar-row .num { width: 36px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---- 表格 ---- */
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.tbl th {
  text-align: left; padding: 11px 12px;
  background: var(--panel-2); color: var(--text-2); font-weight: 600;
  border-bottom: 1px solid var(--border); white-space: nowrap;
  position: sticky; top: 0;
}
.tbl td { padding: 12px; border-bottom: 1px solid #eef1f7; vertical-align: middle; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover td { background: #f7f9ff; }
.tbl tbody tr:last-child td { border-bottom: none; }
.ellipsis { max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- 筛选与分页 ---- */
.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.filters select, .filters input {
  height: 36px; border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  padding: 0 12px; outline: none; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.filters select:focus, .filters input:focus { border-color: var(--primary); box-shadow: var(--ring); }
.pager { display: flex; gap: 10px; align-items: center; margin-top: 16px; font-size: 13px; color: var(--text-2); }

/* ---- 会话详情抽屉 ---- */
.drawer-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .4); z-index: 90; animation: fadeIn .2s var(--ease); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 500px; max-width: 92vw;
  background: #fff; z-index: 95; display: flex; flex-direction: column;
  box-shadow: -12px 0 44px rgba(15, 23, 42, .16);
  animation: slideIn .3s var(--ease);
}
@keyframes slideIn { from { transform: translateX(40px); opacity: .4; } }
.drawer-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: linear-gradient(180deg, #fbfcfe, #fff); }
.drawer-head b { font-size: 15px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 22px; background: var(--bg); }
.drawer-msg { margin-bottom: 14px; }
.drawer-msg .who { font-size: 11.5px; color: var(--text-3); margin-bottom: 4px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.drawer-msg .txt {
  font-size: 13px; background: #fff; border: 1px solid var(--border);
  border-radius: var(--r) var(--r) var(--r) 4px;
  padding: 9px 12px; white-space: pre-wrap; box-shadow: var(--shadow-sm);
}
.drawer-msg.user .txt { background: var(--primary-soft); border-color: #cfdbff; border-radius: var(--r) var(--r) 4px var(--r); }
.drawer-msg.agent .txt { border-left: 3px solid #8b5cf6; background: #fbfaff; }
.drawer-msg.agent .who { color: #6d5df6; font-weight: 600; }
/* 轮询新到的消息：高亮闪一下提醒客服 */
.drawer-msg.flash .txt { animation: msgflash 1.8s ease-out; }
@keyframes msgflash {
  0% { background: #fff3d6; border-color: #f5c26b; box-shadow: 0 0 0 3px rgba(245, 162, 35, .18); }
  100% { box-shadow: var(--shadow-sm); }
}

/* 抽屉人工工作台操作区 */
.drawer-actions {
  border-top: 1px solid var(--border); padding: 14px 18px;
  background: #fff; display: grid; gap: 10px;
  box-shadow: 0 -6px 20px rgba(15, 23, 42, .05);
}
.drawer-reply { display: flex; gap: 8px; }
.drawer-reply input {
  flex: 1; padding: 9px 13px; font-size: 13px;
  border: 1px solid var(--border); border-radius: var(--r);
  background: #fff; color: var(--text-1); outline: none;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.drawer-reply input:focus { border-color: var(--primary); box-shadow: var(--ring); }
.drawer-reply .btn { padding: 9px 16px; font-size: 13px; }
.drawer-actions-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.drawer-hint { font-size: 12px; color: var(--text-2); }

/* 会话列表：待人工行高亮 */
tr.row-warn td { background: #fffaf0; }
tr.row-warn:hover td { background: #fdf3e3; }

/* ---- 客服工作台（V2.0） ---- */
.drawer-wide { width: 580px; }

/* 范围 tabs（待接入 / 我的 / 已结束） */
.scope-tabs { display: flex; gap: 8px; }
.scope-tab {
  padding: 8px 16px; border-radius: 999px; border: 1px solid var(--border);
  background: #fff; font-size: 13.5px; font-weight: 500; color: var(--text-2);
  transition: all .15s var(--ease);
}
.scope-tab:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.scope-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(59, 108, 255, .25); }
.scope-num {
  display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 2px;
  border-radius: 999px; background: var(--red-soft); color: var(--red);
  font-size: 12px; font-weight: 600; line-height: 18px; text-align: center;
}
.scope-tab.active .scope-num { background: rgba(255, 255, 255, .25); color: #fff; }

/* 抽屉工具条 */
.drawer-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.drawer-assign { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mode-flag {
  align-self: center; font-size: 12px; color: var(--orange);
  background: var(--orange-soft); border-radius: 999px; padding: 3px 12px; white-space: nowrap;
}
/* 内部备注消息：用户不可见，客服侧灰色区分 */
.drawer-msg.note .txt {
  background: #f6f7f9; border-style: dashed; color: var(--text-2);
  font-size: 12.5px; font-style: italic;
}
.drawer-msg.note .who { color: var(--text-2); }

/* ---- 话术面板 ---- */
.modal-phrase { width: 520px; max-width: calc(100vw - 40px); display: flex; flex-direction: column; }
.phrase-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.phrase-tab {
  padding: 4px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: #fff; font-size: 12.5px; color: var(--text-2); transition: all .15s;
}
.phrase-tab:hover { border-color: var(--primary); color: var(--primary); }
.phrase-tab.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-deep); font-weight: 600; }
.phrase-list { max-height: 380px; overflow-y: auto; display: grid; gap: 8px; }
.phrase-item {
  border: 1px solid var(--border); border-radius: var(--r); padding: 10px 14px;
  cursor: pointer; background: #fff; transition: all .15s var(--ease);
}
.phrase-item:hover { border-color: var(--primary); background: var(--primary-soft); transform: translateX(2px); box-shadow: var(--shadow-sm); }
.phrase-item-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.phrase-title { font-size: 13.5px; font-weight: 600; }
.phrase-content { font-size: 12.5px; color: var(--text-2); white-space: pre-wrap; word-break: break-word; }

/* ---- 表单区（FAQ / 设置） ---- */
.faq-editor { display: grid; gap: 12px; margin-bottom: 18px; }
.faq-editor input, .faq-editor textarea, .faq-editor select {
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  padding: 9px 12px; outline: none; width: 100%; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.faq-editor input:focus, .faq-editor textarea:focus, .faq-editor select:focus { border-color: var(--primary); box-shadow: var(--ring); }
.faq-editor label { color: var(--text); font-weight: 500; }
.faq-editor input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }

/* ---- 登录页 ---- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, #eaf0ff 0%, #f2f6fd 45%, #e9f8f8 100%);
}
.login-wrap::before, .login-wrap::after {
  content: ""; position: absolute; border-radius: 50%; pointer-events: none;
}
.login-wrap::before {
  width: 420px; height: 420px; left: -120px; top: -120px;
  background: radial-gradient(circle, rgba(59, 108, 255, .14), transparent 65%);
}
.login-wrap::after {
  width: 480px; height: 480px; right: -140px; bottom: -160px;
  background: radial-gradient(circle, rgba(14, 165, 165, .13), transparent 65%);
}
.login-card {
  position: relative; z-index: 1;
  background: rgba(255, 255, 255, .92);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px; width: 400px; max-width: calc(100vw - 40px);
  animation: popIn .35s var(--ease);
}
.login-card .brand { justify-content: center; margin-bottom: 4px; font-size: 19px; }
.login-card .brand .logo { width: 40px; height: 40px; font-size: 19px; border-radius: 12px; }
.login-card h2 { font-size: 20px; margin-bottom: 6px; text-align: center; }
.login-card p.tip { font-size: 13px; color: var(--text-2); margin-bottom: 24px; text-align: center; }
.login-card input {
  width: 100%; height: 44px; border: 1px solid var(--border-strong);
  border-radius: var(--r); padding: 0 14px; outline: none; margin-bottom: 16px;
  background: #fff; transition: border-color .15s, box-shadow .15s;
}
.login-card input:focus { border-color: var(--primary); box-shadow: var(--ring); }
.login-card .btn { width: 100%; justify-content: center; height: 44px; border-radius: var(--r); font-size: 15px; }
.login-err {
  color: var(--red); font-size: 13px; margin-bottom: 12px;
  background: var(--red-soft); border-radius: var(--r-sm); padding: 8px 12px;
}

/* ---- 空态 / Toast ---- */
.empty { text-align: center; color: var(--text-3); padding: 44px 0; font-size: 13px; }
.empty::before { content: "🌱"; display: block; font-size: 26px; margin-bottom: 8px; opacity: .6; }
.toast {
  position: fixed; top: 74px; left: 50%; transform: translateX(-50%);
  background: #1e293b; color: #fff; padding: 9px 20px; border-radius: 999px;
  font-size: 13px; z-index: 200; box-shadow: 0 10px 30px rgba(15, 23, 42, .3);
  animation: toastIn .25s var(--ease);
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -8px); } }

/* ============ 响应式 ============ */
@media (max-width: 760px) {
  .sidebar { display: none; }
  .messages { padding: 16px 14px 8px; }
  .composer, .quick-chips, .chat-actions { padding-left: 14px; padding-right: 14px; }
  .escalate-banner { margin-left: 14px; margin-right: 14px; }
  .msg-box { max-width: 84%; }
  .admin-nav { width: 64px; padding: 12px 8px; }
  .nav-item { font-size: 11px; text-align: center; padding: 10px 4px; flex-direction: column; gap: 2px; }
  .nav-item.active::before { display: none; }
  .admin-content { padding: 18px 16px; }
  .drawer { width: 100vw; }
}
