/* ============================================================
   AIStaff MVP — Salesforce 商务风格
   蓝白灰配色 · 三栏布局 · 状态标签红黄绿
   ============================================================ */

:root {
  --primary: #0176d3;
  --primary-hover: #014486;
  --primary-soft: #f0f8ff;
  --bg: #f3f5f7;
  --surface: #ffffff;
  --border: #dddbda;
  --text: #181818;
  --text-secondary: #706e6b;
  --text-muted: #9b9a97;
  --tag-red-bg: #fce4e4;
  --tag-red-text: #ba0517;
  --tag-yellow-bg: #fef0db;
  --tag-yellow-text: #915e00;
  --tag-green-bg: #d8ebe0;
  --tag-green-text: #2e844a;
  --radius: 8px;
  --radius-sm: 4px;
  --sidebar-w: 180px;
  --list-w: 300px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: Inter, "Microsoft YaHei", system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; height: 100vh; overflow: hidden; }

/* ===== 按钮 ===== */
.btn-primary {
  background: var(--primary); color: #fff; border: none;
  border-radius: var(--radius-sm); padding: 7px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline {
  background: #fff; color: var(--primary); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 7px 16px; font-size: 13px; cursor: pointer;
}
.btn-outline:hover { background: var(--primary-soft); }
.btn-secondary {
  background: #fff; color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 20px; font-size: 13px; cursor: pointer;
}
.btn-send {
  background: var(--primary); color: #fff; border: none;
  border-radius: var(--radius-sm); padding: 10px 18px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn-ai-generate {
  background: #fff; color: var(--primary); border: 1px solid var(--primary);
  border-radius: var(--radius-sm); padding: 9px 14px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn-ai-generate:hover { background: var(--primary-soft); }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ===== 顶部栏 ===== */
.topbar {
  height: 48px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 20px;
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 700; color: var(--primary); }
.brand-icon { font-size: 18px; }
.top-actions { display: flex; gap: 8px; }

/* ===== 主布局 ===== */
.shell {
  display: flex; height: calc(100vh - 48px); margin-top: 48px;
}

/* ===== 左侧导航 ===== */
.sidebar {
  width: var(--sidebar-w); background: var(--bg); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding-top: 12px; flex-shrink: 0;
}
.nav-item {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px;
  font-size: 13px; color: var(--text); text-decoration: none; cursor: pointer;
}
.nav-item:hover { background: #ebeef0; }
.nav-item.active { background: #e5e7e9; border-left: 3px solid var(--primary); color: var(--primary); font-weight: 600; padding-left: 13px; }
.nav-icon { width: 18px; text-align: center; font-size: 14px; }
.sidebar-footer { margin-top: auto; padding: 16px; }
.status-indicator { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.status-indicator .dot { width: 8px; height: 8px; border-radius: 50%; background: #ccc; }
.status-indicator.online .dot { background: #2e844a; box-shadow: 0 0 4px rgba(46,132,74,.4); }
.status-indicator.online .status-text { color: #2e844a; }

/* ===== 会话列表 ===== */
.conversation-list {
  width: var(--list-w); background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.list-header { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.list-header h2 { font-size: 14px; font-weight: 600; }
.list-body { flex: 1; overflow-y: auto; }

.conv-item {
  display: flex; align-items: center; gap: 10px; padding: 11px 16px;
  cursor: pointer; border-bottom: 1px solid #f3f2f2; height: 56px;
}
.conv-item:hover { background: #f7f9fb; }
.conv-item.active { background: var(--primary-soft); border-left: 3px solid var(--primary); }
.conv-avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items:center;
  font-size: 14px; font-weight: 600; color: #fff; flex-shrink: 0;
}
.conv-info { flex: 1; min-width: 0; }
.conv-name-row { display: flex; justify-content: space-between; align-items: center; }
.conv-name { font-size: 13px; font-weight: 500; }
.conv-time { font-size: 11px; color: var(--text-muted); }
.conv-preview { font-size: 12px; color: var(--text-secondary); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-tags { display: flex; gap: 4px; margin-top: 3px; }

.tag {
  font-size: 10px; padding: 1px 6px; border-radius: 2px; font-weight: 600;
}
.tag-pending { background: var(--tag-red-bg); color: var(--tag-red-text); }
.tag-progress { background: var(--tag-yellow-bg); color: var(--tag-yellow-text); }
.tag-done { background: var(--tag-green-bg); color: var(--tag-green-text); }
.tag-group { background: #e8f0ff; color: var(--primary); }

.empty-state { padding: 40px 20px; text-align: center; color: var(--text-muted); }
.empty-state p { font-size: 14px; margin-bottom: 4px; }
.empty-state small { font-size: 12px; }

/* ===== 聊天面板 ===== */
.chat-panel { flex: 1; display: flex; flex-direction: column; background: var(--surface); min-width: 0; }
.chat-header {
  padding: 12px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.chat-title-row { display: flex; align-items: center; gap: 10px; }
.chat-title-row h3 { font-size: 15px; font-weight: 600; }

.chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }

.msg-bubble { max-width: 70%; padding: 10px 14px; border-radius: var(--radius); font-size: 13px; line-height: 1.55; word-break: break-word; }
.msg-customer { background: var(--primary); color: #fff; align-self: flex-end; border-bottom-right-radius: 2px; }
.msg-ai { background: var(--bg); color: var(--text); align-self: flex-start; border-bottom-left-radius: 2px; }
.msg-ai-pending { background: #fff8e1; color: var(--text); align-self: flex-start; border-bottom-left-radius: 2px; border: 1px dashed #ffc107; opacity: 0.8; }
.msg-meta { font-size: 11px; color: var(--text-muted); margin-bottom: 3px; }
.msg-ai .msg-meta { color: var(--primary); }

.empty-chat {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-muted); gap: 6px;
}
.empty-icon { font-size: 36px; opacity: .3; }

/* ===== 输入区 ===== */
.chat-input-area {
  padding: 12px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; align-items: center;
}
.msg-input {
  flex: 1; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 14px; font-size: 13px; outline: none;
}
.msg-input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(1,118,211,.1); }

/* ===== 设置弹窗 ===== */
.settings-dialog {
  border: none; border-radius: 12px; padding: 0; max-width: 720px; width: 90%;
  box-shadow: 0 24px 60px rgba(0,0,0,.18);
}
.settings-dialog::backdrop { background: rgba(0,0,0,.35); }
.dialog-content { display: flex; flex-direction: column; max-height: 85vh; }
.dialog-head {
  padding: 18px 24px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.dialog-head h3 { font-size: 16px; }
.icon-btn-close {
  width: 30px; height: 30px; border: none; background: transparent; font-size: 20px;
  cursor: pointer; border-radius: 6px; color: var(--text-muted);
}
.icon-btn-close:hover { background: var(--bg); }
.dialog-body { overflow-y: auto; padding: 20px 24px; }
.setting-section { margin-bottom: 24px; }
.setting-section h4 { font-size: 14px; font-weight: 600; margin-bottom: 12px; color: var(--text); }
.setting-section label { display: block; margin-bottom: 10px; font-size: 13px; }
.setting-section label > input,
.setting-section label > select,
.setting-section label > textarea {
  width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13px; outline: none; font-family: inherit;
}
.setting-section label > input:focus,
.setting-section label > select:focus,
.setting-section label > textarea:focus { border-color: var(--primary); }
.check-label { display: flex !important; gap: 10px; align-items: flex-start; cursor: pointer; }
.check-label input[type="checkbox"] { width: auto; margin-top: 2px; flex-shrink: 0; }
.check-label span strong { display: block; font-size: 13px; }
.check-label span small { display: block; font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.kb-list { max-height: 160px; overflow-y: auto; margin-bottom: 8px; }
.kb-empty { padding: 12px; background: var(--bg); border-radius: var(--radius-sm); font-size: 12px; color: var(--text-muted); text-align: center; }
.kb-item { padding: 8px 10px; background: var(--bg); border-radius: var(--radius-sm); font-size: 12px; margin-bottom: 4px; display: flex; justify-content: space-between; align-items: center; }
.kb-item .kb-del { color: var(--tag-red-text); cursor: pointer; font-size: 14px; background: none; border: none; }

.dialog-actions {
  padding: 14px 24px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #181818; color: #fff; padding: 10px 20px; border-radius: 8px;
  font-size: 13px; z-index: 200; opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d0d0d0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #b0b0b0; }

/* ===== 登录遮罩 ===== */
.login-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: linear-gradient(135deg, #0176d3 0%, #0a3d62 100%);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: #fff; border-radius: 12px; padding: 40px 36px;
  width: 360px; box-shadow: 0 20px 60px rgba(0,0,0,.3);
  text-align: center;
}
.login-brand { margin-bottom: 8px; }
.login-brand .brand-icon { font-size: 32px; }
.login-brand strong { font-size: 22px; color: var(--primary); vertical-align: super; margin-left: 4px; }
.login-card h2 { font-size: 20px; font-weight: 700; margin: 16px 0 4px; }
.login-hint { font-size: 12px; color: var(--text-muted); margin-bottom: 20px; }
.login-card input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 14px; margin-bottom: 12px; box-sizing: border-box;
}
.login-card input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(1,118,211,.12); }
.btn-login {
  width: 100%; padding: 12px; background: var(--primary); color: #fff;
  border: none; border-radius: 6px; font-size: 15px; font-weight: 600; cursor: pointer;
  transition: background .15s;
}
.btn-login:hover { background: #015a9e; }
.login-error { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ===== 顶部栏图标按钮 ===== */
.top-divider { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.btn-icon { padding: 6px 10px !important; font-size: 15px; }

/* ===== 表单组 ===== */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.form-group input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 4px; font-size: 13px; box-sizing: border-box; }
.form-group input:focus { border-color: var(--primary); outline: none; }

/* ============================================================
   v2 新增样式 — 多视图 / 客户管理 / 看板 / SOP / AI 预览
   ============================================================ */

/* ===== 视图容器通用 ===== */
.content-view {
  flex: 1; flex-direction: column; background: var(--surface);
  padding: 24px; overflow-y: auto; min-width: 0;
}
.content-header { margin-bottom: 20px; }
.content-header h2 { font-size: 18px; font-weight: 700; }
.content-header p { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* ===== 客户管理 — 数据表格 ===== */
.data-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.data-table th {
  text-align: left; padding: 10px 12px; background: var(--bg);
  font-weight: 600; color: var(--text-secondary); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 10px 12px; border-bottom: 1px solid #f0f0f0; vertical-align: middle;
}
.data-table tr:hover { background: #f7f9fb; }
.cell-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== 销售看板 ===== */
.dash-loading { padding: 40px; text-align: center; color: var(--text-muted); }
.dash-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px;
}
.dash-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; text-align: center;
}
.dash-number { font-size: 32px; font-weight: 700; color: var(--text); }
.dash-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.dash-section { margin-bottom: 24px; }
.dash-section h4 { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.dash-today { display: flex; gap: 24px; font-size: 13px; }
.dash-today span { background: var(--bg); padding: 6px 14px; border-radius: var(--radius-sm); color: var(--text-secondary); }

.kw-bars { display: flex; flex-direction: column; gap: 8px; max-width: 500px; }
.kw-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.kw-name { width: 60px; text-align: right; color: var(--text-secondary); }
.kw-bar-wrap { flex: 1; height: 20px; background: var(--bg); border-radius: var(--radius-sm); overflow: hidden; }
.kw-bar { height: 100%; background: var(--primary); border-radius: var(--radius-sm); transition: width .3s; }
.kw-count { width: 30px; font-weight: 600; }

/* ===== SOP 自动化 ===== */
.sop-body { display: flex; flex-direction: column; gap: 20px; }
.sop-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.sop-head { padding: 16px 20px; border-bottom: 1px solid var(--border); background: var(--bg); }
.sop-head h4 { font-size: 15px; font-weight: 600; }
.sop-desc { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.sop-steps { padding: 16px 20px; display: flex; flex-direction: column; gap: 16px; }
.sop-step { display: flex; gap: 12px; }
.sop-step-num {
  width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.sop-step-body { flex: 1; }
.sop-step-action { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.sop-step-template {
  font-size: 13px; color: var(--text-secondary); background: var(--bg);
  padding: 8px 12px; border-radius: var(--radius-sm); border-left: 3px solid var(--primary);
  margin-bottom: 6px; line-height: 1.5;
}
.sop-copy-btn { margin-top: 2px; }

/* ============================================================
   知识库增强样式
   ============================================================ */
.kb-tabs { display: flex; gap: 0; margin-bottom: 8px; border-bottom: 2px solid var(--border); }
.kb-tab {
  padding: 6px 14px; font-size: 12px; border: none; background: none;
  color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: all .15s; font-weight: 500;
}
.kb-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.kb-search-bar { display: flex; gap: 6px; margin-bottom: 8px; }

.kb-item-faq { padding: 10px; background: var(--bg-tint); border-radius: 4px; margin-bottom: 6px; border-left: 3px solid var(--primary); }
.kb-item-doc { padding: 8px; background: var(--bg-tint); border-radius: 4px; margin-bottom: 4px; border-left: 3px solid var(--success); }
.kb-faq-q { font-weight: 600; font-size: 12px; margin-bottom: 4px; }
.kb-faq-a { font-size: 12px; color: var(--text-muted); }
.kb-badge {
  display: inline-block; width: 16px; height: 16px; line-height: 16px; text-align: center;
  font-size: 9px; background: var(--primary); color: #fff; border-radius: 2px; margin-right: 4px; font-weight: 700;
}
.kb-badge-a { background: var(--success); }
.kb-cat {
  display: inline-block; font-size: 10px; padding: 1px 6px; background: var(--tag-yellow-bg);
  color: var(--tag-yellow-text); border-radius: 2px; margin-top: 4px; margin-right: 4px; font-weight: 600;
}
.kb-add-faq { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }

/* ============================================================
   对话流程编排器
   ============================================================ */
.flow-container { display: flex; flex: 1; min-height: 0; gap: 1px; background: var(--border); }
.flow-sidebar { width: 200px; background: var(--bg); padding: 12px; overflow-y: auto; }
.flow-sidebar h4 { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.flow-list { display: flex; flex-direction: column; gap: 4px; }
.flow-item { padding: 8px; background: var(--bg-tint); border-radius: 4px; cursor: pointer; transition: all .15s; border: 2px solid transparent; }
.flow-item:hover { background: var(--bg-hover); }
.flow-item.active { border-color: var(--primary); background: #eaf5ff; }
.flow-item-name { font-size: 13px; font-weight: 600; }
.flow-item-desc { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.flow-toolbox { display: flex; flex-direction: column; gap: 4px; }
.flow-tool { padding: 6px 10px; background: var(--bg-tint); border-radius: 4px; font-size: 12px; cursor: grab; transition: all .15s; display: flex; align-items: center; gap: 6px; }
.flow-tool:hover { background: var(--bg-hover); border-left: 3px solid var(--primary); }

.flow-canvas-wrap { flex: 1; display: flex; flex-direction: column; background: var(--bg); min-width: 0; }
.flow-toolbar { padding: 8px 12px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.flow-canvas { flex: 1; position: relative; overflow: auto; background: var(--bg-tint); background-image: radial-gradient(circle, var(--border) 1px, transparent 1px); background-size: 20px 20px; min-height: 500px; }
.flow-svg { position: absolute; top: 0; left: 0; pointer-events: none; }
.flow-edge { stroke-dasharray: 0; transition: stroke .15s; }
.flow-edge-cond { stroke-dasharray: 5 3; }
.flow-nodes-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }

.flow-node { position: absolute; width: 140px; background: #fff; border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); user-select: none; }
.flow-node-head { padding: 8px 10px; font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 6px; cursor: move; border-left: 3px solid #999; border-radius: 6px 6px 0 0; background: var(--bg-tint); }
.flow-node-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-node-preview { padding: 4px 10px; font-size: 11px; color: var(--text-muted); border-top: 1px solid var(--border); }
.flow-node-ports { padding: 4px 10px; border-top: 1px solid var(--border); }
.flow-port { font-size: 10px; color: var(--primary); padding: 2px 0; }
.flow-node-actions { padding: 4px 10px; display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--border); }
.flow-node-connect, .flow-node-edit, .flow-node-del { cursor: pointer; font-size: 12px; color: var(--text-muted); }
.flow-node-connect:hover { color: var(--primary); }
.flow-node-edit:hover { color: var(--primary); }
.flow-node-del:hover { color: var(--danger); }
.flow-node.connecting { box-shadow: 0 0 0 2px var(--primary); }
.flow-node-start .flow-node-head { background: #e8f5e9; }

/* ===== AI 人格卡片 ===== */
.persona-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 20px; margin-bottom: 12px;
}
.persona-card.inactive { opacity: 0.55; }
.persona-head { display: flex; align-items: center; gap: 12px; }
.persona-avatar { font-size: 28px; }
.persona-info { flex: 1; }
.persona-name { font-size: 15px; font-weight: 700; }
.persona-style { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.persona-actions { display: flex; align-items: center; gap: 8px; }
.switch-toggle { display: flex; align-items: center; gap: 4px; font-size: 12px; cursor: pointer; }
.switch-toggle input { margin: 0; }
.persona-detail { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.persona-section { margin-bottom: 8px; }
.persona-section strong { font-size: 12px; color: var(--text-secondary); }
.persona-section p { font-size: 13px; margin-top: 4px; line-height: 1.5; color: var(--text); }

/* ===== AI 话术预览气泡 ===== */
.msg-ai-preview {
  background: #f0f8ff; border: 1px dashed var(--primary); color: var(--text);
  padding: 12px 16px; border-radius: var(--radius); font-size: 13px; line-height: 1.6;
  outline: none; min-height: 40px;
}
.msg-ai-preview:focus { border-style: solid; box-shadow: 0 0 0 2px rgba(1,118,211,.1); }
.ai-preview-actions {
  display: flex; gap: 8px; margin-top: 8px;
}
.btn-ai-confirm {
  background: var(--primary); color: #fff; border: none;
  border-radius: var(--radius-sm); padding: 6px 14px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.btn-ai-redo {
  background: #fff; color: var(--primary); border: 1px solid var(--primary);
  border-radius: var(--radius-sm); padding: 5px 12px; font-size: 12px; cursor: pointer;
}
.btn-ai-cancel {
  background: transparent; color: var(--text-muted); border: none;
  padding: 5px 10px; font-size: 12px; cursor: pointer;
}

/* ===== 系统消息 ===== */
.msg-system {
  background: #fff8e1; color: #915e00; border: 1px solid #ffe082;
  padding: 6px 14px; border-radius: 20px; font-size: 12px; text-align: center;
  max-width: 80%;
}

/* ===== 模拟消息弹窗 ===== */
.simulate-dialog {
  border: none; border-radius: 12px; padding: 0; max-width: 520px; width: 90%;
  box-shadow: 0 24px 60px rgba(0,0,0,.18);
}
.simulate-dialog::backdrop { background: rgba(0,0,0,.35); }
.sim-hint {
  background: var(--primary-soft); color: var(--primary); padding: 10px 14px;
  border-radius: var(--radius-sm); font-size: 12px; margin-bottom: 16px;
}
#closeSimulate {
  width: 30px; height: 30px; border: none; background: transparent; font-size: 20px;
  cursor: pointer; border-radius: 6px; color: var(--text-muted);
}
#closeSimulate:hover { background: var(--bg); }
.sim-presets { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.preset-btn {
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 20px; padding: 5px 12px; font-size: 12px; cursor: pointer;
}
.preset-btn:hover { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }

/* ===== 徽章 ===== */
.badge-pending {
  display: inline-block; font-size: 10px; padding: 1px 6px;
  background: var(--tag-yellow-bg); color: var(--tag-yellow-text);
  border-radius: 2px; font-weight: 600; margin-left: 6px;
}
.badge-done {
  display: inline-block; font-size: 10px; padding: 1px 6px;
  background: var(--tag-green-bg); color: var(--tag-green-text);
  border-radius: 2px; font-weight: 600; margin-left: 6px;
}

/* ============================================================
   v3 新增 — 快捷话术 / 时间线 / 头部按钮 / 备注 badge
   ============================================================ */

/* ===== 聊天头部操作按钮 ===== */
.chat-header { justify-content: space-between; }
.chat-header-actions { display: flex; gap: 4px; }
.btn-icon {
  width: 32px; height: 32px; border: none; background: transparent;
  font-size: 16px; cursor: pointer; border-radius: 6px; display: grid; place-items: center;
}
.btn-icon:hover { background: var(--bg); }

/* ===== 快捷话术栏 ===== */
.quick-replies-bar {
  border-top: 1px solid var(--border); background: var(--bg); max-height: 180px; overflow: hidden;
  display: flex; flex-direction: column;
}
.qr-tabs {
  display: flex; gap: 2px; padding: 6px 12px 0; border-bottom: 1px solid var(--border); background: var(--surface);
}
.qr-tab {
  border: none; background: transparent; padding: 6px 12px; font-size: 12px; cursor: pointer;
  border-bottom: 2px solid transparent; color: var(--text-secondary);
}
.qr-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.qr-list { flex: 1; overflow-y: auto; padding: 6px 12px; }
.qr-item {
  padding: 6px 10px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 12px; margin-bottom: 4px; cursor: pointer;
  transition: all .15s; line-height: 1.4;
}
.qr-item:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

/* ===== 日期分割线 ===== */
.msg-date-divider {
  align-self: center; font-size: 11px; color: var(--text-muted);
  background: var(--bg); padding: 2px 12px; border-radius: 10px; margin: 8px 0;
}
.msg-meta.right { text-align: right; }

/* ===== 备注 badge ===== */
.conv-note-badge {
  display: inline-block; font-size: 11px; padding: 1px 8px;
  background: #e8f0ff; color: var(--primary); border-radius: 10px;
  margin-left: 6px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.conv-note-mini {
  font-size: 10px; color: var(--text-muted); margin-left: 4px; font-style: italic;
}

/* ===== 标签快捷选择 ===== */
.tag-palette { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.tag-pick.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ============================================================
   移动端响应式适配
   ============================================================ */

/* 平板（768px ~ 1024px） */
@media (max-width: 1024px) {
  .sidebar { width: 56px; }
  .nav-item span:not(.nav-icon) { display: none; }
  .nav-item .nav-icon { font-size: 18px; }
  .sidebar-footer { display: none; }
  .conversation-list { width: 240px; }
  .top-actions .btn-outline span { display: none; }
  .topbar { padding: 0 12px; }
  .brand strong { font-size: 16px; }
  .settings-dialog { max-width: 90vw !important; }
}

/* 手机（< 768px） */
@media (max-width: 768px) {
  /* 整体布局 */
  .topbar {
    padding: 0 10px;
    height: 48px;
  }
  .brand strong { display: none; }
  .brand-icon { font-size: 20px; }
  .top-actions { gap: 4px; }
  .top-actions .btn-primary,
  .top-actions .btn-outline {
    padding: 4px 8px; font-size: 12px;
  }
  .btn-icon { font-size: 16px; padding: 2px 4px; }
  .top-divider { display: none; }

  /* 侧边栏 → 底部 TabBar */
  .shell { flex-direction: column-reverse !important; }
  .sidebar {
    width: 100% !important;
    height: 56px;
    flex-direction: row !important;
    border-right: none !important;
    border-top: 1px solid var(--border);
    overflow-x: auto;
    padding: 0;
    flex-shrink: 0;
    justify-content: space-around;
    align-items: center;
  }
  .nav-item {
    flex-direction: column;
    gap: 2px;
    padding: 6px 4px;
    font-size: 10px;
    border-left: none !important;
    border-top: 3px solid transparent;
    min-width: 52px;
  }
  .nav-item.active {
    border-left: none !important;
    border-top-color: var(--primary);
    background: transparent !important;
    color: var(--primary) !important;
  }
  .nav-item span:not(.nav-icon) { display: block; font-size: 9px; }
  .nav-item .nav-icon { font-size: 16px; }
  .sidebar-footer { display: none !important; }
  .brand { display: none; }

  /* 会话列表 + 聊天面板 → 堆叠切换 */
  #view-inbox { flex-direction: column !important; }
  .conversation-list {
    width: 100% !important;
    height: 40vh;
    border-right: none !important;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .list-header h2 { font-size: 14px; }
  .conv-item { padding: 8px; }
  .conv-avatar { width: 36px; height: 36px; font-size: 14px; }
  .conv-name { font-size: 13px; }
  .conv-preview { font-size: 11px; }

  /* 聊天面板 */
  .chat-panel { flex: 1; min-height: 0; }
  .chat-header { padding: 8px 10px; }
  .chat-header h3 { font-size: 14px; }
  .chat-header-actions { gap: 4px; }
  .chat-header-actions .btn-icon { font-size: 14px; }
  .msg-bubble { max-width: 85% !important; font-size: 14px; }
  .chat-input-area { padding: 6px 10px; }
  .msg-input { font-size: 14px; }
  .btn-ai-generate { font-size: 11px; padding: 4px 8px; }

  /* 快捷话术栏 */
  .quick-replies-bar { max-height: 120px; overflow-y: auto; }
  .qr-tabs { overflow-x: auto; flex-wrap: nowrap; }
  .qr-item { padding: 6px 8px; font-size: 12px; }

  /* 内容视图 */
  .view-container.content-view { padding: 10px !important; }
  .content-header h2 { font-size: 16px; }
  .content-header p { font-size: 12px; }

  /* 数据表格 → 卡片布局 */
  .data-table { font-size: 12px; }
  .data-table th, .data-table td { padding: 6px 4px; }

  /* 看板 */
  .dash-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 8px !important; }
  .dash-card { padding: 12px; }
  .dash-number { font-size: 24px; }
  .dash-label { font-size: 11px; }
  .dash-today { flex-direction: column; gap: 4px; }
  .kw-bar-wrap { min-width: 60px; }

  /* SOP / 流程 */
  .sop-card, .persona-card { padding: 10px; }
  .sop-step-template { font-size: 12px; }

  /* 对话流程画布 */
  .flow-container { flex-direction: column !important; }
  .flow-sidebar { width: 100% !important; max-height: 120px; flex-direction: row; overflow-x: auto; }
  .flow-toolbox { flex-direction: row; }
  .flow-tool { white-space: nowrap; }
  .flow-canvas { min-height: 300px; }

  /* 弹窗全屏化 */
  dialog, .settings-dialog, .simulate-dialog {
    max-width: 95vw !important;
    max-height: 90vh !important;
    margin: 0 !important;
    padding: 12px !important;
  }
  .dialog-content { max-width: 95vw !important; }
  .dialog-body { max-height: 60vh; overflow-y: auto; }
  .setting-section { padding: 10px 0; }
  .setting-section label { font-size: 13px; }
  .setting-section input, .setting-section textarea, .setting-section select {
    font-size: 14px; padding: 8px;
  }

  /* 登录遮罩 */
  .login-card { width: 90vw; padding: 20px; }
  .login-card h2 { font-size: 18px; }
  .login-card input { font-size: 16px; padding: 10px; }

  /* 聊天消息时间线分组 */
  .msg-date-divider { font-size: 10px; }
  .msg-meta { font-size: 10px; }

  /* AI 预览气泡 */
  .ai-preview-actions { flex-wrap: wrap; gap: 4px; }
  .ai-preview-actions button { font-size: 11px; padding: 4px 8px; }
}

/* 小手机（< 480px） */
@media (max-width: 480px) {
  .dash-grid { grid-template-columns: 1fr !important; }
  .conv-avatar { width: 32px; height: 32px; font-size: 12px; }
  .top-actions button { padding: 2px 6px; }
  .top-actions .btn-primary, .top-actions .btn-outline { font-size: 11px; }
}

/* 触控优化（适用于所有触摸设备） */
@media (hover: none) and (pointer: coarse) {
  .conv-item { min-height: 56px; }
  .btn-sm { padding: 6px 10px; }
  .btn-icon { min-width: 32px; min-height: 32px; display: inline-flex; align-items: center; justify-content: center; }
  .nav-item { min-height: 48px; }
  .qr-item { padding: 10px; border: 1px solid var(--border); margin-bottom: 4px; }
  .kb-item { padding: 10px; }
}

/* 网页客服浮动入口（移动端友好） */
.webchat-fab {
  position: fixed; bottom: 72px; right: 16px; width: 44px; height: 44px;
  border-radius: 50%; background: var(--primary); color: #fff; display: none;
  align-items: center; justify-content: center; font-size: 20px; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2); z-index: 9000;
}
@media (max-width: 768px) {
  .webchat-fab { display: flex; }
}
