/* ============================================================
   金融工具手册 · 共享样式
   ============================================================ */
:root {
  --primary: #1a3a5c;
  --primary-dark: #0f2540;
  --accent: #c9a961;
  --accent-dark: #a68843;
  --text: #1a1a1a;
  --muted: #666;
  --border: #d4d4d4;
  --bg-soft: #f7f5f0;
  --bg-code: #f4f4f4;
  --bg-highlight: #fff8e1;
  --bg-danger: #fdf2f2;
  --bg-success: #f0f9f0;
  --sidebar-bg: #1a3a5c;
  --sidebar-hover: #2c5282;
  --sidebar-active: #c9a961;
  --sidebar-text: #e6e6e6;
  --sidebar-muted: #9ab3cc;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  color: var(--text);
  line-height: 1.75;
  font-size: 15px;
  background: #fff;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   子页面内容区(iframe 内嵌 或 独立打开)
   ============================================================ */
.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 40px 64px;
}
.page-header {
  border-bottom: 3px double var(--primary);
  padding-bottom: 16px;
  margin-bottom: 28px;
}
.page-header h1 {
  font-size: 28px;
  color: var(--primary);
  margin: 0 0 8px;
  letter-spacing: 0.5px;
}
.page-header .subtitle {
  font-size: 14px;
  color: var(--muted);
  letter-spacing: 0.3px;
}
h2 {
  color: var(--primary);
  font-size: 22px;
  font-weight: 600;
  padding: 10px 0 6px;
  border-bottom: 2px solid var(--primary);
  margin-top: 40px;
}
h3 {
  color: var(--primary);
  font-size: 18px;
  font-weight: 600;
  padding-left: 12px;
  border-left: 4px solid var(--accent);
  margin-top: 28px;
}
h4 {
  color: var(--primary);
  font-size: 16px;
  margin-top: 20px;
}
p, li { font-size: 15px; }
blockquote {
  background: var(--bg-highlight);
  border-left: 4px solid var(--accent);
  padding: 14px 20px;
  margin: 20px 0;
  color: var(--primary);
  font-weight: 500;
  font-size: 15.5px;
  border-radius: 0 4px 4px 0;
}
code {
  background: var(--bg-code);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  font-size: 13px;
  color: #c7254e;
}
pre {
  background: var(--bg-code);
  padding: 16px 20px;
  border-radius: 6px;
  overflow-x: auto;
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  font-size: 13px;
  line-height: 1.6;
  border-left: 3px solid var(--primary);
}
pre code { background: none; padding: 0; color: inherit; }

table {
  border-collapse: collapse;
  width: 100%;
  margin: 18px 0;
  font-size: 14px;
  background: #fff;
}
thead { background: var(--primary); color: #fff; }
th, td {
  border: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
}
th { font-weight: 600; letter-spacing: 0.3px; }
tbody tr:nth-child(even) { background: var(--bg-soft); }
tbody tr:hover { background: var(--bg-highlight); }
strong { color: var(--primary); }
hr { border: none; border-top: 1px solid var(--border); margin: 32px 0; }
ul, ol { padding-left: 24px; }
li { margin: 5px 0; }

.badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 12px;
  margin-right: 6px;
  font-weight: 500;
}
.highlight-box {
  background: var(--bg-highlight);
  border: 1px solid var(--accent);
  padding: 16px 20px;
  margin: 20px 0;
  border-radius: 6px;
}
.danger-box {
  background: var(--bg-danger);
  border-left: 4px solid #c0392b;
  padding: 14px 18px;
  margin: 20px 0;
  border-radius: 0 4px 4px 0;
}
.success-box {
  background: var(--bg-success);
  border-left: 4px solid #27ae60;
  padding: 14px 18px;
  margin: 20px 0;
  border-radius: 0 4px 4px 0;
}

/* ============================================================
   单证流转图 · SVG 通用样式
   ============================================================ */
.flowchart {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  margin: 24px 0;
  overflow-x: auto;
}
.flowchart-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 12px;
  text-align: center;
}
.flowchart-legend {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.flowchart-legend span {
  display: inline-block;
  margin: 0 8px;
}
.flow-actor-buyer   { fill: #d6e4f0; stroke: #2c5282; }
.flow-actor-seller  { fill: #d4edda; stroke: #27ae60; }
.flow-actor-bank    { fill: #fdf1d1; stroke: #c9a961; }
.flow-actor-third   { fill: #e8daf0; stroke: #6f42c1; }
.flow-arrow-money   { stroke: #c0392b; stroke-width: 2; fill: none; marker-end: url(#arrow-money); }
.flow-arrow-doc     { stroke: #2c5282; stroke-width: 1.5; stroke-dasharray: 6 3; fill: none; marker-end: url(#arrow-doc); }
.flow-arrow-guar    { stroke: #6f42c1; stroke-width: 1.5; stroke-dasharray: 2 2; fill: none; marker-end: url(#arrow-guar); }
.flow-node-label    { font-size: 13px; font-weight: 600; fill: var(--text); text-anchor: middle; }
.flow-node-sublabel { font-size: 10.5px; fill: var(--muted); text-anchor: middle; }
.flow-step          { font-size: 11.5px; fill: var(--primary); font-weight: 600; }
.flow-step-desc     { font-size: 10.5px; fill: var(--muted); }

/* ============================================================
   Mermaid 图容器
   ============================================================ */
.mermaid {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin: 20px 0;
  overflow-x: auto;
  text-align: center;
}
.mermaid-caption {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin-top: -8px;
  margin-bottom: 24px;
  font-style: italic;
}

/* ============================================================
   子页面顶部/底部导航
   ============================================================ */
.subpage-nav {
  display: flex;
  justify-content: space-between;
  margin: 40px 0 0;
  padding: 16px 0;
  border-top: 1px solid var(--border);
  font-size: 14px;
}
.subpage-nav a {
  color: var(--primary);
  text-decoration: none;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  transition: all 0.2s;
}
.subpage-nav a:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.subpage-nav .prev::before { content: "← "; }
.subpage-nav .next::after  { content: " →"; }

/* ============================================================
   子页面内嵌 Sidebar(独立打开时显示 · iframe 中隐藏)
   ============================================================ */
body.has-sidebar { margin: 0; padding: 0; }
body.has-sidebar .page {
  margin-left: 218px;
  max-width: 1080px;
}
.doc-sidebar {
  position: fixed;
  top: 0; left: 0;
  width: 218px;
  height: 100vh;
  background: var(--primary);
  color: #e6e6e6;
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--primary-dark);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
.doc-sidebar::-webkit-scrollbar { width: 5px; }
.doc-sidebar::-webkit-scrollbar-thumb { background: #2c5282; border-radius: 3px; }
.doc-sidebar .ds-brand {
  padding: 10px 12px 9px;
  background: var(--primary-dark);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.doc-sidebar .ds-back {
  display: inline-block;
  padding: 2px 8px;
  background: var(--accent);
  color: #fff !important;
  font-size: 10.5px;
  font-weight: 600;
  border-radius: 3px;
  text-decoration: none;
  margin-bottom: 6px;
  transition: background 0.15s;
  letter-spacing: 0.2px;
}
.doc-sidebar .ds-back:hover { background: #b7952f; }
.doc-sidebar .ds-back-alt {
  background: transparent;
  color: var(--accent) !important;
  border: 1px solid rgba(201,169,97,0.5);
  margin-left: 3px;
}
.doc-sidebar .ds-back-alt:hover {
  background: rgba(201,169,97,0.15);
  border-color: var(--accent);
}
.doc-sidebar .ds-title {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  line-height: 1.25;
  margin: 0 0 1px;
  letter-spacing: 0.2px;
}
.doc-sidebar .ds-subtitle {
  font-size: 10px;
  color: #9ab3cc;
  line-height: 1.35;
}
.doc-sidebar .ds-badge {
  display: inline-block;
  margin-top: 4px;
  padding: 1px 6px;
  background: var(--accent);
  color: #fff;
  font-size: 9.5px;
  border-radius: 3px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.doc-sidebar .ds-group {
  padding: 6px 0 5px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.doc-sidebar .ds-group-title {
  padding: 7px 12px 4px;
  font-size: 9.5px;
  color: #9ab3cc;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 700;
}
.doc-sidebar a.ds-item {
  display: flex;
  align-items: flex-start;
  padding: 5px 12px 5px 14px;
  color: #e6e6e6;
  text-decoration: none;
  font-size: 11.5px;
  border-left: 3px solid transparent;
  line-height: 1.45;
  transition: all 0.15s;
}
/* Sidebar 右边拖拽把手 */
.doc-sidebar-resizer {
  position: fixed;
  top: 0;
  width: 4px;
  height: 100vh;
  cursor: ew-resize;
  background: transparent;
  z-index: 110;
  transition: background 0.15s;
}
.doc-sidebar-resizer::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  left: -3px; right: -3px;
}
.doc-sidebar-resizer::before {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 2px; height: 32px;
  transform: translate(-50%, -50%);
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  transition: background 0.15s;
}
.doc-sidebar-resizer:hover { background: rgba(201,169,97,0.35); }
.doc-sidebar-resizer:hover::before { background: var(--accent); }
.doc-sidebar-resizer.dragging { background: var(--accent); }
.doc-sidebar-resizer.dragging::before { background: #fff; }
body.ds-resizing { cursor: ew-resize; user-select: none; }
.doc-sidebar a.ds-item:hover {
  background: #2c5282;
  color: #fff;
}
.doc-sidebar a.ds-item.active {
  background: rgba(201,169,97,0.15);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}
.doc-sidebar a.ds-item .ds-num {
  display: inline-block;
  min-width: 20px;
  color: #9ab3cc;
  font-family: "SF Mono", monospace;
  font-size: 10px;
  flex-shrink: 0;
}
.doc-sidebar a.ds-item.active .ds-num { color: var(--accent); }

/* ─── 重点阅读高亮 · 克制编辑器风格 ─── */
.doc-sidebar a.ds-item.ds-hot {
  color: #f4f4f4;
  font-weight: 500;
  position: relative;
}
.doc-sidebar a.ds-item.ds-hot::after {
  content: '';
  position: absolute;
  right: 10px;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  margin-top: -2px;
  background: rgba(201,169,97,0.55);
  transition: transform 0.15s, background 0.15s;
}
.doc-sidebar a.ds-item.ds-hot:hover {
  background: rgba(255,255,255,0.04);
  color: #fff;
}
.doc-sidebar a.ds-item.ds-hot:hover::after {
  background: var(--accent);
  transform: scale(1.3);
}
/* SCB 蓝调点位 */
.doc-sidebar a.ds-item.ds-hot-scb::after { background: rgba(77,157,250,0.75); }
.doc-sidebar a.ds-item.ds-hot-scb:hover::after { background: #4d9dfa; }
/* BOC 红调点位 */
.doc-sidebar a.ds-item.ds-hot-boc::after { background: rgba(230,95,116,0.75); }
.doc-sidebar a.ds-item.ds-hot-boc:hover::after { background: #e65f74; }
/* 战略财务模型 · 金色主推 */
.doc-sidebar a.ds-item.ds-hot-gold {
  color: #ffffff;
  font-weight: 600;
  background: linear-gradient(90deg, rgba(201,169,97,0.10) 0%, transparent 70%);
  border-left-color: var(--accent);
}
.doc-sidebar a.ds-item.ds-hot-gold .ds-num {
  color: var(--accent);
  font-weight: 700;
}
.doc-sidebar a.ds-item.ds-hot-gold::after {
  background: var(--accent);
  width: 5px; height: 5px; margin-top: -2.5px;
}
.doc-sidebar a.ds-item.ds-hot-gold:hover {
  background: linear-gradient(90deg, rgba(201,169,97,0.18) 0%, rgba(201,169,97,0.02) 80%);
  color: #fff;
}
/* active 覆盖 */
.doc-sidebar a.ds-item.ds-hot.active {
  background: rgba(201,169,97,0.10);
  color: var(--accent);
  border-left-color: var(--accent);
}
.doc-sidebar a.ds-item.ds-hot.active::after { background: var(--accent); }
.doc-sidebar a.ds-item.ds-hot-gold.active {
  background: linear-gradient(90deg, rgba(201,169,97,0.22) 0%, rgba(201,169,97,0.05) 80%);
  color: var(--accent);
}
/* 分组标题的重点组也 tint accent */
.doc-sidebar .ds-group.ds-group-hot > .ds-group-title {
  color: var(--accent);
  letter-spacing: 0.9px;
}
.doc-sidebar .ds-footer {
  margin-top: auto;
  padding: 10px 14px;
  background: var(--primary-dark);
  font-size: 10px;
  color: #9ab3cc;
  text-align: center;
  line-height: 1.5;
}
/* 移动端汉堡按钮 */
.doc-sidebar-toggle {
  display: none;
  position: fixed;
  top: 8px; left: 8px;
  width: 32px; height: 32px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  cursor: pointer;
  z-index: 200;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
@media (max-width: 900px) {
  body.has-sidebar .page { margin-left: 0; padding: 44px 20px 32px; }
  .doc-sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s;
  }
  .doc-sidebar.open { transform: translateX(0); }
  .doc-sidebar-toggle { display: block; }
}

/* ============================================================
   页内目录 · 右侧 TOC(toc.js 注入)
   ============================================================ */
.page-toc {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 210px;
  max-height: calc(100vh - 40px);
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 10px 12px 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  z-index: 900;
  display: flex;
  flex-direction: column;
  font-size: 12.5px;
}
.page-toc .toc-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 1px;
  padding: 0 4px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 6px;
}
.page-toc .toc-title::before {
  content: '☰';
  font-size: 12px;
  color: var(--accent);
}
.page-toc .toc-list {
  overflow-y: auto;
  padding-right: 4px;
  scroll-behavior: smooth;
}
.page-toc .toc-list::-webkit-scrollbar { width: 4px; }
.page-toc .toc-list::-webkit-scrollbar-thumb { background: #d0d7de; border-radius: 2px; }
.page-toc .toc-list::-webkit-scrollbar-thumb:hover { background: #a0a8b0; }
.page-toc .toc-item {
  display: block;
  padding: 5px 8px 5px 10px;
  color: #555;
  text-decoration: none;
  border-left: 2px solid transparent;
  line-height: 1.4;
  transition: all 0.15s;
  font-size: 12px;
  border-radius: 0 3px 3px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.page-toc .toc-item.toc-h3 {
  padding-left: 22px;
  font-size: 11px;
  color: #7c828a;
}
.page-toc .toc-item:hover {
  background: var(--bg-soft);
  color: var(--primary);
  border-left-color: rgba(201,169,97,0.4);
}
.page-toc .toc-item.active {
  color: var(--primary);
  background: rgba(201,169,97,0.13);
  border-left-color: var(--accent);
  font-weight: 700;
}
.page-toc .toc-item.toc-h3.active {
  background: rgba(201,169,97,0.08);
  font-weight: 600;
}

/* 有左侧 sidebar 时,TOC 保持右侧 */
body.has-sidebar .page-toc { right: 16px; }

/* 圆钮切换(窄屏 & 移动端) */
.page-toc-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 42px;
  height: 42px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  z-index: 901;
  display: none;
  box-shadow: 0 3px 10px rgba(0,0,0,0.22);
  transition: transform 0.15s, background 0.15s;
}
.page-toc-toggle:hover {
  background: var(--accent);
  transform: translateY(-2px);
}

/* 窄屏:折叠为按钮 · 展开覆盖 */
@media (max-width: 1400px) {
  .page-toc {
    transform: translateX(calc(100% + 30px));
    transition: transform 0.2s;
    right: 16px;
    top: 16px;
  }
  .page-toc.open { transform: translateX(0); }
  .page-toc-toggle { display: block; }
}

@media (max-width: 900px) {
  .page-toc { width: 260px; }
  .page-toc-toggle { bottom: 70px; }
}

/* ============================================================
   Print 样式
   ============================================================ */
@media print {
  .page { padding: 16px; margin-left: 0 !important; max-width: 100% !important; }
  .subpage-nav { display: none; }
  .back-to-index { display: none !important; }
  .doc-sidebar { display: none !important; }
  .doc-sidebar-toggle { display: none !important; }
  .page-toc, .page-toc-toggle { display: none !important; }
  body.has-sidebar { padding: 0 !important; }
  table { font-size: 11px; page-break-inside: avoid; }
  h2 { page-break-after: avoid; }
  thead { display: table-header-group; }
}
