/* ============================================================================
   辰鉴智慧财务 · Web 工作台样式
   设计取向：贴近桌面级 AI 工作台（DeepSeek Harness）的克制风格——
   浅灰画布 + 白色内容面、发丝分隔线、13px 正文、圆角 8–12px、
   只在需要强调处用色（状态、阻断、主按钮）。不引入外部字体与图标库。
   ========================================================================== */

:root {
  /* 色板 */
  --bg: #f6f7f8;
  --bg-soft: #fafbfc;
  --surface: #ffffff;
  --ink: #16181d;
  --ink-2: #3d424c;
  --ink-3: #565c68;
  --muted: #737985;
  --faint: #9aa1ad;
  --line: #e8eaee;
  --line-strong: #d8dbe1;
  --hover: #eceef2;
  --active: #e5e8ee;
  --accent: #1f2430;
  --accent-hover: #2b3140;
  --brand: #3d5afe;
  --brand-soft: #eef1ff;
  --ok: #15803d;
  --ok-soft: #e9f7ef;
  --warn: #a16207;
  --warn-soft: #fdf6e3;
  --bad: #b42318;
  --bad-soft: #fdeceb;
  --info-soft: #eef4ff;

  /* 尺寸 */
  --sidebar-w: 236px;
  --evidence-w: 340px;
  --topbar-h: 48px;
  --statusbar-h: 30px;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-pop: 0 8px 24px rgba(16, 24, 40, 0.10);

  --mono: "JetBrains Mono", Consolas, "Cascadia Mono", monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 13.5px/1.6 "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body.is-app { overflow: hidden; }

/* hidden 必须压过任何 display 规则：登录页曾因此留下一块空白带。 */
[hidden] { display: none !important; }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 14px; }
h3 { font-size: 13px; }
p { margin: 0; }
code, pre, .mono { font-family: var(--mono); font-size: 12px; }

.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.loading, .empty-hint {
  color: var(--muted); font-size: 12.5px; padding: 12px 2px;
}
.error-text { color: var(--bad); font-size: 12.5px; }

/* ============================== 布局外壳 ============================== */

.app {
  display: grid;
  grid-template-rows: var(--topbar-h) auto minmax(0, 1fr) var(--statusbar-h);
  position: fixed;
  inset: 0;
  background: var(--surface);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar-brand { display: flex; align-items: center; gap: 8px; min-width: var(--sidebar-w); }
.product-name { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--accent); color: var(--surface);
  font-size: 13px; font-weight: 600;
  letter-spacing: 0;
}
.brand-mark.small { width: 20px; height: 20px; border-radius: 6px; font-size: 11px; }

.topbar-user { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2); }
.user-name { font-weight: 600; }
.user-roles { color: var(--muted); font-size: 11px; }
.topbar-sep { width: 1px; height: 14px; background: var(--line-strong); }
.tenant-chip { color: var(--muted); font-size: 11.5px; }
.tenant-chip b { color: var(--ink-2); font-weight: 600; }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.health {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 10px;
  font: inherit; font-size: 11.5px;
  cursor: pointer;
}
.health:hover { border-color: var(--line-strong); color: var(--ink-2); }
.health-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.health-dot.ok { background: #22a06b; }
.health-dot.warn { background: #d9a441; }
.health-dot.bad { background: #d14233; }

.workarea {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--evidence-w);
  min-height: 0;
  overflow: hidden;
  background: var(--surface);
}

/* ============================== 侧栏 ============================== */

.sidenav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 8px 12px;
  background: var(--bg);
  border-right: 1px solid var(--line);
  overflow: auto;
}
.nav-new {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 8px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit; font-size: 12.5px; font-weight: 600;
  cursor: pointer;
}
.nav-new:hover { border-color: var(--faint); }

.nav-section {
  padding: 14px 10px 5px;
  font-size: 11px;
  color: var(--faint);
  letter-spacing: 0.02em;
}

.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-3);
  font: inherit; font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.nav-item:hover { background: var(--hover); color: var(--ink); }
.nav-item.active { background: var(--active); color: var(--ink); font-weight: 600; }
.nav-icon { display: inline-flex; width: 16px; height: 16px; color: inherit; }
.nav-icon svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tag-init { color: #1a5fb4; background: #eaf1fb; }\n\n/* ===== 对话里的初始化卡片 ===== */
.init-card {
  margin: 10px 0 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2, var(--hover));
  padding: 10px 12px 8px;
}
.init-card-title { margin: 0 0 4px; font-size: 12.5px; font-weight: 600; color: var(--ink); }
.init-card-note { margin: 0 0 8px; font-size: 12px; color: var(--ink-3); line-height: 1.6; }
.init-card-body { margin: 0 0 8px; }
.init-card-counts {
  display: flex; flex-wrap: wrap; gap: 14px;
  font-size: 12px; color: var(--ink-3); margin-bottom: 6px;
}
.init-card-counts b { font-size: 15px; color: var(--ink); margin-right: 3px; }
.init-card-codes {
  margin: 0 0 6px; font-size: 11.5px; color: var(--ink-3); line-height: 1.9;
}
.init-card-codes code {
  padding: 1px 5px; margin: 0 2px 2px 0; border-radius: 4px;
  background: var(--surface, #fff); border: 1px solid var(--line); color: var(--ink);
  font-size: 11px;
}
.init-card-error { margin: 0; font-size: 12px; color: var(--bad, #c0392b); }
.init-card-ok { margin: 0 0 4px; font-size: 12.5px; color: var(--good, #1a7f4b); font-weight: 600; }
.init-card-actions { display: flex; gap: 8px; }

/* ===== 对话工具条：附件 / 语音 ===== */
.chat-tool {
  flex: 0 0 auto;
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-3);
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.chat-tool:hover { border-color: var(--faint); background: var(--hover); }
.chat-tool.is-on { border-color: var(--accent, #2f6df6); color: var(--accent, #2f6df6); }

.chat-attach-list {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 0 0 8px;
}
.attach-chip {
  display: inline-flex; align-items: center; gap: 6px;
  max-width: 260px;
  padding: 3px 6px 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2, var(--hover));
  font-size: 11.5px;
  color: var(--ink-3);
}
.attach-chip b {
  font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 150px;
}
.attach-chip i { font-style: normal; color: var(--faint); white-space: nowrap; }
.attach-chip-warn { border-color: #e6c07a; }
.attach-del {
  border: 0; background: transparent; color: var(--faint);
  font-size: 13px; line-height: 1; cursor: pointer; padding: 0 2px;
}
.attach-del:hover { color: var(--bad, #c0392b); }

/* ===== 左侧对话历史 ===== */
.nav-sessions {
  display: flex; flex-direction: column; gap: 1px;
  margin: 2px 0 0;
  padding: 2px 0 6px;
  max-height: 34vh;
  overflow-y: auto;
}
.nav-empty {
  margin: 2px 0 0;
  padding: 6px 10px;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.5;
}
.nav-session {
  display: flex; align-items: stretch; gap: 2px;
  border-radius: var(--radius-sm);
}
.nav-session:hover { background: var(--hover); }
.nav-session.active { background: var(--active); }
.nav-session-main {
  flex: 1 1 auto; min-width: 0;
  display: flex; flex-direction: column; gap: 1px;
  padding: 6px 8px;
  border: 0; border-radius: var(--radius-sm);
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: var(--ink-3);
  font: inherit;
}
.nav-session.active .nav-session-main { color: var(--ink); font-weight: 600; }
.nav-session-title {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: 12.5px;
}
.nav-session-meta { font-size: 10.5px; color: var(--faint); font-weight: 400; }
.nav-session-del {
  flex: 0 0 auto;
  width: 22px;
  border: 0; border-radius: var(--radius-sm);
  background: transparent;
  color: var(--faint);
  font-size: 14px; line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s;
}
.nav-session:hover .nav-session-del { opacity: 1; }
.nav-session-del:hover { color: var(--bad, #c0392b); background: var(--hover); }

.sidenav-foot {
  margin-top: auto;
  padding: 10px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 11px;
  line-height: 1.5;
}

/* ============================== 主内容区 ============================== */

.page {
  min-width: 0;
  padding: 18px 22px 22px;
  overflow: auto;
  background: var(--surface);
  outline: none;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-width: 0;
}
.panel-head {
  display: flex; align-items: baseline; gap: 10px;
  flex-wrap: wrap;
  margin: -2px 0 10px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { font-size: 13.5px; }
.panel-sub, .panel-note { color: var(--muted); font-size: 11.5px; }
.panel-note { margin: -4px 0 10px; }
.head-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }

/* 页面级三列/两列骨架 */
.page-chat { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 14px; height: 100%; min-height: 0; }
.page-docs { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 14px; height: 100%; min-height: 0; }
.page-analysis { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 14px; height: 100%; min-height: 0; }
.page-kb { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; height: 100%; min-height: 0; }
.page-audit { display: flex; flex-direction: column; gap: 12px; height: 100%; min-height: 0; }

.chat-main, .docs-list, .docs-detail, .analysis-main, .analysis-chat, .kb-search, .kb-qa { min-height: 0; overflow: auto; }
.chat-main, .analysis-chat, .kb-qa { display: flex; flex-direction: column; }

/* ============================== 按钮 ============================== */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-2);
  font: inherit; font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--faint); color: var(--ink); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--surface); font-weight: 500; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--surface); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--hover); color: var(--ink); border-color: transparent; }
.btn-danger { color: var(--bad); border-color: #f0c9c4; background: var(--surface); }
.btn-danger:hover:not(:disabled) { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.btn-xs { padding: 3px 8px; font-size: 11.5px; border-radius: 6px; }
.btn-block { width: 100%; }

/* ============================== 徽标与状态 ============================== */

.badge {
  display: inline-flex; align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--active);
  color: var(--ink-2);
  font-size: 11px; font-weight: 500;
  white-space: nowrap;
}
.badge-level { background: var(--brand-soft); color: #2f45c5; font-family: var(--mono); }

.sev { display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 999px; font-size: 10.5px; font-weight: 600; letter-spacing: 0.02em; }
.sev-critical, .sev-high { background: var(--bad-soft); color: var(--bad); }
.sev-medium { background: var(--warn-soft); color: var(--warn); }
.sev-low, .sev-info { background: var(--info-soft); color: #2f45c5; }

.stale-flag, .fresh-flag { font-size: 11px; padding: 1px 6px; border-radius: 5px; font-family: var(--mono); }
.stale-flag { background: var(--warn-soft); color: var(--warn); }
.fresh-flag { background: var(--ok-soft); color: var(--ok); }

.status-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--ink-2); }
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.st-ready::before { background: #22a06b; }
.st-warn::before { background: #d9a441; }
.st-bad::before { background: #d14233; }
.st-unknown::before { background: var(--faint); }

.tag-clarify, .tag-refuse, .tag-warn, .tag-llm {
  display: inline-flex; padding: 1px 7px; border-radius: 5px;
  font-size: 10.5px; font-weight: 600;
}
.tag-clarify { background: var(--info-soft); color: #2f45c5; }
.tag-refuse { background: var(--bad-soft); color: var(--bad); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-llm { background: var(--ok-soft, #e8f7ee); color: #157a45; }
.answer-tag { font-size: 11px; color: var(--muted); }
.llm-note {
  margin: 8px 0 0; padding: 8px 10px;
  font-size: 12px; line-height: 1.65; color: var(--text-2, #4a5261);
  background: var(--soft, #f6f7f9); border-left: 2px solid var(--line-2, #d8dce3);
  border-radius: 0 6px 6px 0;
}

/* ============================== 提示条 ============================== */

.banner-host { padding: 0; }
.banner-host:not(:empty) { padding: 8px 14px 0; }
.banner {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  font-size: 12.5px;
}
.banner.ok { background: var(--ok-soft); border-color: #c7e9d5; }
.banner.warn { background: var(--warn-soft); border-color: #f0dfb5; }
.banner.error, .banner.bad { background: var(--bad-soft); border-color: #f2cdc8; }
.banner-msg { color: var(--ink-2); }
.banner-code { font-family: var(--mono); font-size: 11px; color: var(--muted); background: rgba(0,0,0,.04); padding: 1px 6px; border-radius: 5px; }
.banner-close { margin-left: auto; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1; }

/* ============================== 表格 ============================== */

.table-wrap { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: auto; }
.data-table, .doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.data-table th, .doc-table th {
  position: sticky; top: 0;
  background: var(--bg-soft);
  color: var(--muted);
  font-weight: 500;
  font-size: 11.5px;
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.data-table td, .doc-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  vertical-align: top;
}
.data-table tr:last-child td, .doc-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover, .doc-table tbody tr:hover { background: var(--bg-soft); }
.doc-row { cursor: pointer; }
.doc-row.selected, .doc-row.active { background: var(--brand-soft) !important; }
.doc-table { min-width: 520px; }
.actions-cell, .action-row { display: flex; gap: 6px; flex-wrap: wrap; }
.pager { display: flex; justify-content: center; padding: 10px 0 2px; }
.result-count { color: var(--muted); font-size: 11.5px; margin: 0 0 8px; }

/* ============================== 表单 ============================== */

.field { display: block; margin: 0 0 12px; }
.field > span { display: block; margin-bottom: 5px; color: var(--ink-3); font-size: 12px; }
input[type="text"], input[type="password"], input[type="date"], input[type="file"], select, textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit; font-size: 13px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(61, 90, 254, 0.12);
}
textarea { resize: vertical; min-height: 64px; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 14px) 52%, calc(100% - 9px) 52%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 26px; }
.input-sm, .select-sm { width: auto; min-width: 120px; padding: 5px 9px; font-size: 12px; }
.inline-label { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-3); }
.inline-note { font-size: 11.5px; color: var(--muted); }
.form-error { color: var(--bad); font-size: 12px; margin: 6px 0; }
.form-note { color: var(--muted); font-size: 11.5px; margin-top: 6px; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 0 0 10px; }
.search-form { display: flex; gap: 8px; margin: 0 0 12px; }
.search-form input { flex: 1; }
.upload-form { border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); padding: 10px 12px; margin: 0 0 12px; background: var(--bg-soft); }
.upload-form .grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; align-items: end; }
.reason-field { margin: 10px 0 0; }
.resolve-form { display: grid; gap: 8px; margin: 8px 0 0; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg-soft); }
.resolve-reason, .resolve-deadline, .resolve-id { font-size: 12px; }
.resolve-action, .resolve-cancel { align-self: start; }

/* ============================== 对话 ============================== */

.chat-host { flex: 1; min-height: 0; display: flex; }
.chat-log { flex: 1; overflow: auto; padding: 4px 2px 8px; display: flex; flex-direction: column; gap: 14px; }
.chat-empty { margin: auto; text-align: center; color: var(--muted); font-size: 13px; }
.bubble {
  max-width: 82%;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble.bubble-user { align-self: flex-end; background: var(--active); border-color: transparent; }
.bubble.bubble-error { background: var(--bad-soft); border-color: #f2cdc8; color: var(--bad); }
/* 流式占位气泡：文字逐段长出来，末尾一个呼吸的光标，避免"卡住了"的观感 */
.bubble.bubble-stream { background: var(--panel); }
.bubble-stream .stream-text { margin: 0; white-space: pre-wrap; word-break: break-word; }
.bubble-stream .stream-text::after {
  content: '▍';
  margin-left: 2px;
  color: var(--ink-3);
  animation: stream-caret 1s steps(2, start) infinite;
}
.bubble-stream .answer-tag { margin: 8px 0 0; }
.stream-dots { animation: stream-caret 1.2s ease-in-out infinite; }
@keyframes stream-caret { 50% { opacity: 0.15; } }
.bubble-meta { display: flex; gap: 8px; align-items: center; font-size: 11px; color: var(--muted); margin: 0 0 4px; }
.narrative { margin: 0 0 8px; }
.citations { margin-top: 8px; border-top: 1px dashed var(--line-strong); padding-top: 8px; }
.citations-block { font-size: 11.5px; color: var(--muted); }
.citation-list { margin: 6px 0 0; padding-left: 0; list-style: none; display: grid; gap: 4px; }
.citation-list li { font-size: 11.5px; color: var(--ink-3); }
.warnings { margin: 8px 0 0; padding-left: 18px; color: var(--warn); font-size: 11.5px; }
.next-steps { margin: 8px 0 0; padding-left: 18px; color: var(--ink-3); font-size: 12px; }
.chat-form { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 8px; }
.chat-input { min-height: 66px; border-radius: 12px; }
.chat-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.chat-hint { color: var(--muted); font-size: 11px; }
.chat-actions .btn-primary { margin-left: auto; border-radius: 999px; padding: 7px 18px; }
.chat-side { overflow: auto; }
.example-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.example {
  text-align: left;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-2);
  font: inherit; font-size: 12.5px;
  cursor: pointer;
}
.example:hover { border-color: var(--line-strong); background: var(--bg-soft); }

/* ============================== 单据审核 ============================== */

.kv { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 5px 10px; margin: 0 0 10px; font-size: 12.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); word-break: break-word; }
.kv-2 { grid-template-columns: 84px minmax(0, 1fr) 84px minmax(0, 1fr); }
.kv-line { font-size: 12.5px; color: var(--ink-2); margin: 0 0 6px; }
.mini-label { color: var(--muted); font-size: 11px; }
.detail-block { margin: 12px 0 0; }
.detail-block > h3 { margin-bottom: 7px; color: var(--ink-3); font-size: 12.5px; }
.issue-list { display: grid; gap: 7px; }
.issue {
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: var(--bg-soft);
}
.issue.issue-blocking { border-left-color: var(--bad); }
.issue.issue-warn { border-left-color: #d9a441; }
.issue-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.issue-field { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.issue-msg { margin-top: 4px; color: var(--ink-2); font-size: 12.5px; }
.tabs { display: flex; gap: 4px; margin: 0 0 12px; }
.tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 7px;
  padding: 5px 12px;
  font: inherit; font-size: 12.5px;
  cursor: pointer;
}
.tab:hover { background: var(--hover); color: var(--ink-2); }
.tab.active { background: var(--active); color: var(--ink); font-weight: 600; }
.candidate-list { display: grid; gap: 7px; }
.candidate {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: var(--surface);
  font-size: 12.5px;
}
.candidate.selected { border-color: var(--brand); background: var(--brand-soft); }
.doc-meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.inline { display: inline-flex; align-items: center; gap: 6px; }

/* ============================== 分析 ============================== */

.period-note { color: var(--muted); font-size: 11.5px; }
.data-asof { color: var(--muted); font-size: 11.5px; margin: 0 0 10px; }
.stale-banner {
  margin: 0 0 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 11.5px;
}
.stale-note { color: var(--muted); font-size: 11px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 13px;
  background: var(--surface);
}
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.card-name { color: var(--ink-3); font-size: 12.5px; }
.card-value { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.card-unit { font-size: 12px; color: var(--muted); margin-left: 4px; font-weight: 400; }
.card-meta { margin-top: 6px; color: var(--muted); font-size: 11px; display: flex; gap: 8px; flex-wrap: wrap; }
.card-formula, .card-reason { margin-top: 8px; font-size: 11.5px; color: var(--ink-3); }
.card-formula summary, .card-reason summary { cursor: pointer; color: var(--muted); }
.card-stale { border-color: #f0dfb5; background: #fffdf6; }
.delta { font-size: 11.5px; color: var(--muted); }
.card-grid { display: grid; gap: 10px; }

/* ============================== 知识库 ============================== */

.hit {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 0 0 8px;
  background: var(--surface);
}
.hit:hover { border-color: var(--line-strong); background: var(--bg-soft); }
.hit-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.hit-score { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-left: auto; }
.hit-snippet { color: var(--ink-2); font-size: 12.5px; }
.hit-foot { display: flex; gap: 10px; align-items: center; margin-top: 6px; font-size: 11px; color: var(--muted); }
.meta-line { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); margin: 0 0 8px; }
.meta-item { display: inline-flex; gap: 5px; }
.preview-text {
  max-height: 320px;
  overflow: auto;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  font-size: 12px;
  white-space: pre-wrap;
}

/* ============================== 证据面板 ============================== */

.evidence {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--line);
  background: var(--bg-soft);
  padding: 12px 12px 0;
}
.evidence-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.evidence-head h2 { font-size: 12.5px; }
.evidence-head .btn { margin-left: auto; }
.evidence-hint { color: var(--muted); font-size: 11px; margin-bottom: 10px; }
.evidence-list { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; }
.ev-empty { color: var(--faint); font-size: 11.5px; }
.ev-line {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 8px 9px;
  font-size: 11px;
}
.ev-line.ev-error { border-color: #f2cdc8; background: #fffafa; }
.ev-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ev-method { font-family: var(--mono); font-size: 10px; font-weight: 600; color: var(--ink-2); background: var(--active); border-radius: 4px; padding: 1px 5px; }
.ev-path { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); word-break: break-all; }
.ev-status { margin-left: auto; font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.ev-ms { font-family: var(--mono); font-size: 10px; color: var(--faint); }
.ev-label { font-family: var(--mono); font-size: 10px; color: var(--faint); }
.ev-cell { color: var(--ink-3); display: block; margin-top: 3px; }
.ev-pre {
  margin: 6px 0 0;
  max-height: 220px;
  overflow: auto;
  padding: 7px 8px;
  border-radius: 6px;
  background: #f3f4f6;
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ============================== 状态栏 ============================== */

.statusbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  border-top: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
}
.statusbar-item { white-space: nowrap; }
.statusbar-item b { color: var(--ink-2); font-weight: 600; }
.statusbar-spacer { flex: 1; }
.statusbar-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #22a06b; margin-right: 5px; }

/* ============================== 提示 & 登录 ============================== */

.toast-host { position: fixed; right: 18px; bottom: 42px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--surface);
  font-size: 12.5px;
  box-shadow: var(--shadow-pop);
  animation: toast-in 0.16s ease-out;
}
.toast.bad { background: var(--bad); }
@keyframes toast-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.login-view {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 40px 16px;
  background:
    radial-gradient(1100px 500px at 15% -10%, #eef1ff 0%, transparent 60%),
    radial-gradient(900px 460px at 100% 0%, #eef7f2 0%, transparent 55%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 388px;
  padding: 26px 26px 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(16, 24, 40, 0.06);
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.login-brand h1 { font-size: 17px; }
.login-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.login-error {
  margin: 0 0 10px;
  padding: 8px 10px;
  border: 1px solid #f2cdc8;
  border-radius: var(--radius-sm);
  background: var(--bad-soft);
  color: var(--bad);
  font-size: 12px;
  line-height: 1.55;
}
.login-submit, #login-submit { margin-top: 4px; }
.login-accounts { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.login-accounts-title { color: var(--muted); font-size: 11.5px; margin-bottom: 8px; }
.login-accounts-title code { background: var(--active); border-radius: 4px; padding: 1px 5px; }
.login-accounts-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.login-account {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-3);
  border-radius: 7px;
  padding: 5px 10px;
  font: inherit; font-size: 12px;
  cursor: pointer;
}
.login-account:hover { border-color: var(--brand); color: var(--brand); }
.login-hint { color: var(--faint); font-size: 11px; margin: 0; }
.noscript { padding: 24px; font-size: 13px; }

/* ============================== 窄屏 ============================== */

@media (max-width: 1280px) {
  :root { --evidence-w: 300px; --sidebar-w: 208px; }
  .page { padding: 16px 16px 18px; }
}

@media (max-width: 1080px) {
  .workarea { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .evidence { display: none; }
  .page-chat, .page-docs, .page-analysis, .page-kb { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
  :root { --sidebar-w: 0px; }
  .sidenav { display: none; }
  .topbar-brand { min-width: 0; }
  .statusbar { display: none; }
}

/* 对话组件：.chat 是 createChat() 的外壳（log + form），必须撑满 .chat-host 才能把输入框压到底部 */
.chat { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.msg { display: flex; }
.msg-user { justify-content: flex-end; }
.msg-system { justify-content: flex-start; }
.msg-user .bubble { background: var(--active); border-color: transparent; }

/* ===== 补充：状态胶囊（.status + st-*）===== */
.status {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 1px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--ink-2);
  font-size: 11.5px;
  white-space: nowrap;
}
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.status.st-ready { color: var(--ok); background: var(--ok-soft); border-color: #c7e9d5; }
.status.st-ready::before { background: var(--ok); }
.status.st-done { color: #1f4bd8; background: var(--brand-soft); border-color: #d6ddff; }
.status.st-done::before { background: #3d5afe; }
.status.st-running { color: var(--ink-2); background: var(--active); border-color: var(--line-strong); }
.status.st-running::before { background: #d9a441; }
.status.st-warn { color: var(--warn); background: var(--warn-soft); border-color: #f0dfb5; }
.status.st-warn::before { background: #d9a441; }
.status.st-bad { color: var(--bad); background: var(--bad-soft); border-color: #f2cdc8; }
.status.st-bad::before { background: var(--bad); }
.status.st-void { color: var(--muted); background: var(--bg-soft); border-style: dashed; }
.status.st-unknown { color: var(--muted); }

/* ===== 补充：指标卡网格（两列起）===== */
.card-grid { grid-template-columns: repeat(auto-fit, minmax(196px, 1fr)); }

/* ===== 补充：证据条目（details/summary 结构）===== */
.ev {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}
.ev.ev-fail, .ev.ev-error { border-color: #f2cdc8; background: #fffafa; }
.ev > summary {
  display: flex; flex-wrap: wrap; align-items: center; gap: 5px;
  padding: 7px 9px;
  cursor: pointer;
  list-style: none;
  font-size: 11px;
}
.ev > summary::-webkit-details-marker { display: none; }
.ev > summary::after {
  content: "▾";
  margin-left: auto;
  color: var(--faint);
  font-size: 9px;
}
.ev[open] > summary::after { content: "▴"; }
.ev > summary .ev-method { order: 1; }
.ev > summary .ev-status { order: 2; margin-left: 0; }
.ev > summary .ev-ms { order: 3; }
.ev > summary .ev-path { order: 4; flex: 1 1 100%; }
.ev-body { padding: 0 9px 8px; }
.ev-line {
  display: flex; gap: 6px; align-items: baseline;
  margin: 0 0 4px;
  border: 0; background: transparent; padding: 0;
  font-size: 11px; color: var(--ink-2);
  word-break: break-all;
}
.ev-line .mini-label { flex: 0 0 52px; }
.ev-line.ev-error { color: var(--bad); }
.ev-label { margin: 8px 0 4px; font-size: 10.5px; color: var(--faint); }

/* ===== 补充：上传表单与行内标签 ===== */
.upload-form .grid-3 { grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); }
.inline-label { white-space: nowrap; }

/* ===== 补充：上传表单改为竖排（面板宽度有限，横排会把标签挤成两行）===== */
.upload-form .grid-3 { grid-template-columns: 1fr; }
.upload-form .grid-3 > .inline { display: grid; grid-template-columns: 64px minmax(0, 1fr); align-items: center; gap: 8px; }
.upload-form .grid-3 > .inline .inline-label { justify-self: start; }
.upload-form .grid-3 > .btn { justify-self: start; }

/* ===== 补充：单据表格不换行，靠横向滚动承载宽度 ===== */
.doc-table { min-width: 620px; }
.doc-table td:nth-child(-n+3), .doc-table th:nth-child(-n+3) { white-space: nowrap; }

/* 上传表单：标签列给足宽度，避免「票据文件」被拆成两行 */
.upload-form .grid-3 > .inline { grid-template-columns: 84px minmax(0, 1fr); }
.upload-form .inline-label { white-space: nowrap; }

/* ===== 补充：稽核发现表（列宽固定 + 两行单元格）===== */
.findings-table { table-layout: fixed; width: 100%; }
.findings-table th:nth-child(1) { width: 16%; }
.findings-table th:nth-child(2) { width: 9%; }
.findings-table th:nth-child(3) { width: 7%; }
.findings-table th:nth-child(4) { width: 22%; }
.findings-table th:nth-child(5) { width: 24%; }
.findings-table th:nth-child(6) { width: 12%; }
.findings-table th:nth-child(7) { width: 10%; }
.findings-table td { vertical-align: top; }
.cell-main { display: block; color: var(--ink); font-size: 12.5px; }
.cell-sub { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 12.5px;
}
.badge.blk { background: var(--bad-soft); color: var(--bad); }

/* 证据 summary：单行省略，避免长 URL 把整块撑成三行 */
.ev > summary { flex-wrap: nowrap; }
.ev > summary .ev-path {
  flex: 1 1 auto; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  order: 2;
}
.ev > summary .ev-method { order: 1; flex: 0 0 auto; }
.ev > summary .ev-status { order: 3; flex: 0 0 auto; margin-left: 6px; }
.ev > summary .ev-ms { order: 4; flex: 0 0 auto; }
.ev > summary::after { content: "▾"; margin-left: 4px; flex: 0 0 auto; }
.ev[open] > summary::after { content: "▴"; }

.ev > summary::marker { content: ""; }
.ev > summary { list-style: none; }

/* 证据条目：button 头部（替代 details/summary，避免 ::marker 残留） */
.ev-head {
  display: flex; align-items: center; gap: 6px;
  width: 100%;
  padding: 7px 9px;
  border: 0;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.ev-head:hover { background: var(--bg-soft); }
.ev-caret { margin-left: auto; color: var(--faint); font-size: 9px; transition: transform 0.12s; }
.ev-head.open .ev-caret { transform: rotate(180deg); }

/* 详情键值：单据面板窄，一律两列 */
.kv, .kv-2 { grid-template-columns: 78px minmax(0, 1fr); }
.kv dd { font-size: 12.5px; }

/* 上传表单：field.inline 用两列网格，标签列固定宽度，避免中文标签竖向折行 */
.upload-form .field.inline {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.upload-form .field.inline > span { margin-bottom: 0; white-space: nowrap; }
.upload-form > .btn { margin: 2px 0 8px; }
.upload-form .form-note { margin-top: 0; }

/* 证据头部显式清掉列表标记（按钮在部分 UA 上仍带 disc marker） */
.ev-head, .ev-head::marker { list-style: none; content: none; }

/* 证据头部：单行，路径省略号截断，状态与耗时靠右 */
.ev-head { flex-wrap: nowrap; }
.ev-head .ev-method, .ev-head .ev-status, .ev-head .ev-ms, .ev-head .ev-caret { flex: 0 0 auto; }
.ev-head .ev-path {
  flex: 1 1 auto; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  word-break: normal;
}

/* 答案表格：数值列不折行 */
.data-table td.num, .data-table th.num { white-space: nowrap; }
.bubble .data-table { font-size: 12px; }
.bubble .data-table th, .bubble .data-table td { padding: 6px 8px; }

/* 答案表格首列（指标名）不折行 */
.bubble .data-table th:first-child, .bubble .data-table td:first-child { white-space: nowrap; }

/* 知识库示例词：一行 chips */
.kb-examples { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.kb-examples .example { padding: 5px 10px; font-size: 12px; border-radius: 999px; color: var(--ink-3); }

/* 品牌方块：字形不要被行高裁切 */
.brand-mark { line-height: 1; font-size: 14px; }
.brand-mark.small { font-size: 11px; }

/* ===== 主题：深色 / 跟随系统 ===== */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #131519;
  --bg-soft: #171a1f;
  --surface: #1c1f26;
  --ink: #e8eaef;
  --ink-2: #c8ccd6;
  --ink-3: #a9afbb;
  --muted: #8b92a0;
  --faint: #6f7684;
  --line: #2a2e37;
  --line-strong: #363b46;
  --hover: #23272f;
  --active: #2a2f39;
  --accent: #e8eaef;
  --accent-hover: #ffffff;
  --brand: #7f93ff;
  --brand-soft: #232a45;
  --ok: #4ade80;
  --ok-soft: #16281d;
  --warn: #fbbf24;
  --warn-soft: #2c2413;
  --bad: #f87171;
  --bad-soft: #2e1a19;
  --info-soft: #1c2436;
}
html[data-theme="dark"] .ev-pre { background: #0f1115; color: #cfd6e4; }
html[data-theme="dark"] .btn-primary { background: #e8eaef; color: #14161a; border-color: #e8eaef; }
html[data-theme="dark"] .btn-primary:hover { background: #ffffff; }
html[data-theme="dark"] .statusbar { background: #101216; }
html[data-theme="dark"] .sidenav-foot { background: transparent; }

/* ===== 设置页 ===== */
.page-settings { display: grid; grid-template-columns: 196px minmax(0, 1fr); gap: 16px; height: 100%; min-height: 0; }
.set-nav { display: flex; flex-direction: column; gap: 2px; padding: 10px 8px; overflow: auto; }
.set-nav button {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0; border-radius: 7px;
  background: transparent; color: var(--ink-2);
  font: inherit; text-align: left; cursor: pointer;
}
.set-nav button:hover { background: var(--hover); }
.set-nav button.active { background: var(--active); color: var(--ink); font-weight: 600; }
.set-body { overflow: auto; min-height: 0; padding: 18px 20px 28px; }
.set-body h3 { margin: 0 0 4px; font-size: 14px; }
.set-sub { color: var(--muted); font-size: 12px; margin: 0 0 14px; }
.set-row {
  display: grid; grid-template-columns: 200px minmax(0, 1fr);
  gap: 16px; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.set-row:last-child { border-bottom: 0; }
.set-row .set-label { font-size: 13px; }
.set-row .set-label small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button {
  border: 0; background: transparent; color: var(--ink-2);
  padding: 6px 12px; font: inherit; font-size: 12.5px; cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--active); color: var(--ink); font-weight: 600; }
.set-actions { display: flex; gap: 8px; margin-top: 16px; }
.set-note { color: var(--muted); font-size: 12px; margin-top: 10px; }
.policy-table { width: 100%; }
.policy-table td, .policy-table th { padding: 8px 10px; font-size: 12.5px; }
.policy-table select { width: 100%; }
.policy-table .locked { color: var(--warn); font-size: 11.5px; }
.card-list { display: grid; gap: 10px; }
.set-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--surface); }
.set-card header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.set-card header strong { font-size: 13px; }
.set-card p { margin: 0; color: var(--muted); font-size: 12px; }
.mcp-box { border: 1px dashed var(--line-strong); border-radius: 10px; padding: 12px 14px; margin-top: 14px; }
.mcp-box code { font-family: var(--mono); font-size: 12px; }

/* ===== 设置页 ===== */
.page-settings { display: grid; grid-template-columns: 196px minmax(0, 1fr); gap: 16px; height: 100%; min-height: 0; }
.set-nav { padding: 8px; display: flex; flex-direction: column; gap: 2px; overflow: auto; }
.set-nav button {
  text-align: left; border: 0; background: transparent; color: var(--ink-2);
  padding: 8px 10px; border-radius: 8px; font-size: 13px; cursor: pointer;
}
.set-nav button:hover { background: var(--hover); }
.set-nav button.active { background: var(--active); color: var(--ink); font-weight: 600; }
.set-body { padding: 18px 20px; overflow: auto; }
.set-body h3 { font-size: 15px; margin: 0 0 4px; }
.set-sub { color: var(--muted); font-size: 12.5px; margin: 0 0 16px; }
.set-row { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 16px; align-items: start; padding: 12px 0; border-top: 1px solid var(--line); }
.set-row:first-of-type { border-top: 0; }
.set-label { color: var(--ink); font-size: 13px; }
.set-label small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 3px; }
.seg { display: inline-flex; background: var(--active); border-radius: 8px; padding: 2px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 6px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.seg button.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(16, 20, 30, .08); }
.set-actions { margin-top: 16px; }
.set-note { color: var(--muted); font-size: 12px; margin: 12px 0 0; }
.policy-table select { border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px; font-size: 12.5px; background: var(--surface); color: var(--ink); }
.policy-table td { vertical-align: middle; }
.locked { color: var(--muted); font-size: 11px; margin-top: 3px; }
.card-list { display: grid; gap: 10px; }
.set-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--surface); }
.set-card header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.set-card p { margin: 0; color: var(--ink-3); font-size: 12.5px; }
.mcp-box { margin-top: 16px; border: 1px dashed var(--line); border-radius: 10px; padding: 14px; }
.mcp-box .set-note { margin-top: 6px; }

.set-toolbar { display: flex; align-items: center; gap: 12px; margin: 0 0 10px; }
.set-toolbar label { font-size: 12.5px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.set-toolbar select { border: 1px solid var(--line); border-radius: 7px; padding: 4px 8px; background: var(--surface); color: var(--ink); font-size: 12.5px; }
.set-toolbar .set-note { margin: 0; }

.set-toolbar label { white-space: nowrap; }

/* ===== 通道接入卡片 ===== */
.set-h4 { margin: 18px 0 8px; font-size: 13px; color: var(--ink); }
.set-section { margin-bottom: 8px; }
.chan-block { margin-bottom: 6px; }
.chan-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; background: var(--surface); }
.chan-card > header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.chan-card .chan-base-echo { font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chan-grid { display: grid; grid-template-columns: 190px minmax(0, 1fr) minmax(0, 1fr); gap: 8px 10px; }
.chan-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); }
.chan-field input, .chan-field select { border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; background: var(--surface); color: var(--ink); font-size: 12.5px; min-width: 0; }
.chan-hint { margin: 8px 0 6px; }
.chan-result { font-size: 12px; color: var(--muted); }
.chan-result.ok { color: #1c7c54; }
.chan-result.bad { color: #b3261e; }
.set-warn { border: 1px solid #f0c2c0; background: #fdf2f1; color: #8a2b23; border-radius: 8px; padding: 8px 10px; font-size: 12.5px; margin-bottom: 10px; }

/* ===== 通道卡片里的模型清单 ===== */
.model-block { margin: 10px 0 2px; padding-top: 10px; border-top: 1px dashed var(--line); }
.model-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.model-title { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.model-chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 24px; }
.model-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 3px 6px 3px 10px; font-size: 12px;
}
.model-chip.is-off { opacity: .55; text-decoration: line-through; }
.model-chip .model-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-tag { font-size: 10.5px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 5px; }
.chip-act {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 11.5px; padding: 1px 4px; border-radius: 6px;
}
.chip-act:hover { background: var(--bg); color: var(--ink); }
.chip-del:hover { color: #c0392b; }
.model-add { display: grid; grid-template-columns: 1.1fr 1.2fr 1.2fr auto; gap: 8px; margin-top: 8px; }
.model-add input {
  width: 100%; border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 9px; font-size: 12px; background: var(--surface); color: var(--ink);
}

/* 模型新增行：换行布局，输入框至少 150px，避免 placeholders 被截断 */
.model-add { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.model-add input { flex: 1 1 150px; min-width: 0; }
.model-add .btn { flex: 0 0 auto; }
.model-add-hint { flex-basis: 100%; color: var(--muted); font-size: 11.5px; }

.model-add input { flex: 1 1 120px; }

/* ===== 模型列表与新增弹窗 ===== */
.btn-sm { padding: 3px 10px; font-size: 12px; }
.model-table { min-width: 480px; }
.model-table th, .model-table td { padding: 5px 8px; font-size: 12.5px; }
.model-id-cell { display: flex; align-items: center; gap: 8px; }
.model-id-cell .status { font-size: 10.5px; padding: 0 6px; }
.model-src .mono { font-family: Consolas, "Courier New", monospace; font-size: 11.5px; color: var(--ink-2); word-break: break-all; }
.model-ops { white-space: nowrap; text-align: right; }
.link-btn { border: 0; background: transparent; color: var(--brand); cursor: pointer; font-size: 12.5px; padding: 0 4px; }
.link-btn.danger { color: #c0392b; }
.link-btn:hover { text-decoration: underline; }
.model-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.model-head .btn { margin-left: auto; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 60; background: rgba(16, 18, 24, .38);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal {
  width: min(520px, 100%); max-height: 88vh; overflow: auto;
  background: var(--surface); border-radius: 14px;
  box-shadow: 0 24px 64px rgba(16, 18, 24, .28); border: 1px solid var(--line);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head strong { font-size: 14px; }
.modal-close { border: 0; background: transparent; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; }
.modal-body { padding: 16px 18px; }
.modal-form { display: grid; gap: 14px; }
.modal-field { display: grid; gap: 5px; }
.modal-field > span { font-size: 12.5px; color: var(--ink-2); }
.modal-field .req { color: #c0392b; font-weight: 600; }
.modal-field input {
  width: 100%; border: 1px solid var(--line); border-radius: 9px;
  padding: 8px 10px; font-size: 13px; background: var(--surface); color: var(--ink);
}
.modal-field input:focus { outline: 2px solid rgba(61, 90, 254, .25); border-color: var(--brand); }
.modal-field em { font-style: normal; font-size: 11.5px; color: var(--muted); }
.modal-check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); }
.modal-error { border-radius: 9px; background: #fdecea; color: #a3271b; padding: 8px 10px; font-size: 12.5px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; }
html[data-theme="dark"] .modal-backdrop { background: rgba(0, 0, 0, .55); }
html[data-theme="dark"] .modal-error { background: #3a1e1b; color: #ffb4a8; }

/* 模型表格：定宽 + 截断，避免「跟随通道」竖排 */
.model-table { table-layout: fixed; width: 100%; min-width: 460px; }
.model-table col.c-id { width: 30%; }
.model-table col.c-base { width: 38%; }
.model-table col.c-key { width: 16%; }
.model-table col.c-ops { width: 16%; }
.model-name { font-family: Consolas, "Courier New", monospace; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-table td.model-src { overflow: hidden; }
.ellipsis { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.model-table .muted { font-size: 12px; }

.model-head .btn-sm { border: 1px solid var(--line); background: var(--surface); }
.model-head .btn-sm:hover { border-color: var(--brand); color: var(--brand); }

/* 模型行内测试结果 */
.model-test-badge { display: inline-block; margin-right: 4px; padding: 0 6px; border-radius: 999px; font-size: 11px; line-height: 17px; }
.model-test-badge.is-ok { background: #e8f5ec; color: #1e7a45; }
.model-test-badge.is-bad { background: #fdecea; color: #a3271b; }
html[data-theme="dark"] .model-test-badge.is-ok { background: #14301f; color: #6fd39a; }
html[data-theme="dark"] .model-test-badge.is-bad { background: #3a1e1b; color: #ffb4a8; }
.model-table col.c-ops { width: 22%; }
.model-table col.c-base { width: 34%; }

.model-id-cell { flex-wrap: wrap; }
.model-test-badge { margin-left: 2px; }
.model-table col.c-id { width: 34%; }
.model-table col.c-ops { width: 26%; }
.model-table col.c-base { width: 28%; }
.model-table col.c-key { width: 12%; }

/* 三列布局：模型标识 / 接口地址 / 操作；Key 提示放在标识下方 */
.model-table col.c-id { width: 40%; }
.model-table col.c-base { width: 34%; }
.model-table col.c-ops { width: 26%; }
.model-id-cell { flex-direction: column; align-items: flex-start; gap: 1px; }
.model-id-cell .model-name { max-width: 100%; }
.model-key-hint { font-size: 10.5px; color: var(--muted); font-family: Consolas, "Courier New", monospace; }
.model-id-cell .model-test-badge { margin: 2px 0 0; }

/* ===================== 数据初始化（三步向导） ===================== */
.page-init { display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: 16px; height: 100%; min-height: 0; }
.page-init .card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; overflow: auto; }
.init-side h2 { font-size: 16px; margin-bottom: 6px; }
.init-steps { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 6px; }
.init-steps li { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 8px; align-items: start; padding: 8px; border-radius: 8px; color: var(--muted); }
.init-steps li span { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; font-size: 12px; }
.init-steps li strong { display: block; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.init-steps li em { font-style: normal; font-size: 11.5px; color: var(--muted); }
.init-steps li.is-current { background: color-mix(in srgb, var(--brand) 8%, transparent); }
.init-steps li.is-current span { border-color: var(--brand); color: var(--brand); }
.init-steps li.is-current strong { color: var(--ink); }
.init-steps li.is-done span { background: var(--brand); border-color: var(--brand); color: #fff; }
.init-tip { margin-top: 14px; line-height: 1.6; }
.init-main { min-height: 0; }
.init-steps-inline { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 12px; flex-wrap: wrap; }
.init-steps-inline span { padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); }
.init-steps-inline span.is-current { border-color: var(--brand); color: var(--brand); }
.init-steps-inline span.is-done { background: var(--brand); border-color: var(--brand); color: #fff; }
.init-steps-inline i { font-style: normal; color: var(--line); }
.init-sources { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin: 12px 0 18px; }
.init-source { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 12px; cursor: pointer; display: grid; gap: 4px; }
.init-source strong { font-size: 13.5px; }
.init-source em { font-style: normal; font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.init-source.is-active { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.init-source.is-disabled { opacity: .55; cursor: not-allowed; }
.init-field { margin-bottom: 14px; display: grid; gap: 6px; max-width: 560px; }
.init-field > label { font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.init-field select, .init-field input[type=file] { width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; }
.init-alert { border-radius: 8px; padding: 9px 12px; font-size: 13px; margin: 10px 0; }
.init-alert.is-bad { background: #fdecec; color: #8f1d1d; border: 1px solid #f6c9c9; }
.init-alert.is-ok { background: #eaf6ee; color: #1c6b3a; border: 1px solid #c3e5ce; }
.init-actions { display: flex; gap: 10px; margin-top: 18px; }
.init-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 12px 0 18px; }
.init-summary div { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.init-summary span { display: block; font-size: 11.5px; color: var(--muted); }
.init-summary strong { font-size: 20px; font-weight: 600; }
.init-block h4 { font-size: 13px; margin-bottom: 6px; }
.init-codes { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.init-codes code { font-family: Consolas, monospace; font-size: 12px; padding: 2px 6px; border-radius: 5px; background: var(--bg); border: 1px solid var(--line); }
.init-codes.is-add code { border-color: #bfe3cd; }
.init-codes.is-del code { border-color: #f2c9c9; color: #8f1d1d; }
.init-errors h4 { font-size: 13px; color: #8f1d1d; margin: 12px 0 6px; }
.init-ok { color: #1c6b3a; }
html[data-theme="dark"] .init-alert.is-bad { background: #3a1d1d; color: #ffb4b4; border-color: #5c2a2a; }
html[data-theme="dark"] .init-alert.is-ok { background: #17301f; color: #a9e3bd; border-color: #2b5138; }

/* 初始化：对象切换（科目表 / 期初余额） */
.init-objects { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 4px 0 14px; }
.init-object {
  text-align: left; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface); cursor: pointer;
}
.init-object strong { display: block; font-size: 13px; }
.init-object em { display: block; font-style: normal; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.init-object.is-active { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(61, 90, 254, 0.12); }
