:root {
  --top: #0f172a;
  --top-border: #1e293b;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --bd: #e2e8f0;
  --tx: #0f172a;
  --mu: #64748b;
  --blue: #2563eb;
  --green: #16a34a;
  --amber: #d97706;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--tx);
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--top);
  color: #e2e8f0;
  border-bottom: 1px solid var(--top-border);
  flex-shrink: 0;
}

.topbar-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #60a5fa, var(--blue));
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
  color: #fff;
}

.brand-title { font-weight: 700; font-size: 15px; color: #f8fafc; }
.brand-sub { font-size: 11px; color: #94a3b8; margin-top: 2px; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.who { font-size: 13px; color: #cbd5e1; }
.who strong { color: #fff; font-weight: 600; }
.who .role {
  margin-left: 8px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.35);
  color: #bfdbfe;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #94a3b8;
  cursor: default;
}

.toggle-label { white-space: nowrap; }

.switch {
  width: 44px;
  height: 24px;
  border-radius: 999px;
  border: 0;
  background: #334155;
  position: relative;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.switch:disabled { opacity: 0.45; cursor: not-allowed; }

.switch.on { background: var(--green); }

.switch .knob {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: transform 0.18s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.switch.on .knob { transform: translateX(20px); }

.btn-ghost {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: #e2e8f0;
  padding: 8px 14px;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
}

.btn-ghost:hover { background: rgba(255, 255, 255, 0.12); }

.shell {
  flex: 1;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 320px;
  min-height: 0;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

@media (max-width: 1100px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(200px, 38vh) minmax(360px, 1fr) auto;
  }
}

.col {
  background: var(--surface);
  border-right: 1px solid var(--bd);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.col:last-child { border-right: 0; }

.col-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--bd);
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.col-head.subhead { font-size: 12px; color: var(--mu); }

.pill {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: #ecfdf5;
  color: #047857;
}

.pill.off {
  background: #fff7ed;
  color: #c2410c;
}

.search {
  margin: 10px 12px;
  padding: 9px 11px;
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  font: inherit;
  background: #f8fafc;
}

.list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px 12px;
}

.thread {
  padding: 10px 11px;
  border-radius: var(--radius);
  margin-bottom: 4px;
  cursor: pointer;
  border: 1px solid transparent;
  position: relative;
}

.thread:hover { background: #f8fafc; }

.thread.on {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.thread .r1 {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.thread .email {
  font-size: 12px;
  font-weight: 600;
  color: var(--tx);
  word-break: break-all;
}

.thread .preview {
  font-size: 11px;
  color: var(--mu);
  margin-top: 4px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.thread .meta {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mu);
  flex-shrink: 0;
}

.dot.live { background: var(--green); box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.2); }

.badge-unread {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.st {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  background: #f1f5f9;
  color: var(--mu);
}

.st-replied { background: #dbeafe; color: #1d4ed8; }
.st-closed { background: #f1f5f9; color: #64748b; }

.mid { min-width: 0; }

.chat-head { align-items: flex-start; }

.chat-title { font-size: 14px; font-weight: 700; }
.chat-sub { font-size: 11px; color: var(--mu); margin-top: 4px; word-break: break-all; }

.chat-actions { flex-shrink: 0; }

.sel {
  font: inherit;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--bd);
  background: #fff;
}

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: linear-gradient(180deg, #f8fafc 0%, #fff 35%);
  min-height: 280px;
}

.bubble {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 14px;
  margin-bottom: 10px;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: var(--shadow);
}

.bubble.v {
  background: #fff;
  border: 1px solid var(--bd);
  margin-right: auto;
  border-bottom-left-radius: 4px;
}

.bubble.a {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

.bubble .time {
  font-size: 10px;
  color: var(--mu);
  margin-top: 6px;
}

.composer {
  border-top: 1px solid var(--bd);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
  position: relative;
}

.composer textarea {
  width: 100%;
  min-height: 44px;
  max-height: 120px;
  padding: 10px 12px;
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  font: inherit;
  resize: vertical;
  box-sizing: border-box;
}

.composer-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.btn-send {
  padding: 10px 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--blue);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* 改价按钮 */
.btn-offer {
  padding: 10px 16px;
  border: 1px solid #fbcfe8;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #fdf2f8, #fff);
  color: #be185d;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  font-size: 13px;
}
.btn-offer:hover { background: #fce7f3; border-color: #f9a8d4; }
.btn-offer:disabled { opacity: 0.4; cursor: not-allowed; }

.detail {
  padding: 12px 14px;
  font-size: 12px;
  overflow-y: auto;
  flex: 1;
  min-height: 120px;
}

.detail dl { margin: 0; }
.detail dt {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--mu);
  margin-top: 12px;
}
.detail dt:first-child { margin-top: 0; }
.detail dd { margin: 4px 0 0; color: var(--tx); line-height: 1.45; word-break: break-word; }

.staff {
  padding: 0 12px 16px;
  font-size: 11px;
  max-height: 220px;
  overflow-y: auto;
}

.staff table { width: 100%; border-collapse: collapse; }
.staff th, .staff td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--bd); }

.empty {
  color: var(--mu);
  font-size: 13px;
  padding: 24px;
  text-align: center;
}

.empty.small { padding: 16px; font-size: 12px; }

.skel {
  background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
  background-size: 200% 100%;
  animation: sh 1.2s ease infinite;
  border-radius: 6px;
}

@keyframes sh {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.skel-line { height: 14px; display: inline-block; border-radius: 4px; }
.skel-item { height: 56px; margin: 8px; border-radius: var(--radius); }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--top);
  color: #f8fafc;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
  z-index: 1000;
}

/* AI 翻译样式 */
.lang-tag {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  background: #dbeafe;
  color: #1d4ed8;
  margin-bottom: 4px;
}
.bubble .msg-orig {
  font-size: 13px;
  color: var(--tx);
}
.bubble .msg-trans {
  font-size: 12px;
  color: var(--mu);
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed #e2e8f0;
  line-height: 1.4;
}
.bubble .msg-trans.agent-reply {
  color: #16a34a;
  border-top-color: #bbf7d0;
}

/* 粉色已读标记 ✓✓（WhatsApp 风格） */
.chk {
  font-size: 11px;
  color: #f472b6;
  margin-right: 4px;
  font-weight: 600;
}
.chk.chk-read {
  color: #f472b6;
}

/* 店铺标签 */
.store-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  background: #f3e8ff;
  color: #7c3aed;
  margin-right: 6px;
  vertical-align: middle;
}

/* 折叠按钮 */
.fold-btn {
  text-align: center;
  padding: 8px;
  font-size: 12px;
  color: #2563eb;
  cursor: pointer;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 6px;
}
.fold-btn:hover { background: #f8fafc; }

/* 语言选择栏 */
.lang-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 0;
  align-items: center;
}
.lang-btn {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
  color: #64748b;
  cursor: pointer;
  font-family: inherit;
}
.lang-btn:hover { border-color: #2563eb; color: #2563eb; }
.lang-btn.on { background: #2563eb; color: #fff; border-color: #2563eb; }
.lang-hint { font-size: 10px; color: #94a3b8; margin-left: 4px; white-space: nowrap; }

/* 改价弹窗 */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.5);
  display: none; align-items: center; justify-content: center;
  z-index: 2000;
}
.modal-box {
  background: #fff; border-radius: 14px; padding: 24px;
  width: min(380px, calc(100vw - 32px)); box-shadow: 0 16px 48px rgba(0,0,0,0.2);
}
.modal-title { font-size: 16px; font-weight: 700; color: #0f172a; margin-bottom: 16px; }
.modal-body { display: flex; flex-direction: column; gap: 10px; }
.modal-label { font-size: 12px; font-weight: 600; color: #64748b; }
.modal-amount-row { display: flex; align-items: center; gap: 6px; }
.modal-dollar { font-size: 20px; font-weight: 700; color: #0f172a; }
.modal-input {
  width: 100%; padding: 10px 12px; border: 1px solid #e2e8f0;
  border-radius: 8px; font: inherit; font-size: 14px; box-sizing: border-box;
}
.modal-input:focus { outline: 2px solid rgba(37,99,235,0.3); border-color: #2563eb; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; justify-content: flex-end; }
.modal-err { color: #dc2626; font-size: 12px; margin-top: 8px; min-height: 1.2em; }

/* 小号幽灵按钮 */
.btn-ghost-sm {
  background: rgba(15,23,42,0.06); border: 1px solid #e2e8f0;
  color: #0f172a; padding: 6px 12px; border-radius: 8px;
  font: inherit; font-weight: 600; font-size: 12px; cursor: pointer;
  white-space: nowrap;
}
.btn-ghost-sm:hover { background: rgba(15,23,42,0.1); }
.btn-ghost-sm:disabled { opacity: 0.45; cursor: not-allowed; }

/* 订单卡片 */
.dt-orders { margin-top: 16px !important; padding-top: 12px !important; border-top: 1px solid #e2e8f0; }
.order-loading, .order-none { font-size: 12px; color: #94a3b8; padding: 4px 0; display: block; }
.order-list { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.order-card {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px;
  background: #f8fafc;
  font-size: 12px;
  line-height: 1.5;
}
.order-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.order-sku { font-weight: 600; color: #0f172a; font-size: 12px; }
.order-total { font-weight: 700; color: #059669; }
.order-body { font-size: 11px; color: #475569; margin-bottom: 8px; }
.order-label { font-weight: 600; color: #64748b; }
.order-confirm-btn {
  width: 100%;
  padding: 8px;
  border: 0;
  border-radius: 6px;
  background: #059669;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.order-confirm-btn:hover { background: #047857; }
.order-confirm-btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* 话术按钮 */
.btn-canned {
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  background: #fff;
  color: #475569;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
}
.btn-canned:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn-canned:disabled { opacity: 0.4; cursor: not-allowed; }

/* 话术下拉 */
.canned-dropdown {
  position: absolute;
  bottom: 100%;
  left: 12px;
  right: 12px;
  max-height: 240px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 -4px 20px rgba(15,23,42,0.12);
  z-index: 100;
}
.canned-item {
  padding: 10px 14px;
  font-size: 12px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  color: #0f172a;
  line-height: 1.4;
}
.canned-item:hover { background: #f8fafc; }
.canned-item:last-child { border-bottom: 0; }
.canned-title { font-weight: 600; font-size: 12px; margin-bottom: 2px; }
.canned-body { font-size: 11px; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 客服状态切换按钮 */
.btn-toggle-status {
  padding: 4px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
  color: #475569;
  font: inherit;
  font-weight: 600;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-toggle-status:hover { background: #f8fafc; border-color: #94a3b8; }

.staff-online { color: #16a34a; font-weight: 700; }
.staff-offline { color: #94a3b8; }
.staff-toggle-btn { font-size: 10px; padding: 2px 8px; border-radius: 4px; border: 1px solid #e2e8f0; background: #fff; cursor: pointer; margin-left: 6px; }
.staff-toggle-btn:hover { background: #f1f5f9; }

/* 订单操作按钮行 */
.order-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

/* 导出 CSV 按钮 */
.order-export-btn {
  width: 100%; padding: 8px; border: 1px solid #e2e8f0;
  border-radius: 6px; background: #fff; color: #475569;
  font-weight: 600; font-size: 12px; cursor: pointer;
  font-family: inherit; margin-top: 4px;
}
.order-export-btn:hover { background: #f8fafc; }

/* 一键复制信息按钮 */
.btn-copy-all {
  width: 100%; padding: 8px; border: 1px solid #e2e8f0;
  border-radius: 6px; background: #fff; color: #475569;
  font-weight: 600; font-size: 12px; cursor: pointer;
  font-family: inherit; margin-top: 4px;
}
.btn-copy-all:hover { background: #f8fafc; }

/* 复制小按钮 */
.btn-copy {
  border: 0; background: transparent; cursor: pointer;
  padding: 0 2px; font-size: 12px; vertical-align: middle;
  color: #64748b;
}
.btn-copy:hover { color: #2563eb; }

/* 订单备注 */
.order-note-input { width: 100%; padding: 6px; border: 1px solid #e2e8f0; border-radius: 4px; font-size: 11px; margin-top: 4px; box-sizing: border-box; resize: vertical; font-family:inherit; }
.order-note-btn { width: 100%; padding: 5px; border: 1px solid #dbeafe; border-radius: 4px; background: #eff6ff; color: #1d4ed8; font-size: 11px; cursor: pointer; font-family: inherit; margin-top: 2px; }
.order-note-btn:hover { background: #dbeafe; }
.order-note-btn:disabled { opacity:0.5; cursor:not-allowed; }
.order-note-item { font-size: 10px; color: #475569; padding: 3px 0; border-bottom: 1px solid #f1f5f9; }
.order-note-staff { font-weight: 600; color: #0f172a; }
.order-note-time { color:#94a3b8; float:right; }

/* AI 建议回复 */
.ai-suggest-btn { padding: 4px 10px; border: 1px solid #dbeafe; border-radius: 12px; background: #fff; color: #1d4ed8; font-size: 11px; cursor: pointer; white-space: nowrap; font-family: inherit; }
.ai-suggest-btn:hover { background: #dbeafe; }
.ai-suggest-btn:active { background:#bfdbfe; }

/* 翻译预览 */
.trans-preview {
  padding: 6px 10px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  font-size: 11px;
  color: #166534;
}
.trans-label {
  font-weight: 600;
  font-size: 10px;
  color: #16a34a;
  margin-bottom: 2px;
}
.trans-result {
  line-height: 1.4;
  word-break: break-word;
}

.btn-recall { border:none; background:none; color:#94a3b8; cursor:pointer; font-size:10px; padding:0 4px; vertical-align:middle; }
.btn-recall:hover { color:#ef4444; }
.btn-coupon { padding:10px 10px; border:1px solid #e2e8f0; border-radius:var(--radius); background:#fff; color:#475569; font:inherit; font-weight:600; cursor:pointer; font-size:13px; }
.btn-coupon:hover { background:#faf5ff; border-color:#d8b4fe; }
.btn-coupon:disabled { opacity:0.4; cursor:not-allowed; }
