* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #0b0f19; color: #e5e7eb; font-size: 14px;
}
button { font: inherit; cursor: pointer; }
.hidden { display: none !important; }

.primary, .danger, select {
  height: 32px; padding: 0 14px; border-radius: 8px; border: 0; color: #fff;
}
.primary { background: linear-gradient(135deg, #7c3aed, #db2777); }
.primary:disabled { opacity: .5; cursor: not-allowed; }
.danger { background: #374151; }
.danger:hover { background: #b91c1c; }
select { background: #1f2937; border: 1px solid #374151; }
.link { background: none; border: 0; color: #a78bfa; }
.link:hover { color: #c4b5fd; }

/* 登录 */
.login { height: 100%; display: flex; align-items: center; justify-content: center; }
.login-box {
  width: 340px; padding: 32px; border-radius: 16px; background: #111827;
  border: 1px solid rgba(139, 92, 246, .3); display: flex; flex-direction: column; gap: 14px;
}
.login-box h1 { font-size: 20px; text-align: center; margin-bottom: 6px; color: #fff; }
.login-box input {
  height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid #374151;
  background: #1f2937; color: #fff; outline: none;
}
.login-box input:focus { border-color: #8b5cf6; }
.login-box button {
  height: 42px; border: 0; border-radius: 10px; color: #fff; font-weight: 600;
  background: linear-gradient(135deg, #7c3aed, #db2777);
}
.err { color: #f87171; font-size: 13px; min-height: 18px; text-align: center; }

/* 布局 */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar {
  height: 52px; flex-shrink: 0; display: flex; align-items: center; gap: 16px; padding: 0 16px;
  background: #111827; border-bottom: 1px solid #1f2937;
}
.topbar b { color: #fff; font-size: 15px; }
.spacer { flex: 1; }
.conn, .agents { display: flex; align-items: center; gap: 6px; color: #9ca3af; font-size: 12px; }
.conn em { font-style: normal; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #6b7280; display: inline-block; }
.dot.on { background: #22c55e; }
.agents .tag { padding: 2px 8px; border-radius: 10px; background: #1f2937; display: inline-flex; align-items: center; gap: 4px; }

.main { flex: 1; display: flex; min-height: 0; }
.sidebar { width: 300px; flex-shrink: 0; border-right: 1px solid #1f2937; display: flex; flex-direction: column; background: #0f1422; }
.chat { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.profile { width: 280px; flex-shrink: 0; border-left: 1px solid #1f2937; background: #0f1422; padding: 16px; overflow-y: auto; }

/* 会话列表 */
.tabs { display: flex; border-bottom: 1px solid #1f2937; }
.tabs button {
  flex: 1; padding: 12px 4px; background: none; border: 0; color: #9ca3af; font-size: 13px;
  border-bottom: 2px solid transparent;
}
.tabs button.active { color: #fff; border-bottom-color: #8b5cf6; }
.tabs i { font-style: normal; color: #f472b6; }
.conv-list { list-style: none; overflow-y: auto; flex: 1; }
.conv-list li { padding: 12px 14px; border-bottom: 1px solid #161d2e; cursor: pointer; display: flex; gap: 10px; }
.conv-list li:hover { background: #151c2c; }
.conv-list li.active { background: #1e1b3a; }
.conv-list .avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; position: relative;
  background: linear-gradient(135deg, #7c3aed, #db2777); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 600;
}
.conv-list .avatar .dot { position: absolute; right: -1px; bottom: -1px; border: 2px solid #0f1422; width: 11px; height: 11px; }
.conv-list .body { flex: 1; min-width: 0; }
.conv-list .line1 { display: flex; justify-content: space-between; gap: 8px; }
.conv-list .name { display: flex; align-items: center; gap: 6px; min-width: 0; color: #f3f4f6; }
.conv-list .name .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-list .name small { color: #6b7280; flex-shrink: 0; }
.conv-list .vip-tag { flex-shrink: 0; font-size: 10px; line-height: 16px; padding: 0 5px; border-radius: 4px; color: #111827; background: #fbbf24; font-weight: 700; }
.conv-list .vip-tag.off { color: #9ca3af; background: #1f2937; font-weight: 500; }
.conv-list .time { color: #6b7280; font-size: 12px; flex-shrink: 0; }
.conv-list .line2 { display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; }
.conv-list .last { color: #9ca3af; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-list .unread { background: #ef4444; color: #fff; border-radius: 9px; min-width: 18px; height: 18px; padding: 0 5px; font-size: 11px; line-height: 18px; text-align: center; flex-shrink: 0; }
.conv-list .owner { font-size: 11px; color: #a78bfa; flex-shrink: 0; }
.conv-list .empty { color: #6b7280; text-align: center; padding: 40px 0; cursor: default; }
.conv-list .empty:hover { background: none; }

/* 聊天区 */
.placeholder { margin: auto; color: #6b7280; }
.chat-inner { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-hd { height: 60px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; border-bottom: 1px solid #1f2937; gap: 12px; }
.chat-hd .who b { color: #fff; font-size: 15px; display: block; }
.chat-hd .who span { color: #9ca3af; font-size: 12px; }
.chat-hd .actions { display: flex; gap: 8px; }
.msgs { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.msgs .more { text-align: center; color: #6b7280; font-size: 12px; }
.msgs .row { display: flex; flex-direction: column; max-width: 70%; }
.msgs .row.agent { align-self: flex-end; align-items: flex-end; }
.msgs .row.user { align-self: flex-start; }
.msgs .meta { color: #6b7280; font-size: 11px; margin: 0 4px 3px; }
.msgs .bub { padding: 9px 13px; border-radius: 14px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.msgs .agent .bub { background: linear-gradient(135deg, #6d28d9, #be185d); color: #fff; border-bottom-right-radius: 4px; }
.msgs .agent.other .bub { background: #312e81; }
.msgs .user .bub { background: #1f2937; border-bottom-left-radius: 4px; }
.msgs .st { color: #9ca3af; font-size: 11px; margin: 3px 4px 0; }
.msgs .st.fail { color: #f87171; cursor: pointer; }
.msgs .sys { align-self: center; color: #9ca3af; font-size: 12px; background: #151c2c; padding: 4px 12px; border-radius: 10px; }
.msgs .vod { display: block; max-width: 320px; text-decoration: none; color: inherit; border: 1px solid rgba(251, 191, 36, .45); background: rgba(251, 191, 36, .08); border-radius: 12px; padding: 10px 12px; }
.msgs .vod b { display: block; color: #fbbf24; }
.msgs .vod span { display: block; margin-top: 4px; color: #d1d5db; font-size: 12px; }
.msgs .divider { align-self: center; color: #4b5563; font-size: 11px; }
.typing { color: #a78bfa; font-size: 12px; padding: 0 20px 6px; min-height: 18px; }
.composer { border-top: 1px solid #1f2937; padding: 10px 16px; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea {
  flex: 1; height: 52px; resize: none; padding: 7px 10px; border-radius: 8px; border: 1px solid #374151;
  background: #111827; color: #f3f4f6; font: inherit; line-height: 19px; outline: none;
}
.composer textarea:focus { border-color: #8b5cf6; }
.composer .primary { height: 34px; padding: 0 18px; }
.readonly { border-top: 1px solid #1f2937; padding: 16px; text-align: center; color: #9ca3af; }

/* 用户资料 */
.profile h3 { color: #fff; font-size: 15px; margin-bottom: 12px; }
.profile dl { display: grid; grid-template-columns: 76px 1fr; gap: 8px 6px; font-size: 13px; }
.profile dt { color: #6b7280; }
.profile dd { color: #e5e7eb; word-break: break-all; }
.vip { color: #fbbf24; font-weight: 600; }
.novip { color: #9ca3af; }

@media (max-width: 1100px) { .profile { display: none; } }
