:root {
  --bg: #f2f5f9;
  --panel: #ffffff;
  --ink: #1e2b3a;
  --muted: #5c6c7e;
  --line: #dbe3ec;
  --accent: #1b6ca8;
  --accent-hover: #145685;
  --accent-soft: #e9f1f8;
  --ok: #18734c;
  --ok-bg: #e7f5ed;
  --warn: #946200;
  --warn-bg: #fff4dc;
  --bad: #b13a4b;
  --bad-bg: #fcecef;
  --muted-bg: #eef2f6;
  --shadow: 0 4px 18px rgba(23, 37, 56, .06);
}

* { box-sizing: border-box; }

html { font-size: 16px; }

body {
  margin: 0;
  background: var(--bg);
  /* 极淡的点阵底纹：只给一点仪表盘的科技味，不铺蓝底、不影响表格可读性 */
  background-image: radial-gradient(circle at 1px 1px, rgba(31, 61, 90, .055) 1px, transparent 0);
  background-size: 22px 22px;
  background-attachment: fixed;
  color: var(--ink);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
  line-height: 1.55;
}

::selection { background: #cfe3f2; color: #123048; }
code, pre, .path { font-family: "SFMono-Regular", Menlo, Consolas, "Courier New", monospace; }
code { background: var(--muted-bg); padding: 0 .25em; border-radius: 4px; font-size: .86em; word-break: break-all; }
pre { margin: .4rem 0; }
pre.wrap, .wrap { white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }
a { color: var(--accent); text-decoration: none; transition: color .15s, background .15s; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
h1 { font-size: 1.5rem; margin: .2rem 0 .6rem; letter-spacing: -.02em; }
h2 { font-size: 1.15rem; margin: .2rem 0 .6rem; }
h3 { font-size: 1rem; margin: .6rem 0 .3rem; }
h4 { font-size: .92rem; margin: .5rem 0 .2rem; }
ul { margin: .3rem 0; padding-left: 1.2rem; }
.small { font-size: .82rem; }
.muted { color: var(--muted); }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }
.disabled { color: var(--muted); }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .8rem;
  padding: .5rem .9rem; background: linear-gradient(110deg, #15202b, #1d3446); color: #fff;
  position: sticky; top: 0; z-index: 30; box-shadow: 0 2px 12px rgba(15, 26, 40, .2);
  border-bottom: 1px solid rgba(42, 168, 196, .4);
}
.brand { color: #fff; font-weight: 700; font-size: 1.05rem; display: flex; flex-direction: column; line-height: 1.15; letter-spacing: .01em; }
.brand:hover { color: #fff; text-decoration: none; }
.brand span { font-size: .72rem; font-weight: 400; color: #8fb3c9; }
.topnav { display: flex; flex-wrap: wrap; gap: .2rem; }
.topnav a { color: #c2d5e3; padding: .3rem .6rem; border-radius: 7px; font-size: .92rem; }
.topnav a:hover { background: #26405a; color: #fff; text-decoration: none; }
.topnav a.on { background: #1e7bbc; color: #fff; font-weight: 600; box-shadow: 0 2px 7px rgba(8, 22, 36, .3); }
.who { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.who .badge { background: #22384d; color: #d8e5f0; border-color: #33516b; }
.inline { display: inline; margin: 0; }
button.link, .link { background: none; border: 0; color: #b6cfe2; cursor: pointer; font-size: .88rem; padding: .2rem .4rem; }
main .link, .single .link, .panel .link { color: var(--accent); }

.global-notice {
  margin: 0; padding: .4rem .9rem; background: var(--warn-bg); color: var(--warn);
  border-bottom: 1px solid #ead7ac; font-size: .86rem;
}
.notice { background: var(--warn-bg); color: var(--warn); padding: .4rem .6rem; border-radius: 7px; }
.notice-inline { color: var(--warn); font-size: .84rem; }
.draft-banner { background: var(--bad-bg); color: var(--bad); padding: .45rem .6rem; border-radius: 7px; margin: .4rem 0; font-weight: 600; }

/* ---------- 身份条 ---------- */
.identity {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .9rem;
  padding: .45rem .9rem; background: rgba(255, 255, 255, .96); border-bottom: 1px solid var(--line);
  font-size: .86rem; position: sticky; top: 46px; z-index: 20;
  box-shadow: 0 2px 10px rgba(23, 37, 56, .035); backdrop-filter: blur(10px);
}
.identity code { font-size: .8rem; }
.switch { display: flex; align-items: center; gap: .35rem; font-weight: 600; }
.switch select { max-width: 24rem; }

/* ---------- 三栏工作台 ---------- */
.workbench { display: grid; grid-template-columns: 17rem minmax(0, 1fr) 21rem; gap: .7rem; padding: .7rem .9rem 2rem; align-items: start; }
.left, .right { position: sticky; top: 92px; max-height: calc(100vh - 110px); overflow: auto; }
.center { min-width: 0; }
.single { max-width: 78rem; margin: 0 auto; padding: .8rem .9rem 2rem; }

.tree, .panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: .6rem .7rem; margin-bottom: .7rem; box-shadow: var(--shadow);
}
.panel.wide { overflow: visible; }
.tree h3 { display: flex; justify-content: space-between; align-items: baseline; margin-top: 0; }
.tree ul { list-style: none; padding-left: 0; margin: .2rem 0; }
.tree li { padding: .18rem 0; border-bottom: 1px dashed #e3eaf1; }
.tree li:last-child { border-bottom: 0; }
.tree a { display: block; padding: .12rem .3rem; margin-left: -.3rem; border-radius: 5px; font-size: .88rem; }
.tree a:hover { background: var(--accent-soft); text-decoration: none; }
.tree a.on { background: var(--accent-soft); font-weight: 700; color: var(--accent-hover); }
.tree .muted { display: block; font-size: .74rem; }
.tabletree { max-height: 22rem; overflow: auto; }
.left, .right, .tabletree, .tablewrap, .yaml { scrollbar-width: thin; scrollbar-color: #a9c2d6 transparent; }
.missing-reason { display: block; font-size: .74rem; color: var(--bad); }
li.missing > .disabled { text-decoration: line-through; }

/* ---------- 卡片 ---------- */
.cards { display: flex; flex-wrap: wrap; gap: .5rem; margin: .5rem 0; }
.card {
  flex: 1 1 8rem; background: var(--panel); border: 1px solid var(--line);
  border-left: 4px solid var(--accent); border-radius: 10px; padding: .5rem .65rem;
  box-shadow: var(--shadow);
}
.card b { display: block; color: #183a55; font-size: 1.5rem; line-height: 1.1; }
.card span { font-size: .8rem; color: var(--muted); }
.card.ok { border-left-color: var(--ok); }
.card.warn { border-left-color: var(--warn); }
.card.bad { border-left-color: var(--bad); }

/* ---------- 徽标：文字 + 颜色 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .25rem; padding: .07rem .45rem;
  border-radius: 999px; border: 1px solid var(--line); background: var(--muted-bg);
  font-size: .76rem; font-weight: 500; white-space: nowrap; margin: .05rem .1rem .05rem 0;
}
.badge code { background: none; padding: 0; font-size: .92em; opacity: .75; }
.badge-ok { background: var(--ok-bg); color: var(--ok); border-color: #b9ddc9; }
.badge-warn { background: var(--warn-bg); color: var(--warn); border-color: #ead7ac; }
.badge-bad { background: var(--bad-bg); color: var(--bad); border-color: #e9c1c9; }
.badge-muted { background: var(--muted-bg); color: var(--muted); }
.badge-formula { background: #e2f2f6; color: #14697a; border-color: #b3dde6; }
.chip { display: inline-block; padding: .07rem .5rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent-hover); font-size: .78rem; margin-right: .25rem; }

/* ---------- 表格 ---------- */
.grid { border-collapse: collapse; width: 100%; background: var(--panel); font-size: .86rem; }
.grid th, .grid td { border: 1px solid var(--line); padding: .32rem .45rem; text-align: left; vertical-align: top; }
.grid thead th { background: #eaf0f6; color: #28405a; position: sticky; top: 0; z-index: 5; }
.grid tbody tr:nth-child(even) { background: #fafcfd; }
.grid tbody tr:hover { background: #eef4f9; }
.grid tr.missing { background: var(--bad-bg); }
.grid tr.on { outline: 2px solid var(--accent); }
.grid td.wrap { max-width: 34rem; }
.tablewrap { overflow: auto; max-width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); box-shadow: var(--shadow); }
.tablewrap.sticky { max-height: 70vh; }
.srctable { border-collapse: collapse; font-size: .86rem; min-width: 100%; }
.srctable caption { text-align: left; padding: .4rem .5rem; font-weight: 600; background: #eaf0f6; }
.srctable th, .srctable td { border: 1px solid #d5dee7; padding: .3rem .45rem; vertical-align: top; }
.srctable th { background: #f2f6fa; }
.srctable td.hdr { background: #f2f6fa; font-weight: 600; }
.srctable td.state-not_detected, .srctable td.state-ambiguous { background: var(--warn-bg); }
.srctable td.state-blank, .srctable td.state-not_reported, .srctable td.state-not_applicable { background: var(--muted-bg); color: var(--muted); }
.srctable td:target { outline: 3px solid var(--accent); }
.rowno { color: var(--muted); font-size: .74rem; background: #f2f6fa; text-align: right; }
.cellmeta { display: block; font-size: .72rem; color: var(--muted); }
.cellink { font-weight: 600; }
.narrow { max-width: 12rem; }

/* ---------- 键值 ---------- */
.kv { display: grid; grid-template-columns: minmax(6rem, 12rem) minmax(0, 1fr); gap: .15rem .6rem; margin: .3rem 0; font-size: .86rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

/* ---------- 表单 ---------- */
.filters { display: flex; flex-wrap: wrap; gap: .5rem .7rem; align-items: flex-end; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: .55rem .7rem; margin: .5rem 0; box-shadow: var(--shadow); }
.filters label, .review-form label { display: flex; flex-direction: column; gap: .15rem; font-size: .8rem; color: var(--muted); }
.filters .chapters { border: 1px solid var(--line); border-radius: 7px; padding: .3rem .5rem; display: flex; gap: .6rem; flex-wrap: wrap; }
.filters .chapters legend { font-size: .78rem; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: .25rem; color: var(--ink); font-size: .86rem; }
input, select, textarea, button { font: inherit; }
input[type="text"], input[type="search"], input[type="number"], input[type="password"], select, textarea {
  padding: .3rem .45rem; border: 1px solid #d2dde7; border-radius: 7px; background: #fff; color: var(--ink); max-width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input[type="text"]:hover, input[type="search"]:hover, input[type="number"]:hover, input[type="password"]:hover, select:hover, textarea:hover { border-color: #8fb2cc; }
input[type="text"]:focus, input[type="search"]:focus, input[type="number"]:focus, input[type="password"]:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(27, 108, 168, .12);
}
textarea { width: 100%; resize: vertical; }
button { cursor: pointer; padding: .3rem .7rem; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink); transition: background .15s, border-color .15s, box-shadow .15s, transform .15s; }
button:hover:not(:disabled) { background: #f3f8fb; border-color: #8fb2cc; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; box-shadow: 0 3px 8px rgba(27, 108, 168, .22); }
button.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); box-shadow: 0 4px 12px rgba(27, 108, 168, .28); transform: translateY(-1px); }
button.primary:active:not(:disabled) { transform: translateY(0); }
button:disabled { opacity: .55; cursor: progress; }
button.copy { padding: .05rem .35rem; border-radius: 5px; font-size: .72rem; background: var(--accent-soft); color: var(--accent); margin-left: .2rem; }
.review-form { display: flex; flex-direction: column; gap: .4rem; }
.review-form.compact { flex-direction: row; flex-wrap: wrap; align-items: center; gap: .25rem; }
.review-form.compact input[type="text"] { width: 11rem; }
.links { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .4rem 0; }
.facet { display: inline-block; margin-right: .7rem; font-size: .78rem; }

/* ---------- 数据项值区 ---------- */
.valuebox { display: flex; flex-wrap: wrap; gap: .6rem; }
.valuebox > div { flex: 1 1 14rem; border: 1px solid var(--line); border-radius: 9px; padding: .5rem .6rem; background: #f8fbfd; box-shadow: 0 2px 9px rgba(23, 37, 56, .04); }
.valuebox .label { display: block; font-size: .76rem; color: var(--muted); margin-bottom: .2rem; }
.valuebox .big { font-size: 1.35rem; word-break: break-word; }
.valuebox .reported { border-left: 4px solid var(--ok); }
.valuebox .canonical { border-left: 4px solid var(--accent); }
.valuebox .correction { border-left: 4px solid var(--warn); }

/* ---------- 章节渲染 ---------- */
.chapter-render, .assembly-view { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: .8rem 1rem; box-shadow: var(--shadow); }
.chapter { margin-bottom: 1.2rem; }
.src-heading { margin: .8rem 0 .3rem; }
.src-paragraph { margin: .35rem 0; }
.permalink { font-size: .8rem; color: var(--muted); }
figure { margin: .5rem 0; }
figure img { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 6px; background: #fff; box-shadow: 0 2px 8px rgba(23, 37, 56, .04); }
figcaption { font-size: .78rem; color: var(--muted); }
.vector { display: inline-block; padding: .2rem .4rem; background: var(--accent-soft); border-radius: 6px; font-size: .82rem; }
.formula-block { border-left: 3px solid var(--warn); border-radius: 0 6px 6px 0; padding: .4rem .6rem; margin: .4rem 0; background: var(--warn-bg); }
.missing-list { list-style: none; padding-left: 0; }
.missing-list .missing, .missing { color: var(--bad); }
ul.errors { list-style: none; padding-left: 0; }
ul.errors li { padding: .2rem 0; border-bottom: 1px dashed #e3eaf1; }
.attachments { margin: .3rem 0; font-size: .84rem; }
.stages { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; padding: 0; }
.stages li { border: 1px solid var(--line); border-radius: 999px; padding: .25rem .55rem; font-size: .84rem; background: var(--muted-bg); }
.stages li.done { background: var(--ok-bg); border-color: #b9ddc9; color: var(--ok); font-weight: 600; }
.progress { height: .5rem; background: var(--muted-bg); border-radius: 999px; overflow: hidden; margin: .3rem 0; }
.progress span { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.events { list-style: none; padding-left: 0; font-size: .82rem; }
.events li { padding: .2rem 0; border-bottom: 1px dashed #e3eaf1; }
.suggestions { list-style: none; padding-left: 0; }
.suggestions li { border-bottom: 1px solid var(--line); padding: .4rem 0; }
.cachekeys { list-style: none; padding-left: 0; }
.yaml { max-height: 32rem; overflow: auto; background: #f7fafc; border: 1px solid var(--line); border-radius: 8px; padding: .5rem; font-size: .8rem; }
details > summary { cursor: pointer; color: var(--accent); font-size: .86rem; }
.pager { display: flex; gap: .8rem; align-items: center; margin: .6rem 0; font-size: .88rem; }
.pager span.muted { opacity: .6; }

/* ---------- 登录与错误 ---------- */
.single.narrow { max-width: 32rem; }
.single.narrow p code { word-break: normal; }
.login { display: flex; flex-direction: column; gap: .7rem; max-width: 26rem; margin: 1rem auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1.2rem; box-shadow: 0 8px 28px rgba(23, 37, 56, .09); }
.login form { display: flex; flex-direction: column; gap: .6rem; }
.login label { display: flex; flex-direction: column; gap: .2rem; font-size: .86rem; color: var(--muted); }
.login button.primary { margin-top: .2rem; padding: .45rem .8rem; }
.error-page { max-width: 46rem; margin: 2rem auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1.2rem; box-shadow: var(--shadow); }

/* ---------- 提示条 ---------- */
.toast {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 60; max-width: 26rem;
  background: #152b3e; color: #fff; padding: .65rem .85rem; border-radius: 10px;
  font-size: .88rem; box-shadow: 0 6px 20px rgba(15, 26, 40, .28);
}
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }

.foot { display: flex; flex-wrap: wrap; gap: .8rem; padding: .6rem .9rem; border-top: 1px solid var(--line); background: #f7fafc; color: var(--muted); font-size: .78rem; }

/* ---------- 投屏与窄屏 ---------- */
@media (max-width: 1500px) {
  .workbench { grid-template-columns: 15rem minmax(0, 1fr) 18rem; }
}
@media (max-width: 1180px) {
  .workbench { grid-template-columns: minmax(0, 1fr); }
  .left, .right { position: static; max-height: none; }
  .identity { position: static; }
}
@media (min-width: 1900px) {
  html { font-size: 18px; }
}
@media print {
  .topbar, .left, .right, .filters, .foot, .toast, button { display: none !important; }
  .workbench { display: block; }
  body { background-image: none; }
}