/* 薄墨纸（light ink-paper）——令牌取值与沙盘 _src/shell.html 同源，两处改了要一起改。 */
:root {
  --bg: #FFFCF4; --card: #FFFFFF; --ink: #2B2B2B; --mut: #6E6759; --faint: #9A9284;
  --line: #E7DFCE; --line2: #D6CBB2; --acc: #2A6F97; --accSoft: #EAF3F8; --warn: #9A6B12;
  --warnSoft: #FBF3E2; --err: #A6362B; --errSoft: #FBEDEA; --ok: #2F6B4F; --okSoft: #EBF4EE;
  --pend: #8A7A55; --pendSoft: #F5EFDF; --sh: 0 1px 2px rgba(43, 43, 43, .04);
  --serif: "Noto Serif SC", "Songti SC", "STSong", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
}
html[data-theme="dark"] {
  --bg: #171613; --card: #1F1E1A; --ink: #EDE8DC; --mut: #A79E8C; --faint: #7C7466;
  --line: #332F28; --line2: #443E34; --acc: #7FB6D6; --accSoft: #22303A; --warn: #D9A85C;
  --warnSoft: #2E2718; --err: #E08373; --errSoft: #33211E; --ok: #7FBFA0; --okSoft: #1D2A22;
  --pend: #B7A57E; --pendSoft: #2C2718; --sh: 0 1px 2px rgba(0, 0, 0, .3);
}
* { box-sizing: border-box }
html, body { margin: 0; padding: 0 }
body {
  background: var(--bg); color: var(--ink);
  font: 14px/1.65 var(--sans); -webkit-font-smoothing: antialiased; letter-spacing: .01em;
}
::selection { background: var(--accSoft); color: var(--acc) }

/* 布局：顶栏 + 左轨 + 主区。grid 子项一律 min-width:0，否则长表格把 390px 撑破（沙盘踩过的静默故障） */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px 56px }
.top {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(6px); border-bottom: 1px solid var(--line);
}
.topin { max-width: 1180px; margin: 0 auto; padding: 11px 20px; display: flex; align-items: baseline; gap: 14px }
.brand { font: 600 17px/1 var(--serif); letter-spacing: .04em }
.brand small { font: 400 12px/1 var(--sans); color: var(--faint); margin-left: 8px; letter-spacing: 0 }
.sp { flex: 1 }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: .02em; margin: 0 }
h1 { font-size: 22px } h2 { font-size: 17px } h3 { font-size: 15px }
.mut { color: var(--mut) } .faint { color: var(--faint) }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums }

/* 步骤条：机构感，不发光 */
.steps { display: flex; gap: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--card); overflow: hidden }
.step { flex: 1; min-width: 0; padding: 9px 12px; border-left: 1px solid var(--line); cursor: pointer; background: transparent }
.step:first-child { border-left: 0 }
.step.on { background: var(--accSoft) }
/* 待审屏左右分栏：选中的列表行（同一 --accSoft 令牌，不新造颜色） */
tbody tr.on td { background: var(--accSoft) }
tbody tr[data-pid] { cursor: pointer }
.step .okm { color: var(--ok); font-size: 11.5px }
.step .k { display: block; font-size: 12.5px; color: var(--mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.step.on .k { color: var(--acc); font-weight: 600 }
.step .n { font: 400 11px/1 var(--mono); color: var(--faint) }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--sh); padding: 16px 18px }
.card + .card { margin-top: 14px }
.card h2 { margin-bottom: 10px }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap }
.grid { display: grid; gap: 14px }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)) }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)) }

button {
  font: 500 13px/1 var(--sans); color: var(--ink); background: var(--card);
  border: 1px solid var(--line2); border-radius: 5px; padding: 8px 14px; cursor: pointer
}
button:hover { border-color: var(--acc); color: var(--acc) }
button:disabled { opacity: .45; cursor: not-allowed }
button.pri { background: var(--acc); border-color: var(--acc); color: #fff }
button.pri:hover { filter: brightness(1.06); color: #fff }
button.gho { border-color: transparent; background: transparent; color: var(--mut); padding: 6px 8px }
button.danger:hover { border-color: var(--err); color: var(--err) }
input, select, textarea {
  font: 400 13px/1.5 var(--sans); color: var(--ink); background: var(--card);
  border: 1px solid var(--line2); border-radius: 5px; padding: 7px 10px; min-width: 0
}
textarea { font-family: var(--serif); font-size: 15px; line-height: 1.9; width: 100%; resize: vertical }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accSoft); border-color: var(--acc) }
label { font-size: 12px; color: var(--mut) }

.pill { display: inline-block; font-size: 11.5px; line-height: 1.5; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line2); color: var(--mut); background: var(--card) }
.pill.ok { color: var(--ok); background: var(--okSoft); border-color: transparent }
.pill.warn { color: var(--warn); background: var(--warnSoft); border-color: transparent }
.pill.err { color: var(--err); background: var(--errSoft); border-color: transparent }
.pill.pend { color: var(--pend); background: var(--pendSoft); border-color: transparent }
.pill.acc { color: var(--acc); background: var(--accSoft); border-color: transparent }

.scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px }
.scroll > * { min-width: max-content }
/* 长字符串列（凭证变量名等）宁可换行也不要把整表顶到横滚：.scroll.wrap 关掉 max-content */
.scroll.wrap { overflow-x: hidden }
.scroll.wrap > * { min-width: 0 }
.scroll.wrap td, .scroll.wrap code { overflow-wrap: anywhere; word-break: break-word }
table { border-collapse: collapse; width: 100%; font-size: 12.8px }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top }
th { font-weight: 600; color: var(--mut); background: color-mix(in srgb, var(--bg) 60%, var(--card)); white-space: nowrap }
tbody tr:last-child td { border-bottom: 0 }
td.t { max-width: 420px; white-space: pre-wrap }

.note { font-size: 12px; color: var(--mut); border-left: 2px solid var(--line2); padding: 2px 0 2px 10px; margin: 8px 0 }
.cost { font: 600 15px/1.4 var(--mono); color: var(--ink) }
.big { font: 600 26px/1.2 var(--serif); letter-spacing: .02em }
.bar { height: 5px; background: var(--line); border-radius: 3px; overflow: hidden }
.bar > i { display: block; height: 100%; background: var(--acc); width: 0; transition: width .35s ease }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 60; max-width: 88vw }
.toast > div { background: var(--card); border: 1px solid var(--line2); border-left: 3px solid var(--acc); border-radius: 5px; padding: 9px 14px; box-shadow: 0 6px 20px rgba(43, 43, 43, .1); margin-top: 8px; font-size: 13px }
.toast > div.err { border-left-color: var(--err) }
.toast > div.ok { border-left-color: var(--ok) }
.hidden { display: none !important }

/* ── 管理台：左功能菜单 + 右操作区。子项一律 min-width:0（长表格在 390px 撑破版面是这屏的老故障） */
.adminshell { display: flex; gap: 18px; align-items: stretch }
.anav {
  width: 178px; flex: 0 0 178px; position: sticky; top: 62px;
  display: flex; flex-direction: column; gap: 2px;
  background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 8px; box-shadow: var(--sh)
}
.anav-item {
  text-align: left; border: 0; background: transparent; border-radius: 5px;
  padding: 8px 10px; font-size: 13px; color: var(--mut)
}
.anav-item:hover { background: var(--bg); color: var(--ink) }
.anav-item.on { background: var(--accSoft); color: var(--acc); font-weight: 600 }
.anav-foot { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 11.5px }
.anav-foot p { margin: 6px 0 0 }
/* flex-basis 必须是 0：列向 flex + align-items:flex-start 会让右列按内容 max-content 算宽，
   宽表（1116px）直接顶破 390px 文档 —— 溢出的是布局不是表格（overflow_probe.py 量出来的） */
.apages { flex: 1 1 0; min-width: 0; width: 0 }
.apage { display: none; min-width: 0 }
.apage.show { display: block }
.aphead { margin-bottom: 12px }
.aphead h2 { margin-bottom: 3px }
.aphead p { margin: 0; font-size: 12.5px }

.atiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 16px }
.atile { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; box-shadow: var(--sh) }
.atile .av { font: 600 22px/1.2 var(--serif); color: var(--ink) }
.atile .av.ok { color: var(--ok) } .atile .av.warn { color: var(--warn) } .atile .av.bad { color: var(--err) }
.atile .al { font-size: 11.5px; color: var(--faint); margin-top: 3px }

.lamp { display: inline-block; font-size: 11.5px; padding: 1px 8px; border-radius: 999px; white-space: nowrap }
.lamp.ok { color: var(--ok); background: var(--okSoft) }
.lamp.warn { color: var(--warn); background: var(--warnSoft) }
.lamp.bad { color: var(--err); background: var(--errSoft) }

.todo { display: flex; flex-direction: column; gap: 8px }
.trow { display: flex; gap: 10px; align-items: flex-start; background: var(--card); border: 1px solid var(--line);
  border-left: 3px solid var(--line2); border-radius: 6px; padding: 10px 12px }
.trow b { font-size: 13px }
.trow p { margin: 2px 0 0; font-size: 12px }
.trow:first-child { border-left-color: var(--warn) }
.okbox { background: var(--okSoft); border-radius: 6px; padding: 12px 14px; font-size: 13px; color: var(--ok) }
.okbox p { margin: 4px 0 0; color: var(--mut) }

.formgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px }
.formgrid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--mut) }
.formgrid label.wide { grid-column: span 2 }
.formgrid label.ck { flex-direction: row; align-items: center; gap: 6px; padding-top: 18px }
pre.json { font: 12px/1.5 var(--mono); background: var(--bg); border: 1px solid var(--line); border-radius: 5px;
  padding: 10px 12px; margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 260px; overflow: auto }
.help { font-size: 12px; color: var(--mut); margin: 8px 0 }
.note.badline { border-left-color: var(--err); color: var(--err) }
.bar > i.hot { background: var(--err) }

@media (max-width: 720px) {
  .g2, .g3 { grid-template-columns: minmax(0, 1fr) } .steps { flex-wrap: wrap } .step { flex: 1 1 45% }
  /* 窄屏不走 flex：块级流下 .apages 宽度由容器定，宽表在 .scroll 里自己滚 */
  .adminshell { display: block }
  .apages { width: auto }
  .anav { position: static; width: 100%; flex: none; flex-direction: row; overflow-x: auto; gap: 4px }
  .anav-item { white-space: nowrap }
  .anav-foot { display: none }
  .formgrid label.wide { grid-column: span 1 }

}
