/* ============ 金融交易平台运维知识体系 ============ */
:root {
  --bg: #eef2f7;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #eff6ff;
  --line: #e2e8f0;
  --sidebar-bg: #0f172a;
  --sidebar-ink: #cbd5e1;
  --sidebar-sub: #94a3b8;
  --code-bg: #0f172a;
  --code-ink: #e2e8f0;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.8;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, kbd {
  font-family: "JetBrains Mono", "Fira Code", Consolas, Menlo, "Courier New", monospace;
}

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: 318px;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  overflow-y: auto;
  z-index: 50;
  display: flex;
  flex-direction: column;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-logo {
  width: 42px; height: 42px; flex-shrink: 0;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff; font-size: 20px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
}
.brand-title { font-size: 15px; font-weight: 700; color: #f1f5f9; line-height: 1.4; }
.brand-sub { font-size: 11.5px; color: var(--sidebar-sub); margin-top: 2px; }

.nav-wrap { flex: 1; overflow-y: auto; padding: 10px 10px 20px; }
.nav { list-style: none; margin: 0; padding: 0; }
.nav li { margin: 0; }
.nav-row {
  display: flex; align-items: center; gap: 2px;
  padding: 1px 0;
}
.nav-toggle {
  background: none; border: none; cursor: pointer;
  width: 18px; height: 24px; flex-shrink: 0;
  padding: 0; font-size: 10px; line-height: 1;
  color: #64748b; border-radius: 4px;
  transition: transform .15s, color .15s, background .15s;
}
.nav-toggle:hover { color: #fff; background: rgba(255,255,255,.1); }
.nav-toggle.ph { visibility: hidden; }
.nav-li.open > .nav-row > .nav-toggle { transform: rotate(90deg); }
.nav-li.collapsed > .nav-sub { display: none; }
.nav-link {
  display: block; flex: 1; min-width: 0;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--sidebar-ink);
  font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.nav-link.active { background: var(--accent); color: #fff; font-weight: 600; }
.nav-link .ico { margin-right: 6px; }
.nav-sub { list-style: none; margin: 0; padding: 0 0 3px 14px; }
.lvl2 .nav-link { padding: 6px 10px 6px 4px; font-size: 12.9px; color: var(--sidebar-sub); }
.lvl2 .nav-link:hover { color: #fff; }
.lvl2 .nav-link.active { color: #fff; }
.lvl3li .nav-link { padding: 4px 10px 4px 2px; font-size: 12.3px; color: #64748b; }
.lvl3li .nav-link:hover { color: #fff; background: rgba(255,255,255,.06); }
.lvl3li .nav-link.active { background: rgba(37,99,235,.32); color: #fff; font-weight: 600; }
.sidebar-foot {
  padding: 12px 18px;
  font-size: 11.5px;
  color: #475569;
  border-top: 1px solid rgba(255,255,255,.06);
  line-height: 1.7;
}

/* ---------- 主区域 ---------- */
.main { margin-left: 318px; flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 22px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.hamburger {
  display: none;
  background: none; border: 1px solid var(--line); border-radius: 8px;
  font-size: 17px; padding: 4px 10px; cursor: pointer; color: var(--ink);
}
.search-wrap { position: relative; flex: 1; max-width: 560px; }
#search {
  width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 14px;
  background: #f8fafc;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.15); background: #fff; }
.search-panel {
  display: none;
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15,23,42,.14);
  max-height: 420px; overflow-y: auto; z-index: 60;
}
.search-panel.show { display: block; }
.search-panel .sp-item { display: block; padding: 9px 14px; border-bottom: 1px solid #f1f5f9; }
.search-panel .sp-item:hover { background: var(--accent-soft); text-decoration: none; }
.sp-item .sp-t { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.sp-item .sp-s { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.sp-item .sp-s em { color: var(--accent-dark); font-style: normal; font-weight: 700; }
.search-panel .sp-empty { padding: 14px; color: var(--muted); font-size: 13px; text-align: center; }
.topbar-link { font-size: 13.5px; color: var(--muted); white-space: nowrap; }
.topbar-link:hover { color: var(--accent); }

.content {
  flex: 1;
  max-width: 1040px;
  width: 100%;
  margin: 0 auto;
  padding: 26px 26px 40px;
}
.chapter {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 30px 36px 44px;
  box-shadow: 0 1px 3px rgba(15,23,42,.05);
}
.loading { text-align: center; color: var(--muted); padding: 60px 0; font-size: 14px; }

/* ---------- 标题 ---------- */
.chapter h1 {
  font-size: 27px;
  line-height: 1.35;
  margin: 0 0 8px;
  padding-bottom: 12px;
  border-bottom: 3px solid var(--accent);
  display: inline-block;
}
.chapter .lead { color: var(--muted); font-size: 15px; margin: 14px 0 26px; }
.chapter h2 {
  font-size: 21px;
  margin: 38px 0 14px;
  padding: 10px 14px;
  background: #f8fafc;
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
}
.chapter h3 {
  font-size: 17px;
  margin: 28px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--line);
}
.chapter h4 { font-size: 15px; margin: 20px 0 8px; color: #334155; }
/* 锚点滚动时避免被吸顶导航栏遮挡 */
.chapter h2[id], .chapter h3[id] { scroll-margin-top: 72px; }
.chapter p { margin: 10px 0; }
.chapter ul, .chapter ol { margin: 8px 0 12px; padding-left: 24px; }
.chapter li { margin: 4px 0; }
.chapter strong { color: #1e293b; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; margin: 14px 0; border: 1px solid var(--line); border-radius: 8px; }
.chapter table { width: 100%; border-collapse: collapse; font-size: 13.8px; min-width: 560px; }
.chapter th {
  background: #f1f5f9;
  text-align: left;
  padding: 9px 12px;
  font-weight: 600;
  color: #334155;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.chapter td { padding: 8px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
.chapter tr:last-child td { border-bottom: none; }
.chapter tr:hover td { background: #f8fafc; }

/* ---------- 代码块 ---------- */
.code-wrap { position: relative; margin: 14px 0; }
.code-wrap pre {
  background: var(--code-bg);
  color: var(--code-ink);
  padding: 14px 16px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.65;
  margin: 0;
}
.code-wrap .copy-btn {
  position: absolute; top: 8px; right: 8px;
  background: rgba(255,255,255,.1);
  color: #cbd5e1;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 6px;
  font-size: 12px;
  padding: 3px 10px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s;
}
.code-wrap:hover .copy-btn { opacity: 1; }
.code-wrap .copy-btn:hover { background: rgba(255,255,255,.2); color: #fff; }
.chapter p code, .chapter li code, .chapter td code {
  background: #f1f5f9;
  color: #be185d;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: .9em;
}
.chapter pre code { background: none; color: inherit; padding: 0; font-size: 13px; }
.chapter .code-tag {
  position: absolute; top: -10px; left: 12px;
  background: var(--accent); color: #fff;
  font-size: 11px; padding: 1px 10px; border-radius: 999px;
}
kbd {
  background: #f1f5f9; border: 1px solid #cbd5e1; border-bottom-width: 2px;
  border-radius: 5px; padding: 1px 7px; font-size: 12.5px; color: #334155;
}

/* ---------- 提示框 ---------- */
.note, .warn, .tip, .danger {
  border-left: 4px solid;
  padding: 10px 16px;
  margin: 16px 0;
  border-radius: 0 8px 8px 0;
  font-size: 14px;
}
.note { background: var(--accent-soft); border-color: var(--accent); }
.note::before { content: "ℹ "; font-weight: 700; }
.warn { background: #fef3c7; border-color: #f59e0b; }
.warn::before { content: "⚠ "; font-weight: 700; }
.danger { background: #fef2f2; border-color: #ef4444; }
.danger::before { content: "✖ "; font-weight: 700; }
.tip { background: #ecfdf5; border-color: #10b981; }
.tip::before { content: "✔ "; font-weight: 700; }

/* ---------- 架构图（CSS 组件） ---------- */
.dg {
  margin: 18px 0;
  padding: 18px 16px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow-x: auto;
}
.dg-title { text-align: center; font-weight: 700; color: #334155; margin-bottom: 14px; font-size: 14px; }
.d-row { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.d-col { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.d-box {
  border: 1.5px solid var(--accent);
  background: var(--accent-soft);
  color: #1e3a8a;
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(15,23,42,.06);
}
.d-box.sm { padding: 5px 10px; font-size: 12px; }
.d-box.green { border-color: #10b981; background: #ecfdf5; color: #065f46; }
.d-box.orange { border-color: #f59e0b; background: #fffbeb; color: #92400e; }
.d-box.red { border-color: #ef4444; background: #fef2f2; color: #991b1b; }
.d-box.gray { border-color: #94a3b8; background: #f1f5f9; color: #334155; }
.d-box.purple { border-color: #8b5cf6; background: #f5f3ff; color: #5b21b6; }
.d-box.cyan { border-color: #06b6d4; background: #ecfeff; color: #155e75; }
.d-box.dark { border-color: #334155; background: #334155; color: #f1f5f9; }
.d-arrow { color: #64748b; font-size: 17px; font-weight: 700; flex-shrink: 0; }
.d-vline { width: 2px; height: 22px; background: #94a3b8; }
.d-caption { text-align: center; color: #94a3b8; font-size: 12.5px; margin-top: 10px; }
.dg .frame {
  border: 1.5px dashed #94a3b8; border-radius: 9px;
  padding: 10px 14px; margin: 4px;
}
.dg .frame .frame-t { font-size: 11.5px; color: #64748b; text-align: center; margin-bottom: 8px; font-weight: 600; }

/* ---------- 目录 ---------- */
.toc {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 14px 20px;
  margin: 22px 0 10px;
  font-size: 14px;
}
.toc .toc-t { font-weight: 700; color: #334155; margin-bottom: 8px; font-size: 13.5px; }
.toc ol { margin: 0; padding-left: 22px; }
.toc li { margin: 3px 0; }
.toc a { color: #475569; }
.toc a:hover { color: var(--accent); }

/* ---------- 卡片 ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin: 18px 0; }
.card {
  border: 1px solid var(--line); border-radius: 10px; padding: 16px;
  background: #fff; transition: box-shadow .15s, transform .15s;
  display: block; color: var(--ink);
}
.card:hover { box-shadow: 0 8px 20px rgba(15,23,42,.10); transform: translateY(-2px); text-decoration: none; }
.card .c-ico { font-size: 24px; }
.card .c-t { font-weight: 700; margin: 8px 0 4px; font-size: 15px; }
.card .c-d { font-size: 12.8px; color: var(--muted); line-height: 1.6; }

/* ---------- 徽章 ---------- */
.badge {
  display: inline-block;
  font-size: 11.5px;
  padding: 1px 9px;
  border-radius: 999px;
  margin: 0 4px 4px 0;
  font-weight: 600;
}
.badge.blue { background: var(--accent-soft); color: var(--accent-dark); }
.badge.green { background: #ecfdf5; color: #047857; }
.badge.orange { background: #fffbeb; color: #b45309; }
.badge.red { background: #fef2f2; color: #b91c1c; }
.badge.gray { background: #f1f5f9; color: #475569; }

/* ---------- 标签列表 / 键值 ---------- */
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; margin: 12px 0; font-size: 14px; }
.kv .k { color: var(--muted); font-weight: 600; }
.kv .v { color: var(--ink); }

/* ---------- 底部导航 ---------- */
.pager { display: flex; justify-content: space-between; gap: 14px; margin-top: 30px; }
.pager a {
  border: 1px solid var(--line); border-radius: 9px; padding: 10px 16px;
  background: #fff; color: var(--ink); font-size: 13.5px; max-width: 48%;
}
.pager a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pager .pg-label { display: block; font-size: 11.5px; color: var(--muted); }
.pager .pg-next { text-align: right; margin-left: auto; }

.foot {
  text-align: center;
  color: #94a3b8;
  font-size: 12.5px;
  padding: 20px;
  border-top: 1px solid var(--line);
  background: #fff;
}

/* ---------- 返回顶部 ---------- */
.back-top {
  position: fixed; right: 26px; bottom: 26px;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--accent);
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(15,23,42,.16);
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
  z-index: 45;
}
.back-top.show { opacity: 1; pointer-events: auto; }
.back-top:hover { background: var(--accent); color: #fff; }

/* ---------- 响应式 ---------- */
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 0 100vmax rgba(15,23,42,.5); }
  .main { margin-left: 0; }
  .hamburger { display: block; }
  .chapter { padding: 22px 18px 32px; }
  .content { padding: 16px 12px 30px; }
}

@media print {
  .sidebar, .topbar, .back-top, .foot, .pager { display: none !important; }
  .main { margin-left: 0; }
  .chapter { box-shadow: none; border: none; }
}
