/* ================= 基础 ================= */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --blue: #3d82fe;
  --blue-dark: #2f6fe0;
  --active-bg: #e3ecf8;
  --rail-bg: #e4ecf3;
  --pane-bg: #f7f9fa;
  --border: #e2e8f0;
  --border2: #d4d9de;
  --text: #1f2937;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --wx: #07c160;
  --red: #ef4444;
  --bubble-in: #e4e7eb;
  --bubble-in-bd: #d7dbe0;
  --bubble-out: #c9e7ff;
  --bubble-out-bd: #b5d7f3;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: #fff;
  font-size: 13px;
  overflow: hidden;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; font-size: 13px; outline: none; }
img { display: block; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }

/* ================= 登录 ================= */
.login-wrap { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #4f8cff 0%, #3d82fe 55%, #6aa0ff 100%); }
.login-card { width: 380px; background: #fff; border-radius: 16px; padding: 40px 36px 34px; box-shadow: 0 20px 60px rgba(30, 64, 175, .25); text-align: center; }
.login-logo { font-size: 44px; }
.login-card h1 { font-size: 20px; margin: 12px 0 6px; }
.login-card p { color: var(--text-2); font-size: 12.5px; margin-bottom: 26px; }
.login-card .field { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 10px; padding: 0 12px; margin-bottom: 14px; transition: border .15s; }
.login-card .field:focus-within { border-color: var(--blue); }
.login-card .field span { color: var(--text-3); font-size: 15px; }
.login-card .field input { flex: 1; border: none; padding: 12px 0; background: transparent; }
.login-err { color: var(--red); font-size: 12px; min-height: 18px; margin-bottom: 4px; text-align: left; }
.btn-primary { width: 100%; padding: 12px; border-radius: 10px; background: var(--blue); color: #fff; font-size: 15px; font-weight: 600; transition: background .15s; }
.btn-primary:hover { background: var(--blue-dark); }

/* ================= 工作台骨架 ================= */
.app, .ws-root { height: 100vh; }
.ws-root { display: flex; }

/* ---- 最左导航 ---- */
.rail {
  width: 64px; flex: 0 0 64px;
  background: var(--rail-bg);
  border-right: 1px solid var(--border2);
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 0 12px;
}
.rail-avatar { width: 38px; height: 38px; border-radius: 50%; overflow: hidden; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.12); background: #dfe5eb; }
.rail-avatar img { width: 100%; height: 100%; object-fit: cover; }
.rail-name { font-size: 11px; color: var(--text-2); margin-top: 6px; max-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-nav {
  position: relative;
  margin-top: 14px;
  width: 52px; padding: 7px 0 6px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  border-radius: 10px;
  color: #5b6470; font-size: 11px; text-decoration: none;
  transition: background .15s;
}
.rail-nav svg { width: 22px; height: 22px; }
.rail-nav:hover { background: rgba(61,130,254,.12); }
.rail-nav.active { background: #cce0ff; color: var(--blue-dark); font-weight: 600; }
.rail-badge {
  position: absolute; top: 2px; right: 6px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--red); color: #fff;
  border-radius: 8px; font-style: normal;
  font-size: 10px; line-height: 16px; text-align: center;
  border: 1.5px solid var(--rail-bg);
}
.rail-spacer { flex: 1; }
.rail-logout {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #5b6470;
}
.rail-logout svg { width: 21px; height: 21px; }
.rail-logout:hover { background: rgba(239,68,68,.12); color: var(--red); }

/* ---- 通用栏 ---- */
.ws-content { flex: 1; display: flex; min-width: 0; height: 100%; }
.pane { background: #fff; display: flex; flex-direction: column; min-height: 0; }
.pane-folders { width: 320px; flex: 0 0 320px; background: var(--pane-bg); border-right: 1px solid var(--border); }
.pane-ids { width: 236px; flex: 0 0 236px; background: #f8f6fd; border-right: 1px solid var(--border); }
.pane-convs { width: 256px; flex: 0 0 256px; background: var(--pane-bg); border-right: 1px solid var(--border); }
.pane-side { width: 272px; flex: 0 0 272px; border-left: 1px solid var(--border); }

.pane-bar {
  height: 52px; flex: 0 0 52px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px;
}
.pane-title { font-size: 15px; font-weight: 700; }
.pill-btn {
  font-size: 11px; color: var(--text-2);
  border: 1px solid var(--border2); border-radius: 999px;
  padding: 3px 10px; background: #fff;
}
.pill-btn:hover:not(:disabled) { color: var(--blue); border-color: var(--blue); }
.pill-btn:disabled { opacity: .45; cursor: default; }

.pane-search {
  margin: 0 12px 8px; position: relative;
  display: flex; align-items: center;
}
.pane-search.sm { margin: 0 10px 8px; }
.pane-search .ic-search {
  position: absolute; left: 9px; width: 14px; height: 14px; color: var(--text-3); pointer-events: none;
}
.pane-search input {
  width: 100%; height: 30px;
  border: 1px solid var(--border); border-radius: 6px;
  background: #fff; padding: 0 26px 0 29px;
  font-size: 12px; color: var(--text);
}
.pane-search input:focus { border-color: var(--blue); }
.ic-clear { position: absolute; right: 6px; width: 18px; height: 18px; border-radius: 50%; background: #cbd2da; color: #fff; display: flex; align-items: center; justify-content: center; }
.ic-clear svg { width: 10px; height: 10px; }

/* ---- 客服文件夹卡片 ---- */
.folder-list { flex: 1; overflow-y: auto; padding: 4px 12px 12px; }
.kf-card {
  position: relative;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 8px;
  display: flex; gap: 10px;
  cursor: pointer; user-select: none;
  transition: border-color .12s, box-shadow .12s;
}
.kf-card:hover { border-color: #b9cdf5; box-shadow: 0 1px 6px rgba(61,130,254,.1); }
.kf-card.dragging { opacity: .45; }
.kf-card.dragover { border-color: var(--blue); border-style: dashed; }
.drag-handle {
  align-self: center; color: #cfd5dd; cursor: grab; flex: 0 0 8px;
  font-size: 14px; line-height: 1; letter-spacing: -2px;
}
.kf-card-body { flex: 1; min-width: 0; }
.kf-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kf-card-name { font-size: 12.5px; font-weight: 600; color: #111827; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kf-card-time { font-size: 10px; color: var(--text-3); flex: 0 0 auto; }
.kf-card-preview { margin-top: 5px; font-size: 10.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kf-card-preview b { color: #374151; font-weight: 500; }

/* 头像（彩色圆角方块） */
.kf-avatar {
  position: relative;
  flex: 0 0 auto;
  width: 40px; height: 40px; border-radius: 8px;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 16px; font-weight: 600;
  background: #dfe5eb;
}
.kf-avatar img { width: 100%; height: 100%; object-fit: cover; }
.av-blue { background: var(--blue); }
.av-green { background: #22c55e; }
.av-purple { background: #a855f7; }
.av-orange { background: #f97316; }
.av-pink { background: #ec4899; }
.av-cyan { background: #06b6d4; }

.kf-avatar-wrap { position: relative; flex: 0 0 auto; }
.ci-avatar-wrap { position: relative; flex: 0 0 36px; width: 36px; height: 36px; }
.unread-badge {
  position: absolute; top: -6px; right: -6px; z-index: 2;
  min-width: 17px; height: 17px; padding: 0 5px;
  background: var(--red); color: #fff;
  border-radius: 9px; border: 2px solid #fff;
  font-size: 10px; font-weight: 600; line-height: 13px; text-align: center;
}

.list-empty { text-align: center; color: var(--text-3); font-size: 12px; padding: 40px 10px; line-height: 1.8; }

/* ---- 会话栏头部 ---- */
.conv-head {
  height: 52px; flex: 0 0 52px;
  display: flex; align-items: center; gap: 7px;
  padding: 0 10px 0 6px;
}
.icon-back {
  width: 28px; height: 28px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: #4b5563; flex: 0 0 auto;
}
.icon-back svg { width: 18px; height: 18px; }
.icon-back:hover { background: #e5eaf0; color: var(--blue); }
.conv-head-kf { position: relative; width: 26px; height: 26px; flex: 0 0 auto; }
.kf-mini-avatar { width: 26px; height: 26px; border-radius: 50%; background: #dfe5eb; }
.online-dot {
  position: absolute; right: -1px; bottom: -1px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--wx); border: 2px solid var(--pane-bg);
}
.conv-head-name { font-size: 13px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-head-count { font-size: 11px; color: var(--text-3); }

/* ---- 状态 tabs ---- */
.conv-tabs {
  flex: 0 0 auto;
  display: flex; border-bottom: 1px solid var(--border);
  background: var(--pane-bg);
}
.conv-tabs button {
  flex: 1; height: 38px;
  font-size: 11.5px; color: var(--text-2);
  border-bottom: 2.5px solid transparent;
  display: flex; align-items: center; justify-content: center; gap: 3px;
}
.conv-tabs button .tn { color: var(--text-3); font-size: 10.5px; }
.conv-tabs button.active { color: #111827; font-weight: 700; border-bottom-color: var(--blue); }
.conv-tabs button.active .tn { color: var(--blue); }

/* ---- 会话行 ---- */
.conv-list { flex: 1; overflow-y: auto; padding: 6px 8px; }
.conv-item {
  position: relative;
  display: flex; gap: 8px;
  padding: 9px 8px; border-radius: 8px;
  cursor: pointer; margin-bottom: 2px;
}
.conv-item:hover { background: #edf1f5; }
.conv-item.active { background: var(--active-bg); }
.ci-avatar {
  position: relative;
  width: 36px; height: 36px; border-radius: 6px; flex: 0 0 36px;
  overflow: hidden; background: #dfe5eb;
}
.ci-avatar img { width: 100%; height: 100%; object-fit: cover; }
.ci-avatar-wrap .unread-badge { top: -5px; right: -5px; min-width: 16px; height: 16px; line-height: 12px; font-size: 9.5px; border-width: 1.5px; }
.ci-body { flex: 1; min-width: 0; }
.conv-item-top { display: flex; align-items: center; gap: 5px; }
.ci-name { font-size: 11.5px; font-weight: 600; color: #111827; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci-time { margin-left: auto; font-size: 9.5px; color: var(--text-3); flex: 0 0 auto; }
.wx-tag {
  display: inline-flex; align-items: center;
  background: rgba(7,193,96,.1); color: var(--wx);
  font-size: 9px; line-height: 1;
  padding: 2px 3px; border-radius: 3px;
  font-weight: 500;
}
.ci-preview { margin-top: 4px; font-size: 10.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci-kf-tag {
  display: inline-block; margin-right: 4px;
  background: rgba(61,130,254,.1); color: var(--blue);
  font-size: 9px; padding: 1px 4px; border-radius: 3px;
}
.ci-preview .timeout { color: var(--red); }
/* 下班待聊角标 */
.pending-tag {
  display: inline-flex; align-items: center;
  background: #fff3e0; color: #e8830c; border: 1px solid #ffd9a8;
  font-size: 9px; line-height: 1; font-weight: 600;
  padding: 2px 4px; border-radius: 3px;
}
/* 聊天窗顶部待聊提示条 */
.chat-pending-bar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
  background: #fff8ef; border-bottom: 1px solid #ffe2bd;
  color: #b06a14; font-size: 12.5px; padding: 9px 16px;
}
.chat-pending-bar .pending-tag { font-size: 10px; padding: 3px 6px; }
.btn-accept {
  margin-left: auto; border: none; cursor: pointer;
  background: #ff9a2e; color: #fff; font-size: 12.5px; font-weight: 600;
  padding: 5px 18px; border-radius: 6px;
}
.btn-accept:hover { background: #f08a1c; }

/* ---- 聊天区 ---- */
.chat-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; background: #f5f7f9; }
.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #c2c9d2; gap: 14px; }
.chat-empty svg { width: 72px; height: 72px; }
.chat-empty p { font-size: 14px; }

.chat-main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-header {
  flex: 0 0 50px; height: 50px;
  background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 18px;
}
.chat-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; }
.chat-title .wx-green {
  background: rgba(7,193,96,.1); color: var(--wx);
  font-size: 10px; padding: 2px 5px; border-radius: 3px; font-weight: 500;
}

.msg-area { flex: 1; overflow-y: auto; padding: 18px 22px; background: #f3f3f3; }
.msg-time { text-align: center; margin: 14px 0 10px; }
.msg-time span { background: rgba(0,0,0,.18); color: #fff; font-size: 10.5px; padding: 2px 8px; border-radius: 4px; }
.msg-sys { text-align: center; margin: 10px 0; }
.msg-sys span { font-size: 11px; color: #8a929c; }
.msg-row { display: flex; margin-bottom: 12px; gap: 8px; }
.msg-row.out { flex-direction: row-reverse; }
.msg-avatar { width: 32px; height: 32px; border-radius: 5px; overflow: hidden; flex: 0 0 32px; background: #dfe5eb; }
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; }
.msg-content { display: flex; flex-direction: column; max-width: 58%; }
.msg-row.out .msg-content { align-items: flex-end; }
.bubble {
  position: relative;
  border: 1px solid var(--bubble-in-bd); background: var(--bubble-in);
  border-radius: 8px; padding: 7px 10px;
  font-size: 13px; line-height: 1.55;
  word-break: break-word; white-space: pre-wrap;
}
.msg-row.out .bubble { background: var(--bubble-out); border-color: var(--bubble-out-bd); }
.bubble.media { padding: 4px; background: #fff; border-color: var(--border); }
.media-img { max-width: 240px; max-height: 240px; border-radius: 6px; cursor: pointer; display: block; }
.voice-box { display: flex; align-items: center; gap: 8px; min-width: 90px; cursor: pointer; }
.voice-box svg { width: 18px; height: 18px; flex: 0 0 auto; }
.voice-box .vd { font-size: 12px; color: var(--text-2); }
.msg-status { font-size: 10.5px; color: var(--text-3); margin-top: 3px; }
.msg-status.fail { color: var(--red); }
.msg-bubble-wrap.sending .bubble { opacity: .6; }
/* 撤回按钮：悬停己方消息时出现 */
.msg-recall-btn {
  align-self: flex-end; border: none; background: none; cursor: pointer;
  font-size: 11px; line-height: 1.4; color: var(--text-3);
  padding: 1px 4px; margin-top: 1px; opacity: 0; transition: opacity .15s;
}
.msg-row.out:hover .msg-recall-btn { opacity: 1; }
.msg-recall-btn:hover { color: var(--red); }

/* ---- 输入区 ---- */
.chat-closed-bar {
  flex: 0 0 auto;
  background: #f0f1f3; color: var(--text-2);
  text-align: center; font-size: 12px; padding: 12px;
  border-top: 1px solid var(--border);
}
.composer { flex: 0 0 auto; background: #fff; border-top: 1px solid var(--border); }
.chat-toolbar { display: flex; align-items: center; gap: 2px; padding: 8px 14px 2px; }
.tb-btn {
  width: 30px; height: 30px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: #5b6470;
}
.tb-btn svg { width: 21px; height: 21px; }
.tb-btn:hover { background: #f0f3f7; color: var(--blue); }
.tb-btn.recording { color: var(--red); background: #fdeaea; }
.rec-hint { font-size: 11px; color: var(--text-2); margin-left: 8px; }
.chat-input-wrap { padding: 4px 14px; }
.chat-input-wrap textarea {
  width: 100%; border: none; resize: none;
  font-size: 13px; line-height: 1.6;
  max-height: 130px; background: transparent;
}
.chat-send-row { display: flex; justify-content: flex-end; padding: 0 14px 10px; }
.btn-send {
  background: #f3f3f3; color: #9aa1ab;
  font-size: 12px; border-radius: 6px;
  padding: 6px 16px; transition: background .12s, color .12s;
}
.btn-send:not(:disabled) { color: #374151; }
.btn-send:not(:disabled):hover { background: var(--blue); color: #fff; }

/* ---- 右侧栏 ---- */
.side-tabs {
  flex: 0 0 46px; height: 46px;
  display: flex; align-items: center; gap: 4px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
}
.side-tab { font-size: 12.5px; color: var(--text-2); padding: 5px 8px; border-radius: 6px; position: relative; }
.side-tab.active { color: var(--blue); font-weight: 700; }
.side-tab.active::after {
  content: ''; position: absolute; left: 8px; right: 8px; bottom: -10px;
  height: 2.5px; background: var(--blue); border-radius: 2px;
}
.btn-end {
  margin-left: auto;
  background: var(--red); color: #fff;
  font-size: 12px; border-radius: 6px;
  padding: 6px 14px;
}
.btn-end:hover { background: #dc2626; }
.btn-end:disabled { background: #d1d5db; cursor: default; }
.btn-end:disabled:hover { background: #d1d5db; }
.btn-end.reopen { background: var(--wx); }
.btn-end.reopen:hover { background: #06a552; }

.side-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.qr-layout { flex: 1; display: flex; min-height: 0; }
.qr-groups { width: 86px; flex: 0 0 86px; background: var(--pane-bg); border-right: 1px solid var(--border); overflow-y: auto; padding: 8px 6px; }
.qr-group {
  display: block; width: 100%; text-align: left;
  padding: 7px 8px; margin-bottom: 3px;
  font-size: 11px; color: var(--text-2);
  border-radius: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.qr-group:hover { background: #eaeff4; }
.qr-group.active { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.qr-list { flex: 1; overflow-y: auto; padding: 10px; }
.qr-item {
  display: block; width: 100%; text-align: left;
  background: #fff; border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px; margin-bottom: 8px;
  font-size: 11.5px; line-height: 1.5; color: #374151;
  white-space: pre-wrap; word-break: break-word;
}
.qr-item:hover { border-color: var(--blue); }
.qr-empty { color: var(--text-3); font-size: 11.5px; text-align: center; padding: 30px 8px; line-height: 1.8; }
.qr-footer { flex: 0 0 auto; border-top: 1px solid var(--border); padding: 10px; }
.qr-footer button {
  width: 100%; border: 1px solid var(--border2); border-radius: 6px;
  background: #fff; font-size: 12px; color: var(--text-2); padding: 7px;
}
.qr-footer button:hover { color: var(--blue); border-color: var(--blue); }

/* 客户详情 */
.detail-body { padding: 20px 16px; overflow-y: auto; }
.detail-avatar { width: 56px; height: 56px; border-radius: 10px; overflow: hidden; background: #dfe5eb; margin: 0 auto 10px; }
.detail-avatar img { width: 100%; height: 100%; object-fit: cover; }
.detail-name { text-align: center; font-size: 15px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 6px; }
.detail-sep { height: 1px; background: var(--border); margin: 16px 0; }
.detail-row { margin-bottom: 13px; }
.detail-label { font-size: 11px; color: var(--text-3); margin-bottom: 3px; }
.detail-val { font-size: 12px; color: var(--text); word-break: break-all; display: flex; align-items: center; gap: 6px; }
.detail-val .st { padding: 1px 7px; border-radius: 4px; font-size: 11px; }
.st-open { background: rgba(7,193,96,.1); color: var(--wx); }
.st-closed { background: #f1f2f4; color: var(--text-2); }
.copy-mini { font-size: 10px; color: var(--blue); border: 1px solid #bcd3fb; border-radius: 4px; padding: 0 5px; flex: 0 0 auto; }

/* ================= 设置页 ================= */
.settings-page { flex: 1; overflow-y: auto; background: #f4f6f8; }
.settings-inner { max-width: 780px; margin: 0 auto; padding: 28px 24px 60px; }
.settings-head h1 { font-size: 20px; margin-bottom: 20px; }
.card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 22px 24px; margin-bottom: 18px; }
.card h3 { font-size: 15px; margin-bottom: 8px; }
.desc { color: var(--text-2); font-size: 12.5px; line-height: 1.7; }
.hint-box { background: #f0f6ff; border: 1px solid #cfe1ff; color: #3a649e; font-size: 12px; line-height: 1.9; border-radius: 8px; padding: 10px 14px; margin: 14px 0 18px; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12.5px; color: #374151; margin-bottom: 6px; }
.form-row input[type=text], .form-row input[type=password], .form-row textarea {
  width: 100%; border: 1px solid var(--border2); border-radius: 8px;
  padding: 9px 12px; background: #fff;
}
.form-row input:focus, .form-row textarea:focus { border-color: var(--blue); }
.form-row textarea { resize: vertical; min-height: 84px; line-height: 1.6; }
.form-inline { display: flex; gap: 8px; }
.form-inline input { flex: 1; }
.copyable { display: flex; gap: 8px; }
.copyable input { flex: 1; background: #f7f9fa; }
.icon-btn { border: 1px solid var(--border2); border-radius: 8px; background: #fff; padding: 0 12px; font-size: 15px; }
.icon-btn:hover { border-color: var(--blue); }
.btn-row { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.btn { border-radius: 8px; padding: 9px 18px; font-size: 13px; }
.btn.blue { background: var(--blue); color: #fff; font-weight: 600; }
.btn.blue:hover { background: var(--blue-dark); }
.status-pill { font-size: 12px; padding: 3px 10px; border-radius: 999px; }
.status-pill.yes { background: rgba(7,193,96,.12); color: var(--wx); }
.status-pill.no { background: #f1f2f4; color: var(--text-2); }
/* 注意：特异性需高于上方的 .form-row label(0,1,1)，否则开关会被 display:block/margin 打乱 */
.form-row .switch { display: inline-flex; align-items: center; margin: 0; flex: 0 0 auto; line-height: 1; }
.switch input { display: none; }
.switch i { display: block; width: 42px; height: 24px; border-radius: 12px; background: #d1d5db; position: relative; transition: background .15s; }
.switch i::after { content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + i { background: var(--blue); }
.switch input:checked + i::after { left: 20px; }
.switch-row { display: flex; align-items: center; gap: 12px; }
.switch-row > div { min-width: 0; }
.switch-row .t { display: block; font-size: 13px; font-weight: 600; line-height: 1.4; }
.switch-row .d { display: block; font-size: 11.5px; color: var(--text-2); line-height: 1.5; margin-top: 2px; }
.managed-hint { color: var(--text-2); font-size: 12.5px; }

/* ================= 弹窗 ================= */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.42); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { width: 560px; max-height: 80vh; background: #fff; border-radius: 12px; display: flex; flex-direction: column; overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 15px; }
.modal-close { color: var(--text-3); font-size: 14px; width: 28px; height: 28px; border-radius: 6px; }
.modal-close:hover { background: #f1f3f6; color: var(--text); }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.qr-admin-list { margin-bottom: 18px; max-height: 280px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.qr-admin-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.qr-admin-item:last-child { border-bottom: none; }
.qr-admin-group { flex: 0 0 80px; font-size: 11px; color: var(--blue); background: rgba(61,130,254,.08); border-radius: 4px; padding: 2px 6px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qr-admin-text { flex: 1; color: #374151; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.qr-del { flex: 0 0 auto; color: var(--text-3); font-size: 12px; padding: 3px 8px; border-radius: 5px; }
.qr-del:hover { color: var(--red); background: #fdeaea; }
.qr-admin-add { border-top: 1px dashed var(--border2); padding-top: 16px; }

/* 常用语：图片/语音 */
.qr-item-media { display: flex; align-items: center; gap: 8px; }
.qr-thumb { width: 38px; height: 38px; border-radius: 6px; object-fit: cover; flex: 0 0 auto; background: #f3f4f6; }
.qr-media-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qr-voice-ico { width: 20px; height: 20px; flex: 0 0 auto; color: #16a34a; }
.qr-admin-media { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.qr-admin-media .qr-thumb { width: 44px; height: 44px; }
.qr-admin-media audio { height: 32px; max-width: 220px; }
.qr-admin-media em { font-style: normal; font-size: 11px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 语音备注行：音频 + 备注输入框 + 文件名，窄屏自动换行 */
.qr-admin-voice { flex-wrap: wrap; row-gap: 6px; }
.qr-remark-input {
  flex: 1 1 130px; min-width: 120px;
  border: 1px solid #e3e6eb; border-radius: 6px;
  padding: 6px 9px; font-size: 12.5px; background: #fff; color: #374151;
}
.qr-remark-input:focus { border-color: #1677ff; box-shadow: 0 0 0 2px rgba(22,119,255,.12); outline: none; }
.qr-admin-voice em { flex: 1 1 100%; font-size: 10.5px; }
.qr-type-seg { display: inline-flex; border: 1px solid #e3e6eb; border-radius: 8px; overflow: hidden; }
.qr-type-seg button { padding: 7px 18px; font-size: 12.5px; background: #fff; color: #6b7280; border-right: 1px solid #e3e6eb; }
.qr-type-seg button:last-child { border-right: none; }
.qr-type-seg button.active { background: #1677ff; color: #fff; font-weight: 500; }
.qr-pick-btn { margin-bottom: 10px; }
.qr-media-preview { display: flex; align-items: center; gap: 10px; }
.qr-pick-preview { max-width: 160px; max-height: 120px; border-radius: 8px; border: 1px solid var(--border); }
audio.qr-pick-preview { max-width: 260px; max-height: none; }
.qr-media-preview em { font-style: normal; font-size: 11.5px; color: var(--text-3); word-break: break-all; }

/* 聊天输入区：附件预览条 */
.attach-tray { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 14px 0; }
.attach-chip { position: relative; width: 64px; height: 64px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.attach-chip img { width: 100%; height: 100%; object-fit: cover; }
.attach-del {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border: none; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; font-size: 10px; line-height: 18px; text-align: center; cursor: pointer; padding: 0;
}
.attach-del:hover { background: var(--red); }
.composer.drag-over { background: #f0f6ff; box-shadow: inset 0 0 0 2px rgba(22,119,255,.45); }

/* ================= Toast ================= */
.toast {
  position: fixed; left: 50%; bottom: 44px; transform: translateX(-50%) translateY(20px);
  background: rgba(17,24,39,.9); color: #fff;
  font-size: 13px; padding: 9px 18px; border-radius: 8px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  z-index: 100; max-width: 70vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ================= 自动化：设置页 Tab 布局 ================= */
.settings-shell { display: flex; min-height: 100%; }
.settings-nav {
  flex: 0 0 150px; background: #fff; border-right: 1px solid var(--border);
  padding: 22px 12px; display: flex; flex-direction: column; gap: 4px;
}
.set-tab {
  text-align: left; padding: 10px 14px; border-radius: 8px; font-size: 13.5px;
  color: var(--text-2); transition: background .15s, color .15s;
}
.set-tab:hover { background: #f1f5f9; }
.set-tab.active { background: var(--active-bg); color: var(--blue-dark); font-weight: 600; }
.settings-shell .settings-inner { flex: 1; max-width: 920px; margin: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-sub-title { font-size: 13.5px; margin: 18px 0 8px; padding-top: 12px; border-top: 1px dashed var(--border); }
.inline-hint { color: var(--text-3); font-size: 12px; white-space: nowrap; }
.status-pill.yes { background: #e7f8ef; color: #0a8a45; }
#workPill { margin-left: auto; }

/* ---- 分段开关 ---- */
.seg-control { display: inline-flex; border: 1px solid var(--border2); border-radius: 8px; overflow: hidden; }
.seg-btn { padding: 7px 16px; font-size: 13px; background: #fff; color: var(--text-2); border-right: 1px solid var(--border2); }
.seg-btn:last-child { border-right: none; }
.seg-btn.active { background: var(--blue); color: #fff; font-weight: 600; }

/* ---- 自动回复：工具栏/树谱 ---- */
.ar-toolbar { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 16px; }
.ar-tools { display: flex; gap: 8px; }
.ar-tree { display: flex; flex-direction: column; gap: 0; }
.ar-level { display: flex; flex-direction: column; align-items: center; }
.ar-level-tag {
  align-self: stretch; text-align: center; background: #eef4ff; color: var(--blue-dark);
  font-weight: 700; border-radius: 8px; padding: 7px; font-size: 13px;
  border: 1px solid #d5e4ff;
}
.ar-level-body { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; padding: 14px 4px; width: 100%; }
.ar-entry-col { flex: 1 1 300px; max-width: 420px; min-width: 260px; }
.ar-drop { border: 2px solid transparent; border-radius: 12px; padding: 4px; transition: border-color .15s, background .15s; }
.ar-drop.dragover { border-color: var(--blue); background: #f0f6ff; }
.ar-arrow { color: var(--text-3); font-size: 16px; line-height: 1; padding: 2px 0 6px; }
.ar-arrow.done { color: var(--wx); font-size: 12px; font-weight: 600; }
.ar-rule {
  background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  cursor: grab; transition: box-shadow .15s, border-color .15s;
}
.ar-rule:hover { border-color: #b9cdf5; box-shadow: 0 2px 10px rgba(61,130,254,.1); }
.ar-rule.is-off { opacity: .55; background: #fafafa; }
.ar-rule-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ar-kw { font-weight: 600; font-size: 13px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ar-kfname { margin-left: auto; color: var(--text-3); font-size: 11.5px; }
.ar-edit { color: var(--blue); padding: 2px 6px; border-radius: 6px; font-size: 12.5px; }
.ar-edit:hover { background: var(--active-bg); }
.ar-rule-body { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.ar-chip {
  display: inline-flex; align-items: center; gap: 4px; background: #f4f6f8;
  border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; font-size: 12px; max-width: 100%;
}
.ar-thumb { width: 34px; height: 34px; object-fit: cover; border-radius: 6px; display: inline-block; }
.muted { color: var(--text-3); font-size: 11.5px; font-style: normal; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 10px; background: #eef2f7; color: var(--text-2); }
.tag-ai { background: #f0ebff; color: #6d3df0; }
.tag-warn { background: #fff4e0; color: #b4680a; }
.tag-danger, .tag.ok { background: #fdecec; color: #dc2626; }
.tag.ok { background: #e7f8ef; color: #0a8a45; }
.tag-off { background: #f1f1f1; color: #999; }
.ar-mount {
  margin-top: 10px; border: 1px dashed var(--border2); border-radius: 8px;
  padding: 8px; background: #fafbfc; display: flex; flex-direction: column; gap: 8px;
}
.ar-mount-title { font-size: 12px; color: var(--text-2); font-weight: 600; }
.ar-mount-empty { color: var(--text-3); font-size: 12px; text-align: center; padding: 10px 4px; border: 1px dashed #e5e7eb; border-radius: 6px; }
.ar-sub { position: relative; padding-left: 22px; }
.ar-step-no {
  position: absolute; left: 0; top: 0; font-size: 10.5px; color: var(--blue);
  background: var(--active-bg); border-radius: 6px; padding: 2px 4px; font-weight: 700;
}
.ar-empty { color: var(--text-3); font-size: 13px; text-align: center; padding: 26px 10px; }

/* ---- 列表明细 ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
.ar-table, .ailog-table { width: 100%; border-collapse: collapse; font-size: 12.5px; background: #fff; }
.ar-table th, .ar-table td, .ailog-table th, .ailog-table td {
  border-bottom: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: middle;
}
.ar-table th, .ailog-table th { background: #f8fafc; color: var(--text-2); font-weight: 600; white-space: nowrap; }
.ar-table tr:last-child td, .ailog-table tr:last-child td { border-bottom: none; }
.ellipsis { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-fail { background: #fff8f8; }

/* ---- 规则编辑弹窗 ---- */
.modal-lg { width: 720px; }
.modal-xl { width: 94vw; max-width: 1100px; }
.modal .modal-body { overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }
.btn.danger { background: #fdecec; color: #dc2626; font-weight: 600; }
.btn.danger:hover { background: #fbdcdc; }
.ar-replies { display: flex; flex-direction: column; gap: 10px; }
/* 回复/兜底条目卡片（对齐参考站） */
.ar-item { position: relative; border: 1px solid #e5e7eb; border-radius: 8px; padding: 12px; background: #f9fafb; }
.ar-item--fb { border-color: #ffedd5; background: rgba(255, 247, 237, .4); }
.ar-item-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.ar-item-no { font-size: 12px; font-weight: 700; color: #9ca3af; }
.ar-item--fb .ar-item-no { color: #fb923c; }
.ar-item-ops { display: flex; align-items: center; gap: 4px; }
.ar-op { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; padding: 2px; border-radius: 4px; color: #9ca3af; }
.ar-op svg { width: 14px; height: 14px; }
.ar-op:hover:not(:disabled) { color: #4b5563; background: rgba(0,0,0,.05); }
.ar-op:disabled { opacity: .3; cursor: default; }
.ar-op-del { color: #f87171; }
.ar-op-del:hover { color: #dc2626; background: #fef2f2; }
.ar-item-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 8px; }
.ar-type-sel { width: 100%; padding: 6px 8px; border: 1px solid var(--border2); border-radius: 8px; background: #fff; font-size: 12px; }
.ar-item-grid input[type="number"] { width: 100%; padding: 6px 8px; border: 1px solid var(--border2); border-radius: 8px; font-size: 12px; background: #fff; }
.ar-item > textarea { width: 100%; border: 1px solid var(--border2); border-radius: 8px; padding: 8px 12px; background: #fff; resize: vertical; font-size: 12px; }
.ar-item > .ar-media-field input[type="text"] { border: 1px solid var(--border2); border-radius: 8px; padding: 6px 8px; background: #f3f4f6; font-size: 12px; }
.ar-media-field { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ar-media-field input { flex: 1; min-width: 180px; }
.ar-media-field audio { height: 32px; }
.ar-exclude { margin-top: 12px; border-top: 1px solid #e5e7eb; padding-top: 8px; }
.ar-exclude > summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: #4b5563; cursor: pointer; list-style: none; user-select: none; }
.ar-exclude > summary::-webkit-details-marker { display: none; }
.ar-exclude-title { font-weight: 500; }
.ar-exclude-state { color: #9ca3af; }
.ar-exclude-box { margin-top: 8px; background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 8px; }
.ar-exclude-tip { font-size: 11px; color: #9ca3af; margin-bottom: 8px; }
.ar-exclude-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; max-height: 128px; overflow-y: auto; padding-right: 4px; }
.ar-exclude-list label { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid #f3f4f6; border-radius: 6px; cursor: pointer; font-weight: normal; min-width: 0; }
.ar-exclude-list label:hover { background: #fef2f2; }
.ar-exclude-list input[type="checkbox"] { flex-shrink: 0; accent-color: #ef4444; }
.ar-kf-meta { display: flex; flex-direction: column; min-width: 0; }
.ar-kf-name { font-size: 12px; color: #374151; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ar-kf-id { font-size: 10px; color: #9ca3af; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ar-exclude-empty { font-size: 12px; color: #9ca3af; text-align: center; padding: 8px 0; }
.ar-time-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ar-time-hint { display: flex; align-items: flex-end; padding-bottom: 8px; font-size: 12px; color: #9ca3af; }

/* ---- AI 日志 ---- */
.ailog-filters { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.ailog-filters select, .ailog-filters input { padding: 7px 10px; border: 1px solid var(--border2); border-radius: 6px; background: #fff; }
.ailog-filters input { flex: 1; min-width: 200px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 12px; font-size: 12.5px; color: var(--text-2); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; margin-bottom: 10px; }
.detail-grid > div { display: flex; gap: 8px; font-size: 12.5px; }
.detail-grid .full { grid-column: 1 / -1; flex-direction: column; gap: 2px; }
.detail-grid b { color: var(--text-2); min-width: 64px; flex: 0 0 auto; }
.detail-grid .err, .detail-grid .err * { color: var(--red); }
.json-pre {
  background: #0f172a; color: #dbe4ff; border-radius: 8px; padding: 12px;
  font-size: 11.5px; line-height: 1.55; overflow: auto; max-height: 280px;
  white-space: pre-wrap; word-break: break-all; margin-bottom: 12px;
}

/* ---- 聊天窗重置AI / 拉黑 ---- */
#btnAiReset { background: #6d3df0; color: #fff; font-size: 12px; }
#btnAiReset:hover { background: #5b2fd0; }
#btnBlock { font-size: 12px; }
#btnBlock.unblock { background: #fff; color: #07a35a; border: 1px solid #07a35a; }
#btnBlock.unblock:hover { background: #eafaf1; }

/* ---- 语音转写 / 图片识图结果 ---- */
.media-text {
  margin-top: 6px; padding: 6px 9px; max-width: 320px;
  font-size: 12px; line-height: 1.55; color: var(--text-2);
  background: #f3f5f9; border-left: 3px solid #b9c2d0; border-radius: 4px;
  white-space: pre-wrap; word-break: break-word;
}
.media-text-tag {
  display: inline-block; margin-right: 6px; padding: 0 5px; font-size: 10.5px;
  color: #6d3df0; background: #efe9fd; border-radius: 3px; vertical-align: 1px;
}

/* ---- ID 汇总卡片 ---- */
.id-card {
  margin-top: 8px; width: 300px; max-width: 100%;
  border: 1px solid #d9c7ff; border-radius: 10px; overflow: hidden;
  background: linear-gradient(180deg, #faf7ff, #f5f0ff);
  box-shadow: 0 2px 8px rgba(109, 61, 240, .10);
}
.id-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 10px; font-size: 12.5px; font-weight: 600; color: #5b2fd0;
  background: #efe9fd;
}
.id-card-tags { display: inline-flex; gap: 4px; }
.id-card-tag {
  display: inline-block; padding: 1px 6px; font-size: 10.5px; font-weight: 500;
  color: #6d3df0; background: #fff; border: 1px solid #d9c7ff; border-radius: 9px;
}
.id-card-tag.dup { color: #d13737; border-color: #f0bcbc; background: #fff3f3; }
.id-card-tag.a18 { color: #b9770e; border-color: #ecd29a; background: #fff8e8; }
.id-card-text {
  margin: 0; padding: 9px 10px; font-family: inherit; font-size: 12.5px; line-height: 1.65;
  color: var(--text-1); white-space: pre-wrap; word-break: break-word;
}
.id-card-edit {
  width: calc(100% - 16px); margin: 8px; padding: 8px; border: 1px solid var(--border2);
  border-radius: 6px; font-size: 12.5px; line-height: 1.6; resize: vertical;
  font-family: inherit;
}
.id-card-actions { display: flex; gap: 8px; padding: 0 10px 9px; }
.id-card-actions .btn { padding: 4px 12px; font-size: 12px; }

/* ---- ID 设置：按客服行 / 尾号路由 ---- */
.id-kf-rows { display: flex; flex-direction: column; gap: 8px; }
.id-kf-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #f7f8fa; border: 1px solid #eef0f3; border-radius: 8px; padding: 9px 14px; }
.id-kf-name { min-width: 0; flex: 1; font-size: 13px; color: var(--text-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.id-kf-row input { flex: 0 0 130px; width: 130px; }
.id-len-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.id-delay-global { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-1); }
.id-delay-global .num-input { text-align: center; }
.id-tail-rows { display: flex; flex-direction: column; gap: 10px; }
.id-tail-empty { background: #fafbfc; border: 1px dashed var(--border2); border-radius: 8px; padding: 14px; text-align: center; font-size: 12.5px; }
.id-tail-row { border: 1px solid #eef0f3; border-radius: 10px; padding: 12px; background: #f7f8fa; }
.id-tail-grid { display: grid; grid-template-columns: minmax(140px,1fr) 140px 84px 24px 30px; gap: 8px; margin-bottom: 10px; align-items: center; }
.id-tail-grid select, .id-tail-grid input { background: #fff; }
.id-tail-sec { font-size: 12.5px; color: var(--text-2); }
.id-tail-del { width: 28px; height: 28px; border: none; border-radius: 6px; background: transparent; color: #ef4444; font-size: 13px; cursor: pointer; }
.id-tail-del:hover { background: #fee2e2; }
.id-tail-row textarea { width: 100%; font-size: 12.5px; background: #fff; }

/* 滚动条 */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,.16); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ====================================================================
   设置中心 v2（顶部水平 Tab，参考站 1:1）
   ==================================================================== */
.settings-page {
  position: fixed; inset: 0; z-index: 30;
  flex: none; overflow-y: auto;
  background: #f4f6f8;
}
/* 顶部栏 */
.set-topbar {
  position: sticky; top: 0; z-index: 20;
  height: 56px; background: #fff;
  border-bottom: 1px solid #eef0f3;
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px;
}
.set-back {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #4b5563;
}
.set-back svg { width: 18px; height: 18px; }
.set-back:hover { background: #f1f5f9; color: #1677ff; }
.set-topbar h1 { font-size: 16px; font-weight: 600; color: #111827; }
.set-topright { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.set-username { font-size: 13px; color: #374151; }
.set-logout {
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; color: #6b7280;
}
.set-logout svg { width: 17px; height: 17px; }
.set-logout:hover { background: #fdecea; color: #ef4444; }

/* 水平 Tab 栏 */
.set-tabs {
  position: sticky; top: 56px; z-index: 19;
  background: #fff; border-bottom: 1px solid #eef0f3;
  display: flex; justify-content: center; gap: 6px;
  padding: 0 20px;
}
.set-tabs .set-tab {
  position: relative;
  text-align: center; padding: 0 18px; height: 48px;
  display: inline-flex; align-items: center;
  border-radius: 0; background: none;
  font-size: 14px; color: #4b5563; font-weight: 400;
}
.set-tabs .set-tab:hover { background: none; color: #1677ff; }
.set-tabs .set-tab.active {
  background: none; color: #1d4ed8; font-weight: 500;
}
.set-tabs .set-tab.active::after {
  content: ''; position: absolute; left: 14px; right: 14px; bottom: -1px;
  height: 2px; background: #1677ff; border-radius: 2px;
}

/* 内容容器 */
.set-main { max-width: 980px; margin: 0 auto; padding: 24px 24px 72px; }
.set-main > section { animation: fadeIn .18s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.set-hero { position: relative; margin-bottom: 18px; }
.set-hero h2 { font-size: 22px; font-weight: 600; color: #111827; }
.set-hero p { margin-top: 6px; font-size: 13px; color: #8a929c; }
.hero-action { position: absolute; right: 0; top: 2px; }

/* 卡片 */
.set-card {
  background: #fff; border-radius: 12px;
  padding: 22px 24px; margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.set-card-title {
  font-size: 15px; font-weight: 600; color: #111827;
  padding-bottom: 14px; margin-bottom: 16px;
  border-bottom: 1px solid #f0f2f5;
}
.set-card-title-flex { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.set-sub { padding: 18px 0; border-bottom: 1px solid #f0f2f5; }
.set-sub:first-of-type { padding-top: 4px; }
.set-sep { height: 1px; background: #f0f2f5; margin: 20px 0; }

/* 表单原子 */
.set-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 24px; }
.f-block { margin-bottom: 14px; min-width: 0; }
.set-grid2 .f-block { margin-bottom: 0; }
.set-grid2 .f-block + .f-block { margin-bottom: 0; }
.f-label { display: block; font-size: 13px; color: #374151; font-weight: 500; margin-bottom: 7px; }
.f-title-lg { font-size: 14px; font-weight: 600; color: #1f2937; }
.f-desc { font-size: 12.5px; color: #8a929c; line-height: 1.6; }
.f-hint { font-size: 12px; color: #9ca3af; line-height: 1.6; margin-top: 6px; }
.f-label-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.set-input, .set-select, .set-textarea {
  width: 100%; border: 1px solid #e3e6eb; border-radius: 8px;
  padding: 9px 12px; background: #fff; color: #1f2937;
  font-size: 13px; transition: border-color .15s, box-shadow .15s;
}
.set-input:focus, .set-select:focus, .set-textarea:focus {
  border-color: #1677ff; box-shadow: 0 0 0 2px rgba(22,119,255,.12);
}
.set-textarea { resize: vertical; line-height: 1.6; min-height: 70px; }
.set-select { appearance: auto; }
.set-input[readonly] { background: #f8fafc; color: #4b5563; }
.num-input { width: 80px; text-align: center; padding: 7px 8px; }
.inline-num { font-size: 13px; color: #4b5563; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.inline-num .num-input { width: 72px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.pink-area { background: #fff7f7; border-color: #f3d4d4; }
.pink-area:focus { border-color: #ef4444; box-shadow: 0 0 0 2px rgba(239,68,68,.1); }

/* 按钮体系 */
.btn-solid-blue, .btn-solid-red, .btn-ghost, .btn-ghost-purple, .btn-purple, .btn-mini-blue {
  border-radius: 8px; font-size: 13px; padding: 9px 18px;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn-solid-blue { background: #1677ff; color: #fff; font-weight: 500; }
.btn-solid-blue:hover { background: #0e68e6; }
.btn-solid-red { background: #ef4444; color: #fff; font-weight: 500; }
.btn-solid-red:hover { background: #dc2626; }
.btn-ghost { background: #fff; color: #4b5563; border: 1px solid #e3e6eb; }
.btn-ghost:hover { color: #1677ff; border-color: #1677ff; }
.btn-ghost-purple { background: #fff; color: #a855f7; border: 1px solid #e9d5ff; }
.btn-ghost-purple:hover { background: #faf5ff; }
.btn-purple { background: #a855f7; color: #fff; font-weight: 500; padding: 8px 14px; }
.btn-purple:hover { background: #9333ea; }
.btn-mini-blue {
  background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe;
  padding: 5px 12px; font-size: 12px;
}
.btn-mini-blue:hover { background: #dbeafe; }
.btn-copy {
  flex: 0 0 auto; border: 1px solid #e3e6eb; border-radius: 8px;
  background: #fff; color: #4b5563; font-size: 12.5px; padding: 8px 16px;
}
.btn-copy:hover { color: #1677ff; border-color: #1677ff; }
.link-blue { color: #1677ff; font-size: 12.5px; padding: 2px 4px; }
.link-blue:hover { text-decoration: underline; }
.link-muted { color: #9ca3af; font-size: 12px; padding: 2px 4px; }
.link-muted:hover { color: #4b5563; }
.link-orange { color: #d97706; font-size: 12.5px; padding: 2px 4px; }
.link-orange:hover { text-decoration: underline; }
.btn-text-danger { color: #ef4444; font-size: 13px; padding: 6px 10px; border-radius: 6px; }
.btn-text-danger:hover { background: #fef2f2; }
.input-eye { position: relative; display: flex; }
.input-eye .set-input { padding-right: 42px; }
.eye-btn {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 28px; border-radius: 6px; color: #9ca3af; font-size: 13px;
}
.eye-btn:hover { background: #f1f5f9; color: #4b5563; }

/* 开关 */
.switch { display: inline-flex; align-items: center; line-height: 1; cursor: pointer; }
.switch input { display: none; }
.switch i { display: block; width: 40px; height: 22px; border-radius: 11px; background: #d1d5db; position: relative; transition: background .18s; flex: 0 0 auto; }
.switch i::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .18s; box-shadow: 0 1px 3px rgba(0,0,0,.22); }
.switch input:checked + i { background: #1677ff; }
.switch input:checked + i::after { left: 20px; }
.switch-green input:checked + i { background: #16a34a; }
.switch-red input:checked + i { background: #ef4444; }
.switch-purple input:checked + i { background: #a855f7; }
.switch-blue input:checked + i { background: #1677ff; }
.switch-lg i { width: 48px; height: 26px; border-radius: 13px; }
.switch-lg i::after { width: 22px; height: 22px; }
.switch-lg input:checked + i::after { left: 24px; }
.switch-txt { font-size: 12.5px; color: #16a34a; font-weight: 500; }
.switch-line { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.switch-line > div { min-width: 0; }
.check-line { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: #374151; cursor: pointer; }
.check-line input { width: 15px; height: 15px; accent-color: #1677ff; }
.mini-check { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: #4b5563; cursor: pointer; white-space: nowrap; }
.mini-check input { width: 14px; height: 14px; accent-color: #1677ff; }
.badge { font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 10px; margin-left: 8px; vertical-align: 1px; }
.badge-purple { background: #f3e8ff; color: #9333ea; }
.badge-blue { background: #eff6ff; color: #2563eb; }

/* ---------- 接待与规则 ---------- */
.work-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.work-state { font-size: 15px; font-weight: 600; color: #111827; }
.work-desc { font-size: 12.5px; color: #8a929c; margin-top: 5px; }
.btn-work {
  flex: 0 0 auto; border-radius: 8px; padding: 9px 22px; font-size: 13px; font-weight: 500;
  background: #fff; color: #ef4444; border: 1px solid #fecaca;
}
.btn-work:hover { background: #fef2f2; }
.btn-work.go { color: #16a34a; border-color: #bbf7d0; }
.btn-work.go:hover { background: #f0fdf4; }
.welcome-foot { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.welcome-foot .btn-solid-blue { margin-left: auto; }

.rules-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 26px 0 14px; }
.rules-head h3 { font-size: 17px; font-weight: 600; color: #111827; display: flex; align-items: center; gap: 10px; }
.rule-count { font-size: 12px; color: #8a929c; font-weight: 400; }
.rules-head p { font-size: 12.5px; color: #8a929c; margin-top: 5px; }
.rules-actions { display: flex; gap: 10px; flex-shrink: 0; }
.seg-control { display: inline-flex; border: 1px solid #e3e6eb; border-radius: 8px; overflow: hidden; background: #fff; }
.seg-btn { padding: 8px 14px; font-size: 12.5px; background: #fff; color: #6b7280; border-right: 1px solid #e3e6eb; }
.seg-btn:last-child { border-right: none; }
.seg-btn.active { background: #1677ff; color: #fff; font-weight: 500; }

.rules-info { background: #fff; border-radius: 12px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(16,24,40,.04); overflow: hidden; }
.rules-info-head {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; font-size: 13.5px; font-weight: 500; color: #374151;
}
.rules-info-head:hover { color: #1677ff; }
.rules-info-head .chev { color: #9ca3af; transition: transform .2s; }
.rules-info-body { padding: 0 20px 16px 38px; color: #6b7280; font-size: 12.5px; line-height: 2; }
.rules-info-body b { color: #374151; }
.ar-master-li { list-style: none; margin-left: -20px; margin-top: 10px; padding-top: 12px; border-top: 1px dashed #eef0f3; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ar-master { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; color: #1677ff; cursor: pointer; }
.ar-master input { width: 15px; height: 15px; accent-color: #1677ff; }
.ar-master-desc { font-size: 12px; color: #9ca3af; font-weight: 400; }

/* ---------- AI 页 ---------- */
.ai-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.ai-panel-head h3 { font-size: 15px; font-weight: 600; }
.ai-note {
  display: flex; gap: 12px; align-items: flex-start;
  background: #f0f6ff; border: 1px solid #d8e7ff; border-radius: 10px;
  padding: 13px 16px; margin-bottom: 20px;
}
.ai-note-icon { font-size: 16px; line-height: 1.5; }
.ai-note b { font-size: 13px; color: #1d4ed8; }
.ai-note p { font-size: 12.5px; color: #5b7bb4; line-height: 1.7; margin-top: 3px; }
.ai-model-block .btn-purple { margin-bottom: 10px; }
.ai-model-block select { margin-top: 8px; }
.purple-link { color: #a855f7; font-weight: 500; }
.blue-note {
  margin-top: 10px; background: #eff6ff; color: #1d4ed8;
  border-radius: 8px; padding: 8px 12px; font-size: 12px; line-height: 1.5;
}
.ai-master-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.reason-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 6px 0; }
.reason-card + .reason-card { margin-top: 14px; }

/* ---------- ID 页 ---------- */
.seg3 { display: inline-flex; border: 1px solid #e3e6eb; border-radius: 8px; overflow: hidden; }
.seg3 button { padding: 8px 18px; font-size: 12.5px; background: #fff; color: #6b7280; border-right: 1px solid #e3e6eb; }
.seg3 button:last-child { border-right: none; }
.seg3 button.active { background: #1677ff; color: #fff; font-weight: 500; }
.id-row-label { font-size: 12.5px; color: #6b7280; flex: 0 0 auto; }
.id-row-unit { font-size: 12.5px; color: #8a929c; }

/* ---------- 提醒页 ---------- */
.vol-head { display: flex; align-items: baseline; gap: 10px; }
.vol-pct { font-size: 12.5px; font-weight: 600; }
.vol-pct.blue { color: #1677ff; }
.vol-pct.red { color: #ef4444; }
.vol-row { display: flex; align-items: center; gap: 12px; }
.vol-ic { font-size: 16px; color: #9ca3af; }
.vol-range { flex: 1; height: 4px; accent-color: #1677ff; }
.vol-range.red { accent-color: #ef4444; }

/* ---------- 列表明细卡片（参考站 v2） ---------- */
.rl-list { display: flex; flex-direction: column; gap: 12px; }
.rlc-card { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 14px 16px; box-shadow: 0 1px 2px rgba(16,24,40,.04); display: flex; flex-direction: column; gap: 8px; }
.rlc-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.rlc-badges { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rlc-no { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 6px; background: #1677ff; color: #fff; font-size: 12px; font-weight: 600; }
.rlc-tag { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 6px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.rlc-slate { background: #f1f5f9; color: #475569; }
.rlc-blue { background: #eaf2ff; color: #1d4ed8; }
.rlc-indigo { background: #eef2ff; color: #4338ca; }
.rlc-purple { background: #f4f0ff; color: #7c3aed; }
.rlc-onoff.is-on { background: #e8f7ee; color: #16a34a; }
.rlc-onoff.is-off { background: #f3f4f6; color: #9ca3af; }
.rlc-badge { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 5px; font-size: 11.5px; font-weight: 500; white-space: nowrap; }
.rlc-badge-blue { background: #eaf2ff; color: #1d4ed8; }
.rlc-badge-amber { background: #fef3e2; color: #d97706; }
.rlc-badge-red { background: #fef0f0; color: #dc2626; }
.rlc-ops { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.rlc-op { width: 30px; height: 30px; border-radius: 7px; border: 1px solid #e5e7eb; background: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.rlc-op svg { width: 15px; height: 15px; }
.rlc-op-gray { color: #6b7280; }
.rlc-op-gray:hover:not(:disabled) { border-color: #cbd5e1; background: #f8fafc; }
.rlc-op:disabled { opacity: .4; cursor: not-allowed; }
.rlc-op-blue { color: #1677ff; border-color: #cfe0ff; }
.rlc-op-blue:hover { background: #f0f6ff; }
.rlc-op-red { color: #ef4444; border-color: #fecaca; }
.rlc-op-red:hover { background: #fef2f2; }
.rlc-kw { font-size: 13px; color: #374151; margin: 0; }
.rlc-kw span { font-weight: 600; color: #111827; }
.rlc-reps { display: flex; flex-direction: column; gap: 6px; }
.rlc-rep { display: flex; align-items: center; gap: 8px; background: #f7f8fa; border-radius: 8px; padding: 7px 10px; font-size: 12.5px; color: #374151; }
.rlc-idx { color: #9ca3af; font-size: 12px; font-weight: 600; flex: 0 0 auto; }
.rlc-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.rlc-empty { font-size: 12.5px; color: #9ca3af; padding: 4px 2px; }
.rlc-fb { background: #fff7eb; border: 1px solid #fde7c3; border-radius: 8px; padding: 7px 10px; font-size: 12.5px; color: #92600a; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rlc-block { margin: 0; font-size: 12.5px; color: #dc2626; }
.rlc-block span { color: #b91c1c; }

/* ---------- 流程树谱 v2（并列分支） ---------- */
#arTree { display: flex; flex-direction: column; gap: 16px; }
.tl-level { background: #fff; border: 1px solid #e5e7eb; border-radius: 14px; padding: 18px 20px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.tl-level-head { display: flex; align-items: center; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid #eef0f3; }
.tl-level-pill { background: #1677ff; color: #fff; font-size: 13px; font-weight: 600; padding: 5px 14px; border-radius: 8px; }
.tl-level-meta { font-size: 13px; color: #6b7280; }
.tl-add-entry { margin-left: auto; border: 1px solid #bcd4ff; background: #f5f9ff; color: #1677ff; font-size: 13px; font-weight: 500; border-radius: 8px; padding: 6px 14px; cursor: pointer; }
.tl-add-entry:hover { background: #eaf2ff; }
.tl-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 14px 26px; padding-top: 16px; align-items: start; }
.tl-branch { display: flex; flex-direction: column; align-items: stretch; }
.tle-card { border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 9px; cursor: grab; border: 1px solid; background: #fff; }
.tle-card:active { cursor: grabbing; }
.tle-card.is-off { opacity: .6; }
.tle-entry { background: #f4f8ff; border-color: #c2d8ff; }
.tle-entry:hover { border-color: #94b8ff; box-shadow: 0 4px 14px rgba(22,119,255,.12); }
.tle-stepcard { background: #f7f8fd; border-color: #dde4fb; }
.tle-stepcard:hover { border-color: #b9c6f3; box-shadow: 0 4px 14px rgba(99,102,241,.1); }
.tle-head { display: flex; align-items: center; gap: 8px; }
.tle-spacer { flex: 1; }
.tle-pill { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 6px; border: 1px solid; }
.tle-pill-blue { color: #1677ff; border-color: #9ec5ff; background: #eef5ff; }
.tle-pill-purple { color: #7c3aed; border-color: #d6c7ff; background: #f5f1ff; }
.tle-icbtn { width: 26px; height: 26px; border-radius: 6px; border: none; background: transparent; color: #94a3b8; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.tle-icbtn svg { width: 14px; height: 14px; }
.tle-icbtn:hover { background: #e8eefc; color: #1677ff; }
.tle-icbtn-red:hover { background: #fef0f0; color: #ef4444; }
.tle-unmount { font-size: 12px; color: #6b7280; background: transparent; border: none; cursor: pointer; padding: 2px 6px; }
.tle-unmount:hover { color: #1677ff; }
.tle-kwbox { background: #fff; border: 1px solid #eef0f4; border-radius: 8px; padding: 8px 10px; font-size: 13px; color: #111827; font-weight: 500; word-break: break-all; }
.tle-kwlabel { font-size: 12px; font-weight: 400; color: #9ca3af; margin-right: 4px; }
.tle-reps { display: flex; flex-direction: column; gap: 6px; }
.tle-rep { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid #eef0f4; border-radius: 8px; padding: 6px 10px; font-size: 12.5px; color: #374151; }
.tle-ic { flex: 0 0 auto; color: #f59e0b; font-size: 13px; }
.tle-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.tle-rep-empty { color: #9ca3af; justify-content: center; background: transparent; border-style: dashed; }
.tle-foot { display: flex; align-items: center; justify-content: space-between; }
.tl-mount-link { border: none; background: transparent; color: #1677ff; font-size: 12.5px; font-weight: 500; cursor: pointer; padding: 2px 0; }
.tl-mount-link:hover { text-decoration: underline; }
.tle-drag { font-size: 12px; color: #9ca3af; }
.tl-connector { align-self: center; width: 2px; height: 22px; background: #9ec5ff; }
.tl-steps { display: flex; flex-direction: column; align-items: stretch; padding: 0 14px; }
.tl-step-pill { align-self: center; font-size: 12px; color: #7c3aed; background: #f1ecff; border: 1px solid #ddcffd; border-radius: 999px; padding: 3px 14px; margin-bottom: 8px; }
.tl-step .tl-connector { margin: 8px 0; }
.tl-dropzone { margin-top: 10px; border: 1.5px dashed #b7c6f5; border-radius: 10px; background: #fafbff; color: #8a94a6; font-size: 12.5px; text-align: center; padding: 12px; transition: border-color .15s, background .15s; }
.tl-dropzone.dragover { border-color: #1677ff; background: #eef5ff; color: #1677ff; }
.ai-fail-box { }

/* ---------- 账号页 ---------- */
.acct-val { font-size: 13.5px; color: #111827; padding: 9px 0; }
.conn-badge {
  font-size: 12px; padding: 3px 12px; border-radius: 999px;
  background: #f1f2f4; color: #6b7280;
}
.conn-badge.ok { background: #e7f8ef; color: #0a8a45; }
.cb-box {
  background: #f8fafc; border: 1px solid #eef0f3; border-radius: 10px;
  padding: 16px 18px;
}
.cb-box-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12.5px; color: #4b5563; margin-bottom: 14px; }
.copy-row { display: flex; gap: 8px; }
.copy-row .set-input { flex: 1; }
.adv-box { margin-top: 14px; font-size: 12.5px; color: #6b7280; }
.adv-box summary { cursor: pointer; padding: 6px 0; user-select: none; }
.adv-box[open] summary { margin-bottom: 4px; }
.pc-empty { text-align: center; color: #9ca3af; font-size: 12.5px; padding: 26px 0; }

/* ---------- 规则编辑弹窗 ---------- */
.ar-modal { width: 780px; max-width: 94vw; max-height: 90vh; border-radius: 14px; }
.ar-modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 18px 24px 14px; border-bottom: 1px solid #f0f2f5;
}
.ar-modal-head h3 { font-size: 16px; font-weight: 600; }
.ar-modal-sub { font-size: 12px; color: #9ca3af; margin-top: 4px; }
.ar-modal-body { padding: 18px 24px; overflow-y: auto; }
.ar-modal-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 24px; border-top: 1px solid #f0f2f5; background: #fcfdfe;
}
.ar-mount-info {
  display: flex; gap: 10px; align-items: flex-start;
  background: #f5f0ff; border: 1px solid #e4d5ff; border-radius: 10px;
  padding: 11px 14px; margin-top: 14px;
}
.ar-mount-info b { font-size: 13px; color: #7e3ef0; }
.ar-mount-info p { font-size: 12px; color: #8b6fc0; line-height: 1.6; margin-top: 3px; }
.ar-active-check { margin-top: 14px; }
.ar-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; font-weight: 600; color: #1f2937; }
.ar-sec-head-sm { font-size: 13px; }
.ar-sec-sub { font-size: 12px; font-weight: 400; color: #9ca3af; }
.ar-adv { border-top: 1px dashed #eef0f3; margin-top: 16px; padding-top: 12px; }

/* 设置页内表格/树在卡片外的留白微调 */
.ar-list .table-wrap { box-shadow: 0 1px 2px rgba(16,24,40,.04); border-radius: 12px; border-color: #fff; }
.ar-tree { gap: 4px; }

/* ---------- 自动回复：按客服号开关 ---------- */
.arkf-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.arkf-mini {
  border: 1px solid #e3e6eb; border-radius: 7px; background: #fff;
  color: #4b5563; font-size: 12.5px; padding: 6px 14px;
}
.arkf-mini:hover { color: #1677ff; border-color: #1677ff; }
.arkf-count { margin-left: auto; font-size: 12.5px; color: #8a929c; }
.arkf-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.arkf-item {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid #eef0f3; border-radius: 10px; background: #fafbfc;
  padding: 10px 12px; transition: border-color .15s, background .15s;
}
.arkf-item.on { border-color: #bfe3cd; background: #f6fdf9; }
.arkf-avatar {
  width: 34px; height: 34px; border-radius: 8px; flex: 0 0 34px;
  overflow: hidden; background: #dfe5eb;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px; font-weight: 600;
}
.arkf-avatar img { width: 100%; height: 100%; object-fit: cover; }
.arkf-name {
  flex: 1; min-width: 0; font-size: 13px; color: #374151;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.arkf-item:not(.on) .arkf-name { color: #9ca3af; }

/* ---------- 会话置顶 ---------- */
.conv-item.pinned { background: #fbf7ee; }
.conv-item.pinned:hover { background: #f6efe0; }
.conv-item.pinned.active { background: #f3e8d2; }
.pin-tag {
  display: inline-flex; align-items: center;
  background: #fff3df; color: #c9841a; border: 1px solid #f4d9a8;
  font-size: 9px; line-height: 1; font-weight: 600;
  padding: 2px 4px; border-radius: 3px;
}
.ci-pin {
  position: absolute; top: 6px; right: 4px;
  width: 22px; height: 22px; border-radius: 5px;
  font-size: 12px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; filter: grayscale(1); transition: opacity .15s, transform .1s, filter .15s;
  background: transparent;
}
.ci-pin:hover { background: #ece3d1; transform: scale(1.12); }
.conv-item:hover .ci-pin { opacity: .65; }
.ci-pin.is-on { opacity: 1; filter: none; }
/* 置顶后置顶标签占位，避免与右上角图钉重叠：置顶态时间缩短 */
.conv-item.pinned .ci-time { margin-right: 16px; }
/* 人工「标为未读」红点（无新消息计数时显示） */
.unread-dot {
  position: absolute; top: -4px; right: -4px; z-index: 2;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--red); border: 2px solid #fff;
}
/* 会话行右上角未读切换按钮（图钉左侧） */
.ci-unread {
  position: absolute; top: 6px; right: 26px;
  width: 22px; height: 22px; border-radius: 5px;
  border: none; background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .15s, transform .1s, background .15s;
}
.ci-unread-dot {
  width: 10px; height: 10px; border-radius: 50%;
  border: 1.5px solid #9aa3af; background: transparent;
}
.conv-item:hover .ci-unread { opacity: .65; }
.ci-unread:hover { background: #fdecec; transform: scale(1.12); opacity: 1 !important; }
.ci-unread.is-on { opacity: 1; }
.ci-unread.is-on .ci-unread-dot { background: var(--red); border-color: var(--red); }
/* 未读标记常显时，时间让出右上角按钮位（置顶规则同等优先，此条在后故生效） */
.conv-item.mu-on .ci-time { margin-right: 40px; }

/* ---------- 聊天记录搜索命中 ---------- */
.msg-hit-label { font-size: 11px; color: #8a929c; font-weight: 600; padding: 10px 8px 4px; }
.msg-hit-label:first-child { padding-top: 2px; }
.msg-hit {
  display: block; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: 8px; margin-bottom: 4px; cursor: pointer;
  background: #fff; border: 1px solid var(--border);
}
.msg-hit:hover { border-color: var(--blue); background: #f5f9ff; }
.msg-hit-top { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.msg-hit-name { font-size: 12px; font-weight: 600; color: #111827; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-hit-kf { background: rgba(61,130,254,.1); color: var(--blue); font-size: 9.5px; padding: 1px 5px; border-radius: 3px; flex: 0 0 auto; }
.msg-hit-dir { font-size: 10px; color: #9ca3af; flex: 0 0 auto; }
.msg-hit-dir.is-out { color: #2563eb; }
.msg-hit-time { margin-left: auto; font-size: 10px; color: #9ca3af; flex: 0 0 auto; }
.msg-hit-text {
  font-size: 12px; color: #4b5563; line-height: 1.5;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg-hit-text mark { background: #ffe58a; color: inherit; padding: 0 1px; border-radius: 2px; }
.mh-type {
  display: inline-block; background: #f0ebff; color: #6d3df0;
  font-size: 10px; padding: 0 4px; border-radius: 3px; margin-right: 4px;
}

/* ---------- 快捷常用语：客服归属 ---------- */
.qr-admin-tools { display: flex; align-items: center; margin-bottom: 12px; }
.qr-filter-label { font-size: 12.5px; color: #4b5563; display: flex; align-items: center; gap: 8px; }
.qr-kf-select {
  border: 1px solid #e3e6eb; border-radius: 7px; background: #fff;
  padding: 6px 9px; font-size: 12.5px; color: #374151; min-width: 150px;
}
.qr-kf-select:focus { border-color: #1677ff; outline: none; }
#qrAddKf { width: 100%; }
.qr-owner-select {
  flex: 0 0 88px; font-size: 11px; padding: 4px 2px;
  border: 1px solid #e3e6eb; border-radius: 6px; background: #fff; color: #4b5563;
}
.qr-owner-select:focus { border-color: #1677ff; outline: none; }

/* ---------- ID 报告条（会话列表侧边栏，对齐参考站） ---------- */
.id-report-bar {
  flex: 0 0 auto;
  margin: 4px 8px 2px;
  border: 1px solid #e7e1fb;
  background: #faf8ff;
  border-radius: 8px;
  overflow: hidden;
}
.idr-chips { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; padding: 8px 7px 4px; }
.idr-chip {
  display: inline-flex; align-items: center; gap: 3px;
  border: 1px solid transparent; border-radius: 11px;
  padding: 2px 8px; font-size: 10.5px; line-height: 16px;
  background: #f1edfd; color: #6d3df0; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.idr-chip b { font-weight: 700; }
.idr-chip:hover { background: #e7e0fb; }
.idr-chip.active { background: #6d3df0; color: #fff; border-color: #6d3df0; }
.idr-chip.id { cursor: default; }
.idr-chip.id:hover { background: #f1edfd; }
.idr-chip.tip { background: #eef1f4; color: #5b6572; cursor: default; }
.idr-chip.tip:hover { background: #eef1f4; }
.idr-chip.unread { background: #fdeeee; color: #d94242; }
.idr-chip.unread:hover { background: #f9e2e2; }
.idr-chip.unread.active { background: #ef4444; color: #fff; border-color: #ef4444; }
.idr-readall {
  margin-left: auto; border: none; background: transparent;
  font-size: 10px; color: #8b7bc9; cursor: pointer; padding: 2px 4px;
}
.idr-readall:hover:not(:disabled) { color: #6d3df0; text-decoration: underline; }
.idr-readall:disabled { color: #c3bfd4; cursor: default; }
.idr-clear {
  border: none; background: transparent;
  font-size: 10px; color: #c98f8f; cursor: pointer; padding: 2px 4px;
}
.idr-clear:hover:not(:disabled) { color: #d94242; text-decoration: underline; }
.idr-clear:disabled { color: #d8c9c9; cursor: default; }
.idr-summary { border-top: 1px solid #efe9fb; }
.idr-summary-btn {
  display: flex; align-items: center; gap: 6px; width: 100%;
  border: none; background: transparent; cursor: pointer;
  padding: 5px 9px; font-size: 10.5px; color: #4b5563; text-align: left;
}
.idr-summary-btn:hover { background: #f4f0fe; }
.idr-summary-title { font-weight: 600; color: #4c3a92; }
.idr-summary-total { color: #8b85a3; }
.idr-chev { width: 11px; height: 11px; margin-left: auto; color: #9a93b8; transition: transform .18s; }
.idr-summary-btn.open .idr-chev { transform: rotate(180deg); }
.idr-summary-body {
  max-height: 150px; overflow-y: auto;
  border-top: 1px dashed #e7e1fb; padding: 4px 7px 6px;
  background: #fff;
}
.idr-kf-row { display: flex; align-items: center; gap: 7px; padding: 3px 2px; }
.idr-kf-avatar { width: 20px; height: 20px; border-radius: 5px; object-fit: cover; background: #dfe5eb; flex: 0 0 20px; }
.idr-kf-name {
  font-size: 11px; color: #374151; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.idr-kf-n { font-size: 10.5px; color: #6d3df0; font-weight: 600; flex: 0 0 auto; }
.idr-kf-empty { font-size: 10.5px; color: #9ca3af; text-align: center; padding: 8px 0; }

/* ---------- 常驻 ID 列表列（每个客服号一份，独立列固定在会话列表左边） ---------- */
.id-list-box {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 4px 8px 8px;
  padding: 6px 6px 7px;
  background: #f5f2fd;
  border: 1px solid #e7e1fb;
  border-radius: 8px;
}
.id-list-box .list-empty { padding: 14px; }
.id-list-empty {
  padding: 18px 10px; text-align: center;
  font-size: 11px; line-height: 1.7; color: #b3a9d6;
  border: 1px dashed #ddd5f3; border-radius: 8px; background: #fbfaff;
}

/* ---------- 独立 ID 列表（每个客服号一份，与会话 tab 无关） ---------- */
.idrow {
  padding: 11px 10px; margin-bottom: 2px;
  border-radius: 8px; cursor: pointer; background: #fff;
}
.idrow:hover { background: #f7f5ff; }
.idrow.is-unread { background: #fbf9ff; }
.idrow.is-unread:hover { background: #f3effe; }
.idrow-main { display: flex; gap: 10px; }
.idrow-avatar {
  position: relative; width: 44px; height: 44px; flex: 0 0 44px;
}
.idrow-avatar .ci-avatar { width: 44px; height: 44px; flex-basis: 44px; border-radius: 8px; }
.idrow-body { flex: 1; min-width: 0; }
.idrow-top { display: flex; align-items: center; gap: 7px; }
.ci-idtag {
  display: inline-flex; align-items: center; flex: 0 0 auto;
  color: #4338ca; font-size: 15px; line-height: 1; font-weight: 800;
  letter-spacing: .2px;
}
.ci-idcnt {
  display: inline-flex; align-items: center;
  background: #e8f0fe; color: #3d82fe;
  font-size: 11px; line-height: 1; font-weight: 600;
  padding: 3px 8px; border-radius: 10px; flex: 0 0 auto;
}
.ci-bell {
  flex: 0 0 auto; width: 24px; height: 24px; padding: 0;
  border: none; background: transparent; border-radius: 5px;
  font-size: 15px; line-height: 24px; cursor: pointer;
}
.ci-bell:hover { background: #efe8fd; }
.ci-bell.is-alert { animation: idbell-pulse 1.8s infinite; }
@keyframes idbell-pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.18); } }
.ci-view {
  flex: 0 0 auto; border: none; background: #6d5efc;
  color: #fff; font-size: 12px; line-height: 1; font-weight: 600;
  padding: 7px 18px; border-radius: 6px; cursor: pointer;
}
.ci-view:hover { background: #5a4ce8; }
.idrow .ci-pin {
  position: static; width: 24px; height: 24px;
  font-size: 14px; line-height: 24px; opacity: .55;
  background: transparent;
}
.idrow .ci-pin:hover { background: #ece3d1; transform: scale(1.12); }
.idrow .ci-pin.is-on { opacity: 1; }
.idrow-time { margin-left: auto; font-size: 11px; color: #9ca3af; flex: 0 0 auto; }
.idrow-sub { display: flex; align-items: center; gap: 5px; margin-top: 7px; }
.idrow-name {
  font-size: 13px; font-weight: 600; color: #1f2937;
  max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.idrow-dot { color: #c4c9d2; font-size: 12px; }
.idrow-kf {
  display: inline-flex; align-items: center; gap: 3px;
  background: #f1edfd; color: #6d3df0;
  font-size: 11px; line-height: 1;
  padding: 2px 7px 2px 3px; border-radius: 10px;
}
.idrow-kf img { width: 16px; height: 16px; border-radius: 50%; object-fit: cover; }
.idrow-preview {
  margin-top: 5px; font-size: 11.5px; color: #b6bdc7;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* 客服号文件夹卡片上的当天 ID 次数 */
.kf-id-badge {
  display: inline-flex; align-items: center; flex: 0 0 auto;
  background: #f1edfd; color: #6d3df0;
  font-size: 9px; line-height: 1; font-weight: 600;
  padding: 2px 5px; border-radius: 3px;
}

/* ================= 手机版适配（≤768px 纯增量，桌面端样式/行为不受影响） ================= */
/* 仅手机端显示的控件（聊天窗返回键、右侧面板开关等），桌面端一律隐藏 */
.m-only { display: none !important; }

@media (max-width: 768px) {
  .app, .ws-root { height: 100dvh; }
  .ws-root { flex-direction: column; }
  .ws-content { order: 1; position: relative; overflow: hidden; }

  /* ---- 最左导航 → 底部 Tab 栏 ---- */
  .rail {
    order: 2; width: 100%; flex: 0 0 auto;
    flex-direction: row; align-items: stretch; justify-content: space-around;
    padding: 3px 6px calc(3px + env(safe-area-inset-bottom));
    border-right: none; border-top: 1px solid var(--border2);
  }
  .rail-avatar, .rail-name, .rail-spacer { display: none; }
  .rail-nav { margin-top: 0; width: auto; flex: 1; max-width: 150px; padding: 5px 0 4px; gap: 2px; }
  .rail-badge { top: 0; right: 14px; }
  .rail-logout { width: auto; height: auto; flex: 1; max-width: 150px; border-radius: 10px; }

  /* ---- 单栏布局：各栏宽度拉满，由 body 类控制谁可见 ---- */
  .pane-folders { width: 100%; flex: 1 1 auto; border-right: none; }
  body.m-in-kf .ws-content { flex-direction: column; }
  body.m-in-kf .pane-folders { display: none; }
  .pane-ids {
    width: 100%; flex: 0 0 auto; max-height: 42%;
    border-right: none; border-bottom: 1px solid var(--border);
  }
  .pane-convs { width: 100%; flex: 1 1 auto; min-height: 0; border-right: none; }
  .conv-tabs button { flex: 1; }

  /* 聊天窗：默认隐藏，打开会话后全屏覆盖 */
  .chat-pane { position: absolute; inset: 0; z-index: 20; display: none; }
  body.m-in-chat .chat-pane { display: flex; }
  .chat-header { flex-basis: 48px; height: 48px; padding: 0 6px; gap: 4px; }
  .chat-title { font-size: 14px; min-width: 0; }
  .chat-title span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* 右侧 快捷回复/客户详情：抽屉式全屏覆盖在聊天窗之上 */
  .pane-side {
    position: absolute; inset: 0; width: 100%; flex: none; z-index: 30;
    border-left: none; transform: translateX(103%);
    transition: transform .18s ease;
  }
  body.m-side-open .pane-side { transform: none; }
  .side-tabs { flex-wrap: wrap; row-gap: 4px; }

  /* 手机端专用按钮显形 */
  button.m-only { display: inline-flex !important; align-items: center; justify-content: center; }

  /* ---- 聊天区触控优化 ---- */
  .msg-area { padding: 12px 10px; }
  .msg-content { max-width: 78%; }
  .media-img { max-width: 200px; max-height: 200px; }
  .chat-toolbar { padding: 6px 8px 2px; }
  .chat-input-wrap { padding: 4px 8px; }
  .chat-send-row { padding: 0 8px calc(8px + env(safe-area-inset-bottom)); }
  .chat-pending-bar { flex-wrap: wrap; gap: 6px; padding: 8px 10px; font-size: 12px; }
  .chat-closed-bar { padding: 10px 8px; }

  /* 输入字号 ≥16px，避免 iOS Safari 聚焦自动放大页面 */
  input, textarea, select,
  .chat-input-wrap textarea, .pane-search input, .num-input,
  .set-input, .set-textarea, .set-select,
  .modal-body input, .modal-body textarea, .modal-body select { font-size: 16px; }
  .conv-tabs button, .set-tab, .side-tab { font-size: 13px; }

  /* ---- 登录页 ---- */
  .login-card { width: calc(100vw - 44px); padding: 30px 22px 26px; }

  /* ---- 设置中心 ---- */
  .set-tabs { justify-content: flex-start; overflow-x: auto; padding: 0 8px; top: 52px; }
  .set-tabs .set-tab { padding: 0 12px; height: 44px; white-space: nowrap; flex: 0 0 auto; font-size: 13px; }
  .set-main { padding: 14px 10px 64px; }
  .set-card { padding: 16px 14px; }
  .set-grid2 { grid-template-columns: 1fr; }
  .set-hero h2 { font-size: 19px; }
  .hero-action { position: static; margin-top: 10px; }
  .rules-head { flex-wrap: wrap; gap: 10px; }
  .rules-actions { flex-wrap: wrap; gap: 8px; }
  .rules-actions .btn-solid-blue, .rules-actions .btn-ghost-purple { flex: 1 1 auto; }
  .ar-tree { overflow-x: auto; }
  .set-card { overflow-x: auto; }

  /* ---- 弹窗 ---- */
  .modal { width: calc(100vw - 20px); max-height: 84vh; }
  .modal-body { padding: 14px; }
}

