/* ==========================================================================
   库存控制工作台 · 设计系统
   原则：中性灰阶 + 单一深墨蓝；1px 细线分隔；等宽数字；无渐变 / 无发光 / 无营销装饰
   ========================================================================== */
:root {
  --bg: #f5f6f7;
  --panel: #ffffff;
  --panel-2: #fafbfc;
  --panel-3: #f1f3f5;
  --line: #e0e4e8;
  --line-soft: #edf0f2;
  --ink: #171a1e;
  --ink-2: #4c555f;
  --ink-3: #8a929c;
  --accent: #1d4e79;
  --accent-2: #2c6ecb;
  --accent-soft: #eef4f9;
  --red: #b42318;
  --red-soft: #fdf0ee;
  --amber: #a76100;
  --amber-soft: #fff6e8;
  --green: #15734b;
  --green-soft: #ecf7f1;
  --violet: #5c4b8a;
  --violet-soft: #f2eff8;
  --mono: "SF Mono", "JetBrains Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  --nav-w: 198px;
  --top-h: 48px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 13px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: #cfe0f0; }

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.muted { color: var(--ink-3); }
.small { font-size: 11px; }
.mono-label {
  font-size: 10px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-3);
}
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }

/* ---------------------------------------------------------------- 顶栏 */
.topbar {
  height: var(--top-h); background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; padding: 0 18px 0 16px; gap: 16px;
  position: sticky; top: 0; z-index: 40;
}
.brand { display: flex; align-items: baseline; gap: 10px; min-width: calc(var(--nav-w) - 16px); }
.brand-mark {
  width: 20px; height: 20px; border: 1.5px solid var(--accent); border-radius: 2px;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  align-self: center;
}
.brand-mark::after { content: ""; width: 8px; height: 8px; border-left: 1.5px solid var(--accent); border-bottom: 1.5px solid var(--accent); transform: translateY(-1px); }
.brand-name { font-size: 13.5px; font-weight: 650; letter-spacing: -.01em; }
.brand-sub { font-size: 10px; color: var(--ink-3); letter-spacing: .06em; text-transform: uppercase; }
.topbar-spacer { flex: 1; }
.top-meta { display: flex; align-items: center; gap: 14px; font-size: 11px; color: var(--ink-2); }
.top-meta .sep { width: 1px; height: 16px; background: var(--line); }
.snapshot-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px;
  border: 1px solid var(--line); border-radius: 2px; background: var(--panel-2);
  font-family: var(--mono); font-size: 10.5px; color: var(--ink-2);
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); flex: none; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 27px; padding: 0 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 2px;
  font-size: 11.5px; color: var(--ink-2); white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--panel-3); border-color: #cdd4db; color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #163d60; border-color: #163d60; color: #fff; }
.btn-xs { height: 22px; padding: 0 7px; font-size: 10.5px; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { border-color: var(--line); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* ---------------------------------------------------------------- 骨架 */
.shell { display: flex; min-height: calc(100vh - var(--top-h)); }
.sidenav {
  width: var(--nav-w); flex: none; background: var(--panel); border-right: 1px solid var(--line);
  padding: 16px 0 12px; display: flex; flex-direction: column;
  position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h)); overflow-y: auto;
}
.nav-group { padding: 0 10px; margin-bottom: 15px; }
.nav-group-title { padding: 0 8px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 9px; height: 30px; padding: 0 8px;
  border-left: 2px solid transparent; border-radius: 0 2px 2px 0;
  color: var(--ink-2); font-size: 12.5px; cursor: pointer; user-select: none;
  position: relative;
}
.nav-item:hover { background: var(--panel-3); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); border-left-color: var(--accent); color: var(--accent); font-weight: 600; }
.nav-item .ico { width: 14px; height: 14px; flex: none; opacity: .8; }
.nav-item .badge {
  margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--ink-3);
  background: var(--panel-3); border-radius: 8px; padding: 1px 6px;
}
.nav-item.active .badge { background: #dce9f4; color: var(--accent); }
.nav-item .badge.alert { background: var(--red-soft); color: var(--red); }
.nav-foot { margin-top: auto; padding: 12px 16px 0; border-top: 1px solid var(--line-soft); }
.nav-foot .src { font-size: 10px; color: var(--ink-3); line-height: 1.6; }

.main { flex: 1; min-width: 0; padding: 20px 24px 34px; }
.page-head { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 15px; }
.page-head h1 { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -.02em; }
.page-head .en { font-size: 11px; color: var(--ink-3); font-weight: 400; margin-left: 8px; letter-spacing: .02em; }
.page-head .desc { font-size: 11.5px; color: var(--ink-2); margin-top: 3px; }
.page-head-actions { margin-left: auto; display: flex; gap: 7px; align-items: center; }
.crumb { font-size: 10.5px; color: var(--ink-3); margin-bottom: 5px; letter-spacing: .02em; }
.crumb b { color: var(--ink-2); font-weight: 500; }

/* ---------------------------------------------------------------- 筛选栏 */
.filterbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 7px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 2px;
  padding: 8px 10px; margin-bottom: 14px;
}
.field { display: flex; align-items: center; gap: 5px; }
.field > label { font-size: 10.5px; color: var(--ink-3); white-space: nowrap; }
select, input[type="text"], input[type="number"], input[type="search"] {
  height: 26px; padding: 0 7px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 2px; font-size: 11.5px; outline: none; color: var(--ink);
}
select:focus, input:focus { border-color: var(--accent-2); box-shadow: 0 0 0 2px rgba(44,110,203,.09); }
select { padding-right: 20px; cursor: pointer; }
.search-input { width: 210px; }
.filterbar .spacer { flex: 1; }
.result-count { font-size: 11px; color: var(--ink-3); font-family: var(--mono); white-space: nowrap; }
.page-head-actions > .result-count { padding-right: 10px; border-right: 1px solid var(--line); }
.filterbar .accent-field { background: var(--accent-soft); border: 1px solid #d3e3f0; padding: 3px 8px; border-radius: 2px; }
.filterbar .accent-field label { color: var(--accent); font-weight: 600; }

/* ---------------------------------------------------------------- 卡片 / KPI */
.grid { display: grid; gap: 12px; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 2px;
  min-width: 0;
}
.card-head {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.card-head h3 { margin: 0; font-size: 12px; font-weight: 650; letter-spacing: -.01em; }
.card-head .sub { font-size: 10.5px; color: var(--ink-3); }
.card-head .right-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card-body { padding: 12px; }
.card-body.tight { padding: 0; }

.kpi { padding: 11px 13px 12px; position: relative; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--accent); opacity: 0; }
.kpi.flag-critical::before { background: var(--red); opacity: 1; }
.kpi.flag-high::before { background: var(--amber); opacity: 1; }
.kpi.flag-good::before { background: var(--green); opacity: 1; }
.kpi .k-label { font-size: 10.5px; color: var(--ink-3); display: flex; align-items: center; gap: 5px; }
.kpi .k-label .hint { cursor: help; border-bottom: 1px dotted var(--ink-3); }
.kpi .k-value { font-family: var(--mono); font-size: 23px; line-height: 1.25; letter-spacing: -.035em; margin-top: 5px; font-variant-numeric: tabular-nums; }
.kpi .k-value .unit { font-size: 11px; color: var(--ink-3); margin-left: 3px; letter-spacing: 0; }
.kpi .k-foot { display: flex; align-items: baseline; gap: 7px; font-size: 10.5px; color: var(--ink-2); margin-top: 4px; }
.kpi .k-foot .k-sub { color: var(--ink-3); }
.kpi .k-foot b { font-family: var(--mono); font-weight: 500; }
.kpi .bar { height: 3px; background: var(--panel-3); border-radius: 2px; margin-top: 9px; overflow: hidden; }
.kpi .bar > i { display: block; height: 100%; background: var(--accent); }
.kpi .bar > i.warn { background: var(--amber); }
.kpi .bar > i.bad { background: var(--red); }

/* ---------------------------------------------------------------- 表格 */
.table-wrap { overflow-x: auto; overflow-y: auto; max-width: 100%; max-height: none; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 11.5px; }
table.tbl thead th {
  position: sticky; top: 0; z-index: 2; background: var(--panel-2);
  border-bottom: 1px solid var(--line); padding: 7px 9px; text-align: left;
  font-size: 10px; font-weight: 600; letter-spacing: .045em; text-transform: uppercase;
  color: var(--ink-3); white-space: nowrap; user-select: none;
}
table.tbl thead th.sortable { cursor: pointer; }
table.tbl thead th.sortable:hover { color: var(--accent); }
table.tbl thead th .arrow { color: var(--accent); margin-left: 3px; font-size: 9px; }
table.tbl thead th.r, table.tbl td.r { text-align: right; }
table.tbl td { padding: 6px 9px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; color: var(--ink-2); }
table.tbl td.primary { color: var(--ink); font-weight: 550; }
table.tbl td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 11px; color: var(--ink); letter-spacing: -.02em; }
table.tbl tbody tr { cursor: default; }
table.tbl tbody tr:hover td { background: #f6f9fc; }
table.tbl tbody tr.clickable { cursor: pointer; }
table.tbl tbody tr.clickable:hover td { background: var(--accent-soft); }
table.tbl tbody tr.selected td { background: #eaf2f9; }
table.tbl .code { font-family: var(--mono); font-size: 10.5px; color: var(--accent); }
table.tbl .desc-cell { max-width: 230px; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
table.tbl .neg { color: var(--red); }
table.tbl .pos { color: var(--green); }
table.tbl .warn { color: var(--amber); }
.empty { padding: 36px; text-align: center; color: var(--ink-3); font-size: 12px; }
.tbl-foot {
  display: flex; align-items: center; gap: 10px; padding: 8px 11px;
  border-top: 1px solid var(--line); font-size: 11px; color: var(--ink-3); background: var(--panel-2);
}
.tbl-foot .pager { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.tbl-foot .pager button {
  height: 22px; min-width: 22px; border: 1px solid var(--line); background: var(--panel);
  border-radius: 2px; font-size: 10.5px; color: var(--ink-2);
}
.tbl-foot .pager button:hover:not([disabled]) { background: var(--panel-3); }
.tbl-foot .pager button[disabled] { opacity: .4; cursor: not-allowed; }
.tbl-foot .pager .cur { border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* ---------------------------------------------------------------- 标签 */
.tag {
  display: inline-flex; align-items: center; gap: 3px; padding: 1px 5px;
  font-size: 10px; line-height: 16px; border-radius: 2px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--ink-2); white-space: nowrap; font-weight: 500;
}
.tag.critical { background: var(--red-soft); border-color: #f3d4cf; color: var(--red); }
.tag.high { background: var(--amber-soft); border-color: #f0dfbc; color: var(--amber); }
.tag.medium { background: var(--accent-soft); border-color: #d5e4f1; color: var(--accent); }
.tag.low { background: var(--panel-3); color: var(--ink-2); }
.tag.good { background: var(--green-soft); border-color: #cfe8dc; color: var(--green); }
.tag.outline { background: transparent; }
.tag-mono { font-family: var(--mono); font-size: 9.5px; letter-spacing: .02em; }
.tags { display: flex; gap: 3px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- 图表 */
.chart { width: 100%; display: block; overflow: visible; }
.chart text { font-family: var(--sans); font-size: 10px; fill: var(--ink-3); }
.chart text.ax-r { fill: var(--accent); font-family: var(--mono); font-size: 9.5px; }
.chart .axis { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.chart .grid-line { stroke: var(--line-soft); stroke-width: 1; shape-rendering: crispEdges; }
.chart .line { fill: none; stroke-width: 1.4; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { opacity: .07; }
.chart .ref { stroke-dasharray: 3 3; stroke-width: 1; }
.chart .bar-rect { shape-rendering: crispEdges; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 10.5px; color: var(--ink-2); margin-top: 8px; }
.chart-legend i { display: inline-block; width: 12px; height: 2px; vertical-align: middle; margin-right: 5px; }
.chart-legend i.swatch { width: 9px; height: 9px; border-radius: 1px; }
.chart-note { font-size: 10px; color: var(--ink-3); margin-top: 6px; line-height: 1.5; }
.hover-tt {
  position: fixed; z-index: 90; pointer-events: none; background: #1b222a; color: #fff;
  font-size: 10.5px; padding: 6px 9px; border-radius: 2px; line-height: 1.65;
  box-shadow: 0 4px 14px rgba(0,0,0,.16); font-family: var(--mono); white-space: pre-line;
}
.hidden { display: none !important; }

/* ---------------------------------------------------------------- 布局辅助 */
.row2 { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 12px; margin-bottom: 12px; }
.row2.even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.row3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; margin-bottom: 12px; }
.section-title { font-size: 12px; font-weight: 650; margin: 18px 0 8px; display: flex; align-items: center; gap: 8px; }
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.section-title .en { font-size: 10px; color: var(--ink-3); font-weight: 400; }

.stat-list { display: flex; flex-direction: column; }
.stat-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center;
  padding: 7px 12px; border-bottom: 1px solid var(--line-soft); font-size: 11.5px;
}
.stat-row:last-child { border-bottom: 0; }
.stat-row .lbl { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-row .val { font-family: var(--mono); font-size: 11px; color: var(--ink); }
.stat-row .track { width: 90px; height: 4px; background: var(--panel-3); border-radius: 2px; overflow: hidden; }
.stat-row .track > i { display: block; height: 100%; background: var(--accent); }

.footnote {
  margin-top: 20px; padding: 11px 13px; border: 1px solid var(--line); border-left: 2px solid var(--accent);
  background: var(--panel); border-radius: 2px; font-size: 10.5px; color: var(--ink-2); line-height: 1.7;
}
.footnote b { color: var(--ink); font-weight: 600; }
.footnote .fn-title { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 3px; }

/* ---------------------------------------------------------------- 抽屉 */
.scrim { position: fixed; inset: 0; background: rgba(20,26,32,.28); z-index: 60; opacity: 0; pointer-events: none; transition: opacity .18s; }
.scrim.show { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 560px; max-width: 96vw; background: var(--panel);
  border-left: 1px solid var(--line); z-index: 70; transform: translateX(100%);
  transition: transform .2s cubic-bezier(.22,.61,.36,1); display: flex; flex-direction: column;
  box-shadow: -8px 0 28px rgba(20,30,40,.07);
}
.drawer.show { transform: translateX(0); }
.drawer.wide { width: 720px; }
.drawer-head { padding: 14px 18px 12px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: flex-start; }
.drawer-head h2 { margin: 2px 0 0; font-size: 16px; font-weight: 650; letter-spacing: -.02em; }
.drawer-head .code { font-family: var(--mono); color: var(--accent); font-size: 11px; }
.drawer-head .close { margin-left: auto; }
.drawer-body { overflow-y: auto; padding: 0 18px 30px; flex: 1; }
.drawer-section { margin-top: 18px; }
.drawer-section > h4 { margin: 0 0 8px; font-size: 11px; font-weight: 650; letter-spacing: .01em; display: flex; align-items: center; gap: 7px; }
.drawer-section > h4 .en { font-size: 10px; color: var(--ink-3); font-weight: 400; }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.metric-grid > div { background: var(--panel); padding: 8px 10px; }
.metric-grid .m-label { font-size: 10px; color: var(--ink-3); }
.metric-grid .m-value { font-family: var(--mono); font-size: 15px; margin-top: 2px; letter-spacing: -.02em; }
.metric-grid .m-note { font-size: 9.5px; color: var(--ink-3); margin-top: 1px; }

.formula {
  background: var(--panel-2); border: 1px solid var(--line); border-left: 2px solid var(--accent);
  padding: 9px 11px; font-family: var(--mono); font-size: 10.5px; line-height: 1.8; color: var(--ink-2);
  overflow-x: auto; white-space: pre-wrap; word-break: break-word;
}
.formula b { color: var(--ink); font-weight: 600; }
.formula .cm { color: var(--ink-3); }

/* ---------------------------------------------------------------- 参数页 */
.param-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.param-row {
  display: grid; grid-template-columns: 1fr 128px; gap: 10px; align-items: center;
  padding: 7px 0; border-bottom: 1px solid var(--line-soft);
}
.param-row:last-child { border-bottom: 0; }
.param-row .p-name { font-size: 11.5px; color: var(--ink); }
.param-row .p-desc { font-size: 10px; color: var(--ink-3); margin-top: 1px; }
.param-row input[type="range"] { width: 100%; margin: 0; display: block; accent-color: var(--accent); }
.param-row .p-val { font-family: var(--mono); font-size: 11px; text-align: right; color: var(--accent); }
.param-row select, .param-row input[type="number"] { width: 100%; }
.param-kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.param-kv > div { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; min-width: 0; padding: 4px 0; border-bottom: 1px solid var(--line-soft); }
.param-kv > div:nth-child(2n+1) { border-right: 1px solid var(--line); padding-right: 12px; }
.param-kv > div:nth-child(2n) { padding-left: 4px; }
.param-kv code { font-family: var(--mono); font-size: 10px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.param-kv b { font-family: var(--mono); font-size: 10.5px; font-weight: 500; color: var(--ink); white-space: nowrap; }
.impact { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.impact > div { background: var(--panel); padding: 10px; }
.impact .i-label { font-size: 10px; color: var(--ink-3); }
.impact .i-value { font-family: var(--mono); font-size: 17px; margin-top: 3px; }
.impact .i-delta { font-size: 10px; margin-top: 2px; }
.impact .up { color: var(--red); } .impact .down { color: var(--green); } .impact .flat { color: var(--ink-3); }

.dict-table { font-size: 11px; }
.dict-table code { font-family: var(--mono); font-size: 10.5px; background: var(--panel-3); padding: 1px 4px; border-radius: 2px; }
/* 需覆盖 table.tbl td 的 nowrap：用同等特异性，避免长口径文本撑破栅格 */
table.tbl.dict-table td { white-space: normal; vertical-align: top; line-height: 1.6; overflow-wrap: anywhere; }
table.tbl.dict-table td:first-child { width: 120px; min-width: 100px; font-weight: 600; color: var(--ink); }
table.tbl.dict-table td a { overflow-wrap: anywhere; }
.dict-table ul { margin: 0; padding-left: 16px; }
.dict-table li { margin: 3px 0; }

/* ---------------------------------------------------------------- 杂项 */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(12px);
  background: #1b222a; color: #fff; font-size: 11.5px; padding: 9px 15px; border-radius: 2px;
  z-index: 100; opacity: 0; pointer-events: none; transition: all .2s;
  box-shadow: 0 6px 20px rgba(0,0,0,.18);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.kbd { font-family: var(--mono); font-size: 10px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 2px; padding: 0 4px; color: var(--ink-3); background: var(--panel-2); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 2px; overflow: hidden; }
.seg button { border: 0; border-right: 1px solid var(--line); background: var(--panel); padding: 4px 9px; font-size: 10.5px; color: var(--ink-2); height: 24px; }
.seg button:last-child { border-right: 0; }
.seg button.active { background: var(--accent); color: #fff; }
.seg button:hover:not(.active) { background: var(--panel-3); }
.hr { height: 1px; background: var(--line); margin: 14px 0; }
.callout { padding: 9px 11px; background: var(--accent-soft); border: 1px solid #d9e7f3; font-size: 11px; color: var(--ink-2); line-height: 1.65; border-radius: 2px; }
.callout.warn { background: var(--amber-soft); border-color: #f0dfbc; }
.callout b { color: var(--ink); }

/* ---------------------------------------------------------------- ABC×XYZ 九宫格 */
.seg-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.seg-cell {
  border: 1px solid var(--line); background: var(--panel); padding: 9px 10px 8px;
  cursor: pointer; transition: border-color .12s; min-width: 0;
}
.seg-cell:hover { border-color: var(--accent-2); }
.seg-cell.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.seg-cell.empty { opacity: .55; }
.seg-top { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.seg-key { font-family: var(--mono); font-size: 12px; font-weight: 650; letter-spacing: .04em; color: var(--ink); }
.seg-csl { font-family: var(--mono); font-size: 11px; color: var(--accent); }
.seg-meta { font-size: 10px; color: var(--ink-3); margin-top: 2px; }
.seg-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; margin-top: 7px; padding-top: 6px; border-top: 1px solid var(--line-soft); }
.seg-stats > div { display: flex; justify-content: space-between; gap: 4px; min-width: 0; font-size: 10px; color: var(--ink-3); }
.seg-stats b { font-family: var(--mono); font-weight: 500; color: var(--ink); white-space: nowrap; }
.matrix-editor { font-size: 11px; table-layout: fixed; }
.matrix-editor th { text-align: left; font-weight: 600; padding: 5px 8px; background: var(--panel-2); }
.matrix-editor td { padding: 4px 8px; }
.matrix-editor select { width: 100%; height: 24px; font-size: 11px; font-family: var(--mono); }
.matrix-editor td:first-child { width: 92px; font-weight: 600; }
.mode-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cmp-table td, .cmp-table th { padding: 6px 8px !important; }
.cmp-table td.r, .cmp-table th.r { text-align: right; font-family: var(--mono); }
.cmp-table tr.hl { background: var(--accent-soft); }
.cmp-table tr.hl td { font-weight: 600; }
/* 差异化模式下全局 CSL 降为对照基线，视觉上弱化以免误操作 */
.field.policy-inactive select { background: var(--panel-3); color: var(--ink-2); }
.field.policy-inactive label { color: var(--ink-3); }

@media (max-width: 1450px) {
  .filterbar { gap: 5px; padding: 7px 8px; }
  .filterbar select { max-width: 118px; }
  .filterbar .accent-field select { max-width: 158px; }
  .search-input { width: 168px; }
}
@media (max-width: 1400px) {
  .kpi-grid { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .kpi .k-value { font-size: 20px; }
}
/* ------------------------------------------------ 供应商交期 · OTD 滚动 */
.neg { color: var(--red); }
.pos { color: var(--green); }
.btn-link { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; }
.btn-link:hover { text-decoration: underline; }
.cmp-table td.cur { background: var(--accent-soft); font-weight: 600; }
#view .card-body > .callout code, #view .callout code { font-size: 10.5px; }

@media (max-width: 1180px) {
  :root { --nav-w: 56px; }
  .brand { min-width: 160px; }
  .nav-group-title, .nav-item span:not(.ico):not(.badge) { display: none; }
  .nav-item { justify-content: center; padding: 0; }
  .nav-item .badge { display: none; }
  .nav-foot { display: none; }
  .row2, .row2.even, .row3, .param-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

/* ------------------------------------------------ 证据与局限 · Evidence & Limits */
.hash { font-family: var(--mono); font-size: 11px; letter-spacing: .01em; overflow-wrap: anywhere; }
.kpi .k-value .hash { font-size: 15px; font-weight: 500; letter-spacing: .02em; }
.ev-recheck .btn { margin-bottom: 8px; }
.ev-check { margin-top: 4px; padding: 8px 10px; border-left: 2px solid var(--line);
  background: var(--panel-2); font-size: 11.5px; line-height: 1.65; color: var(--ink-2); }
.ev-check.ok { border-left-color: var(--green); color: var(--ink); }
.ev-check.bad { border-left-color: var(--red); color: var(--ink); }
.ev-check.warn { border-left-color: #a76100; }
.ev-limits { display: block; }
.ev-limit { display: grid; grid-template-columns: 34px minmax(0,1fr); gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.ev-limit:last-child { border-bottom: 0; }
.ev-num { font-family: var(--mono); font-size: 12px; color: var(--ink-3); padding-top: 2px; }
.ev-title { font-size: 12.5px; font-weight: 600; color: var(--ink); margin-bottom: 4px; }
.ev-fact, .ev-next { font-size: 11.5px; line-height: 1.65; color: var(--ink-2); margin-top: 3px; }
.ev-tag { display: inline-block; min-width: 62px; margin-right: 7px; font-size: 10px;
  color: var(--ink-3); border: 1px solid var(--line); border-radius: 2px;
  padding: 0 4px; text-align: center; }
.ev-red { margin: 0; padding-left: 18px; }
.ev-red li { font-size: 11.5px; line-height: 1.75; color: var(--ink-2); }
@media (max-width: 1180px) {
  .ev-limit { grid-template-columns: 26px minmax(0,1fr); gap: 7px; }
  .ev-tag { display: block; margin: 0 0 2px; }
}

/* -------------------------------- 窄屏：表格横向滚动 + 顶栏紧凑（768px 溢出修复） */
/* 已被 .table-wrap 包裹的表格由上方 overflow-x:auto 承载；此处覆盖字典表、
   抽屉明细、证据页复算表等直接挂在 .card-body / .drawer-body / .ev-recheck
   下的裸表格（含孙级），避免窄屏把栅格撑破。 */
.card-body:has(table.tbl),
.drawer-body:has(table.tbl),
.ev-recheck:has(table.tbl) { overflow-x: auto; min-width: 0; }

@media (max-width: 900px) {
  .topbar { gap: 8px; padding: 0 10px; overflow-x: auto; overflow-y: hidden; }
  .brand { min-width: 0; }
  .brand-sub { display: none; }
  .top-meta { gap: 8px; font-size: 10px; }
  .top-meta .sep { display: none; }
  .snapshot-badge { padding: 3px 5px; }
  .topbar .btn { padding: 0 7px; font-size: 11px; }
}
