:root {
  --primary: #1aad19;
  --primary-dark: #128015;
  --bg: #f5f6f7;
  --card: #ffffff;
  --text: #1f2329;
  --text-light: #646a73;
  --border: #e5e6eb;
  --hover: #f2f3f5;
  --danger: #f53f3f;
  --warn: #ff7d00;
  --success: #00b42a;
  --info: #165dff;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif; color: var(--text); background: var(--bg); }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

/* ===== 登录页 ===== */
.login-body { display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1aad19 0%, #128015 100%); }
.login-card { background: var(--card); border-radius: 16px; padding: 40px; width: 360px; box-shadow: 0 20px 60px rgba(0,0,0,.15); }
.login-card h1 { margin: 0 0 8px; font-size: 22px; }
.login-card .sub { color: var(--text-light); margin: 0 0 24px; font-size: 13px; }
.login-card label { display: block; margin-bottom: 16px; font-size: 13px; color: var(--text-light); }
.login-card input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; margin-top: 6px; }
.login-card input:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
.login-card .err { color: var(--danger); font-size: 13px; min-height: 18px; margin: 8px 0 0; }
.login-card .footer { color: var(--text-light); font-size: 12px; text-align: center; margin: 16px 0 0; }

/* ===== 通用按钮 ===== */
.btn { padding: 6px 14px; border: 1px solid var(--border); background: #fff; color: var(--text); border-radius: 6px; font-size: 13px; }
.btn:hover { background: var(--hover); }
.btn-primary { padding: 8px 18px; background: var(--primary); color: #fff; border: none; border-radius: 6px; font-size: 13px; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: #fff; }
.btn-danger:hover { background: #fff1f0; }
.btn-link { background: none; border: none; color: var(--text-light); font-size: 13px; padding: 4px 8px; }
.btn-link:hover { color: var(--primary); }

/* ===== 顶部栏 ===== */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 0 24px; height: 56px; background: #fff; border-bottom: 1px solid var(--border); }
.brand { font-weight: 600; font-size: 16px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.who { color: var(--text-light); font-size: 13px; }

/* ===== 布局 ===== */
.layout { display: flex; height: calc(100vh - 56px); }
.sidebar { width: 200px; background: #fff; border-right: 1px solid var(--border); padding: 12px 0; }
.nav-item { display: block; padding: 12px 24px; color: var(--text); text-decoration: none; font-size: 14px; }
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: #e8f7e8; color: var(--primary-dark); font-weight: 500; border-right: 3px solid var(--primary); }
.main { flex: 1; overflow: auto; padding: 24px; }

/* ===== View 通用 ===== */
.view-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.view-header h2 { margin: 0; font-size: 18px; }
.empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-light); font-size: 14px; }
.stats { display: flex; gap: 16px; margin-bottom: 16px; font-size: 13px; color: var(--text-light); }
.stats strong { color: var(--text); font-size: 16px; margin-right: 4px; }

/* ===== 会话页面 ===== */
.search-bar { display: flex; gap: 8px; align-items: center; }
.search-bar input[type=text] { padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; min-width: 240px; }
.checkbox { font-size: 13px; color: var(--text-light); display: flex; align-items: center; gap: 4px; }

.conv-grid { display: grid; grid-template-columns: 320px 1fr; gap: 16px; height: calc(100vh - 56px - 24px*2 - 60px - 50px); }
.conv-list { background: #fff; border: 1px solid var(--border); border-radius: 8px; overflow: auto; }
.conv-item { padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .15s; }
.conv-item:hover { background: var(--hover); }
.conv-item.active { background: #e8f7e8; }
.conv-item.is-manual { border-left: 3px solid #ff7a00; background: #fff8ee; }
.conv-item.is-manual.active { background: #ffeed6; }
.conv-item .conv-actions { margin-top: 8px; opacity: 0; transition: opacity .15s; }
.conv-item:hover .conv-actions, .conv-item.active .conv-actions { opacity: 1; }
.conv-item .btn-open { padding: 4px 10px; font-size: 12px; background: var(--primary); color: #fff; border: none; }
.conv-item .btn-open:hover { background: var(--primary-dark); }
.conv-item .name { font-size: 14px; font-weight: 500; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.conv-item .preview { font-size: 12px; color: var(--text-light); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item .unread { background: var(--danger); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 10px; }
.conv-item .ts { font-size: 11px; color: var(--text-light); font-weight: normal; }
.conv-item .mode-badge { font-size: 10px; padding: 1px 6px; border-radius: 8px; font-weight: 500; white-space: nowrap; }
.conv-item .mode-badge.ai { background: #e8f7e8; color: var(--primary-dark); }
.conv-item .mode-badge.manual { background: #fff1d6; color: #d96b00; }

/* ===== 门店信息卡（重点客户列表项内） ===== */
.store-card { margin-top: 8px; padding: 8px 10px; background: #fff; border: 1px solid #f0d98c; border-left: 3px solid #f7b500; border-radius: 6px; font-size: 12px; line-height: 1.6; }
.store-card.store-pending { border-color: #e5e6eb; border-left-color: #86909c; background: #f7f8fa; }
.store-line strong { font-weight: 600; }
.store-brand { display: inline-block; background: #e8f7e8; color: var(--primary-dark); font-size: 11px; padding: 0 6px; border-radius: 8px; margin-left: 4px; }
.store-dist { color: var(--text-light); font-size: 11px; margin-left: 4px; }
.store-addr { color: var(--text); }
.store-tel { color: #d25f00; font-weight: 600; }
.store-tel .internal-only, .store-tel-none { color: var(--text-light); font-size: 11px; font-weight: 400; }

/* ===== 重点关注（星标） ===== */
.star-btn { background: none; border: none; font-size: 16px; line-height: 1; color: #c9cdd4; padding: 0 4px 0 0; cursor: pointer; flex-shrink: 0; }
.star-btn:hover { color: #f7b500; transform: scale(1.15); }
.star-btn.starred { color: #f7b500; text-shadow: 0 0 4px rgba(247,181,0,.4); }
.conv-item.is-focused { background: #fffbe8; }
.conv-item.is-focused:hover { background: #fff7d6; }
.conv-item.is-focused.active { background: #fff1c4; }
.nav-item .focus-count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 6px; background: #f7b500; color: #fff; font-size: 11px; border-radius: 9px; text-align: center; font-weight: 600; }
.conv-detail { background: #fff; border: 1px solid var(--border); border-radius: 8px; display: flex; flex-direction: column; }
.conv-header { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.conv-header .head-left { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.conv-header .title { font-size: 15px; font-weight: 500; }
.conv-header .uid { font-size: 12px; color: var(--text-light); margin-left: 8px; }
.conv-header .mode-bar { display: flex; align-items: center; gap: 10px; }
.conv-header .mode-tag { font-size: 12px; padding: 3px 10px; border-radius: 12px; font-weight: 500; }
.conv-header .mode-tag.ai { background: #e8f7e8; color: var(--primary-dark); }
.conv-header .mode-tag.manual { background: #fff1d6; color: #d96b00; }
.btn-warn { padding: 6px 14px; background: #ff7a00; color: #fff; border: none; border-radius: 6px; font-size: 13px; cursor: pointer; }
.btn-warn:hover { background: #e86d00; }
.btn-warn:disabled { opacity: 0.5; cursor: not-allowed; }
.conv-msgs { flex: 1; overflow: auto; padding: 16px; }
.msg { margin-bottom: 14px; max-width: 70%; display: flex; flex-direction: column; }
.msg.in { margin-right: auto; }
.msg.out { margin-left: auto; align-items: flex-end; }
.msg .bubble { padding: 8px 12px; border-radius: 8px; font-size: 14px; line-height: 1.5; word-break: break-word; white-space: pre-wrap; }
.msg.in .bubble { background: var(--hover); }
.msg.out .bubble { background: #95ec69; }
.msg.event .bubble { background: #fffbe6; color: var(--warn); font-size: 12px; font-style: italic; }
.msg .meta { font-size: 11px; color: var(--text-light); margin-top: 2px; }
.conv-input { padding: 12px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.conv-input textarea { flex: 1; border: 1px solid var(--border); border-radius: 6px; padding: 8px; font-size: 14px; resize: none; min-height: 40px; max-height: 120px; }
.conv-input textarea:focus { outline: 2px solid var(--primary); border-color: var(--primary); }

/* ===== 表格 ===== */
.tbl { width: 100%; background: #fff; border: 1px solid var(--border); border-radius: 8px; border-collapse: collapse; overflow: hidden; }
.tbl th, .tbl td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
.tbl th { background: #fafbfc; font-weight: 500; color: var(--text-light); }
.tbl tr:last-child td { border-bottom: none; }
.tbl .content-cell { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== 状态徽章 ===== */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; }
.badge.active { background: #e8f7e8; color: var(--success); }
.badge.done { background: #f0f0f0; color: var(--text-light); }
.badge.paused { background: #fff7e6; color: var(--warn); }
.badge.admin { background: #fff1f0; color: var(--danger); }
.badge.viewer { background: #e8f7e8; color: var(--success); }

/* ===== Toast 通知 ===== */
.toast { position: fixed; top: 24px; left: 50%; transform: translateX(-50%) translateY(-20px); padding: 10px 20px; border-radius: 8px; font-size: 14px; font-weight: 500; color: #fff; box-shadow: 0 6px 24px rgba(0,0,0,.18); z-index: 99999; opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; max-width: 80vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warn { background: var(--warn); }
.toast-info { background: var(--info); }

/* ===== 自定义模态确认框 ===== */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 99998; animation: fadein .15s; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.modal-box { background: #fff; border-radius: 12px; padding: 24px; min-width: 320px; max-width: 480px; box-shadow: 0 20px 60px rgba(0,0,0,.25); animation: slidein .2s; }
@keyframes slidein { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.modal-body { font-size: 14px; line-height: 1.7; color: var(--text); white-space: pre-line; margin-bottom: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-actions .btn { padding: 8px 18px; }

/* ===== Dialog ===== */
.dialog { padding: 0; border: none; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.2); max-width: 480px; width: 90%; }
.dialog::backdrop { background: rgba(0,0,0,.4); }
.dialog form { padding: 24px; }
.dialog h3 { margin: 0 0 16px; }
.dialog label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--text-light); }
.dialog input, .dialog textarea, .dialog select { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; margin-top: 4px; }
.dialog .dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.dow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.dow label { display: flex; align-items: center; gap: 4px; font-size: 13px; }
