/* ============ reset & base ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #f0f2f5; color: #1a1a1a; height: 100vh; overflow: hidden;
}

/* ============ layout ============ */
.app { display: flex; height: 100vh; }
.main { flex: 1; display: flex; min-width: 0; position: relative; }

/* ============ sidebar ============ */
.sidebar {
  width: 72px; background: #1e2a3a; display: flex; flex-direction: column; align-items: center;
  padding: 16px 0; flex-shrink: 0;
}
.sidebar .logo {
  width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(135deg, #2B7CE9, #1a5fb4);
  display: flex; align-items: center; justify-content: center; font-size: 18px; color: #fff;
  margin-bottom: 20px; font-weight: 700; cursor: pointer; user-select: none;
}
.channel-list { display: flex; flex-direction: column; gap: 8px; width: 100%; padding: 0 10px; }
.channel-btn {
  position: relative; width: 52px; height: 54px; border: none; border-radius: 14px; background: transparent;
  cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #8899aa; font-size: 10px; transition: all .15s; gap: 3px;
}
.channel-btn .ch-icon { font-size: 20px; line-height: 1; }
.channel-btn .ch-name { font-size: 10px; white-space: nowrap; }
.channel-btn:hover { background: rgba(255,255,255,.08); color: #ccd6dd; }
.channel-btn.active { background: rgba(43,124,233,.28); color: #fff; }
.channel-btn.disabled { opacity: .45; cursor: not-allowed; }
.channel-btn .badge {
  position: absolute; top: 3px; right: 3px; min-width: 18px; height: 18px; border-radius: 9px;
  background: #e74c3c; color: #fff; font-size: 10px; font-weight: 700; display: flex;
  align-items: center; justify-content: center; padding: 0 5px; line-height: 1;
}
.sidebar-bottom { margin-top: auto; padding: 0 10px; }
.sidebar-bottom button {
  width: 52px; height: 52px; border: none; border-radius: 14px; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; color: #8899aa; font-size: 9px; gap: 2px;
}
.sidebar-bottom button:hover { background: rgba(255,255,255,.08); color: #ccd6dd; }
.sidebar-bottom .ch-icon { font-size: 18px; }

/* ============ middle list panel ============ */
.msg-panel { width: 360px; background: #fff; border-right: 1px solid #e8e8e8; display: flex; flex-direction: column; flex-shrink: 0; }
.msg-header { padding: 14px 16px 10px; border-bottom: 1px solid #f0f0f0; }
.msg-header h2 { font-size: 16px; font-weight: 600; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.msg-header h2 .ch-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.sub-header { margin: -2px 0 8px; }
.scope-label { font-size: 11px; color: #9a9a9a; }
.search-box { position: relative; margin-bottom: 8px; }
.search-box input {
  width: 100%; height: 34px; border: 1px solid #e0e0e0; border-radius: 8px; padding: 0 12px 0 32px;
  font-size: 13px; outline: none; transition: border-color .15s; background: #f7f8fa;
}
.search-box input:focus { border-color: #2B7CE9; background: #fff; }
.search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-52%); color: #999; font-size: 15px; }
.folder-bar { display: flex; gap: 4px; }
.folder-btn {
  padding: 3px 12px; border: 1px solid #e0e0e0; border-radius: 14px; background: #fff;
  color: #555; font-size: 12px; cursor: pointer; transition: all .15s;
}
.folder-btn.active { background: #2B7CE9; border-color: #2B7CE9; color: #fff; }
.msg-toolbar {
  padding: 7px 16px; display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid #f0f0f0;
}
.msg-toolbar .count { font-size: 12px; color: #888; }
.conn-state { font-size: 11px; color: #4caf50; display: inline-flex; align-items: center; gap: 4px; }
.conn-state.off { color: #e74c3c; }
.conn-state::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; }

.msg-list { flex: 1; overflow-y: auto; padding: 4px 0; }
.msg-item {
  position: relative; display: flex; gap: 12px; padding: 13px 16px; cursor: pointer;
  transition: background .1s; border-left: 3px solid transparent;
}
.msg-item:hover { background: #f7f8fa; }
.msg-item.active { background: #eef4ff; border-left-color: #2B7CE9; }
.msg-item.unread .msg-sender { font-weight: 700; color: #111; }
.msg-item.unread .msg-subject { color: #333; font-weight: 500; }
.msg-item .dot {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  width: 8px; height: 8px; border-radius: 50%; background: #2B7CE9;
}
.msg-avatar {
  width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 600; color: #fff; flex-shrink: 0; user-select: none;
}
.msg-body { flex: 1; min-width: 0; padding-right: 14px; }
.msg-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; gap: 8px; }
.msg-sender { font-size: 13px; font-weight: 500; color: #333; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-time { font-size: 11px; color: #999; flex-shrink: 0; }
.msg-subject { font-size: 12px; color: #555; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-preview { font-size: 12px; color: #8a8a8a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip {
  display: inline-block; font-size: 10px; padding: 0 6px; border-radius: 3px; margin-right: 4px;
  font-weight: 500; vertical-align: 1px;
}
.chip-group { background: #edeff3; color: #5f6b7a; }
.chip-remind { background: #fff3e0; color: #e65100; }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: #bbb; font-size: 13px; gap: 8px; padding: 20px; text-align: center; }
.empty-state .empty-icon { font-size: 38px; opacity: .5; }

/* ============ detail ============ */
.detail-panel { flex: 1; display: flex; flex-direction: column; background: #fafbfc; min-width: 0; }
.detail-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: #bbb; gap: 12px; }
.detail-empty .de-icon { font-size: 52px; opacity: .4; }
.detail-empty .de-text { font-size: 14px; }
.detail-header { padding: 18px 24px 14px; border-bottom: 1px solid #e8e8e8; background: #fff; }
.detail-header .dh-top { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.detail-header .dh-avatar {
  width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 600; color: #fff; flex-shrink: 0;
}
.detail-header .dh-info { flex: 1; min-width: 0; }
.detail-header .dh-sender { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-header .dh-meta { font-size: 12px; color: #999; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-header .dh-subject { font-size: 14px; color: #222; font-weight: 600; margin-top: 8px; word-break: break-all; }
.detail-content { flex: 1; overflow-y: auto; padding: 20px 24px; }
.detail-content .dc-card { background: #fff; border-radius: 12px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.dc-body { font-size: 14px; line-height: 1.8; color: #333; word-break: break-word; }
.dc-body p { margin: 6px 0; }
.dc-body h1, .dc-body h2, .dc-body h3 { margin: 10px 0 6px; font-size: 15px; }
.dc-body ul, .dc-body ol { margin: 6px 0 6px 22px; }
.dc-body li { margin: 2px 0; }
.dc-body a { color: #2B7CE9; text-decoration: none; }
.dc-body pre { background: #f6f8fa; border-radius: 8px; padding: 12px; overflow-x: auto; font-size: 12px; line-height: 1.6; }
.dc-body blockquote { border-left: 3px solid #ddd; padding-left: 12px; color: #666; margin: 8px 0; }
.dc-body table { border-collapse: collapse; margin: 8px 0; }
.dc-body td, .dc-body th { border: 1px solid #e2e2e2; padding: 5px 9px; font-size: 13px; }
.attachments { margin-top: 14px; border-top: 1px dashed #e0e0e0; padding-top: 12px; }
.attachments .att-title { font-size: 12px; color: #999; margin-bottom: 8px; }
.att-item {
  display: inline-flex; align-items: center; gap: 6px; background: #f0f6ff; color: #185FA5;
  border-radius: 8px; padding: 6px 12px; margin: 0 8px 8px 0; font-size: 12px; max-width: 100%;
}
.att-item a { color: inherit; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-item .att-size { color: #7a93b5; font-size: 11px; flex-shrink: 0; }
.session-card .sc-label { font-size: 12px; color: #999; margin-bottom: 8px; }
.session-card .sc-rows { display: flex; flex-direction: column; gap: 8px; }
.session-card .sc-row { display: flex; gap: 10px; font-size: 13px; }
.session-card .sc-row .k { color: #888; width: 64px; flex-shrink: 0; }
.session-card .sc-row .v { color: #333; word-break: break-all; }

/* reply composer */
.reply-box { padding: 14px 24px 18px; border-top: 1px solid #e8e8e8; background: #fff; }
.reply-box .rb-title { font-size: 12px; color: #999; margin-bottom: 8px; }
.reply-box textarea {
  width: 100%; height: 64px; border: 1px solid #e0e0e0; border-radius: 10px; padding: 10px 12px;
  font-size: 13px; resize: none; outline: none; font-family: inherit; transition: border-color .15s; line-height: 1.6;
}
.reply-box textarea:focus { border-color: #2B7CE9; }
.reply-box .reply-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 8px; }
.reply-hint { font-size: 11px; color: #b0b0b0; margin-right: auto; }
.btn-send {
  height: 34px; padding: 0 22px; border: none; border-radius: 8px; background: #2B7CE9;
  color: #fff; font-size: 13px; font-weight: 500; cursor: pointer; transition: background .15s;
}
.btn-send:hover { background: #1a5fb4; }
.btn-send:disabled { background: #bbb; cursor: not-allowed; }

/* ============ 会话历史消息（chat 气泡） ============ */
.chat-history {
  display: flex; flex-direction: column; gap: 14px; padding: 4px 2px 12px;
  max-height: 46vh; overflow-y: auto;
}
.chat-loading, .chat-empty, .chat-more { text-align: center; font-size: 12px; color: #a0a0a0; padding: 10px 0; }
.chat-more { border-bottom: 1px dashed #eee; margin-bottom: 4px; }
.chat-denied {
  text-align: center; padding: 26px 20px; background: #fafbfc; border: 1px solid #e8e8e8;
  border-radius: 12px;
}
.chat-denied .cd-icon { font-size: 34px; margin-bottom: 10px; opacity: .75; }
.chat-denied .cd-title { font-size: 14px; font-weight: 600; color: #555; margin-bottom: 8px; }
.chat-denied .cd-text { font-size: 12px; color: #999; line-height: 1.9; }
.bubble-row { display: flex; gap: 10px; align-items: flex-start; }
.bubble-row.out { flex-direction: row-reverse; }
.bubble-avatar {
  width: 30px; height: 30px; border-radius: 8px; color: #fff; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.bubble-col { max-width: 78%; display: flex; flex-direction: column; }
.bubble-row.out .bubble-col { align-items: flex-end; }
.bubble-meta { font-size: 11px; color: #b0b0b0; margin-bottom: 4px; }
.bubble {
  background: #f4f5f7; border-radius: 12px; padding: 9px 12px; font-size: 13px; line-height: 1.7;
  word-break: break-word; color: #333;
}
.bubble p { margin: 0 0 6px; } .bubble p:last-child { margin-bottom: 0; }
.bubble pre { background: #ececf0; border-radius: 6px; padding: 8px 10px; font-size: 12px; overflow-x: auto; margin: 4px 0; }
.bubble code { background: #ececf0; border-radius: 4px; padding: 1px 5px; font-size: 12px; }
.bubble a { color: #2B7CE9; }
.bubble-row.out .bubble { background: #d8e8fb; }
.bubble-sys { color: #999; font-style: italic; }

/* ============ 邮件快捷回复 ============ */
.mail-reply .reply-actions { align-items: center; }
.mail-reply-btns { display: flex; gap: 8px; }
.btn-ghost { background: #fff; color: #2B7CE9; border: 1px solid #2B7CE9; }
.btn-ghost:hover { background: #eef4fd; }
.detail-panel .reply-box { border-top: 1px solid #eee; padding-top: 12px; margin-top: 8px; }

/* ============ 金融行情 ============ */
.fin-card { margin-bottom: 16px; }
.fin-card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.fin-icon { font-size: 26px; }
.fin-title { font-size: 15px; font-weight: 600; color: #333; }
.fin-sub { font-size: 12px; color: #999; margin-top: 2px; }
.fin-big { font-size: 34px; font-weight: 700; color: #1f2d3d; letter-spacing: .5px; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.fin-unit { font-size: 12px; font-weight: 500; color: #999; background: #f4f5f7; border-radius: 6px; padding: 3px 8px; }
.fin-chg { font-size: 14px; font-weight: 600; }
.fin-chg.up { color: #d63031; }
.fin-chg.down { color: #00b894; }
.fin-note { font-size: 12px; color: #8e9aab; margin: 8px 0 12px; line-height: 1.7; }
.fin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.fin-cell { background: #fafbfc; border: 1px solid #eef0f3; border-radius: 10px; padding: 10px 12px; }
.fin-cell .k { display: block; font-size: 11px; color: #999; margin-bottom: 4px; }
.fin-cell .v { font-size: 15px; font-weight: 600; color: #333; }
.fin-list-note { font-size: 11px; color: #b0b0b0; line-height: 1.8; padding: 12px 14px; }

/* ============ toast & error ============ */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-80px);
  background: #333; color: #fff; padding: 10px 24px; border-radius: 8px; font-size: 13px;
  transition: transform .3s; z-index: 999; pointer-events: none; max-width: 80vw;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.err { background: #c0392b; }
.error-box { color: #c0392b; font-size: 13px; background: #fdf0ef; border: 1px solid #f5c6c2; border-radius: 8px; padding: 12px 14px; line-height: 1.6; }
.placeholder-card { text-align: center; color: #888; padding: 40px 30px; }
.placeholder-card .ph-icon { font-size: 44px; margin-bottom: 12px; opacity: .5; }

/* ============ scrollbar ============ */
.msg-list::-webkit-scrollbar, .detail-content::-webkit-scrollbar { width: 5px; }
.msg-list::-webkit-scrollbar-thumb, .detail-content::-webkit-scrollbar-thumb { background: #d0d0d0; border-radius: 3px; }
.msg-list::-webkit-scrollbar-track, .detail-content::-webkit-scrollbar-track { background: transparent; }

/* ============ responsive ============ */
@media (max-width: 860px) {
  .sidebar { width: 60px; }
  .channel-btn { width: 46px; }
  .channel-btn .ch-name { display: none; }
  .msg-panel { width: 280px; }
}
@media (max-width: 620px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: 54px; flex-direction: row; padding: 0 10px; }
  .sidebar .logo { width: 34px; height: 34px; margin: 0 8px 0 0; font-size: 14px; border-radius: 8px; }
  .channel-list { flex-direction: row; padding: 0; width: auto; }
  .channel-btn { width: 46px; height: 46px; }
  .channel-btn .ch-name { display: none; }
  .sidebar-bottom { margin-left: auto; margin-top: 0; }
  .main { flex-direction: column; }
  .msg-panel { width: 100%; height: 46%; border-right: none; border-bottom: 1px solid #e8e8e8; }
  .detail-panel { height: 54%; }
}
