* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --green: #00a884;
  --green-dark: #008069;
  --bg: #f0f2f5;
  --panel: #ffffff;
  --text: #111b21;
  --text2: #667781;
  --border: #e9edef;
  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;
}
html, body { height: 100%; font-family: "Segoe UI", "Microsoft YaHei", sans-serif; color: var(--text); background: var(--bg); }
.hidden { display: none !important; }

#app { display: flex; height: 100vh; }

/* ---------- 左侧 ---------- */
#sidebar { width: 340px; min-width: 280px; background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.side-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { width: 38px; height: 38px; border-radius: 50%; background: var(--green); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.brand-name { font-weight: 600; font-size: 15px; }
.conn { font-size: 12px; color: var(--text2); }
.conn.online::before { content: "●"; color: var(--green); margin-right: 4px; }
.icon-btn { border: none; background: none; font-size: 18px; cursor: pointer; color: var(--text2); padding: 6px; border-radius: 6px; }
.icon-btn:hover { background: var(--bg); }
.side-actions { display: flex; align-items: center; gap: 2px; }
#repair-btn { background: #fff5e6; }
#repair-btn:hover { background: #ffe8c7; }
.media-pending { font-size: 13px; color: var(--text2); background: var(--bg); border-radius: 8px; padding: 10px 14px; display: inline-block; }
.search-box { padding: 8px 12px; }
#search { width: 100%; padding: 8px 12px; border-radius: 8px; border: none; background: var(--bg); font-size: 13px; outline: none; }
#chat-list { flex: 1; overflow-y: auto; list-style: none; }
.chat-item { display: flex; gap: 12px; padding: 12px 14px; cursor: pointer; align-items: center; }
.chat-item:hover { background: var(--bg); }
.chat-item.active { background: #e7f8f2; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: #dfe5e7; color: #54656f; display: flex; align-items: center; justify-content: center; font-size: 17px; font-weight: 600; flex-shrink: 0; position: relative; overflow: hidden; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .18s; }
.avatar img.on { opacity: 1; }
.ci-main { flex: 1; min-width: 0; }
.ci-top { display: flex; justify-content: space-between; }
.ci-name { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 群聊标记：小方块"群"，让群会话和一对一一眼区分 */
.grp-badge {
  display: inline-block; vertical-align: 1px;
  font-size: 10px; line-height: 1; font-weight: 600;
  color: #fff; background: var(--green-dark, #008069);
  border-radius: 3px; padding: 2px 3px; margin-right: 4px;
}
.ci-time { font-size: 11px; color: var(--text2); }
.ci-bottom { display: flex; justify-content: space-between; align-items: center; }
.ci-last { font-size: 12.5px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.ci-unread { background: var(--green); color: #fff; font-size: 11px; border-radius: 10px; min-width: 18px; height: 18px; line-height: 18px; text-align: center; padding: 0 5px; }
.no-chat { padding: 40px 20px; text-align: center; color: var(--text2); font-size: 13px; }
/* 「通讯录 · N 位未聊过」分组头：默认折叠，点一下展开 */
.sec-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 14px; cursor: pointer; user-select: none;
  font-size: 12px; color: var(--text2); background: var(--bg);
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.sec-head:hover { color: var(--text); }
.sec-toggle { color: var(--green, #00a884); font-weight: 600; }

/* ---------- 筛选栏 ---------- */
.filters { display: flex; gap: 6px; padding: 0 12px 8px; align-items: center; }
.filters select { flex: 1; min-width: 0; font-size: 12px; padding: 5px 6px; border-radius: 6px; border: 1px solid var(--border); background: #fff; color: var(--text); outline: none; }
.filters select:focus { border-color: var(--green); }
.chk { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text2); white-space: nowrap; cursor: pointer; }
.chk input { accent-color: var(--green); }
.filters-sub { padding-top: 0; gap: 14px; }
.pend-count { font-size: 11px; background: #fdecea; color: #c0392b; border-radius: 9px; padding: 1px 7px; font-weight: 600; }

/* ---------- v2-3：待回复标红 / 数据看板 ---------- */
.pend-badge { font-size: 10px; padding: 1px 6px; border-radius: 8px; background: #fdecea; color: #c0392b; font-weight: 600; line-height: 15px; }
.pend-badge.warn { background: #fff4e5; color: #b26a00; }
.dash-modal { width: min(680px, 94vw); }
.kpi-grid { display: flex; gap: 8px; margin-bottom: 14px; }
.kpi { flex: 1; background: var(--bg); border-radius: 10px; padding: 10px 8px; text-align: center; }
.kpi b { display: block; font-size: 20px; line-height: 1.3; }
.kpi span { font-size: 11px; color: var(--text2); }
.kpi.alert b { color: #c0392b; }
.dash-sec { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }
.dash-sec:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.dash-h { font-size: 13px; font-weight: 600; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; }
.dash-h em { font-style: normal; font-size: 11px; color: var(--text2); font-weight: 400; }
.chart { display: flex; align-items: flex-end; gap: 4px; }
.cbar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.cbars { display: flex; align-items: flex-end; gap: 2px; height: 86px; width: 100%; justify-content: center; }
.cbars i { width: 7px; border-radius: 2px 2px 0 0; display: block; min-height: 2px; }
.cbars .bi { background: var(--green); }
.cbars .bo { background: #a9c7d6; }
.cbar > span { font-size: 9.5px; color: var(--text2); white-space: nowrap; transform: scale(.92); }
.legend { display: flex; gap: 12px; font-size: 11px; color: var(--text2); margin-bottom: 8px; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; }
.metric-row { display: flex; gap: 8px; }
.metric { flex: 1; background: var(--bg); border-radius: 10px; padding: 10px; text-align: center; }
.metric b { display: block; font-size: 17px; }
.metric span { font-size: 11px; color: var(--text2); }
.rank-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; margin-bottom: 6px; }
.rank-row .rn { width: 74px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-track { flex: 1; height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.rank-fill { height: 100%; background: var(--green); border-radius: 4px; }
.rank-row .rv { width: 28px; text-align: right; color: var(--text2); }
.pend-item { display: flex; gap: 10px; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--border); cursor: pointer; }
.pend-item:last-child { border-bottom: none; }
.pend-item:hover { background: var(--bg); }
.pend-main { flex: 1; min-width: 0; }
.pend-name { font-size: 13px; font-weight: 500; }
.pend-prev { font-size: 11.5px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pend-wait { font-size: 11px; color: #c0392b; font-weight: 600; white-space: nowrap; }
.pend-wait.ok { color: var(--text2); font-weight: 400; }
.rem-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12.5px; padding: 7px 0; }
.rem-row input[type="number"] { width: 62px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; outline: none; }
.rem-tip { font-size: 11.5px; color: var(--text2); line-height: 1.6; margin-top: 4px; }

/* 会话列表里的标签小点 */
.ci-tags { display: flex; gap: 3px; margin-top: 3px; flex-wrap: wrap; }
.tag-dot { font-size: 10px; padding: 1px 6px; border-radius: 8px; color: #fff; line-height: 15px; max-width: 86px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-badge { font-size: 10px; padding: 1px 6px; border-radius: 8px; background: #eef2f3; color: var(--text2); }

/* ---------- 客户档案抽屉 ---------- */
#profile-pane { width: 330px; min-width: 300px; background: var(--panel); border-left: 1px solid var(--border); display: flex; flex-direction: column; }
.pp-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 14px; }
.pp-body { flex: 1; overflow-y: auto; padding: 16px; }
.pp-hero { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.pp-hero-main { min-width: 0; }
.pp-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-sub { font-size: 12px; color: var(--text2); word-break: break-all; }
.pp-stats { display: flex; gap: 8px; margin-bottom: 16px; }
.pp-stat { flex: 1; background: var(--bg); border-radius: 8px; padding: 8px 6px; text-align: center; }
.pp-stat b { display: block; font-size: 15px; }
.pp-stat span { font-size: 11px; color: var(--text2); }
/* 群成员名单 */
.pp-members { margin-bottom: 16px; }
.pp-sec-title { font-size: 12px; color: var(--text2); margin-bottom: 8px; display: flex; align-items: center; gap: 4px; }
.pp-sec-title b { color: var(--text); font-size: 13px; }
.pp-refresh { margin-left: auto; cursor: pointer; font-size: 13px; color: var(--green-dark); padding: 0 4px; }
.pp-hint { font-size: 12px; color: var(--text2); padding: 6px 0; }
.pp-member-list { max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.pp-member { display: flex; gap: 10px; align-items: center; padding: 7px 10px; }
.pp-member + .pp-member { border-top: 1px solid var(--border); }
.pp-member-av { position: relative; width: 30px; height: 30px; border-radius: 50%; background: var(--green); color: #fff; flex: none; display: flex; align-items: center; justify-content: center; font-size: 12px; overflow: hidden; }
.pp-member-av span { position: absolute; }
.pp-member-av img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pp-member-info { min-width: 0; flex: 1; }
.pp-member-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 5px; }
.pp-admin { flex: none; font-size: 10px; padding: 1px 5px; border-radius: 4px; background: #e8f5ee; color: var(--green-dark); }
.pp-member-phone { font-size: 11px; color: var(--text2); }
.fld { display: block; margin-bottom: 12px; }
.fld > span { display: block; font-size: 12px; color: var(--text2); margin-bottom: 5px; }
.fld input, .fld select, .fld textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; font-family: inherit; outline: none; background: #fff; }
.fld input:focus, .fld select:focus, .fld textarea:focus { border-color: var(--green); }
.fld textarea { resize: vertical; }
.fld-row { display: flex; gap: 10px; }
.fld-row .fld { flex: 1; min-width: 0; }
.tag-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-opt { font-size: 12px; padding: 4px 10px; border-radius: 12px; border: 1px solid var(--border); background: #fff; cursor: pointer; color: var(--text2); }
.tag-opt.on { color: #fff; border-color: transparent; }
.tag-new { margin-top: 6px; }
.tag-new input { font-size: 12px; padding: 6px 9px; }
.pp-actions { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.pp-msg { font-size: 12px; color: var(--green-dark); }
.pp-msg.err { color: #b02a37; }

/* ---------- 快捷回复面板（输入框上方） ---------- */
#quick-panel { background: var(--panel); border-top: 1px solid var(--border); max-height: 300px; display: flex; flex-direction: column; }
.qp-head { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border); }
#quick-search { flex: 1; padding: 7px 10px; border-radius: 7px; border: 1px solid var(--border); font-size: 13px; outline: none; }
#quick-search:focus { border-color: var(--green); }
#tpl-manage { font-size: 12.5px; color: var(--green-dark); cursor: pointer; white-space: nowrap; }
#quick-list { list-style: none; overflow-y: auto; padding: 4px 0; }
.qp-item { padding: 9px 14px; cursor: pointer; }
.qp-item:hover { background: var(--bg); }
.qp-title { font-size: 13px; font-weight: 500; }
.qp-preview { font-size: 12px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.qp-empty { padding: 18px; text-align: center; color: var(--text2); font-size: 12.5px; }

/* ---------- 通用弹窗 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(17,27,33,0.45); z-index: 90; display: flex; align-items: center; justify-content: center; }
.modal { background: #fff; border-radius: 12px; width: min(560px, 92vw); max-height: 84vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 14.5px; }
.modal-body { padding: 14px 16px; overflow-y: auto; }

/* 话术管理 */
.tpl-form input, .tpl-form textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; font-family: inherit; outline: none; margin-bottom: 8px; }
.tpl-form input:focus, .tpl-form textarea:focus { border-color: var(--green); }
.tpl-form-actions { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.tpl-list { list-style: none; }
.tpl-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.tpl-item-main { flex: 1; min-width: 0; }
.tpl-item-title { font-size: 13.5px; font-weight: 500; }
.tpl-item-content { font-size: 12.5px; color: var(--text2); white-space: pre-wrap; word-break: break-word; margin-top: 2px; max-height: 60px; overflow: hidden; }
.tpl-item-actions { display: flex; gap: 4px; }
.link-btn { border: none; background: none; color: var(--green-dark); font-size: 12.5px; cursor: pointer; padding: 4px 6px; }
.link-btn.danger { color: #b02a37; }

/* 自动回复设置 */
.ar-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.ar-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.ar-card-head b { font-size: 13.5px; }
.opt-tag { font-size: 10px; font-weight: 500; color: #7c8288; background: #eef1f3; border-radius: 4px; padding: 1px 5px; margin-left: 4px; vertical-align: 1px; }
.ar-tip { font-size: 12px; color: var(--text2); margin-bottom: 8px; }
.ar-card textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; font-family: inherit; outline: none; margin-bottom: 8px; }
.ar-card textarea:focus { border-color: var(--green); }
.ar-list { list-style: none; margin-bottom: 10px; }
.ar-item { display: flex; gap: 10px; align-items: flex-start; padding: 8px 2px; border-bottom: 1px dashed var(--border); }
.ar-item-main { flex: 1; min-width: 0; }
.ar-kw { font-size: 12.5px; font-weight: 600; color: var(--green-dark); }
.ar-reply-preview { font-size: 12.5px; color: var(--text); white-space: pre-wrap; word-break: break-word; margin-top: 2px; }
.ar-cd { font-size: 11px; color: var(--text2); margin-top: 2px; }
.ar-item.disabled .ar-kw, .ar-item.disabled .ar-reply-preview { opacity: .45; }
.ar-add input, .ar-add textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; font-family: inherit; outline: none; margin-bottom: 8px; }
.ar-add input:focus, .ar-add textarea:focus { border-color: var(--green); }
.ar-add-row { display: flex; align-items: center; gap: 10px; }
.fld-inline { font-size: 12px; color: var(--text2); display: flex; align-items: center; gap: 4px; }
.fld-inline input { margin: 0 !important; padding: 4px 6px !important; }
.ar-note { font-size: 11.5px; color: var(--text2); line-height: 1.6; }

/* 开关 */
.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #cfd8dc; border-radius: 20px; transition: .18s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .18s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::before { transform: translateX(16px); }

/* ---------- 右侧 ---------- */
#chat-pane { flex: 1; display: flex; flex-direction: column; position: relative; background: #efeae2; }
.empty-state { margin: auto; text-align: center; color: var(--text2); max-width: 460px; padding: 20px; }
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h2 { font-weight: 500; color: var(--text); margin-bottom: 10px; }
.empty-state p { font-size: 14px; line-height: 1.7; }

#chat-view { display: flex; flex-direction: column; height: 100%; }
.chat-header { display: flex; align-items: center; gap: 12px; background: var(--panel); padding: 10px 16px; border-bottom: 1px solid var(--border); }
.chat-header .chat-info { flex: 1; min-width: 0; }
.small-btn { font-size: 12px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; white-space: nowrap; }
.small-btn:hover { background: #eef2f3; }
.small-btn:disabled { opacity: .65; cursor: default; }
.chat-name { font-weight: 600; font-size: 15px; }
.chat-jid { font-size: 12px; color: var(--text2); }

#messages { flex: 1; overflow-y: auto; padding: 20px 8%; display: flex; flex-direction: column; gap: 4px;
  background-image: radial-gradient(circle at 20% 30%, rgba(0,0,0,0.02) 0 2px, transparent 2px); }

.row { display: flex; gap: 8px; align-items: flex-end; }
.row.out { justify-content: flex-end; }
/* 消息行小头像 */
.msg-avatar { width: 30px; height: 30px; border-radius: 50%; background: #dfe5e7; color: #54656f;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600;
  flex-shrink: 0; position: relative; overflow: hidden; }
.msg-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .18s; }
.msg-avatar img.on { opacity: 1; }
.bubble { max-width: 65%; background: var(--bubble-in); border-radius: 8px; padding: 7px 10px 5px; box-shadow: 0 1px 1px rgba(11,20,26,0.13); margin-bottom: 3px; position: relative; }
.row.out .bubble { background: var(--bubble-out); }
.bubble .meta { display: flex; justify-content: flex-end; gap: 4px; font-size: 10.5px; color: var(--text2); margin-top: 3px; }
.tick.read { color: #53bdeb; }
.bubble .media { max-width: 260px; max-height: 320px; border-radius: 6px; display: block; cursor: pointer; }
.bubble video.media { width: 260px; }
.bubble audio { width: 240px; height: 36px; }
.file-card { display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,0.04); padding: 10px 12px; border-radius: 6px; min-width: 200px; }
.file-icon { font-size: 26px; }
.file-name { font-size: 13px; word-break: break-all; max-width: 220px; }
.file-size { font-size: 11px; color: var(--text2); }
.bubble .caption { font-size: 13.5px; margin-top: 6px; white-space: pre-wrap; word-break: break-word; }
.bubble .text { font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.date-chip { align-self: center; background: rgba(255,255,255,0.9); color: var(--text2); font-size: 11.5px; padding: 4px 12px; border-radius: 12px; margin: 10px 0 6px; }
.sys-msg { align-self: center; font-size: 12px; color: var(--text2); background: rgba(255,255,255,0.85); padding: 4px 12px; border-radius: 10px; }

/* ---------- 输入区 ---------- */
#composer { display: flex; align-items: flex-end; gap: 6px; background: var(--panel); padding: 8px 14px; border-top: 1px solid var(--border); }
#msg-input { flex: 1; resize: none; border: none; outline: none; font-size: 14px; font-family: inherit; padding: 10px 12px; border-radius: 8px; background: var(--bg); max-height: 120px; }
.send-btn { background: var(--green); color: #fff; border: none; border-radius: 8px; padding: 10px 18px; cursor: pointer; font-size: 14px; }
.send-btn:hover { background: var(--green-dark); }
#rec-bar { background: #fff3cd; padding: 8px 16px; font-size: 13px; color: #856404; border-top: 1px solid var(--border); }
#rec-bar a { cursor: pointer; color: #b02a37; }

/* ---------- QR 遮罩 ---------- */
#qr-overlay { position: fixed; inset: 0; background: rgba(17,27,33,0.75); display: flex; align-items: center; justify-content: center; z-index: 100; }
.qr-card { background: #fff; border-radius: 12px; padding: 32px 40px; text-align: center; max-width: 380px; }
.qr-card h2 { font-size: 18px; margin-bottom: 18px; font-weight: 600; }
#qr-img { width: 260px; height: 260px; }
.qr-tip { font-size: 13px; color: var(--text2); margin-top: 14px; line-height: 1.6; }
.qr-tip.small { font-size: 11.5px; margin-top: 6px; }
.spinner { width: 36px; height: 36px; border: 3px solid #eee; border-top-color: var(--green); border-radius: 50%; margin: 10px auto; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 手机号配对码：8 位码要一眼看清、方便照着输入 */
#pair-code-box { margin-top: 6px; }
/* 绑定引导：说明这台电脑不用装软件，消除员工顾虑 */
.qr-sub { font-size: 12.5px; color: #5f6a72; line-height: 1.7; margin: -6px 0 16px; }
.pc-label { font-size: 13px; font-weight: 600; color: var(--green-dark); margin-bottom: 6px; }
.pc-steps b {
  display: inline-block; width: 17px; height: 17px; line-height: 17px;
  background: var(--green); color: #fff; border-radius: 50%;
  font-size: 11px; font-weight: 600; margin-right: 6px; text-align: center;
}
#pair-code-value {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 42px; font-weight: 700; letter-spacing: 10px;
  color: var(--green); background: #f2f8f4; border: 1px dashed var(--green);
  border-radius: 10px; padding: 18px 10px 18px 20px; margin: 4px auto 10px; width: fit-content;
}
.gw-pair-row { margin-top: 14px; border-top: 1px dashed var(--border); padding-top: 12px; }
.gw-pair-row input { flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }

/* 代理设置 / 诊断 */
.diag { margin-top: 18px; border-top: 1px dashed var(--border); padding-top: 14px; text-align: left; }
.err-line { font-size: 12px; color: #b02a37; margin-bottom: 8px; word-break: break-all; min-height: 0; }
.diag-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
#proxy-input { flex: 1; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 12.5px; outline: none; }
#proxy-input:focus { border-color: var(--green); }
.diag-row button { border: none; background: var(--green); color: #fff; padding: 7px 12px; border-radius: 6px; font-size: 12.5px; cursor: pointer; white-space: nowrap; }
.diag-row button.ghost { background: var(--bg); color: var(--text); }
.diag-result { font-size: 12px; color: var(--text2); word-break: break-all; }

/* ---------- v2-5：自动翻译 ---------- */
/* 消息气泡里的译文块：原文在上、译文在下，用虚线分隔，明确区分"这句是机器的" */
.tr-block { margin-top: 5px; padding-top: 5px; border-top: 1px dashed rgba(11,20,26,0.16);
  display: flex; gap: 6px; align-items: flex-start; }
.tr-tag { flex: none; font-size: 9.5px; line-height: 15px; padding: 0 4px; border-radius: 3px;
  background: rgba(0,168,132,0.12); color: var(--green-dark); font-weight: 600; letter-spacing: .5px; }
.tr-text { font-size: 13.5px; line-height: 1.45; color: #3b4a54; white-space: pre-wrap; word-break: break-word; }
.row.out .tr-block { border-top-color: rgba(11,20,26,0.12); }
.row.out .tr-text { color: #1f3b33; }
.tr-text.pending { color: var(--text2); font-style: italic; }

/* 输入框上方的"已翻译"提示条 */
#tr-bar { display: flex; align-items: center; gap: 8px; padding: 6px 14px; font-size: 12px;
  background: #eaf7f3; border-top: 1px solid var(--border); color: var(--green-dark); }
#tr-bar.hidden { display: none; }
.tr-bar-label b { font-weight: 600; }
.tr-bar-orig { flex: 1; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#tr-undo { color: #b02a37; cursor: pointer; text-decoration: underline; white-space: nowrap; }

/* 设置弹窗里的语言下拉 */
.lang-select { width: 100%; max-width: 260px; }
#tr-send-btn { font-size: 15px; font-weight: 700; color: var(--green-dark); }
#tr-send-btn.busy { opacity: .45; }
/* 译文开关处于"开"的状态 */
#tr-toggle.on { background: var(--green); border-color: var(--green); color: #fff; }
#tr-toggle.on:hover { background: var(--green-dark); }

/* ---- ✨ AI 助手面板（输入框上方，正常流撑开） ---- */
#ai-panel { background: var(--panel); border-top: 1px solid var(--border); padding: 10px 14px 8px; font-size: 13px; }
#ai-panel.hidden { display: none; }
.ai-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ai-head > span:first-child { font-weight: 700; font-size: 13.5px; }
.ai-model { font-size: 11px; color: var(--text2); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-head .icon-btn { margin-left: auto; }
.ai-sec { margin-bottom: 8px; }
.ai-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.ai-row b { font-size: 12.5px; }
.ai-row select { padding: 4px 8px; border: 1px solid var(--border); border-radius: 7px; font-size: 12px; background: #fff; }
.ai-row .small-btn { margin-left: auto; }
.ai-row .small-btn:first-of-type { margin-left: auto; }
.ai-suggestions { display: flex; flex-direction: column; gap: 6px; }
.ai-suggestion { text-align: left; border: 1px solid var(--border); background: #fafbfc; border-radius: 9px; padding: 8px 10px; font-size: 13px; line-height: 1.45; cursor: pointer; }
.ai-suggestion:hover { border-color: var(--green); background: #f0faf6; }
.ai-suggestion .sg-tag { color: var(--text2); font-size: 11px; margin-right: 6px; }
.ai-suggestion .sg-zh { display: block; margin-top: 4px; color: var(--text2); font-size: 11.5px; line-height: 1.45; font-style: normal; }
.ai-suggestion .sg-zh::before { content: '中文：'; opacity: .65; }
#ai-msg { min-height: 14px; margin-top: 2px; }
#ai-msg.err { color: #b02a37; }
#ai-btn { font-size: 14px; }
#ai-btn.busy { opacity: .45; }

/* ---------- 登录门禁 ---------- */

/* hidden 属性必须能覆盖 display:flex，否则登录卡片永远关不掉 */
.login-gate[hidden] { display: none !important; }
.login-gate {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #0b141a 0%, #111b21 55%, #0a3d33 100%);
}
.login-card {
  width: 340px; padding: 32px 28px 24px;
  background: #fff; border-radius: 14px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .35);
  display: flex; flex-direction: column; gap: 14px;
}
.login-brand { font-size: 20px; font-weight: 700; color: var(--text); text-align: center; }
.login-sub { font-size: 13px; color: var(--text2); text-align: center; margin-bottom: 6px; }
.login-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text2); }
.login-field input {
  height: 40px; padding: 0 12px; font-size: 14px; color: var(--text);
  border: 1px solid #d7dde1; border-radius: 8px; outline: none; background: #f7f9fa;
}
.login-field input:focus { border-color: var(--green); background: #fff; box-shadow: 0 0 0 3px rgba(0, 168, 132, .12); }
.login-err { min-height: 18px; font-size: 12.5px; color: #d8453c; }
.login-btn {
  height: 42px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--green); color: #fff; font-size: 15px; font-weight: 600;
}
.login-btn:hover:not(:disabled) { background: var(--green-dark); }
.login-btn:disabled { opacity: .7; cursor: default; }
.login-tip { font-size: 12px; color: var(--text2); text-align: center; margin-top: 2px; }

/* 侧栏当前登录人 */
.me-chip {
  display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text2);
  background: rgba(0, 0, 0, .04); padding: 6px 8px; border-radius: 10px; flex-wrap: wrap;
}
.me-avatar {
  width: 22px; height: 22px; border-radius: 50%; background: #06cf9c; color: #fff;
  font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center; flex: none;
}
.me-name { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: var(--text); }
.me-logout {
  border: 1px solid var(--border); background: #fff; color: var(--text2);
  font-size: 12px; padding: 4px 9px; border-radius: 6px; cursor: pointer;
}
.me-logout:hover { color: #d8453c; border-color: #f0c2bf; }
.me-logout.bind { color: #0a7a4f; border-color: #b7e3cd; background: #eafaf1; }
.me-logout.bind:hover { background: #d9f5e6; color: #0a7a4f; border-color: #96d9b6; }
.me-logout.danger { color: #c0392b; border-color: #f3c6c1; background: #fdeceb; font-weight: 600; }
.me-logout.danger:hover { background: #fbdbd8; color: #a5281b; border-color: #eaa79f; }

/* ---------- 后台管理面板 ---------- */
.admin-mask { position: fixed; inset: 0; z-index: 200; background: rgba(17,27,33,.42); display: flex; align-items: center; justify-content: center; }
.admin-shell { width: min(1080px, 96vw); height: min(760px, 92vh); background: #fff; border-radius: 14px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.28); }
.admin-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.admin-title { display: flex; align-items: center; gap: 12px; }
.admin-logo { width: 36px; height: 36px; border-radius: 10px; background: #eef7f4; color: var(--green-dark); display: flex; align-items: center; justify-content: center; font-size: 17px; }
.admin-t { font-size: 15.5px; font-weight: 600; }
.admin-sub { font-size: 12px; color: var(--text2); margin-top: 2px; }
.admin-head-actions { display: flex; align-items: center; gap: 8px; }

.admin-tabs { display: flex; gap: 4px; padding: 0 18px; border-bottom: 1px solid var(--border); }
.admin-tab { border: 0; background: transparent; padding: 12px 4px; margin-right: 18px; font-size: 13.5px; color: var(--text2); cursor: pointer; border-bottom: 2px solid transparent; }
.admin-tab.active { color: var(--green-dark); font-weight: 600; border-bottom-color: var(--green); }

.admin-body { flex: 1; overflow-y: auto; padding: 18px; background: #f7f9fa; }
.admin-pane { display: flex; flex-direction: column; gap: 16px; }

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.stat-k { font-size: 12px; color: var(--text2); }
.stat-v { font-size: 21px; font-weight: 700; margin: 6px 0 4px; }
.stat-s { font-size: 11.5px; color: var(--text2); }

.card { background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13.5px; font-weight: 600; }

.admin-btn { height: 34px; padding: 0 14px; border: 0; border-radius: 8px; background: var(--green); color: #fff; font-size: 13px; font-weight: 600; cursor: pointer; }
.admin-btn:hover { background: var(--green-dark); }
.admin-btn.ghost { background: #fff; color: var(--text2); border: 1px solid var(--border); }
.admin-btn.ghost:hover { color: var(--text); background: #f2f5f6; }

.new-user-form { display: grid; grid-template-columns: 1fr 1fr 1fr 130px 1fr; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: #fbfdfc; }
.new-user-form input, .new-user-form select { height: 34px; padding: 0 10px; border: 1px solid #d7dde1; border-radius: 7px; font-size: 13px; outline: none; }
.new-user-form input:focus, .new-user-form select:focus { border-color: var(--green); }
.new-user-form .nu-actions { grid-column: 1 / -1; display: flex; gap: 8px; }

.table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th { text-align: left; font-weight: 600; color: var(--text2); font-size: 12px; padding: 10px 16px; background: #fbfcfd; border-bottom: 1px solid var(--border); white-space: nowrap; }
.admin-table td { padding: 11px 16px; border-bottom: 1px solid #f2f5f6; vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table .num { text-align: right; }
.admin-table .ops { text-align: right; white-space: nowrap; }
.admin-table .empty { text-align: center; color: var(--text2); padding: 26px; }
.admin-table .clip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text2); }

.u-cell { display: flex; align-items: center; gap: 10px; }
.u-avatar { width: 30px; height: 30px; border-radius: 50%; background: #e6f4ef; color: var(--green-dark); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; flex: 0 0 auto; }
.u-name { font-weight: 600; }
.u-login { font-size: 11.5px; color: var(--text2); }
.mono { font-family: Consolas, "Courier New", monospace; font-size: 12px; }
.muted { color: var(--text2); }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #eef1f3; color: var(--text2); font-size: 11.5px; }
.pill.admin { background: #e8f3ff; color: #1a6ed8; }
.pill.unread { background: #e7f8ef; color: #00875a; font-weight: 600; }

.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; }
.dot.on { background: #25c26e; }
.dot.off { background: #c7ced3; }

.link-btn { border: 0; background: transparent; color: var(--green-dark); font-size: 12.5px; cursor: pointer; padding: 2px 4px; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: #d8453c; }

.chat-toolbar { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; font-size: 13px; }
.chat-toolbar select, .chat-toolbar input { height: 34px; padding: 0 10px; border: 1px solid #d7dde1; border-radius: 7px; font-size: 13px; outline: none; }
.chat-toolbar input { flex: 1; }

.admin-toast { position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%) translateY(12px); background: #111b21; color: #fff; font-size: 13px; padding: 10px 18px; border-radius: 8px; opacity: 0; pointer-events: none; transition: .22s; z-index: 300; }
.admin-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.admin-toast.err { background: #b3372f; }
.pill { white-space: nowrap; }

/* 配对码弹窗 */
.pair-mask { position: fixed; inset: 0; z-index: 9998; background: rgba(17,27,33,.45); display: flex; align-items: center; justify-content: center; }
.pair-card { width: 320px; background: #fff; border-radius: 14px; padding: 24px 22px 20px; text-align: center; box-shadow: 0 18px 48px rgba(0,0,0,.3); }
.pair-t { font-size: 13px; color: var(--text2); }
.pair-code { font-size: 34px; font-weight: 700; letter-spacing: 8px; color: var(--green-dark); margin: 12px 0 10px; font-family: Consolas, monospace; }
.pair-tip { font-size: 12.5px; color: var(--text2); line-height: 1.6; margin-bottom: 16px; }

/* 测试模式提示条 */
#test-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 500;
  background: #fff7e0; color: #8a6100; border-bottom: 1px solid #f0e0a8;
  font-size: 13px; text-align: center; padding: 7px 12px;
}

/* 云端模式：员工端绑定引导（20261029-bindguide） */
.bind-guide {
  margin: 24px auto 0;
  max-width: 420px;
  padding: 18px 20px 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel2, var(--panel));
  text-align: left;
}
.bind-guide .bg-line {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  line-height: 1.6;
}
.bind-guide .bg-line.ok { color: #1a9c5b; }
.bind-guide .bg-line.warn { color: #c47f00; }
.bind-guide .bg-steps {
  margin: 0 0 16px;
  padding-left: 20px;
  font-size: 13px;
  line-height: 1.9;
  color: var(--text2);
}
.bind-guide .bg-steps code {
  background: rgba(255, 255, 255, .06);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}
.bind-guide .login-btn { width: 100%; }
