/* ============================================================
 * 门户机界面样式（白/黑夜双主题）
 * 依赖：本地化 Bootstrap 5.3 + bootstrap-icons（static/vendor/）
 * ============================================================ */
* { box-sizing: border-box; }
html, body { height: 100%; }
/* 字号切换：大（默认）/ 超大（zoom 等比放大全界面） */
body.zoom-lg { zoom: 1.15; }
body.zoom-xl { zoom: 1.3; }
#btnZoom { width: auto; min-width: 56px; padding: 0 12px; font-size: 14px; font-weight: 700; gap: 5px; }
#btnZoom i { font-size: 16px; }
#zoomLabel { font-size: 14px; font-weight: 700; }

/* ---- 主题变量 ---- */
body {
  color-scheme: light;
  --bg-app: #dde5d8;
  --bg-titlebar: #fff;
  --bg-titlebar-grad: linear-gradient(90deg, #f2f5ef, #e8ece4);
  --bg-sidebar: #e8ece4;
  --bg-main: #dde5d8;
  --bg-card: #f2f5ef;
  --bg-chatbox: #e8ece4;
  --bg-input: #f2f5ef;
  --bg-section: #f2f5ef;
  --bg-section-head: #e0e6db;
  --bg-stat-card: #e8ece4;
  --bg-table: #e8ece4;
  --bg-hover: rgba(0,0,0,.05);
  --bg-nav-active: #1f6feb;
  --text-primary: #1f2d3d;
  --text-titlebar: #1f2d3d;
  --text-sidebar: #2c3e50;
  --text-secondary: #5f748c;
  --text-muted: #93a0b1;
  --border: #dce2ea;
  --border-light: #e8edf3;
  --accent: #1f6feb;
  --accent-light: #4c9aff;
  --msg-user-bg: #1f6feb;
  --msg-assistant-bg: #fff;
  --msg-assistant-border: #e0e5ec;
  --shadow: rgba(0,0,0,.14);
  --tb-border: #d4dbe4;
  --tb-selector-bg: rgba(0,0,0,.04);
  --tb-selector-border: #d4dbe4;
  --titlebar-btn-border: #d4dbe4;
  --titlebar-btn-color: #5f748c;
  --titlebar-btn-hover: #f0f4fa;
  --agent-stage-bg: #e8edf3;
}
body[data-theme="night"] {
  color-scheme: dark;
  --bg-app: #0d131c;
  --bg-titlebar: #1f2d3d;
  --bg-titlebar-grad: linear-gradient(90deg, #1f2d3d, #263a52);
  --bg-sidebar: #1f2d3d;
  --bg-main: #141b26;
  --bg-card: #1e2a3a;
  --bg-chatbox: #141b26;
  --bg-input: #1e2a3a;
  --bg-section: #1e2a3a;
  --bg-section-head: #24344a;
  --bg-stat-card: #24344a;
  --bg-table: #1a2433;
  --bg-hover: rgba(255,255,255,.08);
  --bg-nav-active: #1f6feb;
  --text-primary: #cfd9e4;
  --text-titlebar: #fff;
  --text-sidebar: #cdd9e6;
  --text-secondary: #8fa6bf;
  --text-muted: #6b7d96;
  --border: #3d4f66;
  --border-light: #2c3e55;
  --accent: #4c9aff;
  --accent-light: #6fb3ff;
  --msg-user-bg: #1f6feb;
  --msg-assistant-bg: #1e2a3a;
  --msg-assistant-border: #3d4f66;
  --shadow: rgba(0,0,0,.4);
  --tb-border: #3d4f66;
  --tb-selector-bg: rgba(255,255,255,.08);
  --tb-selector-border: #3d4f66;
  --titlebar-btn-border: #3d4f66;
  --titlebar-btn-color: #dbe4ee;
  --titlebar-btn-hover: #2c3e55;
  --agent-stage-bg: #0d131c;
}

body {
  font-family: "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  display: flex; flex-direction: column; overflow: hidden; margin: 0;
  background: var(--bg-app); color: var(--text-primary); font-size: 14px;
}

/* ---------- 标题栏（基础框架层，永远在内容之上） ---------- */
#titlebar {
  height: 46px; background: var(--bg-titlebar-grad);
  color: var(--text-titlebar); display: flex; align-items: center; padding: 0 14px; gap: 14px;
  flex: 0 0 auto; position: relative; z-index: 100;
}
.titlebar-logo { font-weight: 700; font-size: 15px; letter-spacing: .5px; }
.titlebar-logo i { color: var(--accent); margin-right: 4px; }
.titlebar-selectors { display: flex; align-items: center; gap: 10px; }
.tb-selector {
  display: flex; align-items: center; gap: 5px;
  background: var(--tb-selector-bg); border: 1px solid var(--tb-selector-border);
  border-radius: 6px; padding: 3px 8px;
}
.tb-selector i { color: var(--text-secondary); font-size: 13px; }
.tb-selector select {
  background: transparent; border: 0; color: var(--text-titlebar); font-size: 13px;
  outline: none; cursor: pointer; max-width: 180px;
}
.tb-selector select option { background: var(--bg-card); color: var(--text-primary); }
.titlebar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.titlebar-user { color: var(--text-secondary); font-size: 13px; }
.titlebar-btn {
  border: 1px solid var(--titlebar-btn-border); background: transparent; color: var(--titlebar-btn-color);
  width: 30px; height: 30px; border-radius: 6px; cursor: pointer;
}
.titlebar-btn:hover { background: var(--titlebar-btn-hover); }
#btnAccount {
  width: auto; padding: 0 10px; font-size: 12.5px;
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
}
#btnAccount i { font-size: 14px; }

/* 主题切换下拉 */
.theme-switcher { position: relative; }
.theme-dropdown {
  display: none; position: absolute; top: 36px; right: 0; min-width: 160px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 6px 20px var(--shadow); z-index: 50; overflow: hidden;
}
.theme-dropdown.show { display: block; }
.theme-option {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; cursor: pointer;
  font-size: 13px; color: var(--text-primary);
}
.theme-option:hover { background: var(--bg-hover); }
.theme-option.active { color: var(--accent); font-weight: 600; }
.theme-option i { width: 16px; text-align: center; }

/* ---------- 主区五栏 ---------- */
#appBody { flex: 1; display: flex; min-height: 0; }
#appBody > div { display: flex; flex-direction: column; }
.panel-head {
  padding: 10px 12px; font-size: 13px; font-weight: 600; flex: 0 0 auto;
  border-bottom: 1px solid rgba(0,0,0,.08); background: rgba(0,0,0,.02);
}

/* 1 导航（基础框架层：悬停弹出的二级菜单面板永不被主内容遮挡） */
#sidebar { width: 168px; background: var(--bg-sidebar); color: var(--text-sidebar); flex: 0 0 auto; position: relative; z-index: 100; overflow: visible; }
#sidebar .panel-head { color: var(--text-secondary); background: transparent; border-color: var(--border-light); }
.nav-menu { list-style: none; margin: 0; padding: 8px 6px; flex: 1; overflow: visible; }
.nav-menu li {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px;
  border-radius: 6px; cursor: pointer; margin-bottom: 2px; font-size: 13px;
}
.nav-menu li:hover { background: var(--bg-hover); }
.nav-menu li.active { background: var(--bg-nav-active); color: #fff; }
.nav-menu li i { width: 16px; text-align: center; }
.nav-foot { padding: 10px; font-size: 11px; color: #5f748c; border-top: 1px solid rgba(255,255,255,.07); line-height: 1.7; }

/* 1.5 视频语音按钮区（sidebar 底部） */
.sidebar-agent {
  flex: 0 0 auto; padding: 10px 8px; border-top: 1px solid var(--border-light);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.agent-avatar-btn {
  border: 0; padding: 0; cursor: pointer; background: transparent;
  width: 100%; display: block; border-radius: 10px; overflow: hidden;
  transition: transform .15s, box-shadow .15s;
}
.agent-avatar-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(31,111,235,.4); }
.agent-avatar-btn.active { box-shadow: 0 0 0 2px var(--accent), 0 0 18px rgba(31,111,235,.5); }
.agent-stage {
  position: relative; aspect-ratio: 9 / 16; width: 100%; border-radius: 10px; overflow: hidden;
  background: var(--agent-stage-bg); display: flex; align-items: center; justify-content: center;
}
.agent-stage.speaking { box-shadow: 0 0 0 2px var(--accent), 0 0 22px rgba(31,111,235,.55); }
.avatar-video { width: 100%; height: 100%; object-fit: cover; }
.avatar-img { width: 100%; height: 100%; object-fit: cover; }
.avatar-emoji { font-size: 48px; }
.agent-status {
  position: absolute; left: 6px; bottom: 6px; padding: 2px 8px; border-radius: 20px;
  background: rgba(0,0,0,.55); font-size: 10px; color: #9fe8a9; text-transform: capitalize;
}
.sidebar-tts {
  display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-sidebar); width: 100%;
  justify-content: center;
}
.tts-label { display: flex; align-items: center; gap: 4px; cursor: pointer; }

/* 4 聊天窗口（顶部对齐卡片，宽度与展示面板一致，上下均与主区齐平） */
#chatPanel {
  width: 1000px; max-width: 96%; height: calc(100% - 20px); min-height: 300px;
  background: var(--bg-card); border-radius: 12px; box-shadow: 0 6px 28px var(--shadow);
  flex: 0 0 auto; position: relative; overflow: hidden;
  display: flex; flex-direction: column;
}
.chat-head {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.chat-agent-avatar {
  width: 32px; height: 32px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--border); flex: 0 0 auto;
}
.chat-agent-emoji { font-size: 22px; flex: 0 0 auto; }
.chat-head-stats { display: flex; gap: 6px; flex: 1; min-width: 0; }
.chat-head-right { display: flex; gap: 6px; flex: 0 0 auto; }
#chatBox { flex: 1; overflow: auto; padding: 12px; background: var(--bg-chatbox); }
.chat-empty { text-align: center; color: var(--text-muted); margin-top: 40px; }
.chat-msg { margin-bottom: 10px; display: flex; flex-direction: column; max-width: 92%; }
.chat-msg.user { align-self: flex-end; align-items: flex-end; margin-left: auto; }
.chat-msg .msg-content {
  padding: 9px 12px; border-radius: 10px; font-size: 13.5px; line-height: 1.65;
  word-break: break-word; white-space: normal;
}
.chat-msg.user .msg-content { background: var(--msg-user-bg); color: #fff; border-bottom-right-radius: 3px; }
.chat-msg.assistant .msg-content { background: var(--msg-assistant-bg); border: 1px solid var(--msg-assistant-border); border-bottom-left-radius: 3px; }
.chat-msg.error .msg-content { background: #fdecec; border: 1px solid #f5c6c6; color: #b3362c; }
.chat-msg.thinking .msg-content { background: var(--bg-hover); color: var(--text-secondary); border-style: dashed; font-size: 12.5px; }

/* 思考气泡：spinner + 状态文案 + 横杠滑动动画 */
.thinking-header { display: flex; align-items: center; gap: 8px; }
.thinking-text { flex: 1; }
.thinking-bar { display: none; position: relative; height: 2px; margin-top: 8px; background: var(--border-light); overflow: hidden; border-radius: 1px; }
.thinking-bar::after {
  content: ''; position: absolute; top: 0; height: 100%; width: 35%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: thinking-slide 1.2s ease-in-out infinite;
}
@keyframes thinking-slide { 0% { left: -35%; } 100% { left: 100%; } }

/* 思考气泡三种模式：mode-search(进度条)/mode-think(spinner)/mode-reasoning(思考流) */
.thinking-reasoning { display: none; font-size: 12px; color: var(--text-secondary); margin-top: 8px; white-space: pre-wrap; max-height: 200px; overflow-y: auto; }
.chat-msg.thinking.mode-search .thinking-bar { display: block; }
.chat-msg.thinking.mode-search .thinking-header .spinner-border { display: none; }
.chat-msg.thinking.mode-think .thinking-header .spinner-border { display: inline-block; }
.chat-msg.thinking.mode-reasoning .thinking-reasoning { display: block; }
.chat-msg.thinking.mode-reasoning .thinking-bar { display: none; }
.chat-msg.thinking.mode-reasoning .thinking-header .spinner-border { display: none; }

/* 思考气泡折叠态：只显示摘要行，可点击展开 */
.chat-msg.thinking.collapsed .thinking-bar { display: none; }
.chat-msg.thinking.collapsed .thinking-header .spinner-border { display: none; }
.chat-msg.thinking.collapsed .thinking-text { display: none; }
.chat-msg.thinking.collapsed .thinking-reasoning { display: none; }
.thinking-summary { display: none; align-items: center; gap: 6px; flex: 1; cursor: pointer; }
.thinking-summary .bi { font-size: 11px; color: #2ca45c; }
.chat-msg.thinking.collapsed .thinking-summary { display: flex; }
.thinking-toggle { border: 0; background: transparent; color: var(--text-muted); cursor: pointer; padding: 0 2px; font-size: 11px; }
.thinking-toggle:hover { color: var(--accent); }
.thinking-detail { font-size: 12px; color: var(--text-secondary); margin-top: 6px; white-space: pre-wrap; }
.chat-msg.thinking.error .thinking-summary .bi { color: #b3362c; }
.chat-msg.thinking.error .thinking-summary { color: #b3362c; }
.chat-msg .muted { color: var(--text-muted); background: transparent !important; border: 0 !important; padding: 4px 0; font-size: 12.5px; }
.chat-msg.assistant:hover .btn-replay { display: inline-flex; }
.btn-replay {
  display: none; align-items: center; justify-content: center; margin-top: 4px;
  width: 24px; height: 24px; border: 1px solid var(--border); border-radius: 5px;
  background: var(--bg-card); color: var(--text-secondary); cursor: pointer; font-size: 12px; align-self: flex-start;
}
.btn-replay:hover { color: var(--accent); border-color: var(--accent); }
.code-block { background: #1e2530; color: #d6e2f0; padding: 8px 10px; border-radius: 6px; font-size: 12px; overflow: auto; }
.md-h { color: var(--text-primary); }
.md-num { color: var(--accent); }
.md-table-row { display: block; }
.md-cell { display: inline-block; margin-right: 12px; }

.tool-card { margin-bottom: 8px; border: 1px solid var(--border-light); border-radius: 8px; overflow: hidden; background: var(--bg-card); }
.tool-card.call { border-left: 3px solid var(--accent); }
.tool-card.result { border-left: 3px solid #2ca45c; }
.tool-head { display: flex; align-items: center; gap: 7px; padding: 7px 10px; font-size: 12.5px; background: var(--bg-section-head); }
.tool-name { font-weight: 600; }
.tool-kind { color: var(--text-muted); font-size: 11px; }
.tool-fold { margin-left: auto; border: 0; background: transparent; cursor: pointer; color: var(--text-secondary); }
.tool-detail { margin: 0; padding: 8px 10px; font-size: 12px; background: var(--bg-chatbox); max-height: 220px; overflow: auto; }
.loop-card {
  display: flex; align-items: center; gap: 6px; margin: 6px 0; padding: 5px 10px;
  background: var(--bg-hover); border-radius: 6px; color: var(--text-secondary); font-size: 12px;
}

.chat-input-bar {
  display: flex; flex-direction: column; gap: 6px; padding: 8px 10px;
  border-top: 1px solid var(--border); flex: 0 0 auto;
}
.chat-upload-btn {
  flex: 0 0 auto; padding: 5px 10px; border: 1px solid var(--accent); border-radius: 6px; cursor: pointer;
  background: var(--bg-section); color: var(--text-primary); font-size: 13px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  transition: all .15s; white-space: nowrap;
}
.chat-upload-btn:hover { background: var(--bg-hover); }
.chat-upload-btn i { font-size: 14px; }
.chat-upload-btn.has-attach { border-color: #2ca45c; background: rgba(44,164,92,.12); color: #2ca45c; }
/* 待发送附件条（多附件横向芯片） */
#chatAttachBar {
  display: block; padding: 6px 8px 4px;
  background: var(--bg-section); border: 1px solid var(--accent); border-radius: 8px; font-size: 12.5px;
}
#chatAttachBar .attach-bar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 2px 6px 4px; color: var(--text-primary);
}
#chatAttachBar .attach-bar-title { display: flex; align-items: center; gap: 6px; font-weight: 600; }
#chatAttachBar .attach-count { font-size: 11px; padding: 1px 6px; }
#chatAttachBar .btn-close { font-size: 10px; }
#chatAttachBar .attach-list {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 2px 4px;
}
.attach-chip {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 22px 4px 8px; border-radius: 14px;
  background: rgba(13,110,253,.08); border: 1px solid rgba(13,110,253,.25);
  max-width: 220px;
}
.attach-chip-ic { font-size: 14px; color: var(--text-muted); flex-shrink: 0; }
.attach-chip-name {
  font-weight: 600; color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100px;
}
.attach-chip-meta { color: var(--text-muted); font-size: 11px; flex-shrink: 0; }
.attach-chip-del {
  position: absolute; right: 3px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--text-muted);
  width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; padding: 0; cursor: pointer;
}
.attach-chip-del:hover { background: rgba(220,53,69,.15); color: #dc3545; }
.attach-chip.attach-more {
  background: transparent; border-style: dashed; color: var(--text-muted);
  padding: 4px 10px; font-weight: 500;
}

/* 文件卡片（微信/QQ 风格）—— 压缩包子文件折叠面板 */
.archive-children-toggle {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-top: 6px; padding: 5px 8px; border-radius: 6px;
  background: rgba(13,110,253,.06); color: var(--text-secondary); cursor: pointer;
  font-size: 12px; user-select: none;
}
.archive-children-toggle.muted { background: var(--bg-muted); color: var(--text-muted); cursor: default; }
.archive-children-toggle.bg-light-warning { background: rgba(255,193,7,.15); color: #856404; cursor: default; }
.archive-children-toggle .toggle-ic { transition: transform .2s; color: var(--accent); }
.archive-children-toggle.open .toggle-ic { transform: rotate(90deg); }
.archive-children-panel {
  display: none; margin-top: 4px;
  border: 1px solid var(--border-color); border-radius: 6px; overflow: hidden;
}
.archive-children-panel.show { display: block; }
.archive-children-panel table { margin: 0; }
.file-archive-section { margin-right: 6px; }
.file-card .file-info { min-width: 0; }
/* 文件卡片（微信/QQ 风格） */
.msg-file-wrap { padding: 6px !important; background: transparent !important; border: 0 !important; }
.file-card {
  display: flex; align-items: center; gap: 10px; width: 300px; max-width: 100%;
  padding: 9px 10px; border-radius: 9px; cursor: pointer; user-select: none;
  background: var(--bg-card); border: 1px solid var(--border-light);
  transition: all .15s;
}
.chat-msg.user .file-card { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.25); }
.file-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.14); transform: translateY(-1px); }
.file-card .file-icon { font-size: 26px; color: var(--accent); flex: 0 0 auto; }
.file-card .file-info { flex: 1; min-width: 0; }
.file-card .file-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary); }
.chat-msg.user .file-card .file-name { color: #fff; }
.file-card .file-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-msg.user .file-card .file-meta { color: rgba(255,255,255,.85); }
.file-card .file-summary { font-size: 11.5px; color: var(--text-secondary); margin-top: 3px; max-height: 40px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.chat-msg.user .file-card .file-summary { color: rgba(255,255,255,.9); }
.file-card .file-act { color: var(--text-muted); font-size: 15px; flex: 0 0 auto; }
.chat-msg.user .file-card .file-act { color: rgba(255,255,255,.8); }
.file-card-img { align-items: flex-start; width: 260px; }
.file-card-img .file-thumb {
  width: 58px; height: 58px; border-radius: 6px; object-fit: cover; flex: 0 0 auto;
  background: var(--bg-hover); border: 1px solid var(--border-light);
}
/* 记忆弹窗 */
.mem-item { padding: 10px 12px; border: 1px solid var(--border-light); border-radius: 8px; margin-bottom: 10px; background: var(--bg-section); }
.mem-item .mem-date { font-size: 12px; font-weight: 700; color: var(--accent); margin-bottom: 4px; }
.mem-item .mem-content { font-size: 13px; line-height: 1.7; color: var(--text-primary); white-space: pre-wrap; }
.chat-stat-mini {
  flex: 1; display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 3px;
  background: var(--bg-stat-card); border: 1px solid var(--border-light); border-radius: 6px;
  padding: 3px 6px; min-width: 0;
}
.chat-stat-mini .num { font-size: 14px; font-weight: 700; line-height: 1.2; }
.chat-stat-mini .num.ok { color: #1d8a4e; }
.chat-stat-mini .num.bad { color: #d64541; }
.chat-stat-mini > span:last-child { font-size: 10px; color: var(--text-muted); }
#chatInput { width: 100%; resize: none; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 13.5px; max-height: 120px; background: var(--bg-input); color: var(--text-primary); }
.chat-input-bottom {
  display: flex; align-items: center; gap: 8px; justify-content: space-between;
}
.chat-input-left { display: flex; align-items: center; gap: 6px; min-width: 0; }
.chat-toolbar {
  display: flex; gap: 4px; align-items: center; flex-wrap: wrap;
}
.tb-btn {
  width: 30px; height: 28px; border: 1px solid var(--border); background: var(--bg-input); color: var(--text-secondary);
  border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; transition: all .15s;
}
.tb-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--bg-hover); }
.tb-btn.active { color: #fff; background: var(--accent); border-color: var(--accent); }
.tb-btn:disabled { opacity: .5; cursor: not-allowed; }
#btnSend { flex: 0 0 auto; }

/* 历史会话浮层（日历视图） */
#historyPanel {
  position: absolute; top: 44px; right: 8px; width: 300px; max-height: 62%;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 28px var(--shadow);
  z-index: 30; display: flex; flex-direction: column; overflow: hidden;
}
.history-head { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; border-bottom: 1px solid var(--border); font-weight: 600; }
.cal-nav { display: flex; align-items: center; justify-content: space-between; padding: 6px 12px; }
.cal-nav-btn { border: 0; background: transparent; color: var(--text-secondary); cursor: pointer; padding: 2px 8px; border-radius: 5px; font-size: 13px; }
.cal-nav-btn:hover { background: var(--bg-hover); color: var(--accent); }
.cal-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); padding: 0 8px; }
.cal-weekdays span { text-align: center; font-size: 11px; color: var(--text-muted); padding: 4px 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; padding: 4px 8px 10px; overflow: auto; }
.cal-cell { height: 32px; display: flex; align-items: center; justify-content: center; font-size: 12.5px; border-radius: 6px; user-select: none; }
.cal-cell.empty { background: transparent; cursor: default; }
.cal-cell.no-data { color: var(--text-muted); cursor: not-allowed; opacity: 0.5; }
.cal-cell.has-data { color: var(--accent); cursor: pointer; font-weight: 500; }
.cal-cell.has-data:hover { background: var(--bg-hover); }
.cal-cell.today { border: 1px solid var(--accent); font-weight: 700; }
.cal-cell.today.no-data { color: var(--text-muted); border-color: var(--text-muted); }

/* 2 主区（内容层：位于基础框架之下，内容只在区域内滚动，不遮挡框架） */
#mainArea {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start;
  background: var(--bg-main); overflow: hidden; padding: 10px; min-width: 0;
}

/* 5 展示界面（顶部对齐卡片，上下均与主区齐平） */
#displayPanel {
  width: 1000px; max-width: 96%; height: calc(100% - 20px); min-height: 300px;
  background: var(--bg-card); border-radius: 12px; box-shadow: 0 6px 28px var(--shadow);
  flex: 0 0 auto; overflow: hidden;
  display: flex; flex-direction: column;
}
#displayContent { flex: 1; overflow: auto; padding: 12px; }
.empty-tip { color: var(--text-muted); text-align: center; margin-top: 36px; padding: 20px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.stat-card { background: var(--bg-stat-card); border: 1px solid var(--border-light); border-radius: 10px; padding: 14px; text-align: center; }
.stat-num { font-size: 28px; font-weight: 700; }
.stat-num.warn { color: #d99000; }
.stat-num.ok { color: #1d8a4e; }
.stat-num.bad { color: #d64541; }
.stat-label { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

/* 首页顶部统计卡：紧凑版（6 列一行不换行、更小字号更薄 padding） */
.home-stat-grid { grid-template-columns: repeat(6, minmax(110px, 1fr)); gap: 8px; margin-bottom: 14px; }
.home-stat-grid .stat-card { padding: 8px 6px; border-radius: 8px; }
.home-stat-grid .stat-num { font-size: 22px; }
.home-stat-grid .stat-label { font-size: 11px; margin-top: 0; color: var(--text-muted); }
.home-section { background: var(--bg-section); border: 1px solid var(--border-light); border-radius: 10px; margin-bottom: 14px; overflow: hidden; }

/* 机器节点状态 */
.stat-num.ok { color: #1d8a4e; }
.machine-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.machine-card {
  background: var(--bg-card); border: 1px solid var(--border-light); border-radius: 10px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 5px;
}
.machine-card.unconfigured { opacity: .75; }
.mc-head { display: flex; align-items: center; gap: 8px; }
.mc-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.mc-dot.on { background: #2ecc71; box-shadow: 0 0 6px #2ecc71; }
.mc-dot.off { background: #e74c3c; }
.mc-dot.none { background: var(--border); }
.mc-name { font-weight: 700; font-size: 14px; flex: 1; }
.mc-badge { font-size: 11px; padding: 1px 8px; border-radius: 10px; color: #fff; }
.mc-desc { font-size: 12px; color: var(--text-secondary); }
.mc-url { font-size: 11px; color: var(--text-muted); word-break: break-all; font-family: Consolas, monospace; }
.mc-meta { font-size: 11px; color: var(--text-muted); }
.mc-err { color: #e74c3c; }
.mc-res { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.mc-res-item {
  background: var(--bg-hover); border: 1px solid var(--border-light); border-radius: 6px;
  padding: 2px 8px; font-size: 11px; color: var(--text-secondary);
}
.mc-res-item b { color: var(--text-primary); }

/* 服务商城（账户中心） */
.svc-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.svc-tab {
  border: 1px solid var(--border-light); background: var(--bg-card); color: var(--text-secondary);
  border-radius: 18px; padding: 5px 14px; font-size: 13px; cursor: pointer; transition: all .15s;
}
.svc-tab:hover { border-color: var(--accent); color: var(--accent); }
.svc-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.svc-panel { display: none; }
.svc-panel.active { display: block; }

/* 账户中心 */
.account-wrap { padding: 4px; }
.plan-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.plan-card {
  background: var(--bg-card); border: 1px solid var(--border-light); border-radius: 10px;
  padding: 14px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.plan-card.current { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.plan-name { font-weight: 700; font-size: 15px; }
.plan-price { font-size: 20px; font-weight: 800; color: var(--accent); }
.plan-tokens { font-size: 12px; color: var(--text-secondary); }
.plan-desc { font-size: 12px; color: var(--text-muted); min-height: 32px; }
.home-section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 14px; background: var(--bg-section-head); font-weight: 600; font-size: 14px; color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
}
.home-section-head i { margin-right: 6px; color: var(--accent); }
.home-section-body { padding: 12px 14px; }

/* 设置面板 */
.agent-preview-box { flex: 0 0 auto; width: 130px; }
.agent-img-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.agent-img-choice {
  width: 56px; height: 56px; object-fit: cover; border-radius: 8px;
  border: 2px solid var(--border-light); cursor: pointer; transition: all .15s;
}
.agent-img-choice:hover { transform: scale(1.06); box-shadow: 0 2px 8px var(--shadow); }
.agent-img-choice.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.settings-save-bar {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; margin-bottom: 14px;
  background: var(--bg-section-head); border: 1px solid var(--border-light); border-radius: 10px;
}
.quick-actions { display: flex; gap: 8px; }
.upload-queue .upload-item { font-size: 12.5px; padding: 3px 0; color: #455; }
.file-table .fname { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-actions { display: flex; gap: 4px; }

/* 文件预览弹窗 */
.preview-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.82); display: flex; align-items: center; justify-content: center; z-index: 9999; }
.preview-box { position: relative; max-width: 90vw; max-height: 90vh; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.preview-media { max-width: 90vw; max-height: 85vh; object-fit: contain; border-radius: 6px; }
.preview-close { position: absolute; top: -44px; right: 0; }
.preview-overlay audio { width: 480px; max-width: 90vw; }
.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.archive-children-row { background: var(--bg-hover); }
.voucher-table .v-summary { max-width: 400px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-line { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.status-bar { flex: 1; height: 8px; background: var(--bg-hover); border-radius: 4px; overflow: hidden; }
.status-fill { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

/* Bootstrap 表格主题适配 */
.table { background-color: var(--bg-table); color: var(--text-primary); --bs-table-bg: var(--bg-table); }
.table thead th { background-color: var(--bg-section-head); color: var(--text-primary); border-color: var(--border); }
.table td, .table th { border-color: var(--border-light); color: var(--text-primary); }
.table-hover tbody tr:hover { --bs-table-hover-bg: var(--bg-hover); background-color: var(--bg-hover); }
.table a, .table .btn-outline-primary { color: var(--accent); }
.badge.bg-secondary { background-color: #6c757d !important; }

/* Bootstrap 表单控件主题适配（凭证编辑/大模型配置/问答搜索框等） */
.form-control, .form-select {
  background-color: var(--bg-input); color: var(--text-primary);
  border-color: var(--border);
}
.form-control::placeholder { color: var(--text-muted); opacity: 1; }
.form-control:focus, .form-select:focus {
  background-color: var(--bg-input); color: var(--text-primary);
  border-color: var(--accent); box-shadow: 0 0 0 .2rem rgba(76,154,255,.18);
}
.form-control:disabled, .form-control[readonly],
.form-select:disabled { background-color: var(--bg-hover); color: var(--text-muted); opacity: 1; }
.form-select { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%238fa6bf' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e"); }
.form-select option { background-color: var(--bg-card); color: var(--text-primary); }
.form-label, .form-text { color: var(--text-secondary); }

/* Bootstrap 卡片主题适配（助手配置卡片等） */
.card { background-color: var(--bg-card); border-color: var(--border-light); color: var(--text-primary); }
.card-header { background-color: var(--bg-section-head); color: var(--text-primary); border-bottom-color: var(--border-light); }
.card-body { color: var(--text-primary); }
.card-header .text-muted, .card-body .text-muted { color: var(--text-muted) !important; }
body[data-theme="night"] .bg-light { background-color: var(--bg-hover) !important; }

/* ---------- 状态栏（基础框架层，永远在内容之上） ---------- */
#statusBar {
  height: 28px; background: #1f6feb; color: #fff; display: flex; align-items: center;
  gap: 18px; padding: 0 14px; font-size: 12px; flex: 0 0 auto; position: relative; z-index: 100;
}
#sbState i { font-size: 8px; margin-right: 4px; }
#sbInfo { opacity: .95; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 登录页 ---------- */
body.login-page { background: linear-gradient(135deg, #1f2d3d, #2c4a6e); align-items: center; justify-content: center; }
#loginBox {
  width: 360px; background: #fff; border-radius: 14px; padding: 30px 28px;
  box-shadow: 0 14px 44px rgba(0,0,0,.35);
}
#loginBox .login-logo { text-align: center; font-size: 22px; font-weight: 700; color: #1f2d3d; margin-bottom: 4px; }
#loginBox .login-sub { text-align: center; color: #8a97a8; font-size: 12.5px; margin-bottom: 22px; }
#loginBox .form-control { padding: 9px 11px; }
#loginBox .btn-login { width: 100%; padding: 9px; font-size: 15px; margin-top: 6px; }
#loginBox .login-err { color: #d93025; font-size: 13px; margin-top: 10px; text-align: center; min-height: 18px; }

/* ============================================================
 * 财税系统（凭证 / 账簿 / 报表 / 问答）
 * ============================================================ */

/* ---------- 导航二级菜单（悬停滑出面板） ---------- */
.nav-menu li.nav-group { position: relative; display: block; padding: 0; margin-bottom: 2px; }
/* 桥接悬停缝隙：鼠标从菜单项移到滑出面板时不会消失 */
.nav-group::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: 100%; width: 12px;
}
.nav-group-label {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px;
  border-radius: 6px; cursor: pointer; font-size: 13px;
}
.nav-group-label:hover { background: var(--bg-hover); }
.nav-group-label i:first-child { width: 16px; text-align: center; }
.nav-group-label .group-arrow { margin-left: auto; font-size: 11px; transition: transform .2s; }
.nav-group:hover .group-arrow { transform: rotate(90deg); }
.nav-sub {
  list-style: none; margin: 0; padding: 6px;
  position: absolute; left: calc(100% + 4px); top: -4px; z-index: 60;
  min-width: 178px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 28px var(--shadow);
  visibility: hidden; opacity: 0; transform: translateX(-12px);
  transition: opacity .18s ease, transform .18s ease, visibility .18s;
  pointer-events: none;
}
.nav-group:hover > .nav-sub,
.nav-group.open > .nav-sub {
  visibility: visible; opacity: 1; transform: translateX(0);
  pointer-events: auto;
}
.nav-sub li {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-radius: 6px; cursor: pointer; font-size: 12.5px; margin-bottom: 1px;
  color: var(--text-secondary, inherit); white-space: nowrap;
}
.nav-sub li:hover { background: var(--bg-hover); }
.nav-sub li.active { background: var(--bg-nav-active); color: #fff; }
.nav-sub li i { width: 14px; font-size: 11px; }

/* ---------- 凭证查看 ---------- */
.voucher-list { display: flex; flex-direction: column; gap: 12px; }
.voucher-card {
  border: 1px solid var(--border-light); border-radius: 10px; overflow: hidden;
  background: var(--bg-table, #fff);
}
.voucher-card-head {
  display: flex; align-items: center; gap: 12px; padding: 8px 12px;
  background: var(--bg-section-head, rgba(0,0,0,.03)); border-bottom: 1px solid var(--border-light);
  font-size: 13px; flex-wrap: wrap;
}
.voucher-card-head .voucher-no { font-weight: 700; color: var(--accent, #1f6feb); white-space: nowrap; }
.voucher-card-head .voucher-date { color: var(--text-muted); font-size: 12.5px; white-space: nowrap; }
.voucher-card-head .voucher-summary { flex: 1; min-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voucher-card-head .voucher-actions { display: flex; gap: 6px; }
.voucher-card .voucher-entries { margin: 0; }
.voucher-card .voucher-entries thead th { font-size: 12.5px; }
.voucher-card .voucher-entries tbody td { font-size: 13px; }
.voucher-card .voucher-entries tr.voucher-total td {
  font-weight: 700; background: var(--bg-section-head, rgba(0,0,0,.03));
  border-top: 2px solid var(--border, #dee2e6);
}

/* ---------- 凭证新增 / 编辑 ---------- */
.voucher-form-table { margin-bottom: 8px; }
.voucher-form-table thead th { font-size: 12.5px; }
.voucher-form-table .ve-account { min-width: 160px; }
.voucher-form-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 13.5px; flex-wrap: wrap;
}

/* ---------- 账簿 ---------- */
.ledger-table { font-size: 13px; }
.ledger-table tfoot tr.ledger-total td,
.ledger-detail-table tr.ledger-total td,
.bs-table tr.ledger-total td {
  font-weight: 700; background: var(--bg-section-head, rgba(0,0,0,.04));
}
.ledger-card {
  border: 1px solid var(--border-light); border-radius: 10px; overflow: hidden;
  background: var(--bg-table, #fff); margin-bottom: 12px;
}
.ledger-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px; background: var(--bg-section-head, rgba(0,0,0,.03));
  border-bottom: 1px solid var(--border-light); font-size: 13px; flex-wrap: wrap;
}
.ledger-detail-table { margin: 0; font-size: 12.5px; }

/* ---------- 财务报表 ---------- */
.bs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .bs-grid { grid-template-columns: 1fr; } }
.bs-col h6 { font-size: 13.5px; font-weight: 700; margin-bottom: 6px; color: var(--text-primary); }
.bs-table { font-size: 12.5px; }
.cf-stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.is-table { font-size: 13px; }
.is-table tr.is-total td { font-weight: 700; background: var(--bg-section-head, rgba(0,0,0,.03)); }
.is-table tr.is-sub td { color: var(--text-muted); }

/* ---------- 税务报表 ---------- */
.vat-table, .cit-table, .pbt-table, .pit-table { font-size: 13px; max-width: 560px; }

/* ---------- 财税问答 ---------- */
.qa-wrap { max-width: 760px; }
.qa-item {
  border: 1px solid var(--border-light); border-radius: 10px; margin-bottom: 10px;
  background: var(--bg-table, #fff); overflow: hidden;
}
.qa-item.learned { border-left: 3px solid #28a745; }
.qa-item-head {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; cursor: pointer;
  font-size: 14px; flex-wrap: wrap;
}
.qa-item-head:hover { background: var(--bg-hover); }
.qa-item-head .qa-q { flex: 1; min-width: 180px; }
.qa-item-head .qa-source { font-size: 11.5px; color: var(--text-muted); }
.qa-item-head .qa-arrow { transition: transform .2s; color: var(--text-muted); }
.qa-item.open .qa-arrow { transform: rotate(180deg); }
.qa-a {
  display: none; padding: 12px 14px; font-size: 13px; line-height: 1.75;
  border-top: 1px dashed var(--border-light); color: var(--text-secondary, #333);
  white-space: pre-wrap;
}
.qa-item.open .qa-a { display: block; }

/* 最新热点：工具栏 + 进度条 + 已看标记 + 下一条 */
.qa-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.qa-progress-box { min-width: 220px; flex: 1; max-width: 420px; }
.qa-progress-text { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.qa-progress-text span { font-weight: 600; color: var(--text-primary); }
.qa-progress-bar {
  height: 8px; border-radius: 6px; background: var(--border-light, #e5e7eb); overflow: hidden;
}
.qa-progress-bar span {
  display: block; height: 100%; border-radius: 6px;
  background: linear-gradient(90deg, #28a745, #5cc178);
  transition: width .4s ease;
}
.qa-learned-flag {
  display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px;
  color: #28a745; font-weight: 600; white-space: nowrap;
}
.qa-pin-flag {
  display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px;
  color: #fd7e14; font-weight: 600; white-space: nowrap;
}
.qa-item.pinned { border-left: 3px solid #fd7e14; background: rgba(253,126,20,.12); }
.qa-source-line {
  font-size: 12px; color: var(--text-muted); margin-right: 12px;
  font-style: italic;
}
.qa-a-foot {
  margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--border-light);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.qa-next-btn {
  padding: 2px 8px; font-size: 12.5px; color: #0d6efd !important;
  text-decoration: none !important;
}
.qa-next-btn:hover { text-decoration: underline !important; }
@keyframes qa-spin { to { transform: rotate(360deg); } }
.spin { display: inline-block; animation: qa-spin 0.8s linear infinite; }
.qa-pager { text-align: center; margin-top: 16px; }
.qa-pager-end { font-size: 12.5px; color: var(--text-muted); padding: 10px; }

/* ============================================================
 * 消息中心（铃铛角标 / 面板）+ 全局提示（toast）+ 排队行
 * ============================================================ */
.titlebar-btn { position: relative; }
.notif-badge {
  position: absolute; top: -4px; right: -6px; min-width: 16px; height: 16px;
  padding: 0 4px; border-radius: 8px; background: #e5484d; color: #fff;
  font-size: 10px; line-height: 16px; text-align: center; font-weight: 700;
}

.notif-panel {
  position: fixed; top: 44px; right: 12px; width: 340px; max-height: 70vh;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 8px 28px var(--shadow); z-index: 1200;
  display: flex; flex-direction: column; overflow: hidden;
}
.notif-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; font-weight: 600; border-bottom: 1px solid var(--border-light);
}
.notif-head-right { display: flex; align-items: center; gap: 8px; }
.notif-list {
  list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1;
}
.notif-item {
  display: flex; gap: 10px; padding: 10px 14px; cursor: default;
  border-bottom: 1px solid var(--border-light); font-size: 13px;
}
.notif-item.unread { background: var(--bg-hover); }
.notif-item:hover { background: var(--bg-hover); }
.notif-ico { flex: 0 0 auto; font-size: 15px; line-height: 1.4; }
.notif-text { min-width: 0; }
.notif-msg { color: var(--text-primary); line-height: 1.5; word-break: break-all; }
.notif-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }
.notif-empty { padding: 22px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* 全局提示（上传受理 / 处理完成弹窗） */
.toast-container {
  position: fixed; top: 52px; right: 16px; z-index: 1300;
  display: flex; flex-direction: column; gap: 10px; max-width: 380px;
}
.toast-item {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-left: 4px solid #2f9e44; border-radius: 10px;
  box-shadow: 0 6px 20px var(--shadow); font-size: 13.5px; line-height: 1.55;
  color: var(--text-primary); white-space: pre-line;
  animation: toast-in .25s ease; transition: opacity .3s, transform .3s;
}
.toast-item.toast-danger { border-left-color: #e5484d; }
.toast-item.toast-hide { opacity: 0; transform: translateX(20px); }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
.toast-icon { font-size: 16px; line-height: 1.4; }
.toast-body { flex: 1; min-width: 0; word-break: break-all; }
.toast-action { flex: 0 0 auto; margin-top: 2px; }
.toast-close {
  flex: 0 0 auto; border: none; background: none; color: var(--text-muted);
  padding: 0 2px; font-size: 12px; cursor: pointer;
}
.toast-close:hover { color: var(--text-primary); }

/* 处理状态页排队行 */
.queue-line {
  font-size: 13.5px; color: var(--text-secondary); margin-bottom: 12px;
  padding: 8px 12px; background: var(--bg-section-head); border-radius: 8px;
}
.queue-line b { color: var(--accent); }
