/* 机构级报告组件：前端、管理端、打印与导出共用 */
.md {
  --md-ink: #162033;
  --md-text: #344054;
  --md-muted: #697386;
  --md-faint: #98a2b3;
  --md-paper: #ffffff;
  --md-subtle: #f6f8fb;
  --md-rule: #d9dee8;
  --md-rule-strong: #aeb8c8;
  --md-accent: #315bd6;
  --md-accent-soft: #edf2ff;
  --md-up: #c93f47;
  --md-up-soft: #fff1f1;
  --md-down: #16805c;
  --md-down-soft: #edf8f3;
  --md-warning: #b7791f;
  box-sizing: border-box;
  width: 100%;
  color: var(--md-text);
  background: var(--md-paper);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
  font-size: 15px;
  line-height: 1.85;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  color-scheme: light;
}
.md *, .md *::before, .md *::after { box-sizing: border-box; }
.md-finance { --md-accent: #294f9e; --md-accent-soft: #edf2fa; }
.md-legal { --md-accent: #245f9e; --md-accent-soft: #edf4fa; }
.md-surface-chat { padding: 3px 4px 12px; }
.md-surface-modal, .md-surface-admin { padding: 2px 4px 18px; }
.md-surface-long-image { font-size: 18px; line-height: 1.85; }
.md-surface-print { font-size: 13px; line-height: 1.72; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 {
  color: var(--md-ink); font-weight: 800; line-height: 1.45; letter-spacing: 0;
}
.md h1 { margin: 34px 0 16px; font-size: 26px; }
.md h2 {
  margin: 34px 0 16px; padding: 0 0 9px 14px;
  border-left: 4px solid var(--md-accent); border-bottom: 1px solid var(--md-rule);
  font-size: 21px;
}
.md h3 { margin: 26px 0 12px; font-size: 17px; }
.md h4 { margin: 22px 0 10px; font-size: 15px; }
.md p { margin: 10px 0; }
.md ul, .md ol { margin: 10px 0; padding-left: 25px; }
.md li { margin: 5px 0; }
.md strong { color: var(--md-ink); font-weight: 750; }
.md em { font-style: normal; }
.md a { color: var(--md-accent); text-decoration: none; border-bottom: 1px solid #aabce7; }
.md a:hover { border-bottom-color: var(--md-accent); }
.md hr { border: 0; border-top: 1px solid var(--md-rule); margin: 26px 0; }
.md img { display: block; max-width: 100%; height: auto; margin: 16px auto; border-radius: 5px; }
.md code {
  padding: 2px 6px; border-radius: 3px; background: #eef1f5; color: #26344f;
  font: 12.5px/1.5 Consolas, "Courier New", monospace;
}
.md pre.md-code {
  margin: 16px 0; padding: 15px 17px; overflow-x: auto;
  border: 1px solid var(--md-rule); border-radius: 6px; background: #f7f8fa;
}
.md pre.md-code code { padding: 0; background: none; color: inherit; white-space: pre; }
.md blockquote {
  margin: 16px 0; padding: 13px 17px; border-left: 4px solid var(--md-accent);
  border-radius: 0 5px 5px 0; background: var(--md-accent-soft); color: #526079;
}
.md-cite { font-size: .72em; line-height: 0; vertical-align: super; }
.md-cite a { padding: 0 1px; border: 0; font-weight: 700; }
.md-link { color: var(--md-accent); word-break: break-all; }

/* 结论、法条与风险区域 */
.md-conclusion {
  margin: 20px 0; padding: 17px 19px; border: 1px solid #b9c7e7;
  border-left: 5px solid var(--md-accent); border-radius: 5px;
  background: #f3f6fc; color: #223252; font-weight: 650; line-height: 1.75;
}
.md-quote-law {
  border-left-color: #b7791f !important; background: #fff9eb !important; color: #554521 !important;
}
.md-section { margin: 22px 0; padding: 5px 18px 16px; border-radius: 5px; }
.md-section-risk { border: 1px solid #e5c98a; border-left: 5px solid #b7791f; background: #fffaf0; }
.md-section-risk .md-risk-title { color: #815711; border-left-color: #b7791f; }
.md-section-disclaimer { border: 1px solid var(--md-rule); background: #f7f8fa; }
.md-section-disclaimer .md-disclaimer-title { color: var(--md-muted); border-left-color: var(--md-faint); font-size: 14px; }
.md-section-disclaimer p, .md-section-disclaimer li { color: var(--md-muted); font-size: 12.5px; }

/* 语义表格 */
.md-table-shell {
  position: relative; width: 100%; margin: 18px 0 24px; overflow-x: auto;
  border: 1px solid var(--md-rule); border-radius: 5px; background: #fff;
  scrollbar-color: #b8c1cf transparent; scrollbar-width: thin;
}
.md-table-shell::after {
  content: ""; position: sticky; right: 0; float: right; width: 14px; height: 1px;
  box-shadow: -10px 0 14px rgba(32,45,69,.08); pointer-events: none;
}
.md table.md-table {
  width: 100%; min-width: 620px; margin: 0; border: 0; border-collapse: separate;
  border-spacing: 0; table-layout: auto; color: #29364b; font-size: 13px; line-height: 1.55;
  font-variant-numeric: tabular-nums;
}
.md table.md-table th, .md table.md-table td {
  padding: 10px 12px; border: 0; border-right: 1px solid #d6dce6;
  border-bottom: 1px solid #dfe4ec; text-align: left; vertical-align: middle;
  white-space: nowrap;
}
.md table.md-table th:last-child, .md table.md-table td:last-child { border-right: 0; }
.md table.md-table tbody tr:last-child td { border-bottom: 0; }
.md table.md-table th {
  background: #263b63; color: #fff; font-size: 12px; font-weight: 750;
}
.md table.md-table tbody tr:nth-child(even) td { background: #f8f9fb; }
.md table.md-table tbody tr:hover td { background: #eef3fa; }
.md table.md-table .md-key-column {
  position: sticky; left: 0; z-index: 1; min-width: 132px; font-weight: 700;
  box-shadow: 1px 0 0 #d6dce6;
}
.md table.md-table th.md-key-column { z-index: 2; background: #203352; }
.md table.md-table tr:nth-child(odd) td.md-key-column { background: #fff; }
.md table.md-table tr:nth-child(even) td.md-key-column { background: #f8f9fb; }
.md table.md-table tr:hover td.md-key-column { background: #eef3fa; }
.md table.md-table .md-col-numeric { text-align: right; font-family: Bahnschrift, "Segoe UI", sans-serif; }
.md table.md-table .md-col-forecast { background: #edf3fc; }
.md table.md-table th.md-col-forecast { background: #315081; }
.md table.md-table tbody tr:nth-child(even) td.md-col-forecast { background: #e8f0fb; }
.md table.md-table .md-value-up { color: var(--md-up); font-weight: 750; }
.md table.md-table .md-value-down { color: var(--md-down); font-weight: 750; }
.md-table-shell-evidence { border-left: 3px solid #4b77a8; }
.md-table-shell-evidence-ledger { border-left: 3px solid #246b58; }
.md-table-shell-red-blue { border-left: 3px solid #8f3f49; }
.md-table-shell-forensic-screen { border-left: 3px solid #9a4d3f; }
.md-table-shell-macro-sensitivity { border-left: 3px solid #356c85; }
.md-table-shell-inventory-cycle { border-left: 3px solid #6b7650; }
.md-table-shell-moat-evidence { border-left: 3px solid #3f735f; }
.md-table-shell-capital-allocation { border-left: 3px solid #7a6250; }
.md-table-shell-alt-data-crosscheck { border-left: 3px solid #497088; }
.md-table-shell-expectation-layers { border-left: 3px solid #765378; }
.md-table-shell-market-microstructure { border-left: 3px solid #4d6078; }
.md-table-shell-investment-boundary { border-left: 3px solid #4d6078; }
.md-table-shell-earnings-power-bridge { border-left: 3px solid #356c85; }
.md-table-shell-asset-liquidation { border-left: 3px solid #3f735f; }
.md-table-shell-margin-safety-source { border-left: 3px solid #7a6250; }
.md-table-shell-senior-protection { border-left: 3px solid #66527a; }
.md-table-shell-price-value-gap { border-left: 3px solid #294f9e; }
.md-table-shell-legal { border-left: 3px solid #b7791f; }
.md-table-shell-valuation { border-top: 3px solid #294f9e; }
.md-table-evidence th { background: #345f89 !important; }
.md-table-evidence-ledger th { background: #285f55 !important; }
.md-table-red-blue th { background: #623b4b !important; }
.md-table-forensic-screen th { background: #713f3a !important; }
.md-table-macro-sensitivity th { background: #315d70 !important; }
.md-table-inventory-cycle th { background: #566241 !important; }
.md-table-moat-evidence th { background: #356452 !important; }
.md-table-capital-allocation th { background: #665344 !important; }
.md-table-alt-data-crosscheck th { background: #3f6277 !important; }
.md-table-expectation-layers th { background: #634966 !important; }
.md-table-market-microstructure th { background: #40536b !important; }
.md-table-investment-boundary th { background: #40536b !important; }
.md-table-earnings-power-bridge th { background: #315d70 !important; }
.md-table-asset-liquidation th { background: #356452 !important; }
.md-table-margin-safety-source th { background: #665344 !important; }
.md-table-senior-protection th { background: #59486a !important; }
.md-table-price-value-gap th { background: #213c6c !important; }
.md-table-legal th { background: #3f5068 !important; }
.md-table-valuation th { background: #213c6c !important; }

/* 数据图与 K 线基础 */
.md-data-panel, .md-chart {
  margin: 22px 0 14px; overflow: hidden; border: 1px solid var(--md-rule);
  border-radius: 5px; background: #fff;
}
.md-data-panel-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 18px;
  min-height: 58px; padding: 13px 16px 11px; border-bottom: 1px solid var(--md-rule);
  background: #f8f9fb;
}
.md-data-panel-head > div:first-child { display: flex; align-items: baseline; gap: 10px; flex: 0 0 auto; }
.md-data-panel-head strong { color: var(--md-ink); font-size: 14px; font-weight: 800; }
.md-data-panel-head span, .md-data-panel-note { color: var(--md-muted); font-size: 11.5px; }
.md-data-legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px 14px; }
.md-data-legend-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.md-data-legend-item i {
  display: inline-block; width: 9px; height: 9px; border-radius: 2px;
  background: var(--legend-color); box-shadow: inset 0 0 0 1px rgba(20, 32, 51, .08);
}
.md-data-panel-plot { padding: 8px 12px 0; background: #fff; }
.md-data-panel-note {
  padding: 8px 16px 10px; border-top: 1px solid #edf0f4; text-align: right;
}
.md .md-value-up { color: var(--md-up); }
.md .md-value-down { color: var(--md-down); }
.md-chart-svg, .md-kline-svg {
  display: block; width: 100%; height: auto; max-height: 390px;
  margin: 0; padding: 0; border: 0; border-radius: 0; background: #fff;
}
.md-chart-grid, .md-kline-grid { stroke: #dfe4ec; stroke-width: 1; opacity: .85; }
.md-chart-axis, .md-kline-axis { stroke: #98a2b3; stroke-width: 1; }
.md-chart-line { stroke-linecap: round; stroke-linejoin: round; }
.md-chart-ytick, .md-chart-xtick, .md-chart-legend, .md-chart-val,
.md-kline-ytick, .md-kline-xtick {
  fill: #697386; font-family: "Segoe UI", "Microsoft YaHei", sans-serif; font-size: 10.5px;
}
.md-chart-ytick, .md-kline-ytick { text-anchor: end; }
.md-chart-xtick, .md-kline-xtick { text-anchor: middle; }
.md-chart-bar { transition: opacity .15s; }
.md-chart-bar:hover { opacity: .78; }
.md-waterfall-up { fill: var(--md-up); }
.md-waterfall-down { fill: var(--md-down); }
.md-waterfall-connector { stroke: #8b96a8; stroke-width: 1; stroke-dasharray: 3 3; }
.md-dupont-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px;
  padding: 1px; background: var(--md-rule);
}
.md-dupont-item { min-width: 0; padding: 14px 16px; background: #fff; }
.md-dupont-item > strong { display: block; margin-bottom: 10px; color: var(--md-ink); font-size: 13px; }
.md-dupont-item > div {
  display: grid; grid-template-columns: auto 1fr auto auto 1fr; align-items: center; gap: 6px;
  color: var(--md-muted); font-size: 10.5px;
}
.md-dupont-item b { color: var(--md-ink); font: 750 15px Bahnschrift, "Segoe UI", sans-serif; }
.md-dupont-item i { color: #8b96a8; font-style: normal; }
.md-dupont-item small { display: block; margin-top: 9px; font: 750 12px Bahnschrift, "Segoe UI", sans-serif; }
.md-scenario-grid { padding: 9px 16px 12px; }
.md-scenario-row {
  display: grid; grid-template-columns: minmax(100px, .8fr) minmax(180px, 2fr) minmax(108px, .8fr);
  align-items: center; gap: 14px; min-height: 48px; border-bottom: 1px solid #edf0f4;
}
.md-scenario-row:last-child { border-bottom: 0; }
.md-scenario-row > div:first-child { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.md-scenario-row strong, .md-scenario-row b { color: var(--md-ink); font-size: 12px; }
.md-scenario-row span { color: var(--md-muted); font-size: 11px; }
.md-scenario-row > b { text-align: right; font-family: Bahnschrift, "Segoe UI", sans-serif; }
.md-scenario-track { position: relative; height: 10px; background: #edf1f6; }
.md-scenario-range { position: absolute; top: 0; bottom: 0; background: #315e9d; }
.md-risk-reward-grid, .md-liquidity-grid { padding: 9px 16px 12px; }
.md-risk-reward-row, .md-liquidity-row {
  display: grid; grid-template-columns: minmax(104px, .8fr) minmax(210px, 2fr) minmax(88px, .7fr);
  align-items: center; gap: 14px; min-height: 48px; border-bottom: 1px solid #edf0f4;
}
.md-risk-reward-row:last-child, .md-liquidity-row:last-child { border-bottom: 0; }
.md-risk-reward-row > div:first-child, .md-liquidity-row > div:first-child {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
}
.md-risk-reward-row strong, .md-risk-reward-row b,
.md-liquidity-row strong, .md-liquidity-row b { color: var(--md-ink); font-size: 12px; }
.md-risk-reward-row span, .md-liquidity-row span { color: var(--md-muted); font-size: 11px; }
.md-risk-reward-row > b, .md-liquidity-row > b {
  text-align: right; font-family: Bahnschrift, "Segoe UI", sans-serif;
}
.md-risk-reward-track, .md-liquidity-track { position: relative; height: 12px; background: #edf1f6; }
.md-risk-reward-range { position: absolute; top: 1px; bottom: 1px; background: #315e9d; }
.md-risk-reward-current, .md-risk-reward-floor {
  position: absolute; top: -4px; bottom: -4px; z-index: 2; width: 2px; background: #b3261e;
}
.md-risk-reward-floor { background: #27715f; }
.md-risk-reward-legend { display: flex; gap: 14px; color: var(--md-muted); font-size: 11px; }
.md-risk-reward-legend span { display: inline-flex; align-items: center; gap: 6px; }
.md-risk-reward-legend i { position: static; display: inline-block; width: 2px; height: 14px; }
.md-liquidity-track i { display: block; height: 100%; background: #315e9d; }
.md-liquidity-track i.is-critical { background: #a84a51; }
.md-heatmap-grid {
  display: grid; grid-template-columns: repeat(var(--heatmap-columns), minmax(86px, 1fr));
  gap: 1px; padding: 1px; overflow-x: auto; background: var(--md-rule);
}
.md-heatmap-grid > span, .md-heatmap-grid > strong {
  display: flex; align-items: center; justify-content: center; min-height: 44px;
  padding: 7px 9px; background: #fff; color: var(--md-ink); font-size: 11.5px; text-align: center;
}
.md-heatmap-grid > strong, .md-heatmap-corner { background: #f4f6f9 !important; font-weight: 750; }
.md-heatmap-cell { font: 750 12px Bahnschrift, "Segoe UI", sans-serif !important; }
.md-heatmap-level-0 { background: #eef5f3 !important; }
.md-heatmap-level-1 { background: #d7e9e3 !important; }
.md-heatmap-level-2 { background: #b8d6cc !important; }
.md-heatmap-level-3 { background: #7fb1a3 !important; color: #102e28 !important; }
.md-heatmap-level-4 { background: #3e796d !important; color: #fff !important; }
.md-kline-head {
  padding: 14px 16px 13px; border-bottom: 1px solid var(--md-rule); background: #f8f9fb;
}
.md-kline-head > div:first-child {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 13px;
}
.md-kline-head strong { color: var(--md-ink); font-size: 14px; font-weight: 800; }
.md-kline-head > div:first-child span { color: var(--md-muted); font-size: 11.5px; }
.md-kline-summary { display: grid; grid-template-columns: repeat(4, minmax(90px, 1fr)); gap: 1px; background: var(--md-rule); }
.md-kline-summary > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 8px 11px; background: #fff; }
.md-kline-summary small { color: var(--md-muted); font-size: 10.5px; }
.md-kline-summary b { color: var(--md-ink); font: 750 14px/1.35 Bahnschrift, "Segoe UI", sans-serif; font-variant-numeric: tabular-nums; }
.md .md-kline-up { color: var(--md-up); }
.md .md-kline-down { color: var(--md-down); }
.md-kline-latest-line { stroke-width: 1; stroke-dasharray: 4 3; opacity: .78; }
.md-kline-latest-line.md-kline-up { stroke: var(--md-up); }
.md-kline-latest-line.md-kline-down { stroke: var(--md-down); }
.md-kline-latest-label, .md-kline-volume-label {
  fill: #697386; font: 10px "Segoe UI", "Microsoft YaHei", sans-serif;
}
.md-kline-latest-label.md-kline-up { fill: var(--md-up); }
.md-kline-latest-label.md-kline-down { fill: var(--md-down); }
.md-kline-volume-label { text-anchor: end; }

/* 页面容器只负责布局，报告排版始终由本文件接管。 */
.chat-bubble.assistant:has(.stream-report-body .md) {
  width: min(100%, 1040px); max-width: min(1040px, 94%); padding: 0;
  overflow: hidden; border-color: #d7deea; background: #fff;
  box-shadow: 0 10px 32px rgba(28, 43, 70, .08);
}
.chat-bubble.assistant .stream-report-body { padding: 18px 24px 22px; background: #fff; }
.chat-bubble.assistant .md h1, .chat-bubble.assistant .md h2,
.chat-bubble.assistant .md h3, .chat-bubble.assistant .md h4 { color: var(--md-ink); }
.chat-bubble.assistant .md h1 { margin: 34px 0 16px; font-size: 26px; }
.chat-bubble.assistant .md h2 { margin: 34px 0 16px; font-size: 21px; }
.chat-bubble.assistant .md h3 { margin: 26px 0 12px; font-size: 17px; }
.chat-bubble.assistant .md p { margin: 10px 0; }
.chat-bubble.assistant .md blockquote {
  margin: 16px 0; padding: 13px 17px; border-left-color: var(--md-accent);
  background: var(--md-accent-soft); color: #526079;
}
.research-result-body, .report-view-body, .message-markdown { background: #fff; }
.long-image-body > .md { width: 100%; }

@media (max-width: 640px) {
  .md { font-size: 14px; line-height: 1.78; }
  .md h1 { font-size: 22px; }
  .md h2 { margin-top: 28px; font-size: 18px; }
  .md h3 { font-size: 16px; }
  .md-table-shell { margin-left: 0; margin-right: 0; }
  .md table.md-table { min-width: 660px; font-size: 12.5px; }
  .md table.md-table th, .md table.md-table td { padding: 9px 10px; }
  .md-data-panel-head { display: block; }
  .md-data-panel-head > div:first-child { margin-bottom: 8px; }
  .md-data-legend { justify-content: flex-start; }
  .md-data-panel-plot { padding: 4px 4px 0; overflow-x: auto; }
  .md-chart-svg, .md-kline-svg { min-width: 560px; }
  .md-dupont-grid { grid-template-columns: 1fr; }
  .md-scenario-row { grid-template-columns: 96px minmax(180px, 1fr) 100px; }
  .md-risk-reward-row, .md-liquidity-row { grid-template-columns: 96px minmax(190px, 1fr) 88px; }
  .md-scenario-grid, .md-risk-reward-grid, .md-liquidity-grid, .md-heatmap-grid { overflow-x: auto; }
  .md-kline-head > div:first-child { align-items: flex-start; flex-direction: column; gap: 3px; }
  .md-kline-summary { grid-template-columns: repeat(2, minmax(100px, 1fr)); }
  .chat-bubble.assistant:has(.stream-report-body .md) { max-width: calc(100% - 8px); }
  .chat-bubble.assistant .stream-report-body { padding: 12px 12px 18px; }
}

@media print {
  .md { color: #222 !important; background: #fff !important; }
  .md-table-shell { overflow: visible !important; border-color: #bbb !important; }
  .md-table-shell::after { display: none !important; }
  .md table.md-table { min-width: 0 !important; font-size: 10.5px !important; }
  .md table.md-table .md-key-column { position: static !important; box-shadow: none !important; }
  .md table.md-table th { background: #263b63 !important; color: #fff !important; print-color-adjust: exact; }
  .md table.md-table .md-col-forecast { background: #edf3fc !important; print-color-adjust: exact; }
  .md-data-panel, .md-chart { break-inside: avoid; }
  .md a { color: #222 !important; border: 0 !important; }
}
