/* =========================================================
   在线客服系统 · 管理后台样式 v6
   与用户端共享 9 主题 × 日/夜 模式（html[data-theme][data-mode]）
   ========================================================= */

/* ---------- 主题变量：经典微信（默认·日间） ---------- */
:root {
  --bg: #ededed; --panel: #ffffff; --panel-2: #f7f7f7; --chat-bg: #f5f5f5;
  --card: #ffffff; --text: #191919; --muted: #9b9b9b; --border: #e5e5e5;
  --accent: #07C160; --accent-2: #0ABF6B; --accent-weak: rgba(7, 193, 96, .12);
  --bubble-mine: #95EC69; --bubble-mine-text: #0f210c;
  --bubble-their: #ffffff; --bubble-their-text: #191919;
  --chip: #f2f3f5; --chip-text: #6b6b6b;
  --danger: #fa5151;
  --dialog-bg: #ffffff; --input-bg: #ffffff;
  --toast-bg: rgba(0, 0, 0, .78);
  --mask: rgba(0, 0, 0, .45);
  --shadow: 0 4px 20px rgba(0, 0, 0, .12);
}

/* ---------- 经典微信 · 夜间 ---------- */
html[data-mode="dark"] {
  --bg: #111111; --panel: #1e1e1e; --panel-2: #191919; --chat-bg: #161616;
  --card: #232323; --text: #d5d5d5; --muted: #7d7d7d; --border: #2c2c2c;
  --accent: #2fb463; --accent-2: #07C160; --accent-weak: rgba(47, 180, 99, .16);
  --bubble-mine: #2e9e57; --bubble-mine-text: #eafff1;
  --bubble-their: #2c2c2c; --bubble-their-text: #d5d5d5;
  --chip: #2a2a2a; --chip-text: #9a9a9a;
  --danger: #ff6b6b;
  --dialog-bg: #242424; --input-bg: #2c2c2c;
  --toast-bg: rgba(255, 255, 255, .9);
  --mask: rgba(0, 0, 0, .6);
  --shadow: 0 4px 20px rgba(0, 0, 0, .5);
}

/* ---------- 古风 ---------- */
html[data-theme="gufeng"] {
  --bg: #efe4d1; --panel: #f9f2e4; --panel-2: #f3ead8; --chat-bg: #ecdfc8;
  --card: #faf4e8; --text: #4a3b32; --muted: #a08d78; --border: #e2d4bb;
  --accent: #b03a2e; --accent-2: #8c5a3c; --accent-weak: rgba(176, 58, 46, .12);
  --bubble-mine: #c65d3b; --bubble-mine-text: #fdf3ec;
  --bubble-their: #fffdf6; --bubble-their-text: #4a3b32;
  --chip: #eee1c9; --chip-text: #7c6752; --dialog-bg: #f9f2e4; --input-bg: #fffdf6;
}
html[data-theme="gufeng"][data-mode="dark"] {
  --bg: #1a1410; --panel: #241c15; --panel-2: #201913; --chat-bg: #171009;
  --card: #2a2118; --text: #dcc9b0; --muted: #8a7660; --border: #382c20;
  --accent: #d1683f; --accent-2: #c65d3b; --accent-weak: rgba(209, 104, 63, .16);
  --bubble-mine: #9c4a2d; --bubble-mine-text: #ffeadd;
  --bubble-their: #2b2118; --bubble-their-text: #dcc9b0;
  --chip: #33271c; --chip-text: #b09b7f; --dialog-bg: #241c15; --input-bg: #2b2118;
}

/* ---------- 卡通 ---------- */
html[data-theme="katong"] {
  --bg: #ffeef6; --panel: #fff8fc; --panel-2: #fdf0f8; --chat-bg: #ffe6f2;
  --card: #fffafe; --text: #5b3a4e; --muted: #c393ad; --border: #ffd6ea;
  --accent: #ff5ca8; --accent-2: #7ecbff; --accent-weak: rgba(255, 92, 168, .14);
  --bubble-mine: #ff8fc7; --bubble-mine-text: #fff;
  --bubble-their: #ffffff; --bubble-their-text: #5b3a4e;
  --chip: #ffe3f1; --chip-text: #b06e8e; --dialog-bg: #fff8fc; --input-bg: #ffffff;
}
html[data-theme="katong"][data-mode="dark"] {
  --bg: #1c1018; --panel: #271823; --panel-2: #22141f; --chat-bg: #190e16;
  --card: #2e1d29; --text: #f0cfe2; --muted: #96687f; --border: #3a2434;
  --accent: #ff77b7; --accent-2: #7ecbff; --accent-weak: rgba(255, 119, 183, .16);
  --bubble-mine: #d9558f; --bubble-mine-text: #ffe9f4;
  --bubble-their: #2e1d29; --bubble-their-text: #f0cfe2;
  --chip: #361f30; --chip-text: #c995b3; --dialog-bg: #271823; --input-bg: #2e1d29;
}

/* ---------- 科技 ---------- */
html[data-theme="keji"] {
  --bg: #e6eefb; --panel: #f4f8ff; --panel-2: #eaf2fd; --chat-bg: #dde9f8;
  --card: #f8fbff; --text: #14213d; --muted: #7d8db0; --border: #d3e0f2;
  --accent: #0e6fff; --accent-2: #00c6ff; --accent-weak: rgba(14, 111, 255, .12);
  --bubble-mine: #2563eb; --bubble-mine-text: #f2f8ff;
  --bubble-their: #ffffff; --bubble-their-text: #14213d;
  --chip: #e3ecfa; --chip-text: #5a6f96; --dialog-bg: #f4f8ff; --input-bg: #ffffff;
}
html[data-theme="keji"][data-mode="dark"] {
  --bg: #060d1c; --panel: #0c1729; --panel-2: #0a1222; --chat-bg: #050b17;
  --card: #101d33; --text: #c8dcf5; --muted: #5d7195; --border: #16243d;
  --accent: #00d1ff; --accent-2: #7c5cff; --accent-weak: rgba(0, 209, 255, .14);
  --bubble-mine: #0f4c9e; --bubble-mine-text: #dff4ff;
  --bubble-their: #101d33; --bubble-their-text: #c8dcf5;
  --chip: #12213a; --chip-text: #7fa3cf; --dialog-bg: #0c1729; --input-bg: #101d33;
}

/* ---------- 商务 ---------- */
html[data-theme="shangwu"] {
  --bg: #eceff4; --panel: #f8fafc; --panel-2: #f1f4f9; --chat-bg: #e7ebf2;
  --card: #fbfcfe; --text: #1f2d3d; --muted: #8494a8; --border: #dbe2ec;
  --accent: #1f6feb; --accent-2: #3b82f6; --accent-weak: rgba(31, 111, 235, .12);
  --bubble-mine: #1f6feb; --bubble-mine-text: #f0f6ff;
  --bubble-their: #ffffff; --bubble-their-text: #1f2d3d;
  --chip: #e9edf4; --chip-text: #64748b; --dialog-bg: #f8fafc; --input-bg: #ffffff;
}
html[data-theme="shangwu"][data-mode="dark"] {
  --bg: #10141b; --panel: #1a212b; --panel-2: #161d26; --chat-bg: #0d1219;
  --card: #202836; --text: #d3dce6; --muted: #76879b; --border: #28323f;
  --accent: #4d8dff; --accent-2: #3b82f6; --accent-weak: rgba(77, 141, 255, .16);
  --bubble-mine: #2b5fd9; --bubble-mine-text: #eaf2ff;
  --bubble-their: #202836; --bubble-their-text: #d3dce6;
  --chip: #232d3a; --chip-text: #9fb0c4; --dialog-bg: #1a212b; --input-bg: #202836;
}

/* ---------- 水波纹 ---------- */
html[data-theme="shuibo"] {
  --bg: #dff0f9; --panel: #eef9ff; --panel-2: #e6f4fb; --chat-bg: #d6ecf7;
  --card: #f4fbff; --text: #16394d; --muted: #78a3b8; --border: #cbe4f0;
  --accent: #2196d9; --accent-2: #26c6da; --accent-weak: rgba(33, 150, 217, .12);
  --bubble-mine: #3aa9dc; --bubble-mine-text: #f0faff;
  --bubble-their: #ffffff; --bubble-their-text: #16394d;
  --chip: #e2f1f9; --chip-text: #5b8ba3; --dialog-bg: #eef9ff; --input-bg: #ffffff;
}
html[data-theme="shuibo"][data-mode="dark"] {
  --bg: #081820; --panel: #0e2330; --panel-2: #0b1d28; --chat-bg: #06141c;
  --card: #122a3a; --text: #c6e4f2; --muted: #5f8a9e; --border: #1a3648;
  --accent: #35c0e8; --accent-2: #26c6da; --accent-weak: rgba(53, 192, 232, .14);
  --bubble-mine: #1d7ca6; --bubble-mine-text: #e8f9ff;
  --bubble-their: #122a3a; --bubble-their-text: #c6e4f2;
  --chip: #16303f; --chip-text: #86b7cb; --dialog-bg: #0e2330; --input-bg: #122a3a;
}

/* ---------- 动态 ---------- */
html[data-theme="dongtai"] {
  --bg: #efeaff; --panel: #f8f5ff; --panel-2: #f2edff; --chat-bg: #eae2fd;
  --card: #fbf9ff; --text: #33265c; --muted: #9d8fc4; --border: #e0d7f5;
  --accent: #7c5cff; --accent-2: #ff7ac8; --accent-weak: rgba(124, 92, 255, .12);
  --bubble-mine: #7c5cff; --bubble-mine-text: #f5f0ff;
  --bubble-their: #ffffff; --bubble-their-text: #33265c;
  --chip: #ece5fb; --chip-text: #7a6aa8; --dialog-bg: #f8f5ff; --input-bg: #ffffff;
}
html[data-theme="dongtai"][data-mode="dark"] {
  --bg: #130b22; --panel: #1d1333; --panel-2: #180f2b; --chat-bg: #0e0720;
  --card: #241741; --text: #e2d6f7; --muted: #8a7ab0; --border: #2e1e4d;
  --accent: #a585ff; --accent-2: #ff8fd4; --accent-weak: rgba(165, 133, 255, .16);
  --bubble-mine: #6a48e8; --bubble-mine-text: #f4efff;
  --bubble-their: #241741; --bubble-their-text: #e2d6f7;
  --chip: #2a1b48; --chip-text: #b7a6dd; --dialog-bg: #1d1333; --input-bg: #241741;
}

/* ---------- 水彩 ---------- */
html[data-theme="shuicai"] {
  --bg: #fbeee4; --panel: #fdf6ee; --panel-2: #faeee2; --chat-bg: #f7e7da;
  --card: #fef9f3; --text: #5c4436; --muted: #b39480; --border: #f0dcc9;
  --accent: #d97757; --accent-2: #7fb8a4; --accent-weak: rgba(217, 119, 87, .12);
  --bubble-mine: #e8968a; --bubble-mine-text: #fff8f5;
  --bubble-their: #ffffff; --bubble-their-text: #5c4436;
  --chip: #f6e4d6; --chip-text: #96735d; --dialog-bg: #fdf6ee; --input-bg: #ffffff;
}
html[data-theme="shuicai"][data-mode="dark"] {
  --bg: #1d1512; --panel: #281d19; --panel-2: #231915; --chat-bg: #181110;
  --card: #2f231d; --text: #ecd8c9; --muted: #9c7f6d; --border: #3b2c24;
  --accent: #e8927c; --accent-2: #7fb8a4; --accent-weak: rgba(232, 146, 124, .14);
  --bubble-mine: #b5675a; --bubble-mine-text: #ffefe9;
  --bubble-their: #2f231d; --bubble-their-text: #ecd8c9;
  --chip: #362821; --chip-text: #c9a68f; --dialog-bg: #281d19; --input-bg: #2f231d;
}

/* ---------- 简洁 ---------- */
html[data-theme="jianjie"] {
  --bg: #f5f5f5; --panel: #fafafa; --panel-2: #f0f0f0; --chat-bg: #f2f2f2;
  --card: #ffffff; --text: #2b2b2b; --muted: #9e9e9e; --border: #e8e8e8;
  --accent: #555555; --accent-2: #8a8a8a; --accent-weak: rgba(85, 85, 85, .1);
  --bubble-mine: #9aa0a6; --bubble-mine-text: #ffffff;
  --bubble-their: #ffffff; --bubble-their-text: #2b2b2b;
  --chip: #ececec; --chip-text: #777; --dialog-bg: #fafafa; --input-bg: #ffffff;
}
html[data-theme="jianjie"][data-mode="dark"] {
  --bg: #141414; --panel: #1d1d1d; --panel-2: #181818; --chat-bg: #101010;
  --card: #242424; --text: #d9d9d9; --muted: #7c7c7c; --border: #282828;
  --accent: #a8a8a8; --accent-2: #8a8a8a; --accent-weak: rgba(168, 168, 168, .12);
  --bubble-mine: #5a5f66; --bubble-mine-text: #f0f0f0;
  --bubble-their: #242424; --bubble-their-text: #d9d9d9;
  --chip: #262626; --chip-text: #9d9d9d; --dialog-bg: #1d1d1d; --input-bg: #242424;
}

/* =========================================================
   基础
   ========================================================= */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; overflow: hidden;
}
button { font-family: inherit; border: none; background: none; color: inherit; cursor: pointer; }
input, textarea, select {
  font-family: inherit; font-size: 14px; color: var(--text);
  background: var(--input-bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 11px; outline: none; width: 100%;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--muted); }
a { color: var(--accent); text-decoration: none; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

/* 日夜切换按钮图标 */
#btn-admin-mode .ic-sun { display: none; }
html[data-mode="dark"] #btn-admin-mode .ic-sun { display: block; }
html[data-mode="dark"] #btn-admin-mode .ic-moon { display: none; }

/* 动态主题：主区渐变流动 */
html[data-theme="dongtai"] .admin-main {
  background-image: linear-gradient(120deg, var(--bg), var(--accent-weak), var(--bg));
  background-size: 300% 300%; animation: dongtaiShift 14s linear infinite;
}
@keyframes dongtaiShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
/* 水波纹主题：主区涟漪底纹 */
html[data-theme="shuibo"] .admin-main {
  background-image: repeating-radial-gradient(circle at 20% 30%, transparent 0, transparent 38px, var(--accent-weak) 39px, transparent 41px),
    repeating-radial-gradient(circle at 85% 75%, transparent 0, transparent 46px, var(--accent-weak) 47px, transparent 49px);
}

/* =========================================================
   登录页
   ========================================================= */
.admin-login-wrap {
  position: fixed; inset: 0; z-index: 100; overflow-y: auto;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.admin-login-card {
  background: var(--dialog-bg); color: var(--text); border-radius: 14px;
  padding: 32px 28px; width: 100%; max-width: 380px; box-shadow: 0 12px 48px rgba(0, 0, 0, .22);
}
.admin-login-card h2 { font-size: 19px; margin-bottom: 18px; text-align: center; }
.al-brand { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--accent); }
.al-brand h1 { font-size: 19px; }
.al-brand svg { color: var(--accent); }
.admin-login-card .al-brand { margin-bottom: 14px; }
.form-row { margin-bottom: 13px; }
.remember-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 16px;
  font-size: 13px; color: var(--muted); cursor: pointer; user-select: none;
}
.remember-row input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }
.btn-primary {
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 600;
  border-radius: 8px; padding: 10px 18px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%;
}
.btn-primary:active { opacity: .85; }
.btn-primary.sm { width: auto; font-size: 13px; padding: 8px 14px; }
.btn-primary.danger { background: var(--danger); }
.btn-ghost {
  width: 100%; padding: 10px; border-radius: 8px; background: var(--chip);
  color: var(--chip-text); font-size: 14px; font-weight: 500;
}
.btn-ghost.sm { width: auto; padding: 8px 14px; font-size: 13px; }
.al-tip { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.7; }
.al-back { display: block; text-align: center; margin-top: 12px; font-size: 13px; }

/* =========================================================
   后台布局
   ========================================================= */
.admin-shell { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
.admin-nav {
  width: 190px; flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--border);
  transition: width .22s ease, transform .22s ease; overflow: hidden;
}
/* v8：桌面端点击开关折叠侧边栏（保留 56px 仅显示图标） */
body.nav-closed .admin-nav { width: 56px; }
body.nav-closed .an-brand .an-brand-txt,
body.nav-closed .an-item .lbl,
body.nav-closed .an-mode span,
body.nav-closed .an-me,
body.nav-closed .an-logout,
body.nav-closed .an-home { display: none; }
body.nav-closed .an-brand,
body.nav-closed .an-item,
body.nav-closed .an-mode { justify-content: center; padding-left: 6px; padding-right: 6px; }
body.nav-closed .an-item svg { margin: 0; }

/* v8：侧边栏遮罩（仅移动端可见） */
.nav-mask { display: none; }

/* v8：顶栏（侧边栏开关 + 快捷退出） */
.admin-topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0 14px; border-bottom: 1px solid var(--border); margin-bottom: 14px;
}
.nav-toggle {
  width: 36px; height: 36px; border-radius: 8px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted); background: var(--chip);
}
.nav-toggle:hover { color: var(--accent); }
.at-title { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; color: var(--muted); }
.at-logout {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--danger); padding: 7px 12px; border-radius: 8px;
  background: rgba(250, 81, 81, .1);
}
.at-logout:hover { background: rgba(250, 81, 81, .18); }
.an-brand {
  display: flex; align-items: center; gap: 8px; padding: 16px 14px;
  font-weight: 700; font-size: 16px; color: var(--accent); border-bottom: 1px solid var(--border);
}
.an-brand svg { flex-shrink: 0; }
.an-menu { flex: 1; overflow-y: auto; padding: 10px 8px; }
.an-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 11px 12px; border-radius: 8px; font-size: 14px; color: var(--text);
  margin-bottom: 2px; text-align: left;
}
.an-item:hover { background: var(--chip); }
.an-item.active { background: var(--accent-weak); color: var(--accent); font-weight: 600; }
.an-item svg { flex-shrink: 0; }
.an-foot { padding: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.an-mode {
  display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted);
  padding: 6px 8px; border-radius: 6px;
}
.an-mode:hover { background: var(--chip); color: var(--accent); }
.an-me { display: flex; flex-direction: column; }
.an-me-name { font-size: 13px; font-weight: 600; }
.an-me-role { font-size: 11px; color: var(--muted); }
.an-logout { font-size: 12px; color: var(--danger); text-align: left; padding: 4px 0; }
.an-home { font-size: 12px; color: var(--muted); }

.admin-main { flex: 1; min-width: 0; overflow-y: auto; padding: 20px; }
.admin-view { display: none; max-width: 1200px; margin: 0 auto; }
.admin-view.active { display: block; }
.av-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.av-head h2 { font-size: 19px; }
.av-sub { font-size: 12px; color: var(--muted); }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px; margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 12px; }

/* =========================================================
   工作台
   ========================================================= */
.wb-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.wb-stat {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; text-align: center;
}
.ws-num { font-size: 26px; font-weight: 700; color: var(--accent); }
.ws-label { font-size: 12px; color: var(--muted); margin-top: 4px; }
.wb-chat-wrap {
  display: flex; gap: 14px; height: calc(100vh - 260px); min-height: 340px;
}
.wb-users {
  width: 240px; flex-shrink: 0; background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; overflow-y: auto;
}
.wb-user {
  display: flex; gap: 10px; padding: 11px 12px; cursor: pointer; align-items: center;
  border-bottom: 1px solid var(--border);
}
.wb-user:hover, .wb-user.active { background: var(--panel-2); }
.wb-user-main { flex: 1; min-width: 0; }
.wb-user-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wb-user-msg { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; color: #fff; font-weight: 600; user-select: none; flex-shrink: 0;
}
.unread-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; line-height: 18px;
  display: inline-block; text-align: center; font-weight: 600; flex-shrink: 0;
}
.wb-chat {
  flex: 1; min-width: 0; background: var(--chat-bg); border: 1px solid var(--border);
  border-radius: 12px; display: none; flex-direction: column; overflow: hidden;
}
.wb-chat-head {
  display: flex; align-items: center; gap: 10px; padding: 7px 12px;
  background: var(--panel); border-bottom: 1px solid var(--border);
}
.wb-chat-title { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; line-height: 1.3; }
.wb-chat-acc { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
.wb-online { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.wb-online.on { color: #22c55e; }
.wb-input-bar { background: var(--panel); border-top: 1px solid var(--border); padding: 8px 12px; }
.wb-tools { display: flex; gap: 4px; margin-bottom: 6px; }
.tool-btn { width: 34px; height: 34px; border-radius: 8px; font-size: 17px; display: inline-flex; align-items: center; justify-content: center; }
.tool-btn:hover { background: var(--chip); }
.money-tool { width: auto; padding: 0 10px; gap: 4px; font-size: 13px; font-weight: 600; }
.money-tool span { font-size: 13px; }
#wb-redpacket { color: #f5504e; }
#wb-transfer { color: #fa9d3b; }
.input-row { display: flex; gap: 10px; align-items: flex-end; }
#wb-msg-input { flex: 1; min-width: 0; resize: none; max-height: 100px; border-radius: 10px; }
.btn-send {
  flex-shrink: 0; padding: 9px 18px; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 600;
}
.chat-empty-small { text-align: center; color: var(--muted); font-size: 13px; padding: 40px 16px; }
.wb-chat > .chat-empty-small { margin: auto; }

/* =========================================================
   消息气泡（工作台 + 聊天记录共用）
   ========================================================= */
.msg-list { flex: 1; overflow-y: auto; min-height: 0; max-height: 420px; padding: 16px 14px 8px; }
.msg-row { display: flex; gap: 10px; margin-bottom: 14px; align-items: flex-start; }
.msg-row.mine { justify-content: flex-end; }
.msg-row.their { justify-content: flex-start; }
.msg-stack { max-width: min(560px, 74%); min-width: 0; display: flex; flex-direction: column; }
.msg-row.mine .msg-stack { align-items: flex-end; }
.msg-row.their .msg-stack { align-items: flex-start; }
.msg-bubble {
  padding: 9px 13px; border-radius: 10px; font-size: 14px; word-break: break-word; white-space: pre-wrap;
}
.msg-row.their .msg-bubble { background: var(--bubble-their); color: var(--bubble-their-text); border-top-left-radius: 2px; }
.msg-row.mine .msg-bubble { background: var(--bubble-mine); color: var(--bubble-mine-text); border-top-right-radius: 2px; }
.msg-meta { display: flex; gap: 8px; font-size: 11px; color: var(--muted); margin-top: 4px; padding: 0 2px; }
.read-flag.unread { color: var(--danger); }
.edit-flag { color: var(--muted); }
.msg-recall-tip {
  width: 100%; text-align: center; font-size: 12px; color: var(--muted);
  background: var(--chip); border-radius: 6px; padding: 4px 10px; margin: 4px auto;
}
.msg-quote {
  max-width: 100%; padding: 5px 10px; border-radius: 6px 6px 0 0;
  background: var(--chip); border-left: 3px solid var(--accent);
  font-size: 12px; color: var(--muted); margin-bottom: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.msg-quote b { color: var(--accent); margin-right: 6px; }
.msg-quote-media { cursor: pointer; }
.msg-quote-media:hover { opacity: .8; }
.msg-image, .msg-video { position: relative; cursor: pointer; max-width: 220px; border-radius: 10px; overflow: hidden; }
.msg-image img { display: block; max-width: 220px; max-height: 280px; }
.msg-video video { display: block; max-width: 220px; max-height: 280px; background: #000; }
.video-play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.msg-file {
  display: flex; gap: 10px; align-items: center; cursor: pointer;
  background: var(--bubble-their); color: var(--bubble-their-text);
  border-radius: 10px; padding: 11px 13px; max-width: 250px;
}
.msg-row.mine .msg-file { background: var(--bubble-mine); color: var(--bubble-mine-text); }
.msg-file-name { font-size: 13px; font-weight: 500; word-break: break-all; }
.msg-file-act { font-size: 11px; opacity: .65; margin-top: 2px; }
.msg-money { width: 200px; border-radius: 10px; overflow: hidden; color: #fff; cursor: default; }
.msg-money.transfer { background: linear-gradient(135deg, #f7a35c, #fa9d3b); }
.msg-money.redpacket { background: linear-gradient(135deg, #f5504e, #e83836); }
.money-top { display: flex; justify-content: space-between; padding: 11px 13px 4px; font-size: 14px; font-weight: 600; }
.money-bottom { padding: 0 13px 11px; font-size: 11px; opacity: .85; }

/* =========================================================
   表格 / 分页
   ========================================================= */
.users-toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.users-toolbar input { width: 240px; }
.users-toolbar select { width: auto; min-width: 180px; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 640px; }
.data-table th, .data-table td {
  padding: 10px 10px; text-align: left; font-size: 13px; white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.data-table th { color: var(--muted); font-weight: 500; }
.empty-td { text-align: center; color: var(--muted); padding: 30px 0 !important; }
.op-td { white-space: nowrap; }
.btn-mini {
  padding: 5px 10px; border-radius: 6px; font-size: 12px; font-weight: 500;
  background: var(--chip); color: var(--chip-text);
}
.btn-mini.primary { background: var(--accent); color: #fff; }
.btn-mini.danger { background: rgba(250, 81, 81, .12); color: var(--danger); }
.pager { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.pg-btn {
  padding: 6px 12px; border-radius: 6px; background: var(--chip); color: var(--chip-text); font-size: 13px;
}
.pg-info { font-size: 12px; color: var(--muted); }

/* v25：订单状态徽标 */
.order-status { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; }
.order-status.paid { background: rgba(7,193,96,.12); color: #07c160; }
.order-status.pending { background: rgba(255,180,77,.15); color: #e08a00; }
.order-status.expired { background: var(--chip); color: var(--muted); }
.row-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }

/* =========================================================
   聊天记录（气泡查看）
   ========================================================= */
.rec-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.rec-card { padding: 16px; }
.rec-bubble-box {
  background: var(--chat-bg); border: 1px solid var(--border); border-radius: 10px;
  height: calc(100vh - 320px); min-height: 320px; overflow-y: auto; padding: 16px 14px;
}
.rec-groups { max-height: 200px; overflow-y: auto; margin-bottom: 12px; }
.rec-group-item { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 8px; cursor: pointer; }
.rec-group-item:hover { background: var(--panel-2); }
.rec-group-main { flex: 1; min-width: 0; }
.rec-group-name { font-weight: 600; font-size: 14px; }
.rec-group-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.rec-list { max-height: calc(100vh - 320px); min-height: 320px; overflow-y: auto; }
.rec-user-item { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 8px; cursor: pointer; }
.rec-user-item:hover { background: var(--panel-2); }
.rec-user-main { flex: 1; min-width: 0; }
.rec-user-name { font-weight: 600; font-size: 14px; }
.rec-user-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.rec-role { display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 4px; font-size: 11px; font-weight: 400; background: #07C160; color: #fff; }
.rec-back { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 13px; padding: 0; margin-right: 8px; }
.rec-clear-btn { margin-left: auto; background: none; border: 1px solid var(--danger, #e74c3c); color: var(--danger, #e74c3c); cursor: pointer; font-size: 12px; padding: 3px 10px; border-radius: 6px; }
.rec-clear-btn:hover { background: var(--danger, #e74c3c); color: #fff; }
.group-avatar { background: #4a90d9; }
.msg-sender { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
@media (max-width: 900px) {
  .rec-layout { grid-template-columns: 1fr; }
  .rec-bubble-box { height: 60vh; }
}

/* =========================================================
   公告配置
   ========================================================= */
.ann-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; align-items: start; }
.money-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.ann-opt-row .form-row { margin-bottom: 12px; }
.color-row { display: flex; gap: 10px; }
.color-row input[type="color"] { width: 52px; height: 38px; padding: 3px; flex-shrink: 0; cursor: pointer; }
.color-row input:last-child { flex: 1; min-width: 0; font-family: monospace; }
.mode-row { display: flex; gap: 10px; }
.mode-btn {
  flex: 1; padding: 10px; border-radius: 8px; background: var(--chip);
  color: var(--chip-text); font-size: 13px; font-weight: 500; border: 2px solid transparent;
}
.mode-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-weak); }
.money-btns { display: flex; gap: 10px; margin-top: 14px; }
.money-btns > * { flex: 1; }
.ann-preview-wrap { margin-top: 18px; }
.ann-preview {
  background: var(--dialog-bg); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px; text-align: center; position: relative;
}
.ann-preview.force { box-shadow: 0 0 0 3px var(--danger); }
.ann-flag {
  display: inline-block; background: var(--accent); color: #fff;
  font-size: 11px; padding: 3px 10px; border-radius: 10px; margin-bottom: 10px;
}
.ann-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.ann-content {
  font-size: 13px; text-align: left; white-space: pre-wrap; word-break: break-word;
  line-height: 1.8; background: var(--chip); border-radius: 8px; padding: 10px;
  max-height: 160px; overflow-y: auto;
}
.ann-preview.force::after {
  content: '强制弹窗：不可关闭'; position: absolute; top: 10px; right: 10px;
  font-size: 10px; color: var(--danger);
}
.bell-list { max-height: 480px; overflow-y: auto; }
.bell-item { padding: 12px 2px; border-bottom: 1px solid var(--border); }
.bell-item:last-child { border-bottom: none; }
.bell-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.bell-badge {
  flex-shrink: 0; font-size: 11px; padding: 2px 7px; border-radius: 4px;
  background: var(--accent-weak); color: var(--accent); font-weight: 600;
}
.bell-badge.force { background: rgba(250, 81, 81, .14); color: var(--danger); }
.bell-title { flex: 1; min-width: 120px; font-size: 14px; font-weight: 600; }
.bell-time { flex-shrink: 0; font-size: 11px; color: var(--muted); }
.bell-body { font-size: 13px; color: var(--muted); line-height: 1.7; word-break: break-word; }
.bell-foot { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11px; color: var(--muted); }

/* =========================================================
   缓存管理
   ========================================================= */
.cache-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.cache-btns { display: flex; gap: 10px; margin-bottom: 16px; }
.cache-btns .btn-primary { width: auto; }

/* =========================================================
   配置表单
   ========================================================= */
.cfg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cfg-grid .form-row { margin-bottom: 0; }
.form-row-full { margin-top: 12px; margin-bottom: 0; }
.cfg-textarea {
  width: 100%; min-height: 80px; padding: 10px 12px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  font-size: 12px; line-height: 1.5; color: var(--text); resize: vertical;
  word-break: break-all;
}
.font-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }
.cfg-select {
  width: 100%; padding: 10px 12px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; color: var(--text); outline: none;
}
.pay-test-tip { font-size: 12px; color: var(--muted); line-height: 1.7; margin: 6px 0 12px; }
.pay-test-ok, .pay-test-fail {
  margin-top: 14px; padding: 14px 16px; border-radius: 10px;
  font-size: 13px; line-height: 1.7; word-break: break-all;
}
.pay-test-ok { background: rgba(46, 204, 113, .12); border: 1px solid rgba(46, 204, 113, .4); color: #1e8449; }
.pay-test-fail { background: rgba(231, 76, 60, .1); border: 1px solid rgba(231, 76, 60, .35); color: #c0392b; }
.pay-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.pay-tab { padding: 9px 20px; border-radius: 8px; font-size: 14px; font-weight: 500; background: var(--chip); color: var(--chip-text); border: 1px solid var(--border); cursor: pointer; }
.pay-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pay-panel { padding-top: 4px; }
.pay-panel.hidden { display: none !important; }

/* v27：通用弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none; align-items: center; justify-content: center; z-index: 1200; padding: 16px; }
.modal-mask.show { display: flex; }
.modal-card { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.25); overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 15px; font-weight: 600; }
.modal-close { color: var(--muted); font-size: 18px; padding: 2px 8px; }
.modal-body { padding: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--border); }
.modal-body .form-row { margin-bottom: 14px; }
.modal-body .form-row:last-child { margin-bottom: 0; }
.pay-test-qr { margin-top: 12px; text-align: center; }
.pay-test-qr img { width: 200px; height: 200px; border-radius: 10px; border: 1px solid var(--border); }
.pay-test-qr-tip { font-size: 12px; color: var(--muted); margin-top: 8px; }
.pay-test-link { display: inline-block; margin-top: 8px; font-size: 13px; color: var(--accent); }

/* v28：工作台转账/红包弹窗（复用用户端 money-dialog 样式） */
.mask { position: fixed; inset: 0; background: var(--mask); display: none; align-items: center; justify-content: center; z-index: 1200; padding: 16px; }
.mask.show { display: flex; }
.dialog { width: 100%; max-width: 360px; background: var(--dialog-bg); border-radius: 14px; padding: 22px 20px; box-shadow: 0 12px 40px rgba(0,0,0,.25); display: none; }
.dialog.show { display: block; }
/* v30：工作台转账/红包弹窗居中且置于遮罩之上，修复点击黑屏 */
#wb-money-dialog.show {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 1201; max-height: 90vh; overflow-y: auto;
}
.money-dialog h3 { text-align: center; font-size: 16px; margin-bottom: 14px; }
.money-icon { text-align: center; font-size: 40px; margin-bottom: 12px; }
.money-dialog input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--input-bg); color: var(--text); font-size: 14px; margin-bottom: 10px; }
.money-channels { margin: 6px 0 4px; }
.pay-method { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 2px solid var(--border); border-radius: 10px; background: var(--input-bg); color: var(--text); font-size: 13px; cursor: pointer; }
.pay-method.on { border-color: var(--accent); background: var(--accent-weak); }
.pm-ico { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0; }
.pm-bal { background: #07c160; }
.pm-ali { background: #1677ff; }
.pm-wx { background: #07c160; }
.pay-method span { flex: 1; text-align: left; }
.pay-method em { font-style: normal; color: var(--muted); font-size: 12px; }

/* =========================================================
   灯箱（含边框）
   ========================================================= */
#lightbox {
  position: fixed; inset: 0; z-index: 95; background: rgba(0, 0, 0, .88);
  display: none; flex-direction: column;
}
#lightbox.show { display: flex; }
.lb-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; color: #fff; }
.lb-title { font-size: 14px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-acts { display: flex; gap: 8px; flex-shrink: 0; }
.lb-btn {
  color: #fff; font-size: 13px; background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .35); border-radius: 8px; padding: 6px 13px;
}
.lb-body { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 18px 18px; overflow: auto; }
.lb-body img, .lb-body video {
  max-width: calc(100vw - 72px); max-height: calc(100vh - 150px);
  border: 8px solid #ffffff; border-radius: 8px;
  box-shadow: 0 10px 46px rgba(0, 0, 0, .55); background: #000;
}
.lb-file { text-align: center; color: #fff; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.lb-file svg { color: #cfd8dc; }
.lb-file-name { font-size: 14px; word-break: break-all; max-width: 80vw; }
.lb-file .btn-primary { width: auto; }

/* =========================================================
   Toast
   ========================================================= */
.kefu-toast {
  position: fixed; left: 50%; bottom: 10%; transform: translateX(-50%) translateY(8px);
  background: var(--toast-bg); color: var(--panel); font-size: 13px; line-height: 1.5;
  padding: 10px 16px; border-radius: 8px; z-index: 120; max-width: 78vw;
  opacity: 0; transition: all .22s ease; pointer-events: none; white-space: pre-line;
}
html[data-mode="dark"] .kefu-toast { color: #111; }
.kefu-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.kefu-toast-err { background: rgba(220, 53, 69, .94); color: #fff; }

/* =========================================================
   响应式
   ========================================================= */
@media (max-width: 900px) {
  /* v8：移动端侧边栏改抽屉式，开关按钮弹出，遮罩点击关闭 */
  .admin-shell { display: block; height: 100vh; height: 100dvh; overflow: hidden; }
  .admin-nav {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 110; width: 200px;
    transform: translateX(-100%); box-shadow: 4px 0 24px rgba(0, 0, 0, .25);
  }
  body.nav-open .admin-nav { transform: translateX(0); }
  body.nav-open .nav-mask {
    display: block; position: fixed; inset: 0; z-index: 105;
    background: rgba(0, 0, 0, .45);
  }
  .admin-main { height: 100%; overflow-y: auto; padding: 14px; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .wb-stats { grid-template-columns: repeat(2, 1fr); }
  .ann-grid { grid-template-columns: 1fr; }
  .cfg-grid { grid-template-columns: 1fr; }
  .users-toolbar input { width: 100%; }
  .wb-chat-wrap { flex-direction: column; height: auto; }
  .wb-users { width: 100%; max-height: 200px; }
  .wb-chat { min-height: 480px; }
  .rec-bubble-box { height: 60vh; }
}

/* =========================================================
   v9：仪表盘动态 / API 配置卡片 / 后台表情面板
   ========================================================= */
.dash-feed { display: flex; flex-direction: column; }
.dash-feed-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 2px; border-bottom: 1px dashed var(--border); font-size: 13px; }
.dash-feed-item:last-child { border-bottom: 0; }
.df-users { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.df-meta { flex-shrink: 0; color: var(--muted); font-size: 12px; }
.df-empty { color: var(--muted); font-size: 13px; padding: 14px 0; text-align: center; }

.api-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.api-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.api-card-wide { grid-column: 1 / -1; }
.api-card-head { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; color: var(--accent); }
.api-card-desc { font-size: 12px; color: var(--muted); line-height: 1.6; flex: 1; }
.api-switch { display: inline-flex; align-items: center; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.api-switch input { display: none; }
.api-track { width: 46px; height: 26px; border-radius: 999px; background: var(--chip); border: 1px solid var(--border); position: relative; transition: background .18s, border-color .18s; display: inline-block; }
.api-dot { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s; }
.api-switch input:checked + .api-track { background: var(--accent); border-color: var(--accent); }
.api-switch input:checked + .api-track .api-dot { transform: translateX(20px); }
.api-key-row { display: flex; gap: 8px; flex-wrap: wrap; }
.api-key-row input { flex: 1; min-width: 200px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.api-tip { font-size: 12px; color: var(--muted); }
.api-url { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; word-break: break-all; background: var(--chip); padding: 8px 10px; border-radius: 8px; }
.btn-danger { color: #fa5151; }
.btn-danger.sm { padding: 8px 14px; font-size: 13px; background: rgba(250,81,81,.12); border-radius: 8px; }
.btn-danger.sm:hover { background: rgba(250,81,81,.2); }

/* v9：后台工作台表情面板 */
.wb-emoji-panel { display: none; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 8px; margin-bottom: 6px; }
.wb-emoji-panel.open { display: block; }
.wb-emoji-panel .emoji-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; max-height: 150px; overflow-y: auto; }
.wb-emoji-panel .emoji-item { border: 0; background: transparent; font-size: 20px; padding: 4px 2px; border-radius: 6px; cursor: pointer; line-height: 1.3; }
.wb-emoji-panel .emoji-item:hover { background: var(--chip); }

@media (max-width: 900px) {
  .api-cards { grid-template-columns: 1fr; }
  .api-card { padding: 14px; }
  .api-key-row input { min-width: 0; width: 100%; }
  .api-key-row button { width: 100%; }
  .wb-emoji-panel .emoji-grid { grid-template-columns: repeat(8, 1fr); }
}

/* =========================================================
   v10：工作台微信式切换 / 支付配置易支付开关
   ========================================================= */
.wb-users.hide { display: none; }
.wb-chat.full { flex: 1; min-width: 0; display: flex; }
.wb-back { display: inline-flex; align-items: center; gap: 4px; border: 0; background: transparent; color: var(--accent); font-size: 13px; cursor: pointer; padding: 4px 6px; border-radius: 8px; flex-shrink: 0; }
.wb-back:hover { background: var(--chip); }
.wb-chat-head { gap: 10px; }
.wb-clear { display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; color: var(--muted, #999); cursor: pointer; padding: 4px; border-radius: 8px; flex-shrink: 0; margin-left: auto; }
.wb-clear:hover { background: var(--chip); color: var(--danger, #e74c3c); }
.pay-switch-row { display: flex; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.pay-switch-row:last-child { border-bottom: 0; }
.pay-switch-list { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 6px 14px; margin-bottom: 14px; }
.pay-switch-label { font-size: 14px; flex: 1; }
.pay-switch-tip { font-size: 12px; color: var(--muted); flex: 1; }
@media (max-width: 900px) {
  .wb-chat-wrap { position: relative; }
  .wb-chat.full { min-height: 460px; }
}

