:root {
  --ink: #183344;
  --muted: #5b7285;
  --line: #dbe4ea;
  --bg: #f2f5f7;
  --card: #ffffff;
  --accent: #0b6aa2;
  --warn: #9a5b00;
  --bad: #a3232f;
  --ok: #1c6b45;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.65 -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.side {
  background: #13303f;
  color: #dbe7ee;
  padding: 26px 20px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.brand h1 { margin: 0; font-size: 20px; letter-spacing: .5px; color: #fff; }
.brand .sub { margin: 6px 0 0; font-size: 12px; color: #9fb8c6; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  color: #cfe0ea; text-decoration: none; padding: 9px 12px; border-radius: 8px; font-size: 14px;
}
.nav a:hover { background: #1c4053; color: #fff; }
.nav a.active { background: #f2f5f7; color: #13303f; font-weight: 600; }

.side-foot { margin-top: auto; font-size: 12px; color: #93aebe; display: flex; flex-direction: column; gap: 6px; }
.side-foot p { margin: 0; }
.my-link { display:block; padding:10px 12px; border-radius:8px; color:#cfe0ea; text-decoration:none; font-size:14px; }
.my-link:hover { background:#1c4053; color:#fff; }
.my-link.active { background:#f2f5f7; color:#13303f; font-weight:600; }
.side { position:sticky; top:0; height:100vh; overflow-y:auto; }
.nav > a, .nav details a { display:block; }
.side-foot .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; word-break: break-all; }

.main { padding: 26px 30px 60px; max-width: 1180px; min-width: 0; width: 100%; }

.notice {
  border: 1px solid #f0d9a8; background: #fdf6e6; color: #6b4c0a;
  padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 22px;
}

h2 { font-size: 24px; margin: 0 0 4px; }
.lede { color: var(--muted); margin: 0 0 20px; font-size: 13px; }

.cards { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 18px; min-width: 150px;
}
.card b { display: block; font-size: 26px; line-height: 1.2; }
.card span { font-size: 12px; color: var(--muted); }

.table-wrap { overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
table.data th, table.data td { padding: 11px 12px; text-align: left; border-bottom: 1px solid #edf1f4; vertical-align: top; }
table.data th { background: #eaf0f4; font-weight: 600; white-space: nowrap; position: sticky; top: 0; }
table.data tr:last-child td { border-bottom: none; }
table.data td.mono, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
table.data td .empty { color: var(--muted); }

a { color: var(--accent); }
a.plain { text-decoration: none; }

.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px;
  border: 1px solid var(--line); background: #f7fafb; color: var(--muted); white-space: nowrap;
}
.badge.ok { border-color: #b9dcc9; background: #eaf6ef; color: var(--ok); }
.badge.warn { border-color: #f0d9a8; background: #fdf6e6; color: var(--warn); }
.badge.bad { border-color: #e8bfc3; background: #fbecee; color: var(--bad); }

.alert { border-radius: var(--radius); padding: 12px 14px; margin: 0 0 18px; font-size: 13px; }
.alert.bad { background: #fbecee; border: 1px solid #e8bfc3; color: var(--bad); }
.alert.ok { background: #eaf6ef; border: 1px solid #b9dcc9; color: var(--ok); }
.alert.warn { background: #fdf6e6; border: 1px solid #f0d9a8; color: var(--warn); }
.alert.info { background: #eef5fa; border: 1px solid #cfe1ee; color: #24506b; }
.alert ul { margin: 6px 0 0; padding-left: 20px; }

.section { margin-top: 26px; }
.section h3 { font-size: 16px; margin: 0 0 10px; }
.budget-module { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.budget-module select, .budget-module input { min-width: 0; max-width: 100%; box-sizing: border-box; }
.budget-module button { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 16px; font-size: 13px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

.toolbar { display: flex; gap: 10px; align-items: center; margin: 0 0 14px; }
.toolbar input { flex: 1; max-width: 420px; padding: 9px 12px; border: 1px solid #c3d2db; border-radius: 8px; font: inherit; background: #fff; }

.loading, .empty { color: var(--muted); }
.error { color: var(--bad); }

.form {
  display: grid;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 760px;
}
.form label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.form select {
  padding: 10px 12px;
  border: 1px solid #c3d2db;
  border-radius: 8px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

.btn {
  padding: 9px 18px;
  border-radius: 8px;
  border: 1px solid #c3d2db;
  background: #fff;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #085a8a; color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.form .toolbar { margin: 4px 0 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 5px 9px; border-radius: 6px; border: 1px solid #c3d2db;
  background: #f7fafb; color: var(--accent); cursor: pointer;
}
.chip:hover { border-color: var(--accent); background: #eef5fa; }

.drawer {
  position: fixed; top: 0; right: 0; width: min(470px, 94vw); height: 100vh;
  background: #fff; border-left: 1px solid var(--line);
  box-shadow: -12px 0 32px rgba(19, 48, 63, .18);
  padding: 20px 22px 40px; overflow: auto; z-index: 50;
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.drawer-head h3 { margin: 0; font-size: 17px; }
.excerpt {
  background: #f6f9fb; border-left: 3px solid #c3d2db; margin: 14px 0;
  padding: 10px 12px; white-space: pre-wrap; font-size: 13px; color: #2f4a5b;
}
body.drawer-open { overflow: hidden; }

.field {
  padding: 10px 12px;
  border: 1px solid #c3d2db;
  border-radius: 8px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

.template, .answer {
  width: 100%;
  font: 13px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 12px;
  border: 1px solid #c3d2db;
  border-radius: 8px;
  background: #fbfdfe;
  color: var(--ink);
  resize: vertical;
}
.answer { font-family: inherit; }
h4 { font-size: 14px; margin: 20px 0 8px; }
.note { border: 1px solid var(--line); border-radius: 8px; background: #fff; margin: 8px 0; padding: 10px 14px; }
.note summary { cursor: pointer; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.note-text {
  white-space: pre-wrap; font-size: 12px; line-height: 1.65; background: #f6f9fb;
  padding: 10px 12px; border-radius: 6px; max-height: 300px; overflow: auto;
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; min-width: 0; align-items: center; gap: 16px; padding: 14px 18px; }
  .side-foot { display:flex; width:100%; margin-top:0; }
  .side-foot > p, .side-foot > details { display:none; }
  .side { position:static; height:auto; overflow:visible; }
  .nav { flex-direction: row; max-width: 100%; overflow-x: auto; }
  .nav a { flex-shrink: 0; }
  .main { padding: 18px; }
  .kv { grid-template-columns: 1fr; }
}

.chat-head h1 { margin: 0 0 8px; font-size: 22px; }
.chat-log {
  display: flex; flex-direction: column; gap: 12px;
  margin: 18px 0; max-height: 54vh; overflow: auto; padding: 4px 2px;
}
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.bubble {
  max-width: 76%; padding: 12px 14px; border-radius: 10px;
  line-height: 1.7; font-size: 14px; white-space: pre-wrap;
}
.msg.user .bubble { background: #183344; color: #fff; }
.msg.assistant .bubble { background: #fff; border: 1px solid var(--line); }
.cites { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; }
.cite { margin: 6px 0; font-size: 13px; }
.cite summary { cursor: pointer; }
.cite blockquote {
  margin: 6px 0 0; padding: 8px 10px; background: #f6f9fb;
  border-left: 3px solid #c3d2db; font-size: 12px;
}
.chat-input { display: flex; flex-direction: column; gap: 8px; }
.work-context { margin: 16px 0; padding: 14px; background: #f6f9fb; border-radius: 10px; }
.work-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr); gap: 20px; }
.work-layout > * { min-width: 0; }
.work-context .toolbar, .work-layout .toolbar { flex-wrap: wrap; }
.work-context .field, .work-context input[type="file"] { min-width: 0; max-width: 100%; }
.work-context .field { flex: 1 1 180px; }
.work-context p, .work-context summary { overflow-wrap: anywhere; }
.work-layout .bubble { max-width: 94%; overflow-wrap: anywhere; }
.work-results { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 10px; }
.work-results h2 { font-size: 18px; margin-top: 0; }
.work-card { padding: 12px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.work-card .btn { display: block; margin-top: 12px; }
.work-steps { margin-top: 10px; white-space: normal; }
.work-steps pre { max-height: 260px; overflow: auto; white-space: pre-wrap; font-size: 12px; }
.answer-content { white-space: normal; }
.answer-content p { margin: 0 0 10px; }
.answer-content ul, .answer-content ol { padding-left: 20px; margin: 8px 0; }
.answer-content pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.answer-content code { overflow-wrap: anywhere; background: #f2f5f7; padding: 1px 3px; }
.answer-table { overflow-x: auto; margin: 10px 0; }
.answer-table table { border-collapse: collapse; width: 100%; font-size: 13px; }
.answer-table th, .answer-table td { text-align: left; border: 1px solid var(--line); padding: 7px; }
.answer-table th, .answer-table td.answer-number { white-space: nowrap; overflow-wrap: normal; }
.answer-table td.answer-number { font-variant-numeric: tabular-nums; }
@media (max-width: 1000px) { .work-layout { grid-template-columns: 1fr; } }

.docs { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; background: #fff; margin: 12px 0; }
.docs summary { cursor: pointer; }

.doc-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0; font-size: 13px; }
.btn.small { padding: 4px 10px; font-size: 12px; }

.conv-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.conv-bar .field { min-width: 0; max-width: 100%; flex: 1 1 180px; }
.conv-bar select { max-width: 460px; }

.viewer-body { margin: 0; font: 14px/1.6 system-ui, sans-serif; color: #183344; background: #eef3f6; }
.viewer-bar { display: flex; gap: 12px; align-items: center; padding: 10px 16px; background: #fff; border-bottom: 1px solid #d8e2e8; position: sticky; top: 0; z-index: 5; }
.viewer-main { display: flex; gap: 16px; padding: 16px; align-items: flex-start; }
.viewer-wrap { position: relative; flex: 1; max-width: 900px; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.viewer-wrap img { display: block; width: 100%; height: auto; }
.hit-box { position: absolute; border: 1px solid rgba(200,150,0,.85); background: rgba(255,214,64,.35); cursor: pointer; }
.hit-box.selected { background: rgba(255,140,0,.55); border-color: #d2691e; }
.viewer-panel { width: 280px; background: #fff; border: 1px solid #d8e2e8; border-radius: 8px; padding: 12px; position: sticky; top: 70px; }

.viewer-bar .btn.small { margin-left: 4px; }
.viewer-bar .lede { margin: 0 6px; }

.viewer-wrap { overflow: auto; max-height: calc(100vh - 90px); }
.viewer-wrap img { width: 100%; }

/* 财务人员的对话工作区：左任务，右对话；细节按需展开。 */
body.finance-chat { background:#fff; }
.finance-chat .shell { grid-template-columns:232px minmax(0,1fr); height:100vh; }
.finance-chat .side { background:#f6f7f9; color:#31404a; padding:24px 16px 14px; gap:18px; height:100vh; overflow-y:auto; }
.finance-chat .brand h1 { color:#193a36; font-size:20px; }
.finance-chat .brand .sub { color:#78837f; }
.finance-chat .nav a { color:#54615d; display:block; }
.finance-chat .nav a.active { color:#18705c; background:#e5f0eb; }
.finance-chat .nav a:hover { background:#eaf0ed; color:#193a36; }
.finance-chat .nav summary { padding:8px 12px; font-size:13px; cursor:pointer; }
.finance-chat .side-foot { color:#79857e; font-size:11px; }
.finance-chat .my-link { color:#54615d; }
.finance-chat .my-link:hover { background:#eaf0ed; color:#193a36; }
.finance-chat .my-link.active { color:#18705c; background:#e5f0eb; }
.finance-chat .main { max-width:none; padding:22px 36px 0; height:100vh; display:flex; flex-direction:column; }
.finance-chat .main > .notice { display:none; }
.finance-chat #view { min-height:0; height:100%; display:flex; flex-direction:column; max-width:1020px; width:100%; margin:auto; }
.finance-chat-head { display:flex; justify-content:space-between; align-items:center; gap:12px; }
.finance-chat-head h1 { font-size:21px; line-height:1.4; margin:2px 0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.finance-intro { margin:5px 0 14px; color:#738078; font-size:13px; }
.finance-shortcuts { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:10px; }
.finance-shortcuts .btn { border-radius:18px; background:#fff; color:#356457; border-color:#dbe9e2; padding:7px 13px; }
.finance-chat .finance-materials { background:#fafbf9; border:1px solid #e8ece8; margin:0 0 8px; padding:9px 13px; font-size:13px; flex-shrink:0; max-height:45vh; overflow:auto; }
.finance-materials summary { cursor:pointer; color:#4b6257; }
.finance-materials .upload-pair { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.finance-materials h3 { font-size:14px; margin:10px 0 2px; }
.finance-materials .btn { margin:6px; }
.finance-materials label { display:block; margin:8px 0; }
.finance-chat .knowledge-docs { margin:0 0 8px; padding:0 12px; font-size:12px; color:#788078; max-height:35vh; overflow:auto; flex-shrink:0; }
.finance-conversation { flex:1; min-height:80px; overflow:auto; padding:6px 0 12px; }
.finance-chat .chat-log { max-height:none; min-height:0; overflow:visible; border:0; background:transparent; padding:12px 0; }
.finance-chat .chat-log .bubble { max-width:92%; border-radius:16px; }
.finance-chat .msg.user .bubble { background:#edf5ef; color:#233e32; }
.finance-chat .work-results { border:0; padding:0; margin:8px 0; }
.finance-chat .work-results[hidden] { display:none; }
.finance-chat .work-results h2 { font-size:15px; color:#657769; }
.finance-chat .work-card { border:1px solid #dce9df; background:#fbfdfb; }
.finance-composer { padding:12px 0 14px; background:#fff; flex-shrink:0; }
.finance-composer textarea { min-height:76px; max-height:160px; border:1px solid #dbe4dd; border-radius:15px; padding:14px; background:#fafcfa; font-size:15px; }
.finance-composer .toolbar { display:flex; justify-content:flex-end; align-items:center; margin:0; }
.finance-composer .toolbar > .lede { margin-right:auto; font-size:11px; }
.finance-chat #chat-history-sidebar { display:flex; flex-direction:column; min-height:0; flex:1; gap:8px; }
#chat-history-sidebar h2 { font-size:12px; font-weight:500; margin:16px 0 0; color:#7c8980; }
#chat-history-sidebar > .btn { width:100%; border-radius:9px; background:#e8f1eb; border-color:#d5e6d9; color:#255c45; }
#chat-history-sidebar .field { width:100%; min-width:0; font-size:12px; background:transparent; }
.task-history { overflow:auto; flex:1; min-height:60px; }
.history-item { display:block; border:0; background:none; color:#5a665e; text-align:left; padding:9px 10px; width:100%; cursor:pointer; font:inherit; font-size:12px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; border-radius:7px; }
.history-item:hover,.history-item.active { background:#e8eee9; color:#215039; }
.conversation-tools { font-size:12px; flex-shrink:0; max-width:240px; }
.conversation-tools[open] { position:absolute; right:30px; top:24px; background:#fff; padding:12px; border:1px solid #ddd; z-index:5; box-shadow:0 5px 16px #0001; }
@media(max-width:760px) {
 .finance-chat .shell { grid-template-columns:150px minmax(0,1fr); }
 .finance-chat .side { padding:16px 8px; }.finance-chat .brand h1 { font-size:16px; }
 .finance-chat .main { padding:16px 12px 0; }.finance-chat-head h1 { font-size:17px; }
 .finance-materials .upload-pair { grid-template-columns:1fr; }.finance-shortcuts { gap:5px; }
 .finance-shortcuts .btn { font-size:11px; padding:5px 8px; }.finance-composer textarea { min-height:65px; }
}

@media(max-width:860px) { .finance-chat .side { flex-direction:column; flex-wrap:nowrap; align-items:stretch; } .finance-chat .nav { flex-direction:column; overflow:visible; } }
@media(max-width:600px) {
 .finance-chat .shell { grid-template-columns:minmax(0,1fr); height:auto; }
 .finance-chat .side { position:static; height:auto; padding:14px 18px; }
 .finance-chat .nav { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); }
 .finance-chat #chat-history-sidebar { max-height:140px; overflow:auto; }
 .finance-chat .main { height:85vh; min-height:560px; padding:14px 18px 0; }
 .finance-chat .side-foot { width:100%; margin-top:0; }
 .form input, .form select, .form textarea { min-width:0; max-width:100%; }
}

.completed-result { padding:10px 14px; border:1px solid #dce9df; border-radius:12px; background:#f8fbf8; margin:8px 0; font-size:13px; }
.completed-result .toolbar { display:flex; gap:18px; align-items:center; margin:5px 0; flex-wrap:wrap; }
.completed-result > details { font-size:11px; color:#6d7c70; }
.completed-result > details > summary { cursor:pointer; }
.finance-chat .work-results > .lede { font-size:11px; margin:4px 0; }
/* 父级统一等待，不改子控件原有的岗位限制和勾选状态。 */
.chat-actions { border: 0; margin: 0; padding: 0; min-inline-size: 0; }
