:root {
  --green: #07c160;
  --green-dark: #06ad56;
  --bg: #f5f6f7;
  --panel: #ffffff;
  --line: #e6e8ea;
  --text: #1a1a1a;
  --text-2: #666;
  --text-3: #999;
  --red: #fa5151;
  --blue: #576b95;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
#app { height: 100%; }
[v-cloak] { display: none; }
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }

/* ---------------- 登录 ---------------- */
.login-wrap {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #eef7f1, #f7f9fa 60%);
  padding: 16px;
}
.login-card {
  width: 360px;
  background: #fff;
  border-radius: 14px;
  padding: 28px 24px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .08);
}
.login-card h1 { font-size: 20px; margin: 0 0 6px; }
.login-card p { color: var(--text-3); margin: 0 0 22px; font-size: 13px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.field input {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line);
  border-radius: 8px; outline: none; font-size: 14px; background: #fafbfc;
}
.field input:focus { border-color: var(--green); background: #fff; }
.btn-primary {
  width: 100%; height: 42px; border: 0; border-radius: 8px; background: var(--green);
  color: #fff; font-size: 15px; font-weight: 500; margin-top: 8px;
}
.btn-primary:hover { background: var(--green-dark); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.login-err { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 18px; }
.login-tip { color: var(--text-3); font-size: 12px; margin-top: 14px; line-height: 1.6; }
.login-wecom {
  display: block; text-align: center; margin-top: 14px; color: var(--blue);
  font-size: 13px; text-decoration: none;
}

/* ---------------- 布局 ---------------- */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar {
  height: 52px; flex: none; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; padding: 0 16px; gap: 16px;
}
.brand { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #ccc; display: inline-block; }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px rgba(7, 193, 96, .15); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.top-actions button {
  border: 1px solid var(--line); background: #fff; color: var(--text-2);
  height: 30px; padding: 0 12px; border-radius: 15px; font-size: 13px;
}
.top-actions button:hover { border-color: var(--green); color: var(--green); }
.agent-name { font-size: 13px; color: var(--text-2); margin-right: 4px; }
.agent-name small { color: var(--text-3); margin-left: 4px; }

.layout { flex: 1; display: flex; min-height: 0; }

/* ---------------- 会话列表 ---------------- */
.sidebar {
  width: 300px; flex: none; background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.search { padding: 10px 12px; }
.search input {
  width: 100%; height: 34px; padding: 0 10px; border-radius: 8px; border: 1px solid transparent;
  background: #f2f3f5; outline: none; font-size: 13px;
}
.search input:focus { border-color: var(--green); background: #fff; }
.filters { display: flex; gap: 6px; padding: 0 12px 10px; flex-wrap: wrap; }
.filters button {
  border: 0; background: #f2f3f5; color: var(--text-2); height: 26px; padding: 0 10px;
  border-radius: 13px; font-size: 12px;
}
.filters button.active { background: rgba(7, 193, 96, .12); color: var(--green-dark); font-weight: 500; }
.conv-list { flex: 1; overflow-y: auto; }
.conv {
  display: flex; gap: 10px; padding: 12px; cursor: pointer; border-bottom: 1px solid #f2f3f5;
  position: relative;
}
.conv:hover { background: #fafbfb; }
.conv.active { background: #f0f9f4; }
.conv.active:before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--green);
}
.conv-avatar {
  width: 38px; height: 38px; border-radius: 8px; background: #e8eaed; color: #8a9099;
  display: flex; align-items: center; justify-content: center; font-size: 13px; flex: none;
}
.conv-main { flex: 1; min-width: 0; }
.conv-line1 { display: flex; align-items: center; gap: 6px; }
.conv-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { margin-left: auto; font-size: 11px; color: var(--text-3); flex: none; }
.conv-line2 { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.conv-preview {
  font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; flex: 1;
}
.badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red);
  color: #fff; font-size: 11px; line-height: 18px; text-align: center; flex: none;
}
.tag { font-size: 10px; color: var(--text-3); background: #f2f3f5; padding: 1px 5px; border-radius: 3px; }
.tag.close { color: var(--text-3); }

/* ---------------- 聊天区 ---------------- */
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; background: #f5f6f7; }
.chat-head {
  height: 56px; flex: none; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; padding: 0 16px; gap: 12px;
}
.chat-title { font-size: 15px; font-weight: 600; }
.chat-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.chat-head-actions { margin-left: auto; display: flex; gap: 6px; }
.chat-head-actions button {
  border: 1px solid var(--line); background: #fff; height: 30px; padding: 0 12px;
  border-radius: 15px; font-size: 13px; color: var(--text-2);
}
.chat-head-actions button:hover { border-color: var(--green); color: var(--green); }
.chat-head-actions button.on { background: rgba(7, 193, 96, .1); border-color: transparent; color: var(--green-dark); }
.chat-head-actions select {
  height: 30px; padding: 0 8px; border: 1px solid var(--line); border-radius: 15px;
  background: #fff; color: var(--text-2); font-size: 13px; outline: none; cursor: pointer;
}
.chat-head-actions select:focus { border-color: var(--green); }

.msg-area { flex: 1; overflow-y: auto; padding: 16px 18px 8px; }
.msg-more { text-align: center; padding-bottom: 12px; }
.msg-more button {
  border: 0; background: rgba(0, 0, 0, .05); color: var(--text-2); font-size: 12px;
  padding: 5px 12px; border-radius: 12px;
}
.msg { display: flex; gap: 10px; margin-bottom: 16px; align-items: flex-start; }
.msg.me { flex-direction: row-reverse; }
.msg-face {
  width: 34px; height: 34px; border-radius: 6px; flex: none; display: flex;
  align-items: center; justify-content: center; font-size: 12px; color: #fff; background: #b9c0c8;
}
.msg.me .msg-face { background: var(--green); }
.msg-face img { width: 100%; height: 100%; border-radius: 6px; object-fit: cover; }
.msg-body { max-width: min(560px, 62%); display: flex; flex-direction: column; }
.msg.me .msg-body { align-items: flex-end; }
.msg-name { font-size: 11px; color: var(--text-3); margin-bottom: 4px; }
.bubble {
  background: #fff; padding: 9px 12px; border-radius: 8px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word; box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}
.msg.me .bubble { background: #d9f7c4; }
.msg-meta { font-size: 11px; color: var(--text-3); margin-top: 5px; display: flex; gap: 6px; align-items: center; }
.st-read { color: var(--green); }
.st-fail { color: var(--red); }
.bubble img.pic { max-width: 220px; max-height: 260px; border-radius: 6px; display: block; cursor: zoom-in; }
.bubble video { max-width: 260px; border-radius: 6px; display: block; }
.voice-row {
  display: flex; align-items: center; gap: 8px; background: #fff; padding: 9px 12px;
  border-radius: 8px; cursor: pointer; min-width: 96px; box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}
.msg.me .voice-row { background: #d9f7c4; }
.voice-row.playing { outline: 1px solid var(--green); }
.voice-row svg { width: 15px; height: 15px; }
.file-card {
  display: flex; align-items: center; gap: 10px; background: #fff; padding: 10px 12px;
  border-radius: 8px; text-decoration: none; color: inherit; min-width: 190px; max-width: 300px;
}
.msg.me .file-card { background: #d9f7c4; }
.file-ico {
  width: 34px; height: 34px; border-radius: 6px; background: rgba(0, 0, 0, .05);
  display: flex; align-items: center; justify-content: center; flex: none;
}
.file-ico svg { width: 18px; height: 18px; }
.file-name { font-size: 13px; word-break: break-all; }
.file-size { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.sys-tip { text-align: center; margin: 10px 0 16px; }
.sys-tip span { background: rgba(0, 0, 0, .05); color: var(--text-3); font-size: 12px; padding: 4px 10px; border-radius: 5px; }

/* ---------------- 输入区 ---------------- */
.composer { flex: none; background: #fff; border-top: 1px solid var(--line); padding: 8px 12px 10px; }
.composer-tools { display: flex; align-items: center; gap: 2px; margin-bottom: 6px; }
.icon-btn {
  width: 32px; height: 32px; border: 0; background: transparent; border-radius: 6px;
  display: flex; align-items: center; justify-content: center; color: #555;
}
.icon-btn:hover { background: rgba(0, 0, 0, .05); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.icon-btn.on { background: rgba(7, 193, 96, .12); color: var(--green-dark); }
.composer-row { display: flex; align-items: flex-end; gap: 8px; }
.composer textarea {
  flex: 1; min-height: 40px; max-height: 140px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 8px; resize: none; outline: none; font-size: 14px; line-height: 1.5; background: #fafbfc;
}
.composer textarea:focus { border-color: var(--green); background: #fff; }
.btn-send {
  height: 40px; padding: 0 18px; border: 0; border-radius: 8px; background: var(--green);
  color: #fff; font-size: 14px; font-weight: 500; flex: none;
}
.btn-send:disabled { opacity: .5; cursor: not-allowed; }
.recording-bar {
  display: flex; align-items: center; gap: 10px; background: #fff5f5; border: 1px solid #ffd9d9;
  border-radius: 8px; padding: 9px 12px; color: var(--red); font-size: 13px;
}
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); animation: blink 1s infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .2; } }
.recording-bar button { margin-left: auto; border: 0; background: transparent; color: var(--blue); font-size: 13px; }

/* 快捷回复 */
.quick-panel {
  position: absolute; left: 12px; right: 12px; bottom: 96px; max-height: 320px; background: #fff;
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 30px rgba(0, 0, 0, .12);
  display: flex; flex-direction: column; z-index: 20; overflow: hidden;
}
.quick-head { display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.quick-head button {
  border: 0; background: #f2f3f5; color: var(--text-2); height: 26px; padding: 0 10px;
  border-radius: 13px; font-size: 12px; white-space: nowrap;
}
.quick-head button.active { background: rgba(7, 193, 96, .12); color: var(--green-dark); }
.quick-list { overflow-y: auto; padding: 6px; }
.quick-item { padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.quick-item:hover { background: #f5f7f8; }
.quick-item b { font-size: 13px; font-weight: 500; display: block; }
.quick-item span { font-size: 12px; color: var(--text-3); display: block; margin-top: 2px; }

/* ---------------- 客户资料 ---------------- */
.info {
  width: 300px; flex: none; background: #fff; border-left: 1px solid var(--line);
  overflow-y: auto; padding: 16px;
}
.info h3 { font-size: 14px; margin: 0 0 12px; }
.info-row { display: flex; gap: 8px; font-size: 13px; padding: 7px 0; border-bottom: 1px dashed #f0f1f2; }
.info-row .k { color: var(--text-3); width: 76px; flex: none; }
.info-row .v { flex: 1; word-break: break-all; }
.info-actions { display: flex; gap: 8px; margin-top: 14px; }
.info-actions button {
  flex: 1; height: 32px; border: 1px solid var(--line); background: #fff; border-radius: 8px; font-size: 13px;
}
.info-actions button:hover { border-color: var(--green); color: var(--green); }
.info textarea {
  width: 100%; margin-top: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 8px;
  min-height: 60px; font-size: 13px; resize: vertical; outline: none;
}

.empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-3); gap: 10px;
}
.empty svg { width: 64px; height: 64px; opacity: .25; }

/* ---------------- 弹窗 ---------------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .4); display: flex;
  align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal {
  background: #fff; border-radius: 12px; width: min(760px, 100%); max-height: 86vh;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0, 0, 0, .2);
}
.modal-head {
  display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line);
  font-weight: 600; font-size: 15px;
}
.modal-head button { margin-left: auto; border: 0; background: transparent; font-size: 20px; color: var(--text-3); line-height: 1; }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.modal-foot button { height: 34px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.modal-foot button.primary { background: var(--green); color: #fff; border-color: var(--green); }

.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 18px; }
.stat-card { background: #f7f9fa; border-radius: 10px; padding: 12px; }
.stat-card b { display: block; font-size: 22px; font-weight: 600; }
.stat-card span { font-size: 12px; color: var(--text-3); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.bar-stack { width: 100%; max-width: 26px; display: flex; flex-direction: column; justify-content: flex-end; height: 110px; gap: 2px; }
.bar { width: 100%; border-radius: 3px 3px 0 0; background: var(--green); min-height: 2px; }
.bar.b2 { background: #9fd9b9; }
.bar-label { font-size: 10px; color: var(--text-3); white-space: nowrap; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid #f0f1f2; }
.table th { color: var(--text-3); font-weight: 500; font-size: 12px; }
.table tr:hover td { background: #fafbfb; }
.row-actions button { border: 0; background: transparent; color: var(--blue); font-size: 12px; }
.row-actions button.danger { color: var(--red); }

.form-row { display: flex; gap: 10px; margin-bottom: 10px; }
.form-row > * { flex: 1; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; outline: none;
}
.form-row textarea { min-height: 76px; resize: vertical; }
.hint { font-size: 12px; color: var(--text-3); line-height: 1.6; }

@media (max-width: 1100px) {
  .info { position: fixed; right: 0; top: 52px; bottom: 0; z-index: 30; box-shadow: -8px 0 24px rgba(0,0,0,.08); }
}
@media (max-width: 760px) {
  .sidebar { width: 92px; }
  .chat-head { height: auto; min-height: 56px; padding: 8px 10px; gap: 8px; }
  .chat-title { font-size: 14px; }
  .chat-sub { font-size: 11px; }
  .chat-head-actions { gap: 4px; }
  .chat-head-actions button,
  .chat-head-actions select { height: 28px; padding: 0 8px; font-size: 12px; border-radius: 14px; }
  .conv { padding: 10px 6px; flex-direction: column; align-items: center; gap: 4px; }
  .conv-main { display: none; }
  .search { padding: 8px 6px; }
  .filters { display: none; }
  .chat-head { padding: 0 10px; }
  .msg-body { max-width: 76%; }
  .top-actions button { padding: 0 8px; }
  .agent-name { display: none; }
}
