/* ============ 客服工作台样式 ============ */
:root {
  --brand: #4f46e5;           /* 主色：靛蓝 */
  --brand-600: #4338ca;
  --brand-50: #eef2ff;
  --brand-100: #e0e7ff;
  --rail: #111827;
  --rail-2: #1f2937;
  --bg: #f4f5f9;
  --panel: #ffffff;
  --line: #e6e8ef;
  --line-2: #f0f1f5;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --danger: #e11d48;
  --ok: #10b981;
  --warn: #f59e0b;
  --tg: #229ed9;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 10px 30px rgba(15, 23, 42, .10);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, .22);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; font: 14px/1.5 Inter, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
svg { width: 18px; height: 18px; flex: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; color: var(--text); }
.err { color: var(--danger); font-size: 12px; }
.flex { flex: 1; }

/* ---------- 按钮 ---------- */
.btn-primary { background: var(--brand); color: #fff; border-radius: 8px; padding: 8px 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; transition: background .15s, box-shadow .15s; box-shadow: 0 1px 2px rgba(79, 70, 229, .3); }
.btn-primary:hover:not(:disabled) { background: var(--brand-600); }
.btn-outline { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 12px; font-weight: 500; color: var(--text-2); }
.btn-outline:hover { background: var(--bg); }
.btn-outline.danger { color: var(--danger); border-color: #fecdd3; }
.btn-outline.danger:hover { background: #fff1f2; }
.btn-ghost { border-radius: 8px; padding: 6px 10px; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg); }
.small { padding: 4px 10px !important; font-size: 12px; }
.danger-bg { background: var(--danger); box-shadow: none; }
.danger-bg:hover:not(:disabled) { background: #be123c; }
.danger-text { color: var(--danger) !important; }
.icon-btn { width: 34px; height: 34px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.icon-btn:hover { background: var(--bg); color: var(--text); }

/* ---------- 头像 ---------- */
.avatar { width: 38px; height: 38px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 15px; position: relative; background: var(--muted-2); }
.avatar.lg { width: 64px; height: 64px; font-size: 24px; }
.avatar .ch-badge { position: absolute; right: -3px; bottom: -3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 2px #fff; }
.avatar .ch-badge svg { width: 12px; height: 12px; }
.avatar .ch-badge.tg { background: var(--tg); color: #fff; }
.avatar .ch-badge.web { background: var(--brand); color: #fff; }

/* ---------- 登录 ---------- */
.login { height: 100%; display: flex; }
.login-brand { flex: 1; background: radial-gradient(circle at 20% 20%, #6366f1 0, transparent 45%), radial-gradient(circle at 80% 70%, #0ea5e9 0, transparent 40%), #111827; color: #fff; display: flex; flex-direction: column; justify-content: center; padding: 8vw; }
.login-brand h2 { font-size: 34px; margin: 18px 0 8px; letter-spacing: -.02em; }
.login-brand p { color: #cbd5e1; font-size: 16px; max-width: 420px; margin: 0; }
.brand-mark { width: 56px; height: 56px; border-radius: 16px; background: rgba(255,255,255,.12); display: flex; align-items: center; justify-content: center; backdrop-filter: blur(6px); }
.brand-mark svg { width: 28px; height: 28px; }
.login-side { width: 480px; max-width: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--panel); }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 16px; }
.login-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.login-card h1 { margin: 0; font-size: 24px; letter-spacing: -.01em; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.login-card input { padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; outline: none; transition: border-color .15s, box-shadow .15s; }
.login-card input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.login-card .btn-primary { justify-content: center; padding: 11px; font-size: 15px; }
.ui-lang { border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; font-size: 12px; background: var(--panel); cursor: pointer; }
@media (max-width: 860px) { .login-brand { display: none; } .login-side { width: 100%; } }

/* ---------- 布局 ---------- */
.main { display: flex; height: 100%; }
.rail { width: 64px; flex: none; background: var(--rail); display: flex; flex-direction: column; align-items: center; padding: 14px 0; gap: 6px; position: relative; z-index: 15; }
.rail-logo { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, #6366f1, #0ea5e9); color: #fff; display: flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.rail-logo svg { width: 20px; height: 20px; }
.rail-btn { width: 42px; height: 42px; border-radius: 11px; color: #9ca3af; display: flex; align-items: center; justify-content: center; position: relative; transition: background .15s, color .15s; }
.rail-btn svg { width: 21px; height: 21px; }
.rail-btn:hover { background: var(--rail-2); color: #fff; }
.rail-btn.active { background: rgba(99, 102, 241, .22); color: #fff; }
.rail-btn b { position: absolute; top: 4px; right: 3px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--danger); color: #fff; font-size: 10px; line-height: 16px; padding: 0 4px; }
.rail-btn b:empty { display: none; }
.rail-spacer { flex: 1; }
.rail-avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, #f59e0b, #ef4444); color: #fff; font-weight: 700; position: relative; display: flex; align-items: center; justify-content: center; }
.rail-avatar .presence { position: absolute; right: 0; bottom: 0; width: 11px; height: 11px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 2px var(--rail); }
.me-menu { position: absolute; left: 70px; bottom: 12px; width: 250px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px 0; z-index: 40; }
.menu-head { padding: 10px 14px 12px; border-bottom: 1px solid var(--line-2); margin-bottom: 4px; }
.menu-head .me-name { font-weight: 700; }
.me-role { font-size: 12px; color: var(--muted); }
.menu-row { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 14px; font-size: 14px; cursor: pointer; color: var(--text-2); }
.menu-row:hover { background: var(--bg); }
.menu-val { color: var(--muted); font-size: 13px; }

/* ---------- 会话列表 ---------- */
.side { width: 330px; flex: none; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 10px; }
.side-head h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.online-chip { font-size: 12px; color: #047857; background: #ecfdf5; padding: 3px 9px; border-radius: 999px; max-width: 170px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-wrap { margin: 0 14px 10px; position: relative; }
.search-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted-2); width: 16px; height: 16px; }
.search { width: 100%; padding: 9px 12px 9px 34px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); outline: none; transition: border-color .15s, background .15s; }
.search:focus { border-color: var(--brand); background: #fff; }
.tabs { display: flex; gap: 2px; padding: 0 12px 10px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { padding: 6px 10px; border-radius: 8px; color: var(--muted); font-size: 13px; font-weight: 500; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
.tabs button:hover { color: var(--text); background: var(--bg); }
.tabs button.active { background: var(--brand-50); color: var(--brand); font-weight: 600; }
.tabs b { background: var(--danger); color: #fff; border-radius: 9px; padding: 0 6px; font-size: 11px; line-height: 17px; }
.tabs b:empty { display: none; }
.conv-list { flex: 1; overflow-y: auto; padding: 6px 8px; }
.conv { display: flex; gap: 11px; padding: 11px 10px; border-radius: 10px; cursor: pointer; transition: background .12s; position: relative; }
.conv:hover { background: #f8fafc; }
.conv.active { background: var(--brand-50); }
.conv.active::before { content: ''; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 3px; background: var(--brand); }
.conv-main { flex: 1; min-width: 0; }
.conv-top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.conv-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { font-size: 11px; color: var(--muted-2); flex: none; }
.conv-last { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.conv.unread-row .conv-last { color: var(--text); font-weight: 500; }
.conv-tags { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: #f1f5f9; color: var(--muted); font-weight: 500; }
.tag.waiting { background: #fef3c7; color: #92400e; }
.tag.open { background: #dcfce7; color: #166534; }
.tag.closed { background: #f1f5f9; color: var(--muted); }
.tag.ok { background: #dbeafe; color: #1e40af; }
.tag.lang { background: #f3e8ff; color: #6b21a8; }
.tag.tg { background: #e0f2fe; color: #0369a1; }
.unread { align-self: center; background: var(--danger); color: #fff; border-radius: 10px; min-width: 20px; height: 20px; line-height: 20px; text-align: center; font-size: 11px; font-weight: 600; padding: 0 6px; }
.list-empty { padding: 50px 20px; text-align: center; color: var(--muted-2); }

/* ---------- 聊天 ---------- */
.chat { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.empty { margin: auto; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty-icon { width: 64px; height: 64px; border-radius: 20px; background: var(--brand-50); color: var(--brand); display: flex; align-items: center; justify-content: center; }
.empty-icon svg { width: 30px; height: 30px; }
.chat-inner { display: flex; flex-direction: column; height: 100%; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 18px; background: var(--panel); border-bottom: 1px solid var(--line); }
.chat-head .who { flex: 1; min-width: 0; }
.who-name { font-weight: 700; font-size: 15px; }
.who-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head-actions { display: flex; align-items: center; gap: 8px; }
.back { display: none; font-size: 22px; }
.lang-hint { background: #fffbeb; color: #92400e; font-size: 12px; padding: 6px 18px; border-bottom: 1px solid #fde68a; }
.lang-hint:empty { display: none; }
.msgs { flex: 1; overflow-y: auto; padding: 22px 24px; display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; flex-direction: column; max-width: 68%; }
.row.member { align-self: flex-start; align-items: flex-start; }
.row.agent { align-self: flex-end; align-items: flex-end; }
.row.system { align-self: center; max-width: 90%; }
.meta { font-size: 11px; color: var(--muted-2); margin: 0 6px 3px; }
.bubble { padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; word-break: break-word; background: var(--panel); box-shadow: var(--shadow-sm); line-height: 1.55; }
.member .bubble { border-top-left-radius: 4px; }
.agent .bubble { background: var(--brand); color: #fff; border-top-right-radius: 4px; box-shadow: 0 2px 6px rgba(79, 70, 229, .25); }
.agent.auto .bubble { background: #eef2ff; color: #3730a3; box-shadow: none; border: 1px dashed #c7d2fe; }
.system .bubble { background: #e9ebf2; color: var(--muted); font-size: 12px; box-shadow: none; padding: 4px 12px; border-radius: 999px; }
.bubble img { display: block; max-width: 260px; max-height: 300px; border-radius: 10px; cursor: zoom-in; }
.bubble.img { padding: 4px; background: var(--panel); }
.row.failed .bubble { background: #fff1f2; color: var(--danger); border: 1px solid #fecdd3; box-shadow: none; }
.fail-note { font-size: 11px; color: var(--danger); margin: 3px 6px 0; }

/* 输入区 */
.composer { padding: 12px 18px 16px; position: relative; }
.composer-box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s; }
.composer-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.composer textarea { width: 100%; height: 78px; resize: none; border: none; outline: none; padding: 12px 14px 4px; background: transparent; border-radius: 14px; }
.composer-bar { display: flex; align-items: center; gap: 4px; padding: 6px 8px 8px; }
.tool-btn { display: inline-flex; align-items: center; gap: 5px; padding: 6px 9px; border-radius: 8px; color: var(--muted); font-size: 13px; }
.tool-btn:hover { background: var(--bg); color: var(--text); }
.tool-btn svg { width: 16px; height: 16px; }
.send-btn svg { width: 15px; height: 15px; }
.composer .err { margin-right: 8px; max-width: 50%; text-align: right; }
.quick { position: absolute; bottom: calc(100% - 6px); left: 18px; right: 18px; max-height: 420px; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); z-index: 5; }
.quick .quick-search { position: sticky; top: 0; width: 100%; border: none; border-bottom: 1px solid var(--line); padding: 11px 14px; outline: none; background: var(--panel); z-index: 1; }
.quick .quick-group { padding: 8px 14px 4px; font-size: 11px; font-weight: 700; color: var(--muted-2); text-transform: uppercase; letter-spacing: .04em; }
.quick .quick-item { display: flex; flex-direction: column; gap: 2px; padding: 8px 14px; cursor: pointer; }
.quick .quick-item:hover { background: var(--brand-50); }
.quick .quick-item b { font-size: 13px; font-weight: 600; }
.quick .quick-item span { font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- 资料栏 ---------- */
.info { width: 300px; flex: none; background: var(--bg); border-left: 1px solid var(--line); padding: 16px; overflow-y: auto; position: relative; }
.info-close { position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; border-radius: 8px; color: var(--muted); font-size: 22px; line-height: 28px; z-index: 1; }
.info-close:hover { background: var(--line-2); color: var(--text); }
.info-profile { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 14px 0 18px; }
.info-name { font-weight: 700; font-size: 16px; word-break: break-all; }
.info-sub { font-size: 12px; color: var(--muted); }
.card { background: var(--panel); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); margin-bottom: 12px; }
.card h3 { font-size: 13px; margin: 0 0 10px; color: var(--text); }
.info dl { margin: 0; display: grid; grid-template-columns: 78px 1fr; gap: 8px 10px; font-size: 13px; }
.info dt { color: var(--muted); }
.info dd { margin: 0; word-break: break-all; color: var(--text-2); }
.info-head { display: flex; align-items: center; justify-content: space-between; }
.info-head h3 { display: flex; align-items: center; gap: 6px; margin: 0; }
.lookup { display: flex; gap: 6px; margin: 10px 0; }
.lookup input { flex: 1; min-width: 0; padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.pf-state { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.pf-state.warn { color: #92400e; background: #fef3c7; padding: 6px 8px; border-radius: 8px; }
.pf-state.bad { color: var(--danger); }
#pfList dd { white-space: pre-wrap; word-break: break-word; }
#pfList dd.hl { font-weight: 700; color: #047857; }
#pfList dd.note { color: #b45309; font-weight: 600; }
.admin-btn { width: 100%; margin: 8px 0 6px; padding: 9px; font-weight: 600; background: var(--brand); color: #fff; border-radius: 8px; }
.admin-tip { font-size: 12px; color: #047857; margin-bottom: 8px; }
.admin-tip:empty { display: none; }

.viewer { position: fixed; inset: 0; background: rgba(15, 23, 42, .88); display: none; align-items: center; justify-content: center; z-index: 50; cursor: zoom-out; }
.viewer img { max-width: 95%; max-height: 95%; border-radius: 8px; }

/* ---------- 弹窗（团队 / 渠道） ---------- */
.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); backdrop-filter: blur(2px); z-index: 45; display: flex; align-items: flex-start; justify-content: center; padding: 7vh 16px 16px; }
.modal-card { background: var(--panel); border-radius: 16px; width: 100%; max-width: 780px; max-height: 86vh; overflow: auto; padding: 22px 24px; position: relative; box-shadow: var(--shadow-lg); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.modal-head h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.modal-sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.modal-head .info-close { position: static; }
.team-add { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.team-add input, .team-add select { padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; flex: 1; min-width: 150px; outline: none; }
.team-add input:focus, .team-add select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.team-add select { flex: 0 0 auto; min-width: 110px; }
.team-msg { background: #ecfdf5; border: 1px solid #a7f3d0; border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; font-size: 13px; }
.team-pw { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.team-pw code { font-size: 17px; font-weight: 700; background: #fff; padding: 5px 12px; border-radius: 8px; user-select: all; letter-spacing: .04em; border: 1px solid #a7f3d0; }
.team-note { color: #047857; font-size: 12px; }
.team-err { margin-bottom: 8px; }
.team-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.team-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.team-table th, .team-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.team-table tr:last-child td { border-bottom: none; }
.team-table th { color: var(--muted); font-weight: 600; background: #f8fafc; font-size: 12px; }
.team-table select { padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; }
.team-table .ops { display: flex; gap: 2px; }
.team-table .ops button { padding: 4px 8px; border-radius: 6px; font-size: 12px; color: var(--text-2); }
.team-table .ops button:hover { background: var(--bg); }
.st-on { color: #059669; font-weight: 500; }
.st-off { color: var(--muted-2); }

/* 渠道 */
.ch-section { border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.ch-title { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 15px; }
.ch-icon { width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center; justify-content: center; color: #fff; }
.ch-icon.tg { background: var(--tg); }
.ch-warn { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; font-size: 13px; }
.ch-warn-actions { display: flex; gap: 8px; margin-top: 10px; }
.ch-list { display: flex; flex-direction: column; gap: 8px; }
.ch-item { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line-2); border-radius: 10px; background: #fafbfc; }
.ch-item .ch-meta { flex: 1; min-width: 0; }
.ch-item .ch-name { font-weight: 600; }
.ch-item .ch-state { font-size: 12px; color: var(--muted); }
.ch-item .ch-state.running { color: #059669; }
.ch-item .ch-state.error { color: var(--danger); }
.ch-empty { color: var(--muted-2); font-size: 13px; padding: 8px 2px; }

/* ---------- 窄屏 ---------- */
@media (max-width: 1100px) {
  .info { position: fixed; right: 0; top: 0; bottom: 0; z-index: 20; box-shadow: -10px 0 30px rgba(15,23,42,.12); background: var(--bg); }
}
@media (max-width: 760px) {
  .rail { width: 56px; }
  .side { width: 100%; }
  .main.in-chat .side { display: none; }
  .main:not(.in-chat) .chat { display: none; }
  .back { display: inline-flex; }
  .row { max-width: 86%; }
  .head-actions .btn-outline { padding: 6px 8px; }
  .msgs { padding: 16px 12px; }
}

/* 渠道页：左边渠道类型，右边机器人列表 */
.modal-card.wide { max-width: 1000px; }
.ch-layout { display: flex; gap: 16px; min-height: 360px; }
.ch-nav { width: 220px; flex: none; background: #f8fafc; border-radius: 12px; padding: 10px; }
.ch-nav-title { font-size: 12px; color: var(--muted); padding: 6px 8px; }
.ch-nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-radius: 9px; font-size: 14px; color: var(--text-2); }
.ch-nav-item span:nth-child(2) { flex: 1; }
.ch-nav-item b { font-size: 12px; background: #dcfce7; color: #166534; border-radius: 999px; padding: 0 8px; }
.ch-nav-item.active { background: var(--brand-50); color: var(--brand); font-weight: 600; }
.ch-nav-item.soon { opacity: .55; }
.ch-nav-item i { font-style: normal; font-size: 11px; color: var(--muted); }
.ch-nav-item .ch-icon { width: 26px; height: 26px; border-radius: 50%; font-size: 12px; font-weight: 700; }
.ch-nav-item .ch-icon svg { width: 14px; height: 14px; }
.ch-icon.web { background: var(--brand); }
.ch-icon.wa { background: #25d366; }
.ch-main { flex: 1; min-width: 0; }
.ch-main-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.ch-main-head h3 { margin: 0; font-size: 17px; }
.ch-search { margin: 0; width: 240px; }
.ch-table td { vertical-align: middle; }
.ch-table .bot-name { font-weight: 600; }
.ch-table .bot-user { font-size: 12px; color: var(--muted); }
.status-pill { display: inline-block; font-size: 12px; padding: 3px 9px; border-radius: 6px; }
.status-pill.running { background: #dcfce7; color: #166534; }
.status-pill.starting { background: #e0e7ff; color: #3730a3; }
.status-pill.error { background: #ffe4e6; color: #be123c; white-space: normal; max-width: 260px; }
.status-pill.stopped { background: #f1f5f9; color: var(--muted); }
/* 开关 */
.switch { position: relative; width: 40px; height: 22px; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #cbd5e1; border-radius: 999px; transition: background .15s; cursor: pointer; }
.switch span::before { content: ''; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::before { transform: translateX(18px); }
@media (max-width: 760px) { .ch-layout { flex-direction: column; } .ch-nav { width: auto; } .ch-search { width: 100%; } .ch-main-head { flex-wrap: wrap; } }

/* 开坐席后：网址 + 账号 + 密码 */
.team-cred { margin: 10px 0; padding: 12px 14px; background: #fff; border: 1px solid #a7f3d0; border-radius: 10px; font: 14px/1.7 ui-monospace, Consolas, "Microsoft YaHei", monospace; white-space: pre-wrap; word-break: break-all; user-select: all; color: var(--text); }
.team-msg .btn-primary { margin-bottom: 8px; }

.team-table .ops button.copy-btn { color: var(--brand); font-weight: 600; }
.team-table .ops button.copy-btn:hover { background: var(--brand-50); }

/* 刚开好 / 刚重置的坐席：高亮那一行 */
.team-err.ok-note { color: #047857; background: #ecfdf5; border: 1px solid #a7f3d0; border-radius: 10px; padding: 9px 12px; font-size: 13px; }
.team-err:empty { display: none; }
.team-table tr.just-made td { background: #ecfdf5; }
.team-table tr.just-made .copy-btn { background: var(--brand); color: #fff !important; }

/* 小弹窗：登录信息 */
.modal-card.narrow { max-width: 460px; }
.cred-text { width: 100%; resize: none; border: 1px solid #a7f3d0; background: #f0fdf4; border-radius: 10px; padding: 12px 14px; font: 14px/1.7 ui-monospace, Consolas, "Microsoft YaHei", monospace; color: var(--text); outline: none; }
.cred-actions { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.cred-state { font-size: 13px; }
.cred-state.ok { color: #047857; font-weight: 600; }
.cred-state.warn { color: #b45309; font-weight: 600; }

/* 网页内确认框 */
.ask-modal { z-index: 60; align-items: center; padding-top: 16px; }
.ask-msg { font-size: 15px; line-height: 1.6; white-space: pre-line; color: var(--text); margin: 4px 0 14px; }
.ask-input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; outline: none; margin-bottom: 14px; }
.ask-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.ask-actions { display: flex; justify-content: flex-end; gap: 8px; }
.ask-actions button { padding: 8px 16px; }

/* 平台 */
.pf-filter-wrap { padding: 0 14px 10px; }
.pf-filter { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); font-size: 13px; cursor: pointer; }
.tag.pf { background: #fff7ed; color: #c2410c; }
.pf-checks { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; width: 100%; font-size: 13px; color: var(--text-2); }
.pf-checks b { font-weight: 500; color: var(--muted); }
.pf-checks label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.pf-checks input { width: 15px; height: 15px; accent-color: var(--brand); }
.ask-checks { margin-bottom: 14px; padding: 10px 12px; background: #f8fafc; border-radius: 10px; }
.pf-link { font-size: 12px; background: #f1f5f9; padding: 3px 7px; border-radius: 6px; margin-right: 6px; user-select: all; }
.copy-btn.small { color: var(--brand); font-weight: 600; padding: 3px 8px; border-radius: 6px; }
.copy-btn.small:hover { background: var(--brand-50); }
.pf-cell { white-space: normal !important; max-width: 220px; }
.link-btn { color: var(--brand); font-size: 12px; margin-left: 6px; padding: 0; }
.link-btn:hover { text-decoration: underline; }
.mini-select { padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; background: var(--panel); }
.team-add .pf-checks input, .ask-checks input { flex: none !important; min-width: 0 !important; width: 15px; height: 15px; padding: 0 !important; margin: 0; box-shadow: none !important; }
.team-add .pf-checks { flex-basis: 100%; padding: 2px 2px 0; }
.team-add .pf-checks label { gap: 6px; }

.tag.nopf { background: #f1f5f9; color: #94a3b8; border: 1px dashed #cbd5e1; }

/* 左侧导航栏：平台按钮 */
.rail-pfs { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; overflow-y: auto; max-height: 50vh; padding: 2px 0; }
.rail-sep { width: 28px; height: 1px; background: #374151; margin: 4px 0; }
.rail-pf { position: relative; width: 48px; min-height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center; padding: 4px 3px; color: #d1d5db; background: transparent; border: 1px solid #374151; transition: background .15s, color .15s, border-color .15s; }
.rail-pf span { font-size: 10px; font-weight: 700; line-height: 1.2; word-break: break-all; text-align: center; }
.rail-pf::before { content: ''; position: absolute; left: -9px; top: 50%; width: 4px; height: 0; border-radius: 0 3px 3px 0; background: var(--pf); transform: translateY(-50%); transition: height .15s; }
.rail-pf:hover { background: var(--rail-2); color: #fff; border-color: var(--pf); }
.rail-pf.active { background: var(--pf); color: #fff; border-color: var(--pf); }
.rail-pf.active::before { height: 24px; }
.rail-pf b { position: absolute; top: -6px; right: -6px; min-width: 17px; height: 17px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 10px; line-height: 17px; padding: 0 4px; box-shadow: 0 0 0 2px var(--rail); }
.rail-pf b:empty { display: none; }
.rail-pfs { padding: 8px 0; }
.rail-pf::before { left: -8px; }
.rail-pfs { overflow-x: hidden; scrollbar-width: none; }
.rail-pfs::-webkit-scrollbar { display: none; }
.ch-pf-select { padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); min-width: 170px; cursor: pointer; }

/* 翻译：会员消息下的中文翻译、客服消息下的原文 */
.msg-note { font-size: 12px; line-height: 1.5; margin: 4px 6px 0; padding: 5px 9px; border-radius: 10px; max-width: 100%; white-space: pre-wrap; word-break: break-word; }
.msg-note.tr { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.msg-note.orig { background: #f1f5f9; color: var(--muted); }

/* 机器人 / 自动回复 */
.tag.bot { background: #ede9fe; color: #6d28d9; }
.tabs b.soft { background: #ede9fe; color: #6d28d9; }
.auto-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.auto-off { background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; border-radius: 10px; padding: 8px 12px; font-size: 13px; margin-bottom: 10px; }
.auto-edit { display: flex; flex-direction: column; gap: 8px; background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.auto-edit input, .auto-edit textarea { padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; font: inherit; outline: none; resize: vertical; }
.auto-edit input:focus, .auto-edit textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.auto-edit-actions { display: flex; justify-content: flex-end; gap: 8px; }
.auto-list { display: flex; flex-direction: column; gap: 10px; }
.auto-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--panel); }
.auto-card.off { opacity: .55; }
.auto-card-head { display: flex; align-items: center; gap: 10px; }
.auto-card-head .link-btn { font-size: 13px; margin-left: 8px; }
.auto-kws { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0; }
.kw { font-size: 12px; background: #eef2ff; color: #3730a3; border-radius: 999px; padding: 1px 9px; }
.auto-reply { font-size: 12px; color: var(--muted); white-space: pre-wrap; line-height: 1.5; background: #f8fafc; border-radius: 8px; padding: 8px 10px; }
.dolphin { font-size: 22px; line-height: 1; }
.brand-mark.dolphin { font-size: 30px; }

/* 评分 */
.tag.rate { background: #fef3c7; color: #b45309; }
.row.rating-row .bubble { background: #fef3c7; color: #92400e; font-weight: 600; }
.rate-cell { color: #b45309; font-weight: 600; }

/* 报表 */
.rp-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.rp-ranges { display: flex; gap: 4px; background: #f1f5f9; padding: 3px; border-radius: 10px; }
.rp-ranges button { padding: 6px 12px; border-radius: 8px; color: var(--muted); font-size: 13px; font-weight: 500; }
.rp-ranges button.active { background: var(--panel); color: var(--brand); box-shadow: var(--shadow-sm); font-weight: 600; }
.rp-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 18px; }
.rp-card { background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.rp-card.accent { background: var(--brand-50); border-color: var(--brand-100); }
.rp-num { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.rp-card.accent .rp-num { color: var(--brand); }
.rp-label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.rp-h { font-size: 14px; margin: 18px 0 8px; }
.rp-table td:not(:first-child), .rp-table th:not(:first-child) { text-align: right; }
.rp-foot { margin-top: 12px; }




/* 群发 */
.bc-form { display: grid; gap: 10px; }
.bc-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bc-label { font-size: 13px; color: #475569; min-width: 40px; }
.bc-row select { border: 1px solid #cbd5e1; border-radius: 8px; padding: 7px 10px; font: inherit; font-size: 13px; background: #fff; }
#bcText { width: 100%; box-sizing: border-box; border: 1px solid #cbd5e1; border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 14px; resize: vertical; min-height: 90px; }
.bc-actions { display: flex; align-items: center; gap: 10px; }
.bc-actions .flex { flex: 1; }
.bc-count { font-size: 13px; color: #4f46e5; font-weight: 600; }
.bc-h { margin: 18px 0 8px; font-size: 14px; }
.bc-msg { max-width: 360px; white-space: pre-wrap; word-break: break-word; }
.bc-img { position: relative; display: inline-block; width: max-content; }
.bc-img img { max-width: 220px; max-height: 160px; border-radius: 10px; border: 1px solid #e2e8f0; display: block; }
.bc-img button { position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; border-radius: 50%; border: none; background: #0f172a; color: #fff; cursor: pointer; line-height: 22px; padding: 0; }
.bc-thumb { max-width: 80px; max-height: 60px; border-radius: 6px; display: block; margin-bottom: 4px; }

/* WhatsApp / Facebook / Instagram */
.ch-icon.fb { background: #1877f2; font-weight: 700; }
.ch-icon.ig { background: linear-gradient(45deg, #f58529, #dd2a7b, #8134af); font-weight: 700; font-size: 10px; }
.ch-tab { cursor: pointer; }
.ch-tab:hover:not(.active) { background: #f1f5f9; }
.avatar .ch-badge.wa, .avatar .ch-badge.fb, .avatar .ch-badge.ig { color: #fff; font-size: 9px; font-weight: 800; line-height: 1; }
.avatar .ch-badge.wa { background: #25d366; }
.avatar .ch-badge.fb { background: #1877f2; }
.avatar .ch-badge.ig { background: linear-gradient(45deg, #f58529, #dd2a7b, #8134af); font-size: 7px; }
.meta-hook { border: 1px solid #e2e8f0; background: #f8fafc; border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 13px; display: grid; gap: 6px; }
.meta-hook-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.meta-hook-row > span { color: #475569; min-width: 90px; }
.meta-hook-row code { background: #fff; border: 1px solid #e2e8f0; border-radius: 6px; padding: 3px 8px; font-size: 12px; word-break: break-all; }
.meta-help { margin: 2px 0 0; color: #64748b; font-size: 12px; line-height: 1.6; }

/* AI 学习 */
.ai-tabs { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.ai-tabs .flex { flex: 1; }
.ai-tab { border: none; background: #f1f5f9; color: #475569; border-radius: 999px; padding: 7px 14px; font: inherit; font-size: 13px; cursor: pointer; }
.ai-tab.active { background: var(--brand-50, #eef2ff); color: var(--brand, #4f46e5); font-weight: 600; }
.ai-edit { border: 1px solid #e2e8f0; background: #f8fafc; border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; display: grid; gap: 10px; }
.ai-edit h3 { margin: 0; font-size: 15px; }
.ai-edit label { display: grid; gap: 4px; font-size: 12px; color: #475569; }
.ai-edit input, .ai-edit textarea { border: 1px solid #cbd5e1; border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 13px; background: #fff; resize: vertical; }
.ai-zh { display: flex; gap: 8px; align-items: flex-end; }
.ai-zh label { flex: 1; }
.ai-edit-actions { display: flex; align-items: center; gap: 8px; }
.ai-edit-actions .flex { flex: 1; }
.ai-test { font-size: 12px; color: #64748b; }
.ai-miss-text { max-width: 420px; white-space: pre-wrap; word-break: break-word; }
.ai-kws { max-width: 280px; }
.ai-kws .kw { display: inline-block; background: #eef2ff; color: #4338ca; border-radius: 6px; padding: 1px 6px; margin: 2px; font-size: 12px; }
.ai-kws .kw.more { background: #f1f5f9; color: #64748b; }
.ai-reply { max-width: 320px; font-size: 12px; color: #334155; white-space: pre-wrap; word-break: break-word; }
.ai-search { margin-bottom: 8px; max-width: 320px; }
.teach-btn { align-self: flex-end; border: none; background: none; color: #6366f1; font-size: 11px; cursor: pointer; padding: 2px 4px; opacity: .7; }
.teach-btn:hover { opacity: 1; text-decoration: underline; }
.ai-filter { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.ai-filter .ai-search { margin-bottom: 0; flex: 1; }
.ai-filter select, .ai-edit select { border: 1px solid #cbd5e1; border-radius: 8px; padding: 7px 10px; font: inherit; font-size: 13px; background: #fff; }
/* 规则表：关键词和回复要换行，不然会叠在一起 */
.team-table td.ai-kws, .team-table td.ai-reply, .team-table td.ai-miss-text { white-space: normal; vertical-align: top; }
.ai-kws { min-width: 200px; }
.ai-reply { min-width: 240px; }
/* 平台：会员查询接口 */
.pf-api { margin-top: 14px; border-top: 1px solid #e2e8f0; padding-top: 12px; }
.pf-api h3 { margin: 0 0 8px; font-size: 14px; }
.pf-api-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pf-api-row select, .pf-api-row input { border: 1px solid #cbd5e1; border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 13px; background: #fff; }
.pf-api-row input { flex: 1; min-width: 200px; }
/* AI 大模型设置 */
.llm-pane { display: grid; gap: 10px; }
.llm-pane label { display: grid; gap: 4px; font-size: 12px; color: #475569; }
.llm-pane label.llm-on { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #0f172a; font-weight: 600; }
.llm-pane label.llm-on.llm-sub { font-weight: 400; font-size: 13px; color: #334155; }
.llm-today { font-size: 13px; color: #475569; }
.llm-pf { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 4px; }
.llm-pf .over { color: #b91c1c; font-weight: 600; }
.llm-pane input[type=password], .llm-pane input[type=number], .llm-pane select { border: 1px solid #cbd5e1; border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 13px; background: #fff; max-width: 520px; }
.llm-pane h3 { margin: 8px 0 0; font-size: 14px; }

/* 请发送我的错误（11-28） */
.rpt-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.rpt-form textarea { width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid var(--line, #e5e7eb); border-radius: 10px; font: inherit; resize: vertical; }
.rpt-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rpt-row input[type=text], .rpt-row input:not([type]), .rpt-row select { padding: 6px 10px; border: 1px solid var(--line, #e5e7eb); border-radius: 8px; font: inherit; }
.rpt-h { margin: 14px 0 8px; font-size: 14px; }

.rpt-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.rpt-thumb { position: relative; display: inline-block; }
.rpt-thumb img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line, #e5e7eb); }
.rpt-thumb button { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; border: none; background: #ef4444; color: #fff; cursor: pointer; line-height: 20px; padding: 0; }
.rpt-add { cursor: pointer; }

/* 11-28：功能入口移到个人菜单，左边栏只留会话和平台 */
#broadcastBtn, #reportBtn, #platformsBtn, #autoBtn, #teamBtn, #channelsBtn, #railSep { display: none !important; }
.menu-feats { border-top: 1px solid var(--line, #e5e7eb); border-bottom: 1px solid var(--line, #e5e7eb); margin: 4px 0; padding: 4px 0; }
.menu-feats:empty { display: none; }

