/* ============================================================
   在线客服系统 · 设计系统 v3「精致工作台」
   全站字体：微软雅黑 | 电脑＝左侧栏 + 内容区 | 手机＝顶栏 + 底部菜单
   ============================================================ */

:root {
  --bg: #f4f5f8;
  --bg-2: #eceef3;
  --panel: #ffffff;
  --panel-2: #f7f8fb;
  --panel-3: #eef0f5;
  --text: #101420;
  --text-2: #4a5262;
  --muted: #8a91a1;
  --line: #e6e9f0;
  --line-2: #f0f2f7;
  --brand: #4f46e5;
  --brand-2: #6a63f0;
  --brand-ink: #4338ca;
  --brand-soft: #eeefff;
  --ok: #15a06a;
  --ok-soft: #e8f7ef;
  --danger: #e5484d;
  --danger-soft: #fdeced;

  --radius-xl: 16px;
  --radius-lg: 12px;
  --radius: 10px;
  --radius-sm: 8px;

  --shadow-sm: 0 1px 2px rgba(16, 20, 32, .05);
  --shadow: 0 4px 16px rgba(16, 20, 32, .07);
  --shadow-lg: 0 18px 46px rgba(16, 20, 32, .16);

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "Microsoft YaHei", "微软雅黑", "PingFang SC", "Hiragino Sans GB",
          -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: var(--font) !important;
  font-size: 12px; line-height: 1.6;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body, button, input, textarea, select, h1, h2, h3, h4, p, span, div, b, i, a, label, td, th {
  font-family: var(--font) !important;
}

img { max-width: 100%; display: block; }
button, input, textarea, select { font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); text-decoration: none; }
::selection { background: rgba(79, 70, 229, .16); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #d5d9e2; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #c0c6d1; }

/* ---------------------------- 工具类 ---------------------------- */

.hide { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 11px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }

/* 关键修复：内联 SVG 必须显式限尺，否则按 300×150 默认尺寸撑爆布局 */
svg { flex: 0 0 auto; width: 16px; height: 16px; overflow: visible; }

/* ---------------------------- 按钮 ---------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 30px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--text);
  font-size: 12px; font-weight: 600; white-space: nowrap; user-select: none;
  transition: background .15s, border-color .15s, color .15s, transform .1s, box-shadow .15s;
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { border-color: #dae0ea; background: var(--panel-2); }
.btn:active { transform: scale(.985); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: var(--brand); border-color: var(--brand); color: #fff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, .22);
}
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--panel-3); color: var(--text); }
.btn-danger { color: var(--danger); border-color: #f6d3d4; background: var(--danger-soft); }
.btn-danger:hover { background: #fbe0e1; }
.btn-sm { height: 27px; padding: 0 9px; font-size: 11.5px; border-radius: 7px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-block { width: 100%; }

.icon-btn {
  width: 28px; height: 28px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-2); cursor: pointer;
  font-size: 15px; line-height: 1;
  transition: background .15s, color .15s, transform .1s;
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { background: var(--panel-3); color: var(--text); }
.icon-btn:active { transform: scale(.94); }

/* ---------------------------- 表单 ---------------------------- */

.field { display: block; margin-bottom: 12px; }
.field > .label { display: block; margin-bottom: 5px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.field .hint, .hint { margin-top: 5px; font-size: 11px; color: var(--muted); line-height: 1.6; }

.input, .textarea, select.input {
  width: 100%; padding: 7px 10px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  outline: none; font-size: 11.5px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.textarea { min-height: 56px; resize: vertical; line-height: 1.6; }
.input:focus, .textarea:focus, select.input:focus {
  background: var(--panel); border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .1);
}
select.input { height: 30px; padding: 0 8px; cursor: pointer; }

/* ---------------------------- 卡片 ---------------------------- */

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 13px;
}
.card + .card { margin-top: 12px; }
.card-title {
  display: flex; align-items: center; gap: 6px;
  margin: 0 0 11px; font-size: 12.5px; font-weight: 700; line-height: 1.4;
}
.card-title > svg { width: 17px; height: 17px; color: var(--brand); }
.card-title .sub { margin-left: auto; font-size: 11.5px; font-weight: 500; color: var(--muted); }
.card svg, .pane svg, .login-card svg { max-width: 100%; }

/* ---------------------------- 开关 ---------------------------- */

.switch { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; font-size: 12.5px; }
.switch input { display: none; }
.switch .track {
  width: 44px; height: 26px; border-radius: 999px; background: #d7dbe4;
  position: relative; transition: background .18s; flex: 0 0 auto;
}
.switch .track::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(16, 20, 32, .25); transition: transform .18s;
}
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(18px); }

/* ---------------------------- 徽标 / 头像 / 标签 ---------------------------- */

.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 17px; height: 17px; padding: 0 5px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 1;
}
.badge.soft { background: var(--brand-soft); color: var(--brand-ink); }

.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; }
.dot.online { background: var(--ok); box-shadow: 0 0 0 3px rgba(21, 160, 106, .16); }
.dot.offline { background: #c3cad6; box-shadow: none; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto;
  background: var(--panel-3); display: flex; align-items: center; justify-content: center;
  color: var(--brand-ink); font-weight: 700; font-size: 12px; overflow: hidden;
  border: 1px solid var(--line);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 28px; height: 28px; font-size: 11.5px; }
.avatar.lg { width: 52px; height: 52px; font-size: 17px; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 21px; padding: 0 8px; border-radius: 999px;
  background: var(--panel-3); color: var(--text-2);
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.chip svg { width: 13px; height: 13px; }
.chip b { margin-left: 3px; font-weight: 700; color: var(--text); }
.chip.brand { background: var(--brand-soft); color: var(--brand-ink); }
.chip.brand b { color: var(--brand-ink); }
.chip.ok { background: var(--ok-soft); color: #0f7a52; }
.chip.danger { background: var(--danger-soft); color: #b02a2f; }

/* ---------------------------- 提示 / 空状态 ---------------------------- */

.toast-wrap {
  position: fixed; left: 0; right: 0; bottom: calc(26px + var(--safe-b));
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  z-index: 9999; pointer-events: none;
}
.toast {
  max-width: 80vw; padding: 8px 14px;
  background: rgba(16, 20, 32, .92); color: #fff;
  border-radius: 999px; font-size: 11.5px; font-weight: 500;
  box-shadow: var(--shadow); animation: toast-in .2s ease;
}
.toast.err { background: rgba(200, 40, 45, .96); }
.toast.ok { background: rgba(12, 140, 92, .96); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.empty { padding: 34px 16px; text-align: center; color: var(--muted); font-size: 12px; line-height: 1.7; }
.empty .emoji { font-size: 24px; display: block; margin-bottom: 6px; }

/* ---------------------------- 图片上传控件 ---------------------------- */

.uploader {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px; margin-bottom: 4px;
  background: var(--panel-2); border: 1px dashed #dbe0ea; border-radius: var(--radius);
}
.uploader .grow { padding-top: 2px; }
.uploader svg { width: 15px; height: 15px; }

.up-thumb {
  width: 84px; height: 84px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-sm); overflow: hidden;
}
.up-thumb span { color: #c3c9d6; display: inline-flex; }
.up-thumb span svg { width: 22px; height: 22px; }
.up-thumb img { width: 100%; height: 100%; object-fit: cover; }
.up-thumb.sm { width: 54px; height: 54px; }
.up-thumb.sm span svg { width: 18px; height: 18px; }
.up-thumb.has { border-style: solid; background: var(--panel-3); }

.rule-media { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ============================================================
   聊天区（用户端 / 后台共用）
   ============================================================ */

.chat-body {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 14px 12px 8px;
  display: flex; flex-direction: column; gap: 10px;
  overscroll-behavior: contain;
}

.day-sep {
  align-self: center; flex: 0 0 auto;
  font-size: 10.5px; color: var(--muted);
  background: rgba(255, 255, 255, .92); padding: 1px 9px;
  border-radius: 999px; border: 1px solid var(--line-2);
}

.msg-row { display: flex; gap: 8px; align-items: flex-end; position: relative; animation: msg-in .18s ease; }
.msg-row.me { flex-direction: row-reverse; }
@keyframes msg-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.bubble {
  position: relative; max-width: min(78%, 520px);
  padding: 7px 11px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line);
  font-size: 12.5px; line-height: 1.6; color: var(--text);
  word-break: break-word; white-space: pre-wrap;
  box-shadow: var(--shadow-sm);
}
.msg-row.me .bubble {
  background: var(--brand); color: #fff; border-color: transparent;
  box-shadow: 0 2px 10px rgba(79, 70, 229, .22);
}
.bubble.media { padding: 3px; overflow: hidden; background: var(--panel); }
.msg-row.me .bubble.media { background: var(--panel); border-color: var(--line); box-shadow: var(--shadow-sm); }
.bubble.media .msg-meta { margin: 5px 5px 3px; }
.msg-row.me .bubble.media .msg-meta { color: var(--muted); }
.bubble img.thumb { max-width: 200px; max-height: 260px; border-radius: 9px; cursor: zoom-in; object-fit: cover; }
.bubble.recalled {
  background: var(--panel-3) !important; color: var(--muted) !important;
  border: 1px dashed #d5dbe6 !important; font-style: italic; font-size: 12.5px; box-shadow: none;
}
.bubble.sys-note { background: #fff8e8; border-color: #f2e0b8; color: #8a6212; font-size: 12.5px; }

.msg-meta { display: flex; align-items: center; gap: 5px; margin-top: 4px; font-size: 10px; color: var(--muted); }
.msg-row.me .msg-meta { justify-content: flex-end; }
.msg-row.me .bubble:not(.recalled):not(.sys-note) .msg-meta { color: rgba(255, 255, 255, .82); }
.msg-status { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; }
.msg-row:not(.me) .msg-status.read { color: var(--brand); }

.recall-btn {
  border: none; background: transparent; color: inherit; padding: 0 1px;
  font-size: 10px; font-weight: 600; cursor: pointer; text-decoration: underline; opacity: .75;
}
.recall-btn:hover { opacity: 1; }

.new-msg-btn {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: 74px; z-index: 30; display: none; align-items: center; gap: 4px;
  height: 28px; padding: 0 12px; border: none; border-radius: 999px;
  background: var(--brand); color: #fff; font-size: 12px; font-weight: 600; cursor: pointer;
  box-shadow: 0 6px 16px rgba(79, 70, 229, .32);
}
.new-msg-btn.show { display: inline-flex; animation: pop .18s ease; }

/* ---------------------------- 输入区 ---------------------------- */

.composer {
  flex: 0 0 auto; position: relative;
  padding: 7px 10px calc(8px + var(--safe-b));
  background: var(--panel); border-top: 1px solid var(--line);
}

.tool-pill {
  display: none; gap: 2px; align-items: center; width: max-content;
  margin-bottom: 6px; padding: 2px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line);
}
.tool-pill.show { display: inline-flex; animation: pop .16s ease; }

/* 用户端 / 后台：表情 / 图片 / 常用语 常驻在输入框左侧（不再需要点「+」展开）
   统一 32px 高度 = 单行输入框高度 → 三个图标与输入框、发送按钮在同一水平线上（手机 / 电脑一致） */
body.page-user .tool-pill,
body.page-admin .tool-pill {
  display: inline-flex; align-items: center; gap: 0; flex: 0 0 auto;
  height: 32px;
  margin: 0; padding: 0; border: none; background: transparent; border-radius: 0;
}
body.page-user .tool-pill .icon-btn,
body.page-admin .tool-pill .icon-btn { width: 27px; height: 27px; }
body.page-user .tool-pill .icon-btn svg,
body.page-admin .tool-pill .icon-btn svg { width: 16px; height: 16px; }
body.page-user .composer-inner,
body.page-admin .composer-inner { gap: 3px; padding-left: 5px; }
@media (max-width: 360px) {
  body.page-user .tool-pill .icon-btn,
  body.page-admin .tool-pill .icon-btn { width: 24px; height: 24px; }
  body.page-user .tool-pill .icon-btn svg,
  body.page-admin .tool-pill .icon-btn svg { width: 15px; height: 15px; }
}

.composer-inner {
  display: flex; align-items: flex-end; gap: 5px;
  padding: 3px 4px 3px 6px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 18px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.composer-inner:focus-within {
  background: var(--panel); border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .1);
}
.composer textarea {
  flex: 1 1 auto; min-width: 0;
  border: none; background: transparent; outline: none; resize: none;
  padding: 6px 2px; max-height: 96px; min-height: 32px;   /* 单行 = 32px，与左侧工具按钮 / 发送按钮等高对齐 */
  font-size: 12.5px; line-height: 1.5;
}
.composer textarea::placeholder { color: var(--muted); }
.composer .tool { color: var(--muted); }
.composer .tool:hover { color: var(--brand); }

.send-btn {
  width: 32px; height: 32px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 50%; cursor: pointer;
  background: var(--brand); color: #fff;
  transition: transform .1s, opacity .15s, background .15s;
}
.send-btn svg { width: 16px; height: 16px; }
.send-btn:hover { background: var(--brand-2); }
.send-btn:active { transform: scale(.94); }
.send-btn[disabled] { opacity: .4; cursor: not-allowed; }

.emoji-pop {
  position: absolute; bottom: calc(100% - 2px); left: 10px; z-index: 60;
  width: min(300px, 88vw); max-height: 200px; overflow-y: auto;
  padding: 8px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 1px;
  animation: pop .14s ease;
}
.emoji-pop button {
  border: none; background: transparent; cursor: pointer;
  font-size: 16px; line-height: 1; padding: 4px 0; border-radius: 6px;
}
.emoji-pop button:hover { background: var(--panel-3); }

.upload-card {
  align-self: flex-end; flex: 0 0 auto; width: min(74%, 280px);
  padding: 10px 12px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line);
}
.upload-card .name { font-size: 12px; font-weight: 600; }
.progress-bar { margin-top: 7px; height: 4px; border-radius: 999px; background: var(--panel-3); overflow: hidden; }
.progress-bar i { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--brand); transition: width .15s linear; }

.lightbox {
  position: fixed; inset: 0; z-index: 1000; padding: 16px;
  background: rgba(10, 12, 18, .94);
  display: flex; align-items: center; justify-content: center; animation: fade .16s ease;
}
.lightbox img { max-width: 94vw; max-height: 86vh; border-radius: 10px; }
.lightbox .close {
  position: absolute; top: calc(10px + var(--safe-t)); right: 10px;
  width: 34px; height: 34px; border-radius: 50%; border: none;
  background: rgba(255, 255, 255, .16); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.lightbox .close svg { width: 18px; height: 18px; }

/* ============================================================
   客服后台布局
   手机：顶栏 + 内容 + 底部菜单 ｜ ≥900px：左侧栏 + 内容
   ============================================================ */

body.page-admin {
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  overflow: hidden; background: var(--bg);
}

/* ---------------------------- 登录页 ---------------------------- */

.login-wrap {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background:
    radial-gradient(900px 460px at 12% -12%, #e4e6ff 0%, rgba(228, 230, 255, 0) 62%),
    radial-gradient(760px 420px at 100% 108%, #dff0ff 0%, rgba(223, 240, 255, 0) 58%),
    #f4f5f8;
}
.login-card {
  width: min(352px, 100%); padding: 28px 24px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-lg);
  text-align: center; animation: pop .26s ease;
}
.login-card .logo-badge {
  width: 50px; height: 50px; margin: 0 auto 14px;
  border-radius: 14px; display: grid; place-items: center; font-size: 24px;
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  color: #fff; box-shadow: 0 10px 24px rgba(79, 70, 229, .28);
}
.login-card h1 { margin: 0 0 5px; font-size: 16px; font-weight: 700; letter-spacing: -.2px; }
.login-card .desc { margin: 0 0 18px; font-size: 12px; color: var(--muted); }
.login-card .field { text-align: left; }
.login-card .input { padding: 9px 11px; font-size: 12px; }
.login-card .btn { height: 36px; font-size: 12.5px; border-radius: var(--radius); }
.login-card .foot { margin: 14px 0 0; font-size: 11px; color: var(--muted); line-height: 1.6; }

/* ---------------------------- 骨架 ---------------------------- */

.admin-app {
  flex: 1 1 auto; min-height: 0; height: 100%; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto;
  background: var(--bg);
}

/* 左侧栏（≥900px 显示） */
.side-nav {
  display: none; flex-direction: column; gap: 14px;
  padding: 16px 12px 14px; height: 100%; min-height: 0;
  background: var(--panel); border-right: 1px solid var(--line);
}
.side-brand { display: flex; align-items: center; gap: 9px; padding: 0 4px; }
.side-brand .logo {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  color: #fff; font-size: 16px; flex: 0 0 auto;
}
.side-brand .txt { display: flex; flex-direction: column; line-height: 1.25; }
.side-brand .txt b { font-size: 12.5px; font-weight: 700; }
.side-brand .txt i { font-size: 11px; font-style: normal; color: var(--muted); }

.side-menu { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; }
.side-item {
  position: relative; display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 10px; border: none; border-radius: var(--radius);
  background: transparent; color: var(--text-2); text-align: left;
  font-size: 12.5px; font-weight: 600;
  transition: background .16s, color .16s;
}
.side-item .ic { display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.side-item .ic svg { width: 18px; height: 18px; }
.side-item .tx { flex: 1 1 auto; }
.side-item .badge { position: static; }
.side-item:hover { background: var(--panel-2); color: var(--text); }
.side-item:hover .ic { color: var(--text-2); }
.side-item.active { background: var(--brand-soft); color: var(--brand-ink); }
.side-item.active .ic { color: var(--brand); }

.side-foot { display: flex; flex-direction: column; gap: 6px; padding-top: 12px; border-top: 1px solid var(--line-2); }
.side-logout {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 9px 10px; border: none; border-radius: var(--radius);
  background: transparent; color: var(--muted); font-size: 12px; font-weight: 600;
  transition: background .16s, color .16s;
}
.side-logout .ic { display: inline-flex; }
.side-logout .ic svg { width: 17px; height: 17px; }
.side-logout:hover { background: var(--danger-soft); color: var(--danger); }

/* 内容区 */
.admin-wrap { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; overflow: hidden; }

.topbar {
  flex: 0 0 auto; z-index: 30;
  display: flex; align-items: center; gap: 8px; flex-wrap: nowrap;
  padding: calc(9px + var(--safe-t)) 12px 9px;
  background: rgba(255, 255, 255, .92);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar .brand { display: flex; align-items: center; gap: 7px; }
.topbar .brand .logo {
  width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  color: #fff; font-size: 14px;
}
.topbar .brand .txt { display: none; font-size: 12.5px; font-weight: 700; }
.page-title { display: none; margin: 0; font-size: 14px; font-weight: 700; letter-spacing: -.2px; }
.top-stats { display: flex; align-items: center; gap: 5px; margin-left: auto; }
.top-stats .chip { white-space: nowrap; }
.top-stats .only-md, .top-stats .only-lg { display: none; }

/* 底部菜单（手机） */
.bottom-nav {
  flex: 0 0 auto; z-index: 40;
  display: flex; justify-content: center;
  padding: 4px 8px calc(4px + var(--safe-b));
  background: rgba(255, 255, 255, .97);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.nav-pills { display: flex; gap: 3px; width: 100%; align-items: stretch; }
.pill {
  position: relative; flex: 1 1 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: 5px 4px; border: none; border-radius: 10px;
  background: transparent; color: var(--muted); cursor: pointer;
  font-size: 10px; font-weight: 600;
  transition: background .16s, color .16s;
}
.pill .ic { display: inline-flex; align-items: center; justify-content: center; }
.pill svg, .pill .ic svg { width: 19px; height: 19px; }
.pill:hover { color: var(--text-2); }
.pill.active { background: var(--brand-soft); color: var(--brand-ink); }
.pill .badge { position: absolute; top: 1px; right: 50%; margin-right: -22px; }

/* ---------------------------- 主区域 / 面板 ---------------------------- */

.admin-main {
  display: grid; grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr);
  min-height: 0; overflow: hidden;
}
.pane { display: none; min-height: 0; min-width: 0; }
.pane-scroll {
  overflow-y: auto; overscroll-behavior: contain;
  padding: 14px 12px calc(22px + var(--safe-b)); background: var(--bg);
}
.settings-wrap { max-width: 780px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-content: start; }
.settings-wrap .card { margin-top: 0; }

.pane-list { flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); }
.pane-chat { flex-direction: column; background: var(--bg); }

/* 搜索栏 */
.list-head {
  flex: 0 0 auto; display: flex; gap: 6px; align-items: center;
  padding: 8px 10px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.search-box { position: relative; flex: 1 1 auto; min-width: 0; }
.search-box .input { padding-left: 11px; }
.list-head select.input { flex: 0 0 auto; width: auto; min-width: 76px; }

.conv-list { flex: 1 1 auto; overflow-y: auto; padding: 6px; -webkit-overflow-scrolling: touch; }

.conv-item {
  position: relative; display: flex; gap: 9px;
  padding: 9px 10px; border-radius: var(--radius); cursor: pointer;
  transition: background .14s;
}
.conv-item + .conv-item { margin-top: 2px; }
.conv-item:hover { background: var(--panel-2); }
.conv-item.active { background: var(--brand-soft); }
.conv-item .meta { flex: 1 1 auto; min-width: 0; }
.conv-item .top { display: flex; align-items: center; gap: 5px; min-width: 0; }
.conv-item .n { font-weight: 600; font-size: 12.5px; flex: 0 1 auto; min-width: 0; }
.conv-item .t { margin-left: auto; flex: 0 0 auto; font-size: 10px; color: var(--muted); }
.conv-item .preview { margin-top: 1px; font-size: 11px; color: var(--muted); }
/* 会话列表：访客 IP / 归属地跟在名字后面，一行紧凑显示（与聊天头部一致） */
.conv-info {
  display: inline-flex; align-items: center; gap: 3px;
  flex: 0 1 auto; min-width: 0; overflow: hidden;
}
.conv-info .chip {
  height: 17px; padding: 0 6px; font-size: 10px;
  white-space: nowrap; font-variant-numeric: tabular-nums;
  max-width: 116px; overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 359px) {
  .conv-info .chip { max-width: 74px; padding: 0 5px; }
}
.conv-item .badge { margin-left: 5px; }

/* ---------------------------- 会话头部 / 信息条 / 空状态 ---------------------------- */

.chat-head .back { display: inline-flex; }
.chat-head .head-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
/* 会话信息（IP / 归属地）：直接跟在访客名字后面，同一行内联显示，不再单独占一行 */
.chat-head .name-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.chat-head .name-row .name { flex: 0 1 auto; min-width: 0; }
.chat-info {
  display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap;
  flex: 0 1 auto; min-width: 0; padding: 0; background: none; border: none;
}
.chat-info .chip { height: 19px; padding: 0 7px; font-size: 10.5px; font-variant-numeric: tabular-nums; }
.chat-empty {
  flex: 1 1 auto; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px;
  padding: 28px 20px; text-align: center; color: var(--muted); font-size: 12.5px;
}
.chat-empty .big { font-size: 34px; line-height: 1; }
.chat-empty h3 { margin: 6px 0 0; font-size: 13.5px; color: var(--text-2); }
.chat-empty p { margin: 0; max-width: 300px; font-size: 11.5px; line-height: 1.7; }

/* ---------------------------- 设置页组件 ---------------------------- */

.opt-row, .rule-item {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 9px; margin-bottom: 8px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
}
.opt-row:last-child, .rule-item:last-child { margin-bottom: 0; }
.opt-row .grow, .rule-item .grow { display: flex; flex-direction: column; gap: 6px; }
.opt-row .idx, .rule-item .idx {
  width: 22px; height: 22px; flex: 0 0 auto; border-radius: 7px;
  display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-ink);
  font-size: 11px; font-weight: 700;
}
.rule-item .idx { background: var(--ok-soft); color: #0f7a52; }
.rule-actions {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  flex: 0 0 auto; padding-top: 1px;
}
.rule-actions .switch { justify-content: center; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat {
  padding: 11px 12px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.stat .v { font-size: 16.5px; font-weight: 800; letter-spacing: -.4px; line-height: 1.25; }
.stat .k { margin-top: 1px; font-size: 11px; color: var(--muted); }

.qr-box { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.qr-info { width: 100%; max-width: 520px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.qr-info .row { justify-content: center; }
.qr-info .link-item { width: 100%; justify-content: center; }
.qr-canvas {
  flex: 0 0 auto; margin: 0 auto; padding: 9px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
}
.qr-canvas svg, .qr-canvas img, .qr-canvas canvas { display: block; width: 132px; height: 132px; border-radius: 5px; }
.link-item {
  display: flex; align-items: center; gap: 7px; justify-content: center;
  margin-top: 7px; padding: 7px 10px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 11.5px; color: var(--text-2); word-break: break-all; text-align: center;
}
.link-item b { color: var(--text); }
.link-item svg { width: 14px; height: 14px; }

/* ---------------------------- 底部弹出菜单 / 确认框 ---------------------------- */

.sheet-mask { position: fixed; inset: 0; z-index: 940; background: rgba(16, 20, 32, .45); animation: fade .16s ease; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 950;
  padding: 9px 12px calc(14px + var(--safe-b));
  background: var(--panel); border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-lg); animation: sheet-in .2s ease;
}
@keyframes sheet-in { from { transform: translateY(24px); opacity: .5; } to { transform: none; opacity: 1; } }
.sheet .grab { width: 34px; height: 4px; margin: 2px auto 10px; border-radius: 99px; background: #dfe4ee; }
.sheet .title { margin: 0 0 6px; padding: 0 10px; font-size: 11px; font-weight: 600; color: var(--muted); }
.sheet .item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 11px 10px; border: none; border-radius: var(--radius);
  background: transparent; color: inherit;
  font-size: 12px; font-weight: 600; text-align: left; cursor: pointer;
}
.sheet .item svg { width: 17px; height: 17px; opacity: .85; }
.sheet .item:hover { background: var(--panel-2); }
.sheet .item.danger { color: var(--danger); }

.dialog-mask {
  position: fixed; inset: 0; z-index: 960; padding: 20px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(16, 20, 32, .5); animation: fade .16s ease;
}
.dialog {
  width: min(340px, 100%); padding: 18px;
  background: var(--panel); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); animation: pop .18s ease;
}
.dialog h3 { margin: 0 0 7px; font-size: 14px; }
.dialog p { margin: 0 0 16px; font-size: 12px; color: var(--text-2); line-height: 1.6; }
.dialog .acts { display: flex; gap: 8px; justify-content: flex-end; }

/* ============================================================
   用户端（访客聊天页）
   ============================================================ */

body.page-user {
  height: 100%; display: flex;
  background:
    radial-gradient(760px 420px at 6% -8%, #e6e8ff 0%, rgba(230, 232, 255, 0) 60%),
    radial-gradient(700px 400px at 100% 106%, #e2f2ff 0%, rgba(226, 242, 255, 0) 58%),
    var(--bg);
}

.user-shell {
  display: flex; gap: 16px; width: 100%;
  max-width: 1120px; margin: 0 auto;
  height: 100vh; height: 100dvh; padding: 16px;
}

.user-aside { width: 252px; flex: 0 0 252px; min-height: 0; overflow-y: auto; }
.aside-stack { display: flex; flex-direction: column; gap: 12px; }

.side-title {
  margin: 0 0 9px; font-size: 11.5px; font-weight: 700;
  color: var(--text-2); letter-spacing: .2px;
}
.sig { font-size: 11.5px; color: var(--muted); line-height: 1.6; }

.quick-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 10px; margin-bottom: 6px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); color: var(--text);
  font-size: 12px; font-weight: 600; text-align: left; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.quick-item:last-child { margin-bottom: 0; }
.quick-item:hover { background: var(--brand-soft); border-color: #dcdefc; color: var(--brand-ink); }

.chat-card {
  flex: 1 1 auto; min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-xl); box-shadow: var(--shadow);
  overflow: hidden;
}

.chat-head {
  flex: 0 0 auto; display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; padding-top: calc(9px + var(--safe-t));
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.chat-head .who { flex: 1 1 auto; min-width: 0; }
.chat-head .name { font-size: 13px; font-weight: 700; line-height: 1.35; }
.chat-head .status { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); margin-top: 1px; }

.notice-bar {
  flex: 0 0 auto; padding: 6px 12px;
  background: #fff8e8; border-bottom: 1px solid #f4e6c4;
  color: #8a6212; font-size: 11.5px; line-height: 1.5;
}

/* ---------------------------- 平台禁止访问（被拉黑） ---------------------------- */

/* 被客服拉黑后，客户端立即显示该提示且无法继续聊天；解除拉黑后自动消失 */
.ban-mask {
  position: fixed; inset: 0; z-index: 980; padding: 22px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(16, 20, 32, .66);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  animation: fade .18s ease;
}
.ban-card {
  width: min(340px, 100%); padding: 26px 22px; text-align: center;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-lg);
  animation: pop .22s ease;
}
.ban-badge {
  width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 50%;
  display: grid; place-items: center; font-size: 26px; line-height: 1;
  background: var(--danger-soft); color: var(--danger);
}
.ban-title { margin: 0 0 9px; font-size: 15px; font-weight: 700; color: var(--danger); }
.ban-desc { margin: 0; font-size: 12px; line-height: 1.85; color: var(--muted); }
.ban-state {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 16px;
  font-size: 11.5px; color: var(--muted);
}
.ban-state .dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(229, 72, 77, .16);
  animation: ban-pulse 1.5s ease-in-out infinite;
}
@keyframes ban-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
/* 被拉黑时隐藏输入区：不能进入聊天、不能发送消息 */
body.is-blocked .composer { display: none; }

/* ---------------------------- 欢迎 / 服务卡片 ---------------------------- */

.welcome-mask {
  position: fixed; inset: 0; z-index: 900; padding: 18px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(16, 20, 32, .5);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  animation: fade .18s ease;
}
.welcome-card {
  width: min(400px, 100%); max-height: 86vh; overflow-y: auto;
  padding: 20px 18px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg); animation: pop .22s ease;
}
.welcome-card .wave { font-size: 28px; line-height: 1; margin-bottom: 8px; }
.welcome-card h2 { margin: 0 0 6px; font-size: 15px; font-weight: 700; line-height: 1.4; }
.welcome-card .desc { margin: 0 0 14px; font-size: 12px; color: var(--muted); line-height: 1.65; }

.welcome-opts { display: flex; flex-direction: column; gap: 7px; }
.welcome-opt {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; padding: 10px 12px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--text);
  font-size: 12px; font-weight: 600; text-align: left; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.welcome-opt:hover { background: var(--brand-soft); border-color: #dcdefc; color: var(--brand-ink); }
.welcome-opt .arrow { color: var(--muted); font-size: 14px; }
.welcome-opt:hover .arrow { color: var(--brand); }

.welcome-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-2);
}

/* ---------------------------- 视图切换 ---------------------------- */

body.tab-chats.view-list .pane-list { display: flex; }
body.tab-chats.view-chat .pane-chat { display: flex; }
body.tab-settings .pane-settings { display: block; }
body.tab-me .pane-me { display: block; }

/* ---------------------------- 用户端：手机全屏 ---------------------------- */

@media (max-width: 899px) {
  .user-shell { padding: 0; gap: 0; max-width: none; }
  .user-aside { display: none; }
  .chat-card { border: none; border-radius: 0; box-shadow: none; }
}

/* ---------------------------- 后台：≥900px 左侧栏 + 双栏会话 ---------------------------- */

@media (min-width: 900px) {
  .admin-app { grid-template-columns: 244px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .side-nav { display: flex; }
  .admin-wrap { grid-column: 2; }
  .bottom-nav { display: none; }

  .topbar { padding: 12px 18px; }
  .topbar .brand { display: none; }
  .page-title { display: block; margin-left: 2px; }
  .top-stats .only-md { display: inline-flex; }

  .admin-main { grid-template-columns: 300px minmax(0, 1fr); }
  body.tab-chats .pane-list,
  body.tab-chats .pane-chat { display: flex; }
  body.tab-settings .pane-settings,
  body.tab-me .pane-me { display: block; grid-column: 1 / -1; }
  .chat-head .back { display: none; }
  .chat-body { padding: 18px 20px 10px; }
  .composer { padding: 9px 16px 11px; }
  .new-msg-btn { bottom: 82px; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .pane-scroll { padding: 18px 20px 26px; }
}

/* ---------------------------- 后台：≥1200px 双列设置卡片 ---------------------------- */

@media (min-width: 1200px) {
  .admin-main { grid-template-columns: 400px minmax(0, 1fr); }
}

/* ---------------------------- 手机细节 ---------------------------- */

@media (max-width: 767px) {
  .input, .textarea, .composer textarea, .list-head .input { font-size: 11.5px; }
  .bubble { max-width: 84%; }
  .pane-scroll { padding: 12px 10px calc(20px + var(--safe-b)); }
  .chat-body { padding: 12px 10px 6px; }
  .chat-head { padding: 8px 10px; padding-top: calc(8px + var(--safe-t)); }
  .stat .v { font-size: 16.5px; }
  .up-thumb { width: 72px; height: 72px; }
}

/* ---------------------------- 深色模式（跟随系统） ---------------------------- */

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f14;
    --bg-2: #12151c;
    --panel: #15181f;
    --panel-2: #1b1f27;
    --panel-3: #232833;
    --text: #e9ecf2;
    --text-2: #a7afbd;
    --muted: #868f9e;
    --line: #252a34;
    --line-2: #1e222a;
    --brand: #5b54f0;
    --brand-2: #7b75f6;
    --brand-ink: #b7b3ff;
    --brand-soft: #232148;
    --ok-soft: #11301f;
    --danger-soft: #351b1c;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .45);
    --shadow: 0 4px 18px rgba(0, 0, 0, .5);
    --shadow-lg: 0 20px 54px rgba(0, 0, 0, .62);
  }
  body.page-user { background: var(--bg); }
  .login-wrap { background: var(--bg); }
  .topbar, .bottom-nav, .chat-head, .composer, .list-head, .side-nav { background: rgba(21, 24, 31, .96); }
  .day-sep { background: rgba(27, 31, 39, .9); }
  .qr-canvas { background: #fff; }
  .notice-bar { background: #2a1f11; border-color: #493519; color: #eeb273; }
  .bubble.sys-note { background: #2a2211; border-color: #4a3a17; color: #f0c274; }
  .bubble.recalled { background: var(--panel-3) !important; border-color: #2d323d !important; }
  .uploader { border-color: #2c323d; }
  .up-thumb { background: var(--panel-2); }
  .up-thumb span { color: #4b5364; }
  .chip.ok { background: var(--ok-soft); color: #6ddba4; }
  .chip.danger { background: var(--danger-soft); color: #f0a1a4; }
  ::-webkit-scrollbar-thumb { background: #333a46; }
  ::-webkit-scrollbar-thumb:hover { background: #3e4653; }
}

/* ---------------------------- 减少动画偏好 ---------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}









