/* ===== GoChat 智能客服系统 — 全局样式（现代 SaaS Support Dashboard） ===== */
:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #fafbfc;
  --border: #e7e9ee;
  --border-strong: #d7dae1;
  --text: #1f2430;
  --text-2: #6b7280;
  --text-3: #9aa1ad;
  --primary: #4f7cff;
  --primary-d: #3b66e0;
  --primary-soft: #eef3ff;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #ef4444;
  --purple: #8b5cf6;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
  --shadow-lg: 0 8px 28px rgba(16,24,40,.12);
  --sidebar-w: 232px;
  --list-w: 340px;
  --profile-w: 312px;
  /* 末段补泰文/越南文字体：默认系统栈在部分安卓机上没有泰文字形，会显示成豆腐块 */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial,
    "Noto Sans Thai", "Leelawadee UI", "Tahoma", "Noto Sans", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 14px; }
a { color: var(--primary); text-decoration: none; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #d3d7df; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #b9bfca; }

/* ---------- 登录页 ---------- */
.login-wrap { min-height: 100vh; min-height: 100dvh; min-height: var(--vvh, 100dvh); display: grid; place-items: center; background: linear-gradient(180deg,#eef2ff,#f5f6f8); }
.login-card { width: 380px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 34px 30px; }
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card .sub { color: var(--text-2); margin: 0 0 22px; font-size: 13px; }
.login-card label { display: block; font-size: 12px; color: var(--text-2); margin: 12px 0 6px; font-weight: 600; }
.login-card input { width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); outline: none; }
.login-card input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: var(--radius-sm); padding: 9px 14px; font-weight: 600; font-size: 13px; transition: .15s; background: var(--primary); color: #fff; }
.btn:hover { background: var(--primary-d); }
.btn.full { width: 100%; margin-top: 20px; padding: 11px; }
.btn.ghost { background: #fff; color: var(--text); border-color: var(--border-strong); }
.btn.ghost:hover { background: var(--panel-2); }
.btn.sm { padding: 6px 10px; font-size: 12px; }
.btn.danger { background: #fff; color: var(--danger); border-color: #f3c2c2; }
.btn.danger:hover { background: #fef2f2; }
.btn.success { background: var(--success); }

/* ---------- 主框架 ---------- */
/* 高度用 dvh（dynamic viewport height）：
   移动端浏览器地址栏会让 100vh 比实际可视区高出 60~100px，
   底部 composer 因此被顶到视口外——「要往下滑才看得到输入框」。
   dvh 会随地址栏收放而变化，输入框始终贴在真实可视底部。
   仍保留 100vh 一行作为不支持 dvh 的旧浏览器兜底。 */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; height: 100dvh; height: var(--vvh, 100dvh); overflow: hidden; }

/* 左侧导航 */
/* 注意：flex 子项默认 min-height:auto，会拒绝收缩到内容高度以下，
   导致 13 个菜单项撑破 .sidebar，而 .app 又是 overflow:hidden，
   结果底部菜单被裁掉且无法滚动。故显式设 min-height:0 并允许滚动。 */
.sidebar { background: #11151f; color: #c7ccd6; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px; font-weight: 700; color: #fff; font-size: 15px; border-bottom: 1px solid rgba(255,255,255,.06); flex-shrink: 0; }
.sidebar .brand .logo { width: 26px; height: 26px; border-radius: 7px; background: linear-gradient(135deg,#4f7cff,#8b5cf6); display: grid; place-items: center; color: #fff; font-size: 14px; }
.nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 10px 8px 16px; overscroll-behavior: contain; }
/* 细滚动条（默认滚动条在深色侧栏里很难看且占位） */
.nav::-webkit-scrollbar { width: 8px; }
.nav::-webkit-scrollbar-track { background: transparent; }
.nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.16); border-radius: 4px; }
.nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.28); }
.nav { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; }
.nav-group-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #6b7280; padding: 14px 12px 6px; font-weight: 700; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius-sm); color: #c7ccd6; cursor: pointer; font-size: 13.5px; margin: 1px 0; user-select: none; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item .ico { width: 18px; text-align: center; opacity: .9; }
.nav-item .badge { margin-left: auto; background: rgba(255,255,255,.14); color: #fff; font-size: 11px; padding: 1px 8px; border-radius: 10px; font-weight: 700; }
.nav-item.active .badge { background: rgba(255,255,255,.25); }
.sidebar .me { padding: 12px; border-top: 1px solid rgba(255,255,255,.06); display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.sidebar .me .av { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; }
.sidebar .me .info { flex: 1; min-width: 0; }
.sidebar .me .name { color: #fff; font-size: 13px; font-weight: 600; }
.sidebar .me .role { font-size: 11px; color: #8b93a3; }

/* 主区域 */
.main { display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }
.topbar { height: 54px; background: var(--panel); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 14px; padding: 0 18px; flex-shrink: 0; }
.topbar h2 { font-size: 15px; margin: 0; font-weight: 700; }
.topbar .spacer { flex: 1; }
.global-search { position: relative; width: 320px; max-width: 40vw; }
.global-search input { width: 100%; padding: 8px 12px 8px 32px; border: 1px solid var(--border-strong); border-radius: 20px; background: var(--panel-2); outline: none; }
.global-search input:focus { border-color: var(--primary); background: #fff; }
.global-search .si { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.search-dropdown { position: absolute; top: 40px; left: 0; right: 0; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); max-height: 420px; overflow-y: auto; z-index: 40; }
.search-sec { padding: 8px 12px; font-size: 11px; text-transform: uppercase; color: var(--text-3); font-weight: 700; letter-spacing: .04em; }
.search-row { padding: 8px 12px; cursor: pointer; border-top: 1px solid var(--border); }
.search-row:hover { background: var(--panel-2); }
.search-row .t { font-size: 13px; }
.search-row .m { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: #fff; display: grid; place-items: center; position: relative; color: var(--text-2); }
.icon-btn:hover { background: var(--panel-2); }
.icon-btn .dot { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; background: var(--danger); border-radius: 50%; border: 2px solid #fff; }
.avatar-sm { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 12px; }

/* ---------- 收件箱三栏 ---------- */
.inbox { display: grid; grid-template-columns: var(--list-w) 1fr; flex: 1; overflow: hidden; position: relative; min-height: 0; }
.conv-list { border-right: 1px solid var(--border); background: var(--panel); display: flex; flex-direction: column; overflow: hidden; }
.conv-list .head { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.conv-list .head .title-row { display: flex; align-items: center; justify-content: space-between; }
.conv-list .head .title-row h3 { margin: 0; font-size: 15px; }
.seg { display: flex; gap: 4px; background: var(--panel-2); padding: 3px; border-radius: 8px; }
.seg button { flex: 1; border: none; background: transparent; padding: 6px 4px; border-radius: 6px; font-size: 12px; color: var(--text-2); font-weight: 600; }
.seg button.active { background: #fff; color: var(--text); box-shadow: var(--shadow); }
.list-search { width: 100%; padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); outline: none; }
.list-search:focus { border-color: var(--primary); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters select { padding: 6px 8px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: #fff; outline: none; font-size: 12px; color: var(--text-2); }
.conv-items { flex: 1; overflow-y: auto; }
.conv-item { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; position: relative; }
.conv-item:hover { background: var(--panel-2); }
.conv-item.active { background: var(--primary-soft); }
.conv-item.active::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--primary); }
.conv-item .ava { width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; color: #fff; font-weight: 600; }
.conv-item .body { flex: 1; min-width: 0; }
.conv-item .row1 { display: flex; align-items: center; gap: 6px; }
.conv-item .uname { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .time { margin-left: auto; font-size: 11px; color: var(--text-3); flex-shrink: 0; }
.conv-item .last { font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.conv-item .meta { display: flex; align-items: center; gap: 6px; margin-top: 5px; }
.unread-pill { background: var(--primary); color: #fff; font-size: 10.5px; font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px; display: grid; place-items: center; }

/* ---------- 访客在线状态（🟢 在线 / 🟡 暂时离线 / 🔴 已离开） ---------- */
/* 列表上的小圆点。用 ::before + 纯 CSS 圆点而不是 emoji：
   emoji 在不同系统上大小/基线不一致，塞进 13.5px 的行高里会顶歪整行。 */
.presence-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.presence-dot.online  { background: #16a34a; box-shadow: 0 0 0 2.5px #16a34a26; }
.presence-dot.offline { background: #f59e0b; box-shadow: 0 0 0 2.5px #f59e0b26; }
.presence-dot.away    { background: #9ca3af; box-shadow: 0 0 0 2.5px #9ca3af26; }
/* 在线时轻微呼吸，让「这个人此刻真的在」在一屏会话里一眼可辨。
   加了 prefers-reduced-motion 兜底，别让对动效敏感的人难受。 */
@keyframes presence-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
.presence-dot.online { animation: presence-pulse 2.4s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .presence-dot.online { animation: none; } }

/* 聊天窗头部那行详细文案，例如「🟢 在线 · 最后活跃 2 分钟前」 */
.presence-line { font-size: 11.5px; margin-top: 1px; display: flex; align-items: center; gap: 5px; }
.presence-line.online  { color: #16a34a; }
.presence-line.offline { color: #b45309; }
.presence-line.away    { color: #6b7280; }
.presence-line .ptext { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 状态/优先级标签 */
.tag { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 5px; white-space: nowrap; }
.st-new { background: #e0edff; color: #2563eb; }
.st-open { background: #dcfce7; color: #16a34a; }
.st-waiting { background: #fef3c7; color: #b45309; }
.st-resolved { background: #eceef1; color: #6b7280; }
.pri-low { background: #eceef1; color: #6b7280; }
.pri-normal { background: #e0edff; color: #2563eb; }
.pri-high { background: #ffedd5; color: #c2410c; }
.pri-urgent { background: #fee2e2; color: #dc2626; }
.lang-flag { font-size: 11px; color: var(--text-3); }

/* ---------- 聊天区 ---------- */
.chat { display: flex; flex-direction: column; overflow: hidden; background: var(--bg); min-height: 0; }
.chat-empty { flex: 1; display: grid; place-items: center; color: var(--text-3); }
/* 聊天区：头部紧凑、消息区占满剩余高度、气泡更宽以便一屏看更多内容 */
.chat-head { min-height: 52px; background: var(--panel); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; padding: 6px 14px; flex-shrink: 0; flex-wrap: wrap; }
.chat-head .ava { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 12px; flex-shrink: 0; }
.chat-head .uinfo { flex: 1; min-width: 120px; }
.chat-head .uinfo .n { font-weight: 700; font-size: 14px; line-height: 1.35; }
.chat-head .uinfo .s { font-size: 11.5px; color: var(--text-2); line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head .actions { display: flex; gap: 6px; align-items: center; }
.chat-head select { padding: 5px 7px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: #fff; font-size: 12px; }
.icon-toggle { border: 1px solid var(--border-strong); background: #fff; border-radius: var(--radius-sm); padding: 5px 9px; font-size: 12px; color: var(--text-2); }
.icon-toggle.on { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }

.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 18px 10px; display: flex; flex-direction: column; gap: 8px; overscroll-behavior: contain; }
.msg { display: flex; gap: 8px; max-width: 82%; }
.msg.user { align-self: flex-start; }
.msg.agent { align-self: flex-end; flex-direction: row-reverse; }
.msg .bubble { padding: 8px 12px; border-radius: 13px; font-size: 13.5px; line-height: 1.5; word-break: break-word; }
.msg.user .bubble { background: #fff; border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.agent .bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.msg .av { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 600; align-self: flex-end; }
.msg .meta { font-size: 10.5px; color: var(--text-3); margin-top: 2px; }
.msg.agent .meta { text-align: right; }
.msg.internal .bubble { background: #fff7e6; border: 1px solid #f3d99a; color: #8a5a00; border-radius: 10px; }
.msg.internal .badge-int { font-size: 10px; font-weight: 700; color: #b45309; }
.msg.system { align-self: center; max-width: 90%; }
.msg.system .bubble { background: transparent; color: var(--text-3); font-size: 12px; border: none; text-align: center; }
.msg .img { max-width: 240px; border-radius: 10px; cursor: pointer; }
.msg .file { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.15); padding: 8px 12px; border-radius: 10px; }
.msg.user .file { background: var(--panel-2); border: 1px solid var(--border); }

.read-receipt { font-size: 10px; color: var(--text-3); }
.read-receipt.read { color: var(--primary); }

/* 输入区 */
/* composer 必须是定位祖先：表情/快捷回复/FAQ 选取三个弹层都用
   position:absolute + bottom:100% 向上弹出。若这里不是 relative，
   它们会相对更外层（.chat / body）定位，bottom:100% 直接把弹层推到视口外，
   表现为「点了按钮没反应」——功能其实正常执行了，只是内容渲染在屏幕外。 */
.composer { position: relative; border-top: 1px solid var(--border); background: var(--panel); padding: 8px 12px 10px; flex-shrink: 0; }
.composer.internal { background: #fffbeb; }
.ai-suggest { background: linear-gradient(180deg,#f3f6ff,#eef3ff); border: 1px solid #d7e1ff; border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; display: flex; gap: 10px; align-items: flex-start; }
.ai-suggest .spark { font-size: 16px; }
.ai-suggest .content { flex: 1; min-width: 0; }
.ai-suggest .label { font-size: 11px; font-weight: 700; color: var(--primary); margin-bottom: 3px; display: flex; align-items: center; gap: 6px; }
.ai-suggest .text { font-size: 13px; color: var(--text); white-space: pre-wrap; }
.ai-suggest .src { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.ai-suggest .acts { display: flex; gap: 6px; margin-top: 8px; }
.composer-tools { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.composer-tools .tool { width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--border); background: #fff; display: grid; place-items: center; color: var(--text-2); font-size: 14px; }
.composer-tools .tool:hover { background: var(--panel-2); }
.composer-tools .mode-switch { margin-left: auto; display: flex; gap: 4px; }
.composer-input { display: flex; gap: 8px; align-items: flex-end; }
.composer-input textarea { flex: 1; resize: none; border: 1px solid var(--border-strong); border-radius: 10px; padding: 9px 12px; outline: none; max-height: 160px; min-height: 40px; line-height: 1.5; }
.composer-input textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.send-btn { width: 40px; height: 40px; border-radius: 10px; background: var(--primary); color: #fff; border: none; display: grid; place-items: center; font-size: 17px; flex-shrink: 0; }
.send-btn:hover { background: var(--primary-d); }

/* 输入中指示 */
.typing { display: flex; align-items: center; gap: 6px; padding: 4px 2px; color: var(--text-3); font-size: 12px; height: 18px; }
.typing .dots span { display: inline-block; width: 5px; height: 5px; background: var(--text-3); border-radius: 50%; margin: 0 1px; animation: blink 1.2s infinite; }
.typing .dots span:nth-child(2){ animation-delay: .2s; } .typing .dots span:nth-child(3){ animation-delay: .4s; }
@keyframes blink { 0%,60%,100%{opacity:.3} 30%{opacity:1} }

/* ---------- 右侧资料 ---------- */
/* ---------- 右侧访客资料抽屉（覆盖式，不占用聊天宽度） ---------- */
.profile-drawer {
  position: absolute; top: 0; right: 0; bottom: 0; z-index: 60;
  width: 340px; max-width: 88vw;
  background: var(--panel); border-left: 1px solid var(--border);
  box-shadow: -10px 0 30px rgba(16,24,40,.14);
  overflow-y: auto; overscroll-behavior: contain;
  transform: translateX(102%); transition: transform .22s ease;
  visibility: hidden;
}
.profile-drawer.open { transform: translateX(0); visibility: visible; }
.profile-drawer .ph { position: relative; padding: 18px 16px; text-align: center; border-bottom: 1px solid var(--border); }
.profile-drawer .dr-close { position: absolute; top: 10px; right: 12px; cursor: pointer; color: var(--text-3); font-size: 15px; line-height: 1; padding: 4px 6px; border-radius: 6px; }
.profile-drawer .dr-close:hover { background: var(--panel-2); color: var(--text); }
.drawer-mask {
  position: absolute; inset: 0; z-index: 55; background: rgba(16,24,40,.28);
  opacity: 0; visibility: hidden; transition: opacity .22s ease;
}
.drawer-mask.open { opacity: 1; visibility: visible; }

/* 旧的常驻资料栏样式保留兼容（移动端复用） */
.profile { width: var(--profile-w); border-left: 1px solid var(--border); background: var(--panel); overflow-y: auto; flex-shrink: 0; }
.profile .ph { padding: 16px; text-align: center; border-bottom: 1px solid var(--border); }
.profile .ph .ava { width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 8px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 20px; }
.profile .ph .n { font-weight: 700; font-size: 15px; }
.profile .ph .uid { font-size: 12px; color: var(--text-2); }
.profile .sec { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.profile .sec h4 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); }
/* 抽屉内部区块与旧的资料栏共用同一套样式 */
.profile-drawer .ph .ava { width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 8px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 20px; }
.profile-drawer .ph .n { font-weight: 700; font-size: 15px; }
.profile-drawer .ph .uid { font-size: 12px; color: var(--text-2); }
.profile-drawer .sec { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.profile-drawer .sec h4 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); }

.kv { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13px; }
.kv .k { color: var(--text-2); }
.kv .v { font-weight: 600; text-align: right; }
.tags-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip { font-size: 12px; padding: 3px 9px; border-radius: 12px; font-weight: 600; }
.note-add { display: flex; gap: 6px; margin-top: 8px; }
.note-add input { flex: 1; padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); outline: none; }
.note-item { background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-top: 8px; font-size: 12.5px; }
.note-item .by { font-size: 11px; color: var(--text-3); margin-top: 3px; }

/* ---------- 通用页面（FAQ/客户/报表等） ---------- */
.page { flex: 1; overflow-y: auto; padding: 20px 26px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.page-head h2 { margin: 0; font-size: 19px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .grow { flex: 1; }
.toolbar input, .toolbar select { padding: 8px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); outline: none; }
.toolbar input.search { min-width: 240px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-3); padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 700; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
.table tr:hover td { background: var(--panel-2); }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; }
.table input[type="checkbox"] { accent-color: var(--primary); width: 15px; height: 15px; cursor: pointer; vertical-align: middle; }
.batch-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; padding: 8px 12px; border-radius: var(--radius-sm); background: #fff4f4; border: 1px solid #f3c2c2; font-size: 13px; }
.muted { color: var(--text-2); }
.empty { padding: 40px; text-align: center; color: var(--text-3); }

/* 仪表盘 */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat .label { font-size: 12px; color: var(--text-2); font-weight: 600; }
.stat .value { font-size: 26px; font-weight: 800; margin-top: 6px; }
.stat .sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.panel-box { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.panel-box h3 { margin: 0 0 12px; font-size: 14px; }
.workload-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.workload-row:last-child { border: none; }
.workload-row .ava { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 12px; }
.workload-row .bar { flex: 1; height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.workload-row .bar > i { display: block; height: 100%; background: var(--primary); }
.workload-row .num { font-weight: 700; font-size: 13px; }

/* 模态框 */
.modal-mask { position: fixed; inset: 0; background: rgba(16,24,40,.45); display: grid; place-items: center; z-index: 100; }
.modal { background: #fff; border-radius: 12px; width: 520px; max-width: 92vw; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal .mh { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal .mh h3 { margin: 0; font-size: 16px; }
.modal .mb { padding: 18px 20px; }
.modal .mf { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.modal .field { margin-bottom: 14px; }
.modal .field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.modal .field input, .modal .field select, .modal .field textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); outline: none; }
.modal .field textarea { min-height: 90px; resize: vertical; }
.modal .field input:focus, .modal .field select:focus, .modal .field textarea:focus { border-color: var(--primary); }

/* 通知抽屉 */
.notif-drawer { position: fixed; top: 54px; right: 0; width: 320px; max-height: calc(100vh - 54px); max-height: calc(100dvh - 54px); background: #fff; border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); z-index: 60; overflow-y: auto; transform: translateX(100%); transition: .2s; }
.notif-drawer.open { transform: translateX(0); }
.notif-item { padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.notif-item:hover { background: var(--panel-2); }
.notif-item .t { font-size: 13px; font-weight: 600; }
.notif-item .m { font-size: 12px; color: var(--text-2); }

/* 快捷回复弹层 */
.sr-pop { position: absolute; bottom: 100%; left: 0; margin-bottom: 6px; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); width: 280px; max-height: 240px; overflow-y: auto; z-index: 30; }
.sr-pop .item { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.sr-pop .item:hover { background: var(--primary-soft); }
.sr-pop .item .sc { font-weight: 700; color: var(--primary); font-size: 12px; }
.sr-pop .item .tt { font-size: 13px; }

/* FAQ 选取器弹层 */
.picker-pop { position: absolute; bottom: 100%; left: 0; margin-bottom: 6px; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); width: 360px; max-height: 280px; overflow-y: auto; z-index: 30; }
.picker-pop .item { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.picker-pop .item:hover { background: var(--primary-soft); }
.picker-pop .item .q { font-size: 13px; font-weight: 600; }
.picker-pop .item .a { font-size: 12px; color: var(--text-2); }

/* 移动端 */
.menu-btn { display: none; }

/* 软键盘弹起（visualViewport 变矮）时，把真实可视高度同步给布局，
   保证贴底的输入框不被键盘顶出屏幕。桌面端不会命中 .kbd，无副作用。 */
html.kbd body { overflow: hidden; }
html.kbd .app { height: var(--vvh, 100dvh); }
html.kbd .sidebar { height: var(--vvh, 100dvh); max-height: var(--vvh, 100dvh); }

@media (max-width: 640px) {
  html.kbd .chat-panel { height: var(--vvh, 100dvh); max-height: var(--vvh, 100dvh); top: 0; bottom: auto; }
}

/* 手机上 UI 更紧凑：输入框别在键盘弹起时独占整屏 */
@media (max-width: 768px) {
  .composer { padding: 7px 10px 8px; }
  .composer-input textarea { max-height: 96px; }
  .w-comp textarea { max-height: 96px; }
}
@media (max-width: 1024px) {
  :root { --list-w: 280px; --profile-w: 260px; }
}
@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 80; width: 250px; height: 100vh; height: 100dvh; height: var(--vvh, 100dvh); max-height: 100vh; max-height: 100dvh; display: flex; flex-direction: column; min-height: 0; transform: translateX(-100%); transition: .2s; }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: grid; }
  .inbox { grid-template-columns: 1fr; }
  .conv-list { display: none; }
  .conv-list.show { display: flex; }
  .profile { display: none; }
  .profile.show { display: block; position: fixed; right: 0; top: 54px; bottom: 0; z-index: 70; box-shadow: var(--shadow-lg); }
  /* 移动端抽屉：占满屏宽更易读 */
  .profile-drawer { width: 100%; max-width: 100%; }
  .global-search { width: 160px; }
  .stat-grid { grid-template-columns: repeat(2,1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .chat-head .actions select { display: none; }
}
/* pointer-events:none 是必需的，不是可选优化：
   toast 淡出后只是 opacity 归 0，元素仍留在 DOM 里且【依然可被点击命中】。
   它固定停在屏幕底部居中（bottom:22px / left:50%），正好压在聊天输入框上方，
   于是会出现「输入框某些位置点不动、点了没光标」——被挡宽度还随上一条提示的
   文案长度变化，所以表现为时好时坏。提示条本身不需要任何交互，直接关掉命中。 */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #11151f; color: #fff; padding: 11px 18px; border-radius: 10px; box-shadow: var(--shadow-lg); z-index: 200; font-size: 13px; opacity: 0; transition: .25s; pointer-events: none; }
.toast.show { opacity: 1; }
.switch { position: relative; width: 40px; height: 22px; background: #cbd2dc; border-radius: 12px; transition: .2s; cursor: pointer; flex-shrink: 0; }
.switch.on { background: var(--success); }
.switch::after { content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: .2s; }
.switch.on::after { left: 20px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--border); }
.setting-row .desc { font-size: 12px; color: var(--text-2); margin-top: 2px; }

/* ===== 用户端 Chat Widget ===== */
.chat-bubble { position: fixed; right: 22px; bottom: 22px; width: 58px; height: 58px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 26px; box-shadow: var(--shadow-lg); cursor: pointer; z-index: 90; transition: transform .15s; }
.chat-bubble:hover { transform: scale(1.06); }
.chat-bubble .badge { position: absolute; top: -2px; right: -2px; background: var(--danger); color: #fff; font-size: 11px; min-width: 20px; height: 20px; border-radius: 10px; display: grid; place-items: center; border: 2px solid #fff; padding: 0 4px; }
.chat-panel { position: fixed; right: 22px; bottom: 22px; width: 372px; max-width: calc(100vw - 24px); height: 560px; max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; z-index: 95; transform: translateY(20px); opacity: 0; pointer-events: none; transition: .2s; }
.chat-panel.open { transform: none; opacity: 1; pointer-events: auto; }
.chat-panel .w-head { background: linear-gradient(135deg,#4f7cff,#6d8bff); color: #fff; padding: 14px 16px; display: flex; align-items: center; gap: 10px; }
.chat-panel .w-head .ava { width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,.25); display: grid; place-items: center; font-weight: 700; }
.chat-panel .w-head .info { flex: 1; }
.chat-panel .w-head .info .n { font-weight: 700; font-size: 14px; }
.chat-panel .w-head .info .s { font-size: 12px; opacity: .9; display: flex; align-items: center; gap: 5px; }
.chat-panel .w-head .x { cursor: pointer; font-size: 20px; opacity: .9; }
.chat-panel .w-msg { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: #f7f8fa; }
.chat-panel .wm { display: flex; gap: 8px; max-width: 82%; }
.chat-panel .wm.me { align-self: flex-end; flex-direction: row-reverse; }
.chat-panel .wm .b { padding: 8px 12px; border-radius: 14px; font-size: 13px; line-height: 1.5; word-break: break-word; }
.chat-panel .wm.agent .b { background: #fff; border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-panel .wm.me .b { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-panel .wm .t { font-size: 10px; color: var(--text-3); margin-top: 3px; }
.chat-panel .wm.me .t { text-align: right; }
.chat-panel .wm img { max-width: 200px; border-radius: 10px; }
.chat-panel .wm .file { display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,.15); padding: 7px 10px; border-radius: 10px; font-size: 12px; }
.chat-panel .wm.me .file { background: rgba(255,255,255,.2); }
.chat-panel .w-typing { height: 16px; font-size: 12px; color: var(--text-3); padding: 0 4px; }
.chat-panel .w-comp { border-top: 1px solid var(--border); padding: 8px 10px; background: #fff; }
.chat-panel .w-comp .row { display: flex; gap: 8px; align-items: flex-end; }
.chat-panel .w-comp textarea { flex: 1; resize: none; border: 1px solid var(--border-strong); border-radius: 10px; padding: 9px 11px; outline: none; max-height: 100px; min-height: 40px; font-size: 13px; }
.chat-panel .w-comp textarea:focus { border-color: var(--primary); }
.chat-panel .w-comp .send { width: 40px; height: 40px; border-radius: 10px; background: var(--primary); color: #fff; border: none; font-size: 17px; }
.chat-panel .w-tools { display: flex; gap: 4px; margin-bottom: 6px; }
.chat-panel .w-tools button { width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--border); background: #fff; color: var(--text-2); }
.chat-panel .w-online { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; display: inline-block; }
.chat-panel .w-online.off { background: #cbd2dc; }

/* 会话已结束：会员端输入区被替换为结束提示条 */
.chat-panel .w-ended { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.chat-panel .w-ended .t { font-size: 13px; color: var(--text-2); }
.chat-panel .w-ended .new-session { border: none; border-radius: 8px; padding: 8px 14px; font-size: 13px;
  background: var(--primary); color: #fff; cursor: pointer; white-space: nowrap; }
.chat-panel .w-ended .new-session:hover { filter: brightness(1.06); }

/* 坐席端：会话已结束时的底部提示条（替代 composer） */
.composer-ended { position: relative; border-top: 1px solid var(--border); background: var(--panel);
  padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-shrink: 0; }
.composer-ended .ce-text { font-size: 13px; color: var(--text-2); }

/* 右上角头像 — 在线状态切换菜单 */
.avatar-sm { cursor: pointer; }

/* ===== 品牌 Logo ===== */
.sidebar .brand img.logo { width: 28px; height: 28px; border-radius: 8px; background: transparent; display: block; object-fit: contain; }
.chat-panel .w-head .ava { overflow: hidden; }
.chat-panel .w-head .ava img { width: 26px; height: 26px; border-radius: 7px; display: block; object-fit: contain; }
.cp-page-bar img { display: inline-block; }
.status-menu { position: fixed; background: #1b2230; border: 1px solid #2a3344; border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.35); padding: 6px; z-index: 1000; min-width: 140px; }
.status-menu .smi { display: block; width: 100%; text-align: left; background: none; border: none; color: #e6eaf2; padding: 9px 12px; border-radius: 7px; font-size: 13px; cursor: pointer; }
.status-menu .smi:hover { background: #262f40; }
.status-menu .smi.cur { background: #262f40; color: #4f7cff; font-weight: 700; }

/* 状态菜单 — 分隔线与退出项 */
.status-menu .smi-sep { height: 1px; background: #2a3344; margin: 5px 6px; }
.status-menu .smi-logout { color: #f87171; }
.status-menu .smi-logout:hover { background: rgba(248,113,113,.12); }

/* ===== Pre-chat 表单（管理员开启后，会员进入聊天前必须填用户名） ===== */
/* 复用聊天面板外观，让它看起来就是「同一张卡片的第二步」，而不是跳到另一个页面。 */
.prechat-card { display: flex; flex-direction: column; }
.prechat-card .pc-body { padding: 20px 18px 18px; display: flex; flex-direction: column; gap: 12px; }
.prechat-card .pc-desc { margin: 0; font-size: 13px; line-height: 1.7; color: var(--text-2); }
.prechat-card .pc-input {
  width: 100%; box-sizing: border-box; padding: 11px 13px; font-size: 15px; font-family: var(--font);
  border: 1px solid var(--border-strong); border-radius: 10px; background: var(--panel-2); color: var(--text-1); outline: none;
}
.prechat-card .pc-input:focus { border-color: #4f7cff; box-shadow: 0 0 0 3px rgba(79,124,255,.15); }
.prechat-card .pc-err { min-height: 16px; font-size: 12px; color: #ef4444; }
.prechat-card .pc-go {
  width: 100%; padding: 12px; font-size: 15px; font-weight: 700; color: #fff; background: #4f7cff;
  border: none; border-radius: 10px; cursor: pointer; font-family: var(--font);
}
.prechat-card .pc-go:hover { background: #3d68e8; }
.prechat-card .pc-go:disabled { background: #93a4c8; cursor: not-allowed; }

/* 悬浮挂件内的 Pre-chat：盖在消息区上，占满面板剩余高度 */
/* 多了一个口令输入框和一行提示，矮面板里可能装不下，允许内部滚动 */
/* ---------- 访客端语言切换（右上角 🌐） ---------- */
/* 四个入口共用：聊天页头部 / Pre-chat 卡片 / 挂件头部 / 挂件 Pre-chat 浮层 */
/* 注意：.w-head 把文字色设成了白色，菜单浮在它上面，所以菜单里的颜色全部写死，
   不能用 var(--text) 之类继承 —— 否则蓝底白字会一路渗进白底菜单里。 */
.w-lang { position: relative; margin-left: auto; display: flex; align-items: center; flex: none; }
/* 做成一颗「胶囊按钮」：地球图标 + 当前语言 + 下拉箭头 + 描边。
   光一个地球图标太隐晦，很多人不知道那是能点的 —— 加上语言名和箭头才像按钮。
   颜色全部用 currentColor，蓝底头部是白框白字，白底浮层是深框深字，两种背景都看得清。 */
.w-lang .lang-btn {
  background: rgba(127,127,127,.10); border: 1px solid currentColor; cursor: pointer; line-height: 1;
  padding: 5px 8px; border-radius: 999px; color: inherit;
  display: flex; align-items: center; gap: 5px;
  font-family: var(--font); font-size: 11.5px; font-weight: 600;
}
.w-lang .lang-btn svg { display: block; flex: none; }
.w-lang .lang-cur { white-space: nowrap; max-width: 88px; overflow: hidden; text-overflow: ellipsis; }
.w-lang .lang-btn:hover { background: rgba(127,127,127,.22); }
.w-lang .lang-btn:active { transform: translateY(1px); }
.w-lang .lang-menu {
  position: absolute; top: 100%; right: 0; margin-top: 4px; z-index: 30;
  min-width: 132px; background: #fff; border: 1px solid #e7e9ee;
  border-radius: 10px; box-shadow: 0 8px 24px rgba(17,24,39,.14); padding: 4px; color: #1f2430;
}
.w-lang .lang-item {
  display: flex; align-items: center; gap: 6px; padding: 8px 10px;
  font-size: 13px; border-radius: 7px; cursor: pointer; color: #1f2430; white-space: nowrap;
}
.w-lang .lang-item:hover { background: #f3f5f9; }
.w-lang .lang-item.on { color: #4f7cff; font-weight: 700; }
.w-lang .lang-item .tick { width: 12px; font-size: 12px; }

.w-prechat { position: absolute; inset: 0; background: var(--panel); border-radius: 14px; z-index: 5;
  display: flex; flex-direction: column; padding: 18px; gap: 12px; box-sizing: border-box; overflow-y: auto; }
.w-prechat .pc-t { font-size: 15px; font-weight: 700; }
.w-prechat .pc-desc { margin: 0; font-size: 13px; line-height: 1.7; color: var(--text-2); }
.w-prechat .pc-input { width: 100%; box-sizing: border-box; padding: 10px 12px; font-size: 14px; font-family: var(--font);
  border: 1px solid var(--border-strong); border-radius: 9px; background: var(--panel-2); color: var(--text-1); outline: none; }
.w-prechat .pc-input:focus { border-color: #4f7cff; }
.w-prechat .pc-err { min-height: 15px; font-size: 12px; color: #ef4444; }
.w-prechat .pc-go { width: 100%; padding: 11px; font-size: 14px; font-weight: 700; color: #fff; background: #4f7cff;
  border: none; border-radius: 9px; cursor: pointer; font-family: var(--font); }
.w-prechat .pc-go:hover { background: #3d68e8; }
.w-prechat .pc-go:disabled { background: #93a4c8; cursor: not-allowed; }
