/* TF Fiscal API 文档中心 —— 由 comandos/docs_build.py 生成的页面共用 */

:root {
  --bg: #f6f6f4;
  --paper: #ffffff;
  --ink: #1b2130;
  --muted: #5f6b7a;
  --line: #e2e5ea;
  --line-strong: #cfd4dc;
  --accent: #0e7c6b;
  --accent-ink: #0b5f52;
  --accent-soft: #e4f3ef;
  --code-bg: #0f1a2b;
  --code-ink: #e6ebf2;
  --code-dim: #8a97ab;
  --code-inline: #eef0f3;
  --get: #1d4ed8;
  --post: #15803d;
  --put: #b45309;
  --delete: #b91c1c;
  --warn-bg: #fff7e6;
  --warn-line: #e6a417;
  --info-bg: #eaf3ff;
  --info-line: #3b82f6;
  --shadow: 0 1px 2px rgba(20, 28, 40, .06), 0 8px 24px rgba(20, 28, 40, .06);
  --logo-filter: none;

  /* 旧片段里的内联样式引用这些名字，指到新令牌上就能跟随主题 */
  --surface-light: var(--paper);
  --border-light: var(--line);
  --text-light: var(--ink);
  --text-muted-light: var(--muted);
  --code-bg-light: var(--code-inline);
  --primary: var(--accent);
  --secondary: #6d5bd0;
  --tertiary: #15803d;
  --quaternary: #b45309;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116;
    --paper: #151a21;
    --ink: #e6e9ee;
    --muted: #98a2b3;
    --line: #262d37;
    --line-strong: #364050;
    --accent: #3fcbb0;
    --accent-ink: #8fe3d2;
    --accent-soft: #12302b;
    --code-bg: #0a0e14;
    --code-ink: #e6ebf2;
    --code-dim: #7d8a9d;
    --code-inline: #1c232d;
    --get: #7aa2ff;
    --post: #5fd08a;
    --put: #f0b35c;
    --delete: #ff8a8a;
    --warn-bg: #2a2313;
    --warn-line: #d9a133;
    --info-bg: #13233a;
    --info-line: #6ea3ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
    --logo-filter: brightness(0) invert(1);
    --secondary: #a595ff;
    --tertiary: #5fd08a;
    --quaternary: #f0b35c;
  }
}

:root[data-theme="dark"] {
  --bg: #0e1116;
  --paper: #151a21;
  --ink: #e6e9ee;
  --muted: #98a2b3;
  --line: #262d37;
  --line-strong: #364050;
  --accent: #3fcbb0;
  --accent-ink: #8fe3d2;
  --accent-soft: #12302b;
  --code-bg: #0a0e14;
  --code-ink: #e6ebf2;
  --code-dim: #7d8a9d;
  --code-inline: #1c232d;
  --get: #7aa2ff;
  --post: #5fd08a;
  --put: #f0b35c;
  --delete: #ff8a8a;
  --warn-bg: #2a2313;
  --warn-line: #d9a133;
  --info-bg: #13233a;
  --info-line: #6ea3ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  --logo-filter: brightness(0) invert(1);
  --secondary: #a595ff;
  --tertiary: #5fd08a;
  --quaternary: #f0b35c;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 76px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.65 -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans", "Microsoft YaHei",
        "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, kbd, .path, .mm {
  font-family: ui-monospace, "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- 顶栏 ---------- */
.top {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 14px;
  height: 56px; padding: 0 20px;
  background: var(--paper); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img { height: 24px; width: auto; display: block; filter: var(--logo-filter); }
.topnav { display: flex; gap: 2px; margin-left: 4px; padding-left: 14px; border-left: 1px solid var(--line-strong); }
.topnav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); font-size: 14px; white-space: nowrap; }
.topnav a:hover { color: var(--ink); background: var(--bg); text-decoration: none; }
.topnav a.on { color: var(--accent-ink); background: var(--accent-soft); font-weight: 600; }
.kb-lead { max-width: 760px; margin: -8px 0 24px; color: var(--muted); }
.kb-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.kb-card { padding: 18px 20px; gap: 6px; }
.kb-card b { font-size: 16px; }
.kb-card p { margin: 0; font-size: 13px; line-height: 1.5; color: var(--muted); }
.burger { display: none; width: 36px; height: 36px; border: 0; background: none; position: relative; }
.burger span, .burger span::before, .burger span::after {
  content: ""; position: absolute; left: 9px; width: 18px; height: 2px; background: var(--ink); border-radius: 2px;
}
.burger span { top: 17px; }
.burger span::before { top: -6px; left: 0; }
.burger span::after { top: 6px; left: 0; }
.search-btn {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  width: min(420px, 40vw); height: 36px; padding: 0 10px 0 12px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--muted);
  cursor: text; text-align: left;
}
.search-btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.search-btn span { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13.5px; }
.search-btn kbd { font-size: 11px; padding: 1px 6px; border: 1px solid var(--line-strong); border-radius: 5px; color: var(--muted); }
.lang {
  height: 36px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--paper); color: var(--ink); font-size: 13.5px;
}
.theme { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); cursor: pointer; }
.theme svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; }

/* ---------- 框架 ---------- */
.frame { display: grid; grid-template-columns: 280px minmax(0, 1fr); }
.side {
  position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto;
  padding: 18px 12px 40px; border-right: 1px solid var(--line); background: var(--paper);
  font-size: 13.5px;
}
.side ul { list-style: none; margin: 0; padding: 0; }
.grp { margin-bottom: 18px; }
.grp-t {
  padding: 4px 10px 6px; font-size: 11px; font-weight: 650; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}
.grp > ul > li > a, .cat-l {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 6px; color: var(--ink);
}
.grp > ul > li > a:hover, .cat-l:hover { background: var(--bg); text-decoration: none; }
.grp > ul > li.on > a { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.cat-l a { flex: 1; color: inherit; }
.cat-l a:hover { text-decoration: none; }
.cat.open > .cat-l { color: var(--accent-ink); font-weight: 600; }
.cat-l .n { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chev { width: 20px; height: 20px; border: 0; background: none; cursor: pointer; position: relative; }
.chev::before {
  content: ""; position: absolute; left: 7px; top: 6px; width: 6px; height: 6px;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg); transition: transform .15s;
}
.cat.open .chev::before { transform: rotate(45deg); }
.eps { display: none; margin: 2px 0 6px 10px; padding-left: 8px; border-left: 1px solid var(--line); }
.cat.open .eps { display: block; }
.eps a {
  display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 5px;
  color: var(--muted); font-size: 13px; line-height: 1.35;
}
.eps a:hover { color: var(--ink); background: var(--bg); text-decoration: none; }
.eps a.active { color: var(--accent-ink); background: var(--accent-soft); }
.eps a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mm { flex: none; width: 34px; font-size: 10px; font-weight: 700; letter-spacing: .02em; text-align: center; font-style: normal; }
.m-get { color: var(--get); }
.m-post { color: var(--post); }
.m-put { color: var(--put); }
.m-delete { color: var(--delete); }
.m-note { color: var(--muted); background: var(--code-inline); border-radius: 4px; padding: 1px 0; font-size: 9.5px; letter-spacing: .02em; }
.eps li.note a span { color: var(--muted); }
.ep.ep-note { grid-template-columns: 1fr; }
.ep-note .ep-main { max-width: 860px; }
.ep-note .ep-head .eyebrow { margin-bottom: 2px; color: var(--muted); }
.ep-note .ep-title { font-size: 21px; }
.side-mask { display: none; }

.doc { padding: 36px 44px 60px; min-width: 0; }
.doc-body { max-width: 1320px; }
.foot { margin-top: 60px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }

/* ---------- 页头 ---------- */
.page-head { max-width: 760px; margin-bottom: 8px; }
.eyebrow { margin: 0 0 6px; font-size: 12px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-ink); }
h1 { margin: 0; font-size: 32px; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; text-wrap: balance; }
.lede { margin: 10px 0 0; font-size: 16px; color: var(--muted); }

/* ---------- 首页 ---------- */
.hero { max-width: 900px; padding-bottom: 28px; }
.hero h1 { font-size: 40px; }
.hero .lede { max-width: 720px; }
.block { padding: 36px 0 8px; border-top: 1px solid var(--line); margin-top: 28px; }
.block > h2 { margin: 0 0 18px; font-size: 22px; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 46%); gap: 32px; align-items: start; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.cat-card {
  display: flex; flex-direction: column; gap: 4px; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink);
  transition: border-color .15s, transform .15s;
}
.cat-card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.cat-card b { font-weight: 600; }
.cat-card span { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.api-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 22px; }
.api-card { padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.card-title { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.card-content { display: flex; align-items: center; gap: 8px; }
.card-code { font-size: 13px; word-break: break-all; }

/* ---------- 接口区块 ---------- */
.ep {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 44%); gap: 0 44px;
  padding: 44px 0 36px; border-top: 1px solid var(--line); margin-top: 16px;
}
.ep:first-of-type { border-top: 0; margin-top: 0; padding-top: 28px; }
.ep-main { min-width: 0; }
.ep-side { position: sticky; top: 76px; align-self: start; min-width: 0; }
.ep-head { margin-bottom: 18px; }
.ep-sig { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.method {
  padding: 2px 9px; border-radius: 6px; font-size: 12px; font-weight: 700; letter-spacing: .04em;
  color: #fff; background: var(--post);
}
.method.m-get { background: var(--get); }
.method.m-put { background: var(--put); }
.method.m-delete { background: var(--delete); }
.path { font-size: 15px; font-weight: 500; word-break: break-all; }
.ep-title { margin: 0; font-size: 24px; line-height: 1.25; font-weight: 700; letter-spacing: -.01em; }
.ep-title a { color: inherit; }
.ep-title a:hover { text-decoration: none; }
.ep-title a::after { content: " #"; color: var(--line-strong); font-weight: 400; opacity: 0; transition: opacity .15s; }
.ep-title:hover a::after { opacity: 1; }
.subhead { padding: 36px 0 8px; margin-top: 16px; border-top: 2px solid var(--line-strong); }
.subhead h2 { margin: 0 0 8px; font-size: 22px; }

.cp {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--muted); cursor: pointer;
}
.cp:hover { color: var(--ink); border-color: var(--line-strong); }
.cp svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linejoin: round; }
.cp.ok { color: var(--post); border-color: var(--post); }

/* 右侧代码面板 */
.panel { position: relative; border-radius: 10px; background: var(--code-bg); color: var(--code-ink); overflow: hidden; box-shadow: var(--shadow); }
.panel-tabs { display: flex; gap: 2px; padding: 6px 8px 0; overflow-x: auto; border-bottom: 1px solid rgba(255, 255, 255, .08); scrollbar-width: none; }
.panel-tabs button {
  flex: none; padding: 8px 10px; border: 0; border-bottom: 2px solid transparent; background: none;
  color: var(--code-dim); font-size: 12.5px; white-space: nowrap; cursor: pointer;
}
.panel-tabs button[aria-selected="true"] { color: #fff; border-color: var(--accent); }
.pane { position: relative; }
.pane .cp { position: absolute; right: 10px; top: 10px; background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .12); color: var(--code-dim); }
.pane .cp:hover { color: #fff; }
.pane .cp.ok { color: #6ee7b7; border-color: #6ee7b7; }
.panel pre {
  margin: 0; padding: 16px 44px 16px 16px; overflow: auto; max-height: min(72vh, 720px);
  font-size: 12.5px; line-height: 1.55; tab-size: 2; color: var(--code-ink);
}
.panel pre .k { color: #9ad1ff; }
.panel pre .s { color: #c9f0c7; }
.panel pre .n { color: #ffcf8a; }
.panel pre .c { color: var(--code-dim); font-style: italic; }
.panel pre .b { color: #d7b8ff; }

/* ---------- 正文排版（沿用片段里的类名） ---------- */
.prose { font-size: 14.5px; }
.prose > :first-child { margin-top: 0; }
.prose p { margin: 10px 0; }
.prose h2 { font-size: 22px; margin: 34px 0 12px; }
.prose h3 { font-size: 17px; margin: 28px 0 10px; }
.prose h4, .param-title {
  margin: 26px 0 10px; font-size: 12px; font-weight: 650; letter-spacing: .07em;
  text-transform: uppercase; color: var(--muted);
}
.prose h4 code, .param-title code { text-transform: none; letter-spacing: 0; font-size: 12.5px; }
.prose code { padding: 1px 5px; border-radius: 4px; background: var(--code-inline); font-size: .92em; }
.prose pre code { padding: 0; background: none; }
.prose ul, .prose ol { padding-left: 22px; margin: 8px 0; }
.prose li { margin: 3px 0; }
.info-text { color: var(--muted); }
.code-block { margin: 12px 0; border-radius: 8px; background: var(--code-inline); border: 1px solid var(--line); overflow: hidden; }
.code-block pre { margin: 0; padding: 12px 14px; overflow: auto; font-size: 12.5px; line-height: 1.55; }
.full-width-code { grid-column: 1 / -1; }
.endpoint-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }

.prose table, .param-table, .field-table {
  width: 100%; border-collapse: collapse; margin: 8px 0 16px; font-size: 13.5px;
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
}
.prose th, .prose td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; }
.prose thead th { background: var(--bg); font-size: 12px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.prose tbody tr:last-child td { border-bottom: 0; }
.prose td:first-child { white-space: nowrap; }
.param-field { font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
.param-type { display: inline-block; padding: 0 6px; border-radius: 4px; background: var(--code-inline); color: var(--muted); font-size: 11.5px; }

.info-note, .warning-note {
  position: relative; margin: 14px 0; padding: 12px 14px 12px 16px; border-radius: 8px; font-size: 13.5px;
  border-left: 3px solid var(--info-line); background: var(--info-bg);
}
.warning-note { border-left-color: var(--warn-line); background: var(--warn-bg); }
.info-note p:first-child, .warning-note p:first-child { margin-top: 0; }
.info-note p:last-child, .warning-note p:last-child { margin-bottom: 0; }

.method-badge {
  display: inline-block; padding: 1px 7px; border-radius: 5px; font-size: 11px; font-weight: 700;
  letter-spacing: .04em; color: #fff; background: var(--post); vertical-align: middle;
}
.method-badge.method-get { background: var(--get); }
.method-badge.method-put { background: var(--put); }
.method-badge.method-delete { background: var(--delete); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--code-inline); }
.badge-primary { background: var(--accent-soft); color: var(--accent-ink); }
.badge-success { background: #dcfce7; color: #166534; }
.api-description { color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; margin-right: 14px; font-size: 13px; color: var(--muted); }

/* ---------- CFOP 知识库 ---------- */
.cfop-table td.cc { white-space: nowrap; vertical-align: top; }
.cfop-table td:first-child { white-space: normal; min-width: 180px; }
.cf-item { display: inline-flex; align-items: baseline; gap: 4px; margin: 2px 8px 2px 0; }
.cf { padding: 1px 7px; border-radius: 5px; background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; font-size: 12.5px; cursor: help; }
.cf-item small { color: var(--muted); font-size: 11.5px; }
.cf-none { color: var(--line-strong); }
.cfop-desc { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; font-weight: 400; }
.cfop-rules li { margin: 6px 0; }
.table-wrap { overflow-x: auto; }

/* ---------- 引导页 ---------- */
.guide-grid { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 40px; align-items: start; margin-top: 20px; }
.guide .prose { max-width: 860px; }
.toc { position: sticky; top: 76px; font-size: 13px; }
.toc-t { font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc li a { display: block; padding: 4px 12px; color: var(--muted); border-left: 2px solid transparent; margin-left: -1px; }
.toc li.l3 a { padding-left: 24px; }
.toc li a:hover, .toc li a.active { color: var(--accent-ink); border-left-color: var(--accent); text-decoration: none; }

/* ---------- 搜索面板 ---------- */
.search { position: fixed; inset: 0; z-index: 100; background: rgba(10, 14, 20, .45); padding: 10vh 16px 0; }
.search-box { max-width: 640px; margin: 0 auto; border-radius: 12px; background: var(--paper); box-shadow: var(--shadow); overflow: hidden; }
.search-box input {
  width: 100%; height: 52px; padding: 0 18px; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; color: var(--ink); font: inherit; font-size: 16px; outline: none;
}
.search-box ul { list-style: none; margin: 0; padding: 6px; max-height: 60vh; overflow: auto; }
.search-box li a { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--ink); }
.search-box li a:hover, .search-box li.active a { background: var(--accent-soft); text-decoration: none; }
.search-box li b { font-weight: 600; display: block; }
.search-box li small { display: block; color: var(--muted); font-size: 12px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.search-box li .c { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.search-empty { padding: 20px; text-align: center; color: var(--muted); }

/* ---------- 响应式 ---------- */
@media (max-width: 1240px) {
  .ep, .two { grid-template-columns: 1fr; }
  .ep-side { position: static; margin-top: 20px; }
  .guide-grid { grid-template-columns: 1fr; }
  .toc { display: none; }
}
@media (max-width: 960px) {
  .frame { grid-template-columns: 1fr; }
  .burger { display: block; }
  .brand span { display: none; }
  .search-btn { width: 40px; padding: 0; justify-content: center; }
  .search-btn span, .search-btn kbd { display: none; }
  .side {
    position: fixed; left: 0; top: 56px; width: 300px; height: calc(100vh - 56px); z-index: 60;
    transform: translateX(-100%); transition: transform .2s;
  }
  body.nav-open .side { transform: none; }
  body.nav-open .side-mask { display: block; position: fixed; inset: 56px 0 0; z-index: 55; background: rgba(10, 14, 20, .4); }
  .doc { padding: 24px 18px 48px; }
  h1 { font-size: 26px; }
  .hero h1 { font-size: 30px; }
  .ep-title { font-size: 20px; }
  .prose td:first-child { white-space: normal; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
