/* CardPlug 管理后台样式。零依赖，浅色/深色跟随系统。 */

:root {
  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface-alt: #e9e9ee;
  --text: #000000;
  --text-secondary: rgba(60, 60, 67, 0.62);
  --text-tertiary: rgba(60, 60, 67, 0.36);
  --border: rgba(60, 60, 67, 0.18);
  --accent: #0a84ff;
  --success: #248a3d;
  --warning: #b26a00;
  --danger: #d70015;
  --warning-bg: rgba(255, 149, 0, 0.12);
  --danger-bg: rgba(255, 59, 48, 0.1);
  --success-bg: rgba(52, 199, 89, 0.14);
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-alt: #2c2c2e;
    --text: #ffffff;
    --text-secondary: rgba(235, 235, 245, 0.62);
    --text-tertiary: rgba(235, 235, 245, 0.32);
    --border: rgba(84, 84, 88, 0.6);
    --accent: #0a84ff;
    --success: #30d158;
    --warning: #ff9f0a;
    --danger: #ff453a;
    --warning-bg: rgba(255, 159, 10, 0.16);
    --danger-bg: rgba(255, 69, 58, 0.16);
    --success-bg: rgba(48, 209, 88, 0.16);
    --shadow: none;
  }
}

* { box-sizing: border-box; }

/*
 * 必须放在所有布局规则之前（或用 !important）。
 *
 * 原因：浏览器默认样式是 `[hidden] { display: none }`，但**作者样式里的 display
 * 优先级更高**。下面 .modal / .panel / .login-view 都设置了 display，
 * 如果不加这条，标了 hidden 的元素依然会显示出来
 * （典型症状：弹窗挡住页面、所有面板同时可见）。
 */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; }
p { margin: 0; }
button { font: inherit; cursor: pointer; }
.muted { color: var(--text-secondary); }
.small { font-size: 13px; }
.center { text-align: center; }
.error { color: var(--danger); font-size: 13px; white-space: pre-line; }

/* 服务器连接状态指示 */
.status {
  font-style: normal;
  font-size: 12px;
  padding: 1px 7px;
  border-radius: 999px;
  margin-left: 4px;
}
.status.checking { background: var(--surface-alt); color: var(--text-tertiary); }
.status.ok { background: var(--success-bg); color: var(--success); }
.status.bad { background: var(--danger-bg); color: var(--danger); }

/* ---------- 登录 ---------- */

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 16px;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow);
}

.login-brand { text-align: center; display: flex; flex-direction: column; gap: 6px; align-items: center; margin-bottom: 8px; }
.login-brand h1 { font-size: 20px; }

.logo {
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-weight: 600; font-size: 18px; letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.logo.sm { width: 26px; height: 26px; border-radius: 7px; font-size: 11px; margin: 0; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-secondary); }

input[type="email"], input[type="password"], input[type="text"], select, textarea {
  width: 100%;
  padding: 11px 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface-alt);
  border: 1px solid transparent;
  border-radius: 10px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }

/* ---------- 按钮 ---------- */

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 16px;
  font-weight: 500;
  background: var(--surface-alt);
  color: var(--text);
  transition: opacity 0.12s;
}
.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.block { width: 100%; padding: 12px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.success { background: var(--success); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--text-secondary); }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 20px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; }

.tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.tabs button {
  border: none; background: transparent; color: var(--text-secondary);
  padding: 8px 14px; border-radius: 9px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
}
.tabs button:hover { background: var(--surface-alt); }
.tabs button.active { background: var(--accent); color: #fff; }

.badge {
  min-width: 20px; padding: 0 6px; height: 18px; line-height: 18px;
  border-radius: 9px; background: var(--danger); color: #fff;
  font-size: 11px; text-align: center; font-weight: 600;
}
.tabs button.active .badge { background: rgba(255, 255, 255, 0.28); }

.user { display: flex; align-items: center; gap: 10px; }

/* ---------- 内容区 ---------- */

main { padding: 24px; max-width: 1180px; margin: 0 auto; }
.panel { display: flex; flex-direction: column; gap: 14px; }

.section-head {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  margin-bottom: 2px;
}
.section-head h2 { font-size: 17px; }

/* 概览卡片 */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 14px; }
.stat {
  background: var(--surface); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px;
}
.stat .value { font-size: 30px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .label { font-size: 13px; color: var(--text-secondary); }
.stat.warn .value { color: var(--warning); }
.stat.danger .value { color: var(--danger); }

/* 列表项 */
.item {
  background: var(--surface); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px;
}
.item-head { display: flex; align-items: flex-start; gap: 12px; }
.item-title { font-weight: 600; font-size: 15px; word-break: break-word; }
.item-sub { font-size: 13px; color: var(--text-secondary); }
.item-meta { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.chip.neutral { background: var(--surface-alt); color: var(--text-secondary); }
.chip.warn { background: var(--warning-bg); color: var(--warning); }
.chip.danger { background: var(--danger-bg); color: var(--danger); }
.chip.success { background: var(--success-bg); color: var(--success); }
.chip.accent { background: rgba(10, 132, 255, 0.14); color: var(--accent); }

.note {
  display: flex; gap: 8px; align-items: flex-start;
  background: var(--warning-bg); color: var(--warning);
  padding: 10px 12px; border-radius: 9px; font-size: 13px;
}

.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* 工单对话气泡 */
.thread { display: flex; flex-direction: column; gap: 8px; }
.bubble {
  background: var(--surface-alt);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  max-width: 92%;
  word-break: break-word;
}
.bubble.admin { background: rgba(10, 132, 255, 0.14); align-self: flex-end; }
.bubble-head { font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }

/* 日志条目更紧凑 */
.item.compact { padding: 12px 16px; gap: 4px; }

.empty {
  background: var(--surface); border-radius: var(--radius);
  padding: 56px 24px; text-align: center;
  display: flex; flex-direction: column; gap: 6px;
  box-shadow: var(--shadow);
}

.loading { padding: 48px; text-align: center; color: var(--text-secondary); }

/* 卡片管理工具条 */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar select { width: auto; min-width: 160px; }
.toolbar .opt { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.toolbar .opt input { width: auto; }

/* 提示音音量滑块 */
.toolbar .opt input[type="range"] { width: 92px; accent-color: #0a84ff; cursor: pointer; }
.toolbar .opt input[type="range"]:disabled { opacity: .4; cursor: not-allowed; }
.toolbar .opt #opt-volume-label {
  min-width: 36px; text-align: right; font-variant-numeric: tabular-nums;
}

/* ---------- 品种编辑弹窗里的表单 ---------- */

.form-grid { display: grid; gap: 12px; margin: 14px 0; }

.form-grid .field { display: flex; flex-direction: column; gap: 5px; }
.form-grid .field > span { font-size: 13px; color: var(--text-secondary); }

.form-grid .field input:not([type="checkbox"]) {
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
}

.form-grid .field.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.form-grid .field.checkbox > span { font-size: 14px; color: var(--text); }
.form-grid .field.checkbox input { width: auto; }

/* Logo 选择：左边预览，右边按钮 */
.logo-picker { display: flex; align-items: center; gap: 12px; }
.logo-preview {
  width: 64px;
  height: 64px;
  flex: none;
  border: 1px dashed var(--border);
  border-radius: 12px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--surface-alt);
}
.logo-preview img { width: 100%; height: 100%; object-fit: contain; }
.logo-actions { display: flex; flex-direction: column; gap: 6px; }

/* 列表里的 Logo（没有 logo 时回退成 icon + tint 的圆形色块） */
.cat-logo {
  width: 40px; height: 40px; border-radius: 10px; flex: none;
  display: grid; place-items: center; overflow: hidden;
  background: var(--surface-alt);
}
.cat-logo img { width: 100%; height: 100%; object-fit: contain; }

/* 品种列表每行 */
.cat-change { font-size: 12px; font-weight: 600; }
.cat-change.up { color: var(--danger); }    /* 涨 = 红 */
.cat-change.down { color: var(--success); } /* 跌 = 绿 */

/* ---------- 成交明细 ---------- */

.deal-detail {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px 20px;
}

.deal-row { display: flex; gap: 10px; align-items: baseline; }

.deal-row dt {
  flex: 0 0 64px;
  font-size: 13px;
  color: var(--text-secondary);
}

.deal-row dd {
  margin: 0;
  font-size: 13px;
  word-break: break-all;
}

/* 卡密：等宽字体 + 可整段选中，方便复制 */
.deal-code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
  background: var(--surface-alt);
  border-radius: 6px;
  padding: 2px 8px;
  user-select: all;
}

.deal-thumb {
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  text-decoration: none;
  width: fit-content;
}

.deal-thumb img {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* 成交页的状态标签（待付 / 已付 / 异常） */
.tabs-inline { display: flex; gap: 4px; }
.tabs-inline button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 4px 14px;
  font-size: 13px;
  cursor: pointer;
}
.tabs-inline button:hover { border-color: var(--accent); color: var(--accent); }
.tabs-inline button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* 成交项底部的操作行：联系客户 + 改状态 */
.deal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* 积分充值：每笔成交都有，待付 / 已付 / 异常三个标签通用 */
.deal-points {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-alt);
}
.deal-points-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.deal-points-title { font-size: 13px; font-weight: 600; }
.deal-points-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.deal-points-row input {
  width: 130px;
  height: 32px;
  padding: 0 10px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
}
.deal-points-row input:focus { border-color: var(--accent); }
/* 数字输入框的上下箭头在窄格子里很挤，去掉 */
.deal-points-row input::-webkit-outer-spin-button,
.deal-points-row input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.deal-points-row input[type="number"] { -moz-appearance: textfield; }

/* ---------- 汇率页 ---------- */

/* 阶梯：每条一个胶囊，一行放不下就换行 */
.tier-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tier-chip {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* 弹窗里的阶梯编辑器：一行 = 起始余额 + 费率 + 删除 */
.tier-editor { margin: 6px 0 4px; }
.tier-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
}
.tier-edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.tier-edit-row input {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
}
.tier-edit-row input:focus { border-color: var(--accent); }
.tier-edit-row input[type='number']::-webkit-outer-spin-button,
.tier-edit-row input[type='number']::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

/* ---------- 弹窗 / 提示 ---------- */

.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, 0.4);
  display: grid; place-items: center; padding: 24px;
}
.modal-card {
  background: var(--surface); border-radius: 14px;
  padding: 22px; width: 100%; max-width: 420px;
  display: flex; flex-direction: column; gap: 10px;
}
.modal-card h2 { font-size: 17px; }
.modal-actions { display: flex; gap: 10px; margin-top: 6px; }
.modal-actions .btn { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  z-index: 200; padding: 11px 20px; border-radius: 10px;
  background: #1c1c1e; color: #fff; font-size: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  max-width: 90vw; text-align: center;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* ---------- 实时客服：会话列表 ---------- */

.conv {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
  border-left: 3px solid transparent;
}
.conv:hover { background: var(--surface-alt); }
.conv.unread { border-left-color: var(--danger); }
.conv.active { border-left-color: var(--accent); }

.conv-avatar {
  width: 40px; height: 40px; border-radius: 20px;
  background: var(--surface-alt); color: var(--text-secondary);
  display: grid; place-items: center; font-weight: 600; flex: none;
}
.conv-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.conv-row { display: flex; align-items: center; gap: 8px; }
.conv-name { font-weight: 600; font-size: 15px; }
.conv-preview {
  font-size: 13px; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-time { font-size: 12px; color: var(--text-tertiary); flex: none; }
.conv-count {
  min-width: 20px; height: 20px; line-height: 20px; padding: 0 6px;
  border-radius: 10px; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 600; text-align: center; flex: none;
}

/* ---------- 浮动客服窗口（可拖动 / 可最小化） ---------- */

.chat-window {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 720px;
  height: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: row; /* 左右两栏：客户列表 + 当前会话 */
  overflow: hidden;
  z-index: 150;
}

/* 最小化：只剩一条标题栏。左栏也一起收起，未读数显示在标题上 */
.chat-window.minimized { height: 54px; }
.chat-window.minimized .chat-side,
.chat-window.minimized .chat-body,
.chat-window.minimized .chat-form,
.chat-window.minimized .chat-locked-note { display: none; }
.chat-window.minimized .chat-main { flex: 1; }

/* ---------- 左栏：多客户列表 ---------- */

.chat-side {
  width: 240px;
  flex: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: var(--surface-alt);
}

.chat-side-head {
  flex: none;
  padding: 9px 12px;
  background: var(--accent);
  color: #fff;
  cursor: grab;
  user-select: none;
}
.chat-side-head:active { cursor: grabbing; }
.chat-side-title { font-weight: 600; font-size: 13px; }

.chat-side-filter { display: flex; gap: 4px; margin-top: 7px; }
.chat-side-filter button {
  flex: 1;
  border: none;
  border-radius: 6px;
  padding: 3px 0;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  cursor: pointer;
}
.chat-side-filter button.active { background: #fff; color: var(--accent); font-weight: 600; }

.chat-side-list { flex: 1; overflow-y: auto; min-height: 0; }
.chat-side-empty {
  padding: 28px 12px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 12px;
  line-height: 1.6;
}

.chat-side-item {
  position: relative;
  padding: 10px 12px 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.chat-side-item:hover { background: var(--surface); }
.chat-side-item.active { background: var(--surface); }
/* 选中态：左侧一条蓝条 */
.chat-side-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
}
/* 已被别人认领 → 整行置灰，一眼看出「这个我不能回」 */
.chat-side-item.locked { opacity: 0.5; }

.chat-side-row1 { display: flex; align-items: center; gap: 6px; }
.chat-side-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-side-badge {
  flex: none;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: grid;
  place-items: center;
}

.chat-side-preview {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-side-row3 {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-tertiary);
}
.chat-side-owner { margin-left: auto; white-space: nowrap; }
.chat-side-owner.me { color: var(--accent); font-weight: 600; }
.chat-side-owner.other { color: var(--warning); }

/* 悬停时出现的「认领 / 释放」 */
.chat-side-action {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: none;
  border: none;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 11px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.chat-side-item:hover .chat-side-action { display: block; }
.chat-side-action.release {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* ---------- 右栏：当前会话 ---------- */

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px;
  background: var(--accent); color: #fff;
  cursor: grab; user-select: none; flex: none;
}
.chat-head:active { cursor: grabbing; }
.chat-title { font-weight: 600; font-size: 14px; }
.chat-sub { font-size: 11px; opacity: 0.85; margin-top: 2px; }
.chat-head-actions { display: flex; gap: 4px; }
.chat-icon {
  width: 26px; height: 26px; border: none; border-radius: 7px;
  background: rgba(255, 255, 255, 0.18); color: #fff;
  font-size: 15px; line-height: 1; display: grid; place-items: center;
}
.chat-icon:hover { background: rgba(255, 255, 255, 0.32); }

/* 标题栏里的「认领 / 释放」——文字比图标宽，用胶囊 */
.chat-pill {
  height: 26px;
  padding: 0 10px;
  border: none;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
}
.chat-pill:hover { background: rgba(255, 255, 255, 0.32); }

/* 会话被别人认领时，用这条提示替换输入框 */
.chat-locked-note {
  flex: none;
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--warning);
  background: var(--warning-bg);
  border-top: 1px solid var(--border);
}

.chat-body {
  flex: 1; overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.chat-empty { margin: auto; color: var(--text-tertiary); font-size: 13px; text-align: center; }

.msg {
  max-width: 78%; padding: 8px 12px; border-radius: 12px;
  font-size: 14px; line-height: 1.5;
  word-break: break-word; white-space: pre-wrap;
}
.msg.agent { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.user { align-self: flex-start; background: var(--surface-alt); color: var(--text); border-bottom-left-radius: 4px; }
.msg-time { font-size: 11px; opacity: 0.7; margin-top: 4px; }

.chat-form {
  display: flex; gap: 8px; padding: 10px;
  border-top: 1px solid var(--border); flex: none; align-items: flex-end;
}
.chat-form textarea { flex: 1; resize: none; max-height: 100px; padding: 9px 10px; font-size: 14px; }

/* 窄屏塞不下 720px 的两栏：左栏收起，窗口铺满。
   想看完整客户列表可以去「客服会话」标签页。 */
@media (max-width: 780px) {
  .chat-window { left: 12px; right: 12px; width: auto; }
  .chat-side { display: none; }
}

@media (max-width: 640px) {
  .topbar { padding: 10px 14px; gap: 10px; }
  main { padding: 14px; }
  .brand span:not(.logo) { display: none; }
}
