:root {
  /* 基础色（对齐 docs/ERP_UIUX.md §7.2） */
  --bg: #eef3f5;
  --panel: #ffffff;
  --panel-soft: #f7fafb;
  --panel-tint: #f2f7f7;
  --ink: #17212b;
  --muted: #5f6d78;
  --muted-2: #8a98a5;
  --line: #d7e2e6;
  --line-soft: #e9eff2;

  /* 语义色：前景 / 浅背景 成对 */
  --c-ops: #176d72;        --c-ops-soft: #e7f3f3;       /* 主操作/当前选择 */
  --c-sales: #3f6f9f;      --c-sales-soft: #eaf1f8;     /* 销售/信息 */
  --c-purchase: #3e7a5a;   --c-purchase-soft: #eaf4ee;  /* 采购/成功 */
  --c-produce: #6d5d91;    --c-produce-soft: #f0edf7;   /* 生产/版本 */
  --c-research: #8a5c75;   --c-research-soft: #f7edf2;  /* 研发/实验 */
  --c-warning: #96672c;    --c-warning-soft: #faf2e5;   /* 待完善/警告 */
  --c-danger: #a34b4b;     --c-danger-soft: #f9eaea;    /* 危险/失败 */

  /* 兼容别名（旧代码引用） */
  --accent: var(--c-ops);
  --accent-dark: #135a5e;
  --accent-soft: var(--c-ops-soft);
  --danger: var(--c-danger);
  --danger-soft: var(--c-danger-soft);
  --warning: var(--c-warning);
  --warning-soft: var(--c-warning-soft);
  --success: var(--c-purchase);
  --success-soft: var(--c-purchase-soft);

  --shadow-sm: 0 1px 2px rgba(22, 42, 56, 0.05);
  --shadow-md: 0 8px 24px rgba(22, 42, 56, 0.08);
  --shadow-focus: 0 0 0 3px rgba(23, 109, 114, 0.16);
  --radius: 8px;
  --radius-sm: 6px;
  --sidebar-bg: #fbfdfd;
  --sidebar-active: #e7f3f3;
}

/* 配方历史是工作记录，不与当前配方争夺视觉层级。 */
.formula-timeline > header { margin-bottom: 4px; }
.formula-timeline-list { display: grid; }
.formula-timeline-entry { padding: 12px 0; border-top: 1px solid var(--line-soft); }
.formula-timeline-entry:first-child { border-top: 0; }
.formula-timeline-entry p { margin: 0; color: var(--ink); }
.formula-timeline-entry time { color: var(--muted); font-variant-numeric: tabular-nums; }
.formula-timeline-entry a { margin-left: 4px; font-weight: 600; font-variant-numeric: tabular-nums; }
.formula-timeline-entry small { display: block; margin-top: 3px; color: var(--muted); }
.formula-version-code { color: var(--muted); font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; }
.formula-history-header { margin-bottom: 18px; }
.formula-history-layout { display: grid; grid-template-columns: minmax(250px, 300px) minmax(0, 1fr); gap: 20px; align-items: start; }
.formula-history-rail, .formula-history-content { min-width: 0; }
.formula-history-rail { position: sticky; top: 16px; border: 1px solid var(--line); background: var(--surface); }
.formula-history-rail-heading { display: flex; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line-soft); font-weight: 650; }
.formula-history-rail-heading small { color: var(--muted); font-weight: 500; }
.formula-history-list { display: grid; }
.formula-history-node { display: grid; grid-template-columns: 14px minmax(0, 1fr); gap: 9px; padding: 12px 14px; border-bottom: 1px solid var(--line-soft); color: var(--ink); text-decoration: none; }
.formula-history-node:last-child { border-bottom: 0; }
.formula-history-node:hover, .formula-history-node.is-selected { background: var(--accent-soft); text-decoration: none; }
.formula-history-node-marker { width: 8px; height: 8px; margin-top: 5px; border: 2px solid var(--muted-2); border-radius: 50%; }
.formula-history-node.is-selected .formula-history-node-marker { border-color: var(--accent); background: var(--accent); }
.formula-history-node-body { display: grid; gap: 3px; min-width: 0; }
.formula-history-node-body strong { font-size: 13px; font-variant-numeric: tabular-nums; }
.formula-history-node-body time, .formula-history-node-body small { color: var(--muted); font-size: 12px; }
.formula-history-node-body em { color: var(--muted); font-size: 11px; font-style: normal; }
.formula-history-selection { display: flex; justify-content: space-between; gap: 16px; align-items: start; padding: 18px 20px; border: 1px solid var(--line); background: var(--surface); }
.formula-history-selection h2 { margin: 0; font-variant-numeric: tabular-nums; }
.formula-history-selection p:last-child { margin: 5px 0 0; color: var(--muted); }
.formula-history-output-links { margin: 10px 0 0; color: var(--muted); }
.formula-history-output-links a { margin-right: 6px; font-weight: 600; }
.formula-history-snapshot { margin-top: 12px; }
.formula-history-process { margin-top: 12px; }
.formula-history-unavailable { margin-top: 12px; text-align: left; }
@media (max-width: 800px) {
  .formula-history-layout { grid-template-columns: 1fr; }
  .formula-history-rail { position: static; }
  .formula-history-selection { display: block; }
  .formula-history-selection .pill { display: inline-block; margin-top: 10px; }
}

.formula-change-detail {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(120px, 1fr) auto minmax(120px, 1fr);
  gap: 8px;
  align-items: start;
  padding: 7px 0;
  color: var(--muted);
  font-size: 13px;
}
.formula-change-detail strong { color: var(--ink); font-weight: 600; }
.formula-change-detail span { overflow-wrap: anywhere; }

@media screen and (max-width: 720px) {
  .formula-change-detail { grid-template-columns: 1fr; gap: 3px; }
  .formula-change-detail span[aria-hidden="true"] { display: none; }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #f7fafb 0, var(--bg) 260px);
  color: var(--ink);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: #fff;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
  color: #fff;
}

/* ── Layout ───────────────────────────────────────────── */

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--sidebar-bg);
  color: var(--ink);
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  box-shadow: 1px 0 0 rgba(255, 255, 255, 0.72) inset;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--ink);
  margin-bottom: 20px;
  padding: 2px 4px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--c-ops);
  color: white;
  font-weight: 700;
  box-shadow: 0 6px 14px rgba(23, 109, 114, 0.18);
}

.brand small {
  display: block;
  color: var(--muted);
}

.board-switch {
  display: inline-flex;
  align-self: flex-start;
  gap: 2px;
  margin-bottom: 10px;
  padding: 2px;
  background: var(--panel-tint);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
}

.board-switch a {
  text-align: center;
  padding: 4px 8px;
  border-radius: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}

.board-switch a:hover {
  text-decoration: none;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.7);
}

.board-switch a.active {
  background: var(--panel);
  color: var(--accent-dark);
  box-shadow: var(--shadow-sm);
}

.nav {
  display: grid;
  gap: 10px;
  align-items: start;
}

/* 导航不写分类标题，用浅色背景块把同组链接聚成一块 */
.nav > .nav-group {
  display: grid;
  gap: 2px;
  align-content: start;
  align-self: start;
  padding: 5px;
  background: #f2f6f7;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}

.nav-primary {
  font-weight: 700;
}

.nav a {
  color: #31424f;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  transition: background 0.12s ease, color 0.12s ease;
  font-size: 14px;
}

.nav a:hover {
  background: rgba(255, 255, 255, 0.8);
  color: var(--accent-dark);
  text-decoration: none;
}

.nav a.active,
.nav-primary.active {
  background: var(--sidebar-active);
  color: var(--accent-dark) !important;
  font-weight: 700;
}

.main {
  padding: 28px 32px 40px;
  width: 100%;
  min-width: 0;
}

/* ── Multi-tab workspace ─────────────────────────────── */

.auth-app-shell,
.workspace-embedded-shell {
  display: block;
  min-height: 100vh;
}

.workspace-shell {
  /* Chrome <108 / older WeChat and DingTalk WebViews do not understand dvh.
     Keep vh first so the workspace panes retain a definite height there. */
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.workspace {
  display: grid;
  grid-template-rows: 44px minmax(0, 1fr);
  min-width: 0;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
}

.workspace-tabs-bar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: end;
  min-width: 0;
  padding: 6px 10px 0;
  background: #f6f9fa;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.88) inset;
}

.workspace-tabs-scroll {
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  overscroll-behavior-x: contain;
}

.workspace-tabs {
  display: flex;
  align-items: end;
  gap: 4px;
  min-width: max-content;
}

[data-workspace-board][hidden] {
  display: none !important;
}

/* 移动端外壳控件：桌面默认隐藏，≤820px 媒体查询内启用 */
.workspace-mobile-brand,
.workspace-menu-button,
.sidebar-feedback,
.mobile-menu-backdrop {
  display: none;
}

.workspace-tab {
  position: relative;
  display: flex;
  align-items: center;
  width: clamp(132px, 16vw, 220px);
  height: 34px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px 6px 0 0;
  transition:
    color 140ms ease,
    background-color 140ms ease,
    border-color 140ms ease;
}

.workspace-tab:hover {
  color: var(--ink);
  background: #edf3f5;
}

.workspace-tab.active {
  color: var(--ink);
  background: var(--panel);
  border-color: var(--line);
  border-bottom-color: var(--panel);
  box-shadow: 0 -2px 0 var(--accent) inset;
}

/* 顶部工作标签区分经营生产与研发；颜色只表达页面归属，不扩散到侧栏。 */
.workspace-tab.workspace-tab-research {
  color: #765669;
  background: #fbf5f8;
  border-color: #f0e3ea;
}

.workspace-tab.workspace-tab-research:hover {
  color: var(--c-research);
  background: #f8eff4;
}

.workspace-tab.workspace-tab-research.active {
  color: #5f4051;
  background: var(--c-research-soft);
  border-color: #e7d6df;
  border-bottom-color: var(--c-research-soft);
  box-shadow: 0 -2px 0 var(--c-research) inset;
}

.workspace-tab.workspace-tab-research .workspace-tab-close:hover {
  background: #eadce4;
}

.workspace-tab-main,
.workspace-tab-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  margin: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 4px;
  box-shadow: none;
  cursor: pointer;
}

.workspace-tab-main:hover,
.workspace-tab-close:hover {
  color: inherit;
  background: transparent;
  box-shadow: none;
}

.workspace-tab-main {
  flex: 1 1 auto;
  justify-content: flex-start;
  min-width: 0;
  height: 100%;
  padding: 0 6px 0 11px;
  font-size: 13px;
  font-weight: 550;
  text-align: left;
}

.workspace-tab-label {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-tab-close {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  margin-right: 3px;
  color: var(--muted-2);
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
}

.workspace-tab-close:hover {
  color: var(--ink);
  background: #e1eaed;
}

.workspace-tab-main:focus-visible,
.workspace-tab-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.workspace-panes {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

.workspace-pane {
  position: absolute;
  inset: 0;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}

.workspace-pane[hidden] {
  display: none;
}

.workspace-frame {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--bg);
  border: 0;
}

.workspace-loading {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  background: rgba(247, 250, 251, 0.92);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
}

.workspace-pane.is-loading .workspace-loading {
  opacity: 1;
}

.workspace-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: workspace-spin 700ms linear infinite;
}

.workspace-live {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.workspace-embedded,
.workspace-embedded-shell {
  min-height: 100%;
  background: var(--bg);
}

.workspace-embedded-main {
  min-height: 100vh;
}

@keyframes workspace-spin {
  to { transform: rotate(360deg); }
}

/* ── Page header ──────────────────────────────────────── */

.page-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 18px 20px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.page-header > div:first-child {
  flex: 1 1 360px;
  min-width: 0;
}

.page-header > .button:first-of-type,
.page-header > .actions,
.page-header > .page-actions {
  margin-left: auto;
}

.page-header > .page-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

h1,
h2 {
  margin: 0;
  line-height: 1.3;
  letter-spacing: 0;
}

h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
}

h2 {
  font-size: 17px;
  font-weight: 650;
  color: var(--ink);
}

h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.page-header p {
  display: none;
}

.page-header .page-purpose {
  display: block;
  max-width: 72ch;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-wrap: pretty;
}

.dossier-current-formula .section-header {
  margin-bottom: 12px;
}

.dossier-formula-component + .dossier-formula-component {
  margin-top: 14px;
}

.dossier-formula-component h3 {
  display: flex;
  gap: 12px;
  align-items: baseline;
  margin: 0 0 6px;
}

.dossier-formula-component h3 span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.dossier-formula-process {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.dossier-formula-process > span {
  color: var(--muted);
  font-size: 12px;
}

.dossier-formula-process p {
  margin: 4px 0 0;
}

.formula-phase-cell {
  width: 88px;
  min-width: 88px;
}

.formula-phase-cell input {
  width: 100%;
  min-width: 72px;
}

.back-link {
  display: inline-block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
}
.back-link:hover { text-decoration: underline; }

/* ── Buttons ──────────────────────────────────────────── */

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0 14px;
  background: var(--accent);
  color: white;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
  white-space: nowrap;
}

.button:hover,
button:hover {
  background: var(--accent-dark);
  text-decoration: none;
  box-shadow: 0 4px 10px rgba(23, 109, 114, 0.16);
}

.button:active,
button:active {
  transform: translateY(1px);
}

.button:focus-visible,
button:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

/* Secondary: light background, subtle border */
.button.secondary {
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
  box-shadow: none;
}

.button.secondary:hover {
  background: var(--panel-soft);
  border-color: #cbd5e1;
  box-shadow: var(--shadow-sm);
}

/* Danger: red for destructive actions */
.button.danger,
button.danger {
  background: var(--danger);
  color: white;
}

.button.danger:hover,
button.danger:hover {
  background: #a53024;
}

/* Ghost button: text-only, minimal weight */
.button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  box-shadow: none;
}

.button.ghost:hover {
  background: var(--panel-soft);
  color: var(--ink);
}

.button.small {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

/* ── Archive card (detail page top summary) ───────────── */

.archive-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
}

.archive-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.archive-card-header h1 {
  font-size: 22px;
  margin: 0;
}

.archive-card-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 8px;
}

.archive-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.archive-card-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
}

.archive-card-fields > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.archive-card-fields span {
  color: var(--muted);
  font-size: 12px;
}

.archive-card-fields strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

/* ── Stats & Module grids ─────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat {
  display: block;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.stat span {
  color: var(--muted);
  font-size: 13px;
}

.stat strong {
  display: block;
  font-size: 26px;
  margin-top: 4px;
  color: var(--ink);
  font-weight: 700;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.module-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.module-panel.sales { border-top-color: var(--c-sales); }
.module-panel.production { border-top-color: var(--c-purchase); }
.module-panel.purchase { border-top-color: var(--c-warning); }
.module-panel.quality { border-top-color: var(--c-research); }
.module-panel.master-data { border-top-color: var(--c-ops); }
.module-panel.traceability { border-top-color: var(--c-produce); }

.module-panel:hover {
  border-color: #c8d7dc;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.module-panel h2 {
  font-size: 16px;
  margin-bottom: 12px;
}

.module-panel a {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 8px;
  border-top: 1px solid var(--line);
  border-radius: 4px;
}

.module-panel a:first-of-type {
  border-top: 0;
}

.module-panel a:hover {
  background: var(--panel-tint);
  text-decoration: none;
}

.module-panel strong {
  color: var(--ink);
}

/* ── Panels & Cards ───────────────────────────────────── */

.flow,
.form-panel,
.table-wrap,
.component-panel,
.detail-grid {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.flow ol {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  margin: 14px 0 0;
  list-style: none;
}

/* ── Pills / Tags ─────────────────────────────────────── */

.flow li,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 2px 8px;
  margin: 2px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  border: 1px solid transparent;
}

/* Role pills — 低饱和语义色，对齐 ERP_UIUX.md */
.pill-role-purchase {
  background: var(--c-purchase-soft);
  color: var(--c-purchase);
  border-color: #c7dccd;
}

.pill-role-sell {
  background: var(--c-sales-soft);
  color: var(--c-sales);
  border-color: #cdddec;
}

.pill-role-produce {
  background: var(--c-produce-soft);
  color: var(--c-produce);
  border-color: #d6cee6;
}

.pill-role-input {
  background: var(--c-research-soft);
  color: var(--c-research);
  border-color: #e3d2dd;
}

/* Status pills */
.pill-status-warning {
  background: var(--warning-soft);
  color: #92600a;
  border-color: #f5dfa0;
}

.pill-status-success {
  background: var(--success-soft);
  color: #1a6940;
  border-color: #a8dcc0;
}

.pill-status-danger {
  background: var(--danger-soft);
  color: #9c2920;
  border-color: #f0bdb7;
}

.pill-status-neutral {
  background: #f1f5f9;
  color: #64748b;
  border-color: #cbd5e1;
}

.pill-status-draft,
.pill-status-pending {
  background: #fff7df;
  color: #7a5312;
  border-color: #e8c875;
}

.pill-status-progress {
  background: #e8f2fc;
  color: #225f91;
  border-color: #a9cbe7;
}

.pill-status-cancelled,
.pill-status-closed {
  background: #eef1f3;
  color: #56636d;
  border-color: #c8d0d5;
}

.pill-status-production {
  background: var(--c-produce-soft);
  color: #5b4a83;
  border-color: #cfc4e2;
}

/* Batch tracking pill */
.pill-batch-tracking {
  background: #edf5fb;
  color: #1a6090;
  border-color: #b0d4f1;
}

/* Generic tag (used in tables) */
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 4px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 600;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

.tag.diff {
  background: var(--warning-soft);
  color: var(--warning);
  border-color: #f5dfa0;
}

/* ── Toolbar / Filters ────────────────────────────────── */

.toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  padding: 10px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}

.toolbar a:not(.button) {
  color: var(--muted);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 13px;
}

.toolbar a:not(.button):hover {
  color: var(--ink);
  background: var(--panel-tint);
}

.toolbar a:not(.button).active {
  color: var(--accent-dark);
  font-weight: 600;
  background: var(--accent-soft);
}

.toolbar-divider {
  color: var(--muted-2);
  font-size: 13px;
  margin: 0 2px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  align-items: end;
  width: 100%;
}

.search {
  display: grid;
  gap: 4px;
  max-width: 420px;
  width: 100%;
}

label span,
.field label,
.detail-grid span {
  color: var(--muted);
  font-size: 12px;
}

/* ── Form inputs ──────────────────────────────────────── */

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: var(--shadow-focus);
}

textarea {
  min-height: 100px;
}

/* ── Tables ───────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  padding: 0;
  -webkit-overflow-scrolling: touch;
  border-color: var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  padding: 11px 14px;
  vertical-align: middle;
  font-size: 14px;
}

th {
  color: #51616d;
  font-weight: 700;
  background: #f5f8fa;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody tr:hover {
  background: #f7fbfb;
}

tbody tr:last-child td {
  border-bottom: none;
}

/* Numeric right-align */
td.numeric,
th.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Primary column: bold */
td.primary,
th.primary {
  font-weight: 600;
  color: var(--ink);
}

/* Secondary: muted small text */
td.secondary {
  color: var(--muted);
  font-size: 13px;
}

/* Empty placeholder */
td.empty-text {
  color: var(--muted-2);
  font-style: italic;
  font-size: 13px;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 24px 14px;
  font-size: 14px;
}

/* 已取消行视觉弱化（生产任务列表、关联生产任务历史区） */
tr.row-cancelled td {
  color: var(--muted-2);
}
tr.row-cancelled a {
  color: var(--muted);
}

tr.row-cancelled td:first-child,
tr.row-blocked td:first-child,
tr.row-progress td:first-child {
  border-left: 4px solid transparent;
}

tr.row-cancelled td:first-child { border-left-color: #aab4bb; }
tr.row-blocked td:first-child { border-left-color: var(--c-danger); }
tr.row-progress td:first-child { border-left-color: var(--c-sales); }
tr.row-blocked { background: #fffafa; }
tr.row-progress { background: #f8fbfe; }

/* ── Forms ────────────────────────────────────────────── */

.form-panel {
  max-width: 760px;
}

.stack-form {
  display: grid;
  gap: 14px;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-line input {
  width: auto;
  min-height: auto;
}

.muted {
  color: var(--muted);
}

.compact-table th,
.compact-table td {
  padding: 8px 10px;
}

.business-form {
  display: grid;
  gap: 16px;
  max-width: 980px;
  width: 100%;
  min-width: 0;
}

.form-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.form-section header {
  margin-bottom: 16px;
}

.form-section h2 {
  font-size: 16px;
}

.form-section p {
  margin: 6px 0 0;
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}

.field {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
}

.business-form .field {
  margin-bottom: 0;
}

.field.wide {
  grid-column: 1 / -1;
}

.field small {
  color: var(--muted);
}

.checkbox-list > div,
.checkbox-list ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.checkbox-list label {
  color: var(--ink);
}

.checkbox-list input[type="checkbox"] {
  width: auto;
  min-height: auto;
  margin-right: 8px;
}

.field input[type="checkbox"],
.field input[type="radio"] {
  width: auto;
  min-height: auto;
}

.field ul,
.field > div:has(input[type="checkbox"]) {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.field li,
.field div:has(> label > input[type="checkbox"]) {
  margin: 0;
}

.field label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.line-form-table {
  overflow-x: auto;
}

.line-form-table table {
  min-width: 1100px;
}

.line-form-table td:nth-child(3),
.line-form-table th:nth-child(2) {
  min-width: 260px;
}

.formula-editor .line-form-table td:nth-child(4),
.formula-editor .line-form-table th:nth-child(3) {
  min-width: 280px;
  width: 280px;
}

.formula-editor .line-form-table th:nth-child(2),
.formula-editor .line-form-table td:nth-child(3) {
  min-width: 74px;
}

.formula-editor .line-form-table th:nth-child(4),
.formula-editor .line-form-table th:nth-child(6),
.formula-editor .line-form-table th:nth-child(7),
.formula-editor .line-form-table th:nth-child(8) {
  white-space: nowrap;
}

.formula-editor .line-form-table th:nth-child(4),
.formula-editor .line-form-table td:nth-child(5) {
  min-width: 120px;
  width: 120px;
}

.line-form-table textarea {
  min-height: 72px;
}

/* ── Autocomplete ─────────────────────────────────────── */

.autocomplete-select {
  position: relative;
  display: block;
}

.autocomplete-input {
  width: 100%;
}

.autocomplete-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.autocomplete-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-muted);
}

.autocomplete-chip button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.autocomplete-source {
  display: none;
}

.formula-supplier-rule {
  min-width: 190px;
}

.formula-supplier-rule > select:not(.autocomplete-source) {
  width: 100%;
  min-height: 40px;
}

.formula-allowed-suppliers {
  margin-top: 6px;
}

.formula-allowed-suppliers[hidden] {
  display: none;
}

.formula-allowed-suppliers .autocomplete-input {
  min-height: 40px;
}

/* 带 data-autocomplete-source 的原生 <select> 从首帧起即隐藏，
   避免 JS 增强前闪出 `---------` 原生下拉；JS 仍负责构建可见搜索输入框。 */
select[data-autocomplete-source] {
  display: none;
}

/* Global portal for autocomplete dropdowns */
.autocomplete-portal {
  position: relative;
  z-index: 9999;
  pointer-events: none;
}

.autocomplete-portal > * {
  pointer-events: auto;
}

.autocomplete-results {
  position: fixed;
  z-index: 10000;
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  box-shadow: var(--shadow-md);
  min-width: 0;
  max-width: 560px;
}

.autocomplete-results-upward {
  box-shadow: 0 -8px 24px rgba(22, 42, 56, 0.1);
}

.autocomplete-option,
.autocomplete-empty {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
  justify-content: stretch;
  justify-items: stretch;
  cursor: pointer;
}

.autocomplete-option:last-child,
.autocomplete-empty:last-child {
  border-bottom: none;
}

.autocomplete-option-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  border-bottom: 1px solid var(--line);
}

.autocomplete-option-row:last-child {
  border-bottom: none;
}

.autocomplete-option-row .autocomplete-option {
  border-bottom: none;
}

.autocomplete-option-readonly {
  cursor: default;
  opacity: 1;
}

.autocomplete-option-open {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-left: 1px solid var(--line);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.autocomplete-option-open:hover,
.autocomplete-option-open:focus {
  background: var(--accent-soft);
  text-decoration: underline;
}

.autocomplete-option > span {
  font-size: 14px;
  line-height: 1.4;
  max-height: 40px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.autocomplete-option small {
  font-size: 12px;
  color: var(--muted);
}

.autocomplete-empty {
  font-size: 14px;
  color: var(--muted);
  padding: 12px;
}

.autocomplete-option:hover,
.autocomplete-option:focus,
.autocomplete-option.autocomplete-highlighted {
  background: var(--accent-soft);
}

/* Issue 48 P2：编码置顶加粗 */
.autocomplete-option .autocomplete-code-bold {
  font-weight: 700;
}

/* ── Print previews ───────────────────────────────────── */

.print-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 16px;
}

.formula-print-scale-form {
  display: grid;
  gap: 4px;
  margin-right: auto;
}

.formula-print-scale-form > label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.formula-print-scale-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.formula-print-scale-control input {
  width: 150px;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  font: inherit;
  font-variant-numeric: tabular-nums;
}

.formula-print-scale-control input:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
  outline: none;
}

.sample-workbench {
  max-width: 1040px;
  margin: 0 auto;
}

.sample-workbench-controls {
  align-items: flex-start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.sample-workbench-field {
  display: grid;
  gap: 5px;
}

.sample-workbench-field > label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.sample-component-quantity-group {
  display: flex;
  flex-wrap: wrap;
  flex: 1 1 360px;
  min-width: 0;
  gap: 12px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.sample-component-quantity-group .sample-workbench-field {
  flex: 1 1 140px;
  min-width: 0;
}

.sample-quantity-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sample-quantity-control input {
  width: 150px;
  max-width: 100%;
  min-height: 44px;
  font-variant-numeric: tabular-nums;
}

.sample-workbench-note {
  flex: 1 1 360px;
}

.sample-workbench-note textarea {
  min-height: 44px;
  resize: vertical;
}

.sample-workbench-controls > .button:first-child {
  margin-right: auto;
}

.sample-workbench-controls > button[type="submit"] {
  min-height: 44px;
}

.sample-workbench-hint {
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.sample-print-sheet {
  margin-bottom: 24px;
}

.sample-print-preview-scroll {
  overflow-x: auto;
  padding-bottom: 4px;
}

.sample-preview-notes {
  min-height: 1.5em;
  white-space: pre-wrap;
}

.print-settings {
  max-width: 940px;
  margin: 0 auto 16px;
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.print-settings header {
  margin-bottom: 12px;
}

.print-settings h1 {
  margin: 0;
  font-size: 18px;
}

.print-settings header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.print-settings-grid {
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(180px, 0.7fr) minmax(260px, 1.6fr);
  gap: 12px;
}

.print-settings-grid .wide {
  grid-column: auto;
}

.purchase-print-settings-grid {
  grid-template-columns: minmax(180px, 0.7fr) minmax(300px, 2fr);
}

.print-option-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.print-option-toggles label {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  gap: 7px;
  font-weight: 600;
  cursor: pointer;
}

.print-option-toggles input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.print-sheet {
  margin: 0 auto 32px;
  box-sizing: border-box;
  background: #fff;
  color: #000;
  border: 1px solid #111;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.12);
  font-size: 14px;
  line-height: 1.35;
}

.print-sheet-a4 {
  width: min(210mm, 100%);
  min-height: 297mm;
  padding: 10mm;
}

.print-sheet-a5-landscape {
  width: min(210mm, 100%);
  min-height: 148mm;
  padding: 8mm;
}

.print-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  padding-bottom: 12px;
  border-bottom: 2px solid #000;
}

.print-header.compact {
  padding-bottom: 8px;
}

.print-company {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

.print-header h1 {
  margin: 4px 0 0;
  color: #000;
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: 0;
}

.print-header.compact h1 {
  font-size: 22px;
}

.print-doc-meta {
  display: grid;
  gap: 4px;
  min-width: 190px;
}

.print-doc-meta div,
.print-info-grid div {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 8px;
  align-items: baseline;
}

.print-doc-meta span,
.print-info-grid span,
.print-note-box span {
  color: #000;
  font-weight: 700;
}

.print-doc-meta strong,
.print-info-grid strong {
  color: #000;
  font-weight: 500;
}

.print-info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 20px;
  padding: 12px 0;
}

.print-info-grid.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px 16px;
  padding: 8px 0;
}

.print-info-grid .wide {
  grid-column: span 2;
}

.print-info-grid.compact .wide {
  grid-column: span 3;
}

.print-table {
  width: 100%;
  /* separate + 逐格画线：collapse 表格在 Chrome 打印跨页/缩放时会随机丢边框。
     顶线画在 thead、左边线画在首列，跨页续表时每一页都能闭合边框。 */
  border-collapse: separate;
  border-spacing: 0;
  color: #000;
  font-size: 13px;
}

.print-table th,
.print-table td {
  padding: 7px 7px;
  border-right: 1px solid #000;
  border-bottom: 1px solid #000;
  background: #fff;
  color: #000;
  vertical-align: top;
}

.print-table thead th {
  border-top: 1px solid #000;
}

.print-table th:first-child,
.print-table td:first-child {
  border-left: 1px solid #000;
}

.print-table tbody tr:last-child td {
  border-bottom: 1px solid #000;
}

.print-table th {
  font-weight: 700;
  text-align: left;
}

.print-table .numeric {
  text-align: right;
  white-space: nowrap;
}

.print-table-production th,
.print-table-production td {
  padding: 7px 6px;
  font-size: 12.5px;
}

.production-print-product-summary {
  margin-top: 12px;
}

.production-print-product-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  align-items: baseline;
  color: #000;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.35;
}

.production-print-task-meta {
  padding-top: 9px;
  padding-bottom: 9px;
}

.production-print-task-meta strong {
  font-variant-numeric: tabular-nums;
}

.print-table-production .production-col-code { width: 16%; }
.print-table-production .production-col-name { width: 26%; }
.print-table-production .production-col-supplier { width: 16%; }
.print-table-production .production-col-quantity { width: 14%; }
.print-table-production .production-col-actual-quantity { width: 14%; }
.print-table-production .production-col-batch { width: 14%; }

.print-table-production .production-material-name {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}

.print-table-production .production-actual-quantity-write-cell,
.print-table-production .production-batch-write-cell {
  height: 36px;
}

.print-table-production .production-total-row td {
  vertical-align: middle;
}

.print-table-shipping th,
.print-table-shipping td {
  padding: 7px 6px;
  font-size: 13.5px;
  text-align: center;
  vertical-align: middle;
}

.print-table-shipping .numeric {
  text-align: center;
}

.shipping-print-sheet {
  min-height: 0;
  padding: 7mm;
}

.shipping-print-header {
  position: relative;
  min-height: 36px;
  padding: 0 120px 8px;
  border-bottom: 1px solid #000;
  text-align: center;
}

.shipping-print-company {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.shipping-print-header h1 {
  position: absolute;
  top: 2px;
  right: 0;
  margin: 0;
  color: #000;
  font-size: 18px;
  line-height: 1.2;
}

.shipping-print-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 22px;
  padding: 9px 0 7px;
  font-size: 12.5px;
}

.shipping-print-meta div {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 5px;
}

.shipping-print-meta .wide {
  grid-column: 1 / -1;
}

.shipping-print-meta span,
.shipping-print-meta strong {
  color: #000;
}

.shipping-print-meta strong {
  font-weight: 500;
  overflow-wrap: anywhere;
}

.shipping-print-total td {
  font-weight: 600;
}

.shipping-print-signatures {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 80px;
  padding: 14px 28px 0;
  color: #000;
  font-size: 13px;
  font-weight: 700;
}

.shipping-print-sheet.hide-specification .print-col-specification,
.shipping-print-sheet.hide-batch .print-col-batch,
.shipping-print-sheet.hide-price .print-col-price,
.shipping-print-sheet.hide-line-notes .print-col-line-notes {
  display: none;
}

.shipping-print-sheet.code-mode-customer .print-code-internal,
.shipping-print-sheet.code-mode-internal .print-code-customer {
  display: none;
}

.purchase-print-sheet {
  padding: 11mm;
}

.purchase-print-header {
  position: relative;
  min-height: 42px;
  padding: 0 140px 10px;
  border-bottom: 2px solid #000;
  text-align: center;
}

.purchase-print-company {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.25;
}

.purchase-print-header h1 {
  position: absolute;
  top: 3px;
  right: 0;
  margin: 0;
  color: #000;
  font-size: 20px;
  line-height: 1.2;
}

.purchase-print-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 24px;
  padding: 13px 0 11px;
  color: #000;
  font-size: 13px;
}

.purchase-print-meta div {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 6px;
}

.purchase-print-meta .wide {
  grid-column: 1 / -1;
}

.purchase-print-meta span {
  font-weight: 700;
}

.purchase-print-meta strong {
  color: #000;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.purchase-print-table th,
.purchase-print-table td {
  padding: 7px 7px;
  font-size: 12px;
}

.purchase-print-total td {
  font-weight: 600;
}

.purchase-print-signatures {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 80px;
  padding-top: 24px;
  color: #000;
  font-size: 13px;
  font-weight: 700;
}

.purchase-print-sheet.hide-specification .print-col-specification,
.purchase-print-sheet.hide-price .print-col-price,
.purchase-print-sheet.hide-receipt .print-col-receipt,
.purchase-print-sheet.hide-line-notes .print-col-line-notes {
  display: none;
}

.formula-version-print-sheet {
  padding: 10mm;
  color: #000;
  overflow-x: hidden;
}

.formula-version-print-header {
  padding-bottom: 9px;
  border-bottom: 2px solid #000;
  text-align: center;
}

.formula-version-print-header > div {
  font-size: 18px;
  font-weight: 700;
}

.formula-version-print-header h1 {
  margin: 3px 0 0;
  color: #000;
  font-size: 24px;
}

.formula-version-print-meta {
  padding: 10px 0;
  color: #000;
}

.formula-version-print-meta div {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 5px;
}

.formula-version-print-meta span {
  font-weight: 700;
}

.formula-version-print-meta strong {
  color: #000;
  font-weight: 500;
}

.formula-version-print-requirements {
  margin-top: 0;
  padding: 8px 0 10px;
  border-top: 1px solid #000;
}

.formula-version-print-requirements .wide {
  grid-column: 1 / -1;
}

.formula-version-print-requirements strong {
  color: #000;
  font-weight: 500;
  white-space: normal;
}

.formula-version-print-table th,
.formula-version-print-table td {
  padding: 5px 6px;
  font-size: 11.5px;
  vertical-align: middle;
}

.formula-version-print-component {
  margin-top: 10px;
  overflow-x: auto;
  break-inside: avoid;
}

.formula-version-print-component h2 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0;
  padding: 5px 7px;
  border: 1px solid #000;
  border-bottom: 0;
  color: #000;
  font-size: 14px;
}

.formula-version-print-component h2 small {
  color: #000;
  font-size: 11px;
  font-weight: 500;
}

.formula-version-print-component .print-table {
  margin-top: 0;
}

.formula-version-component-total td {
  background: #f3f3f3;
  text-align: right;
}

.formula-version-print-notes {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.formula-version-print-notes > div {
  padding: 7px 8px;
  border: 1px solid #000;
  break-inside: avoid;
}

.formula-version-print-notes p {
  margin: 3px 0 0;
  color: #000;
  white-space: pre-wrap;
}

.formula-version-print-signatures {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-top: 18px;
  color: #000;
  font-weight: 700;
  break-inside: avoid;
}

.signature-cell {
  min-width: 46px;
  height: 34px;
}

.print-empty {
  text-align: center;
}

.print-note-box {
  min-height: 54px;
  margin-top: 12px;
  padding: 8px;
  border: 1px solid #000;
}

.print-note-box p {
  margin: 6px 0 0;
  color: #000;
  white-space: pre-wrap;
}

.print-signatures {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-top: 18px;
  color: #000;
  font-weight: 700;
}

.print-signatures.compact {
  grid-template-columns: repeat(4, 1fr);
  margin-top: 14px;
}

.clipboard-image-capture {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px 14px;
  align-items: center;
  margin: 0 0 20px;
  padding: 14px 16px;
  color: var(--c-research);
  background: linear-gradient(110deg, var(--c-research-soft), var(--panel));
  border: 1px dashed color-mix(in srgb, var(--c-research) 38%, var(--line));
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.clipboard-image-capture:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--c-research) 28%, transparent);
  outline-offset: 2px;
}

.clipboard-image-capture[aria-busy="true"] { opacity: 0.72; }

.clipboard-image-capture__mark {
  min-width: 42px;
  padding: 6px 8px;
  border: 1px solid color-mix(in srgb, var(--c-research) 26%, var(--line));
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--c-research);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: center;
}

.clipboard-image-capture__body { display: grid; gap: 1px; min-width: 0; }
.clipboard-image-capture__body strong { font-size: 15px; color: var(--ink); }
.clipboard-image-capture__body span { color: var(--muted); font-size: 13px; }
.clipboard-image-capture__fallback { font-weight: 600; white-space: nowrap; }

.clipboard-image-capture__status,
.clipboard-image-capture__preview {
  grid-column: 2 / -1;
  margin: 0;
}

.clipboard-image-capture__status { min-height: 1.3em; color: var(--muted); font-size: 13px; }
.clipboard-image-capture__status[data-state="success"] { color: var(--c-purchase); }
.clipboard-image-capture__status[data-state="error"] { color: var(--c-danger); }

.clipboard-image-capture__preview,
.clipboard-image-attachment-list { display: flex; flex-wrap: wrap; gap: 8px; }
.clipboard-image-capture__thumbnail {
  display: block;
  width: 88px;
  height: 62px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
}
.clipboard-image-capture__thumbnail img { width: 100%; height: 100%; object-fit: cover; }
.clipboard-image-attachment-list a {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
}

@media (max-width: 680px) {
  .clipboard-image-capture { grid-template-columns: auto minmax(0, 1fr); }
  .clipboard-image-capture__fallback { grid-column: 2; justify-self: start; }
  .clipboard-image-capture__status,
  .clipboard-image-capture__preview { grid-column: 1 / -1; }
}

@media print {
  .sidebar,
  .messages,
  .print-toolbar,
  .print-settings,
  .feedback-trigger,
  .feedback-dialog {
    display: none !important;
  }

  .sample-record-screen-only,
  .sample-workbench-hint {
    display: none !important;
  }

  .sample-print-preview-scroll {
    overflow: visible;
    padding: 0;
  }

  body,
  .app-shell,
  .main {
    display: block;
    min-height: auto;
    margin: 0;
    padding: 0;
    background: #fff;
  }

  .print-sheet {
    width: auto;
    min-height: 0;
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .print-table {
    table-layout: fixed;
  }

  .formula-version-print-component {
    overflow: visible;
  }

  .formula-version-print-sheet {
    overflow: visible;
  }

  .print-table thead {
    display: table-header-group;
  }

  .print-table tr,
  .print-table th,
  .print-table td {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .print-note-box,
  .print-signatures {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

@media (max-width: 720px) {
  .print-toolbar {
    align-items: stretch;
  }

  .formula-print-scale-form {
    width: 100%;
    margin-right: 0;
  }

  .formula-print-scale-control input {
    flex: 1;
    min-width: 0;
  }

  .print-settings-grid {
    grid-template-columns: 1fr;
  }

  .print-settings-grid .field {
    grid-column: auto;
  }

  .print-option-toggles label {
    min-height: 44px;
  }

  .sample-workbench-controls {
    display: grid;
    grid-template-columns: 1fr;
  }

  .sample-workbench-controls > .button:first-child {
    margin-right: 0;
  }

  .sample-workbench-note,
  .sample-quantity-control input {
    width: 100%;
  }

  .sample-workbench-hint {
    text-align: left;
  }

  .sample-print-sheet {
    min-width: 760px;
  }
}

/* ── Line items (sales order) ─────────────────────────── */

.lines-section {
  border: none;
  background: transparent;
  padding: 0;
  margin: 8px 0 0;
  min-width: 0;
}

.lines-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.lines-header h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.lines-help {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 12px;
}

.lines-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

.lines-table-wrap table {
  min-width: 1040px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--panel);
}

.lines-table-wrap thead {
  background: #f8f9fa;
}

.lines-table-wrap th {
  font-weight: 600;
  font-size: 12px;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.lines-table-wrap td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.lines-table-wrap tbody tr:last-child td {
  border-bottom: none;
}

.lines-table-wrap .col-sales-product { width: 240px; min-width: 240px; }
.lines-table-wrap .col-quantity { width: 110px; min-width: 110px; }
.lines-table-wrap .col-unit-price { width: 170px; min-width: 170px; }
.lines-table-wrap .col-notes { width: 280px; min-width: 280px; }
.lines-table-wrap .col-action { width: 5%; text-align: right; }

.sales-order-editor input[name$="-notes"] {
  min-width: 250px;
}

.customer-product-cell { min-width: 150px; }
.customer-product-toggle { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; font-size: 12px; color: var(--text-muted, #667085); }
.customer-product-fields { margin-top: 6px; display: grid; gap: 4px; }
.customer-product-fields input { width: 100%; }

.checkbox-cell input {
  width: auto;
  min-height: auto;
}

.field-error,
.form-errors {
  color: var(--danger);
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.actions.left {
  justify-content: flex-start;
}

.sales-order-editor input[name$="-unit_price"],
.sales-order-editor .line-price-hint {
  min-width: 150px;
  text-align: right;
}

/* Keep numeric validation and decimal keyboards without the easy-to-misclick steppers. */
input.no-number-spinner {
  appearance: textfield;
  -moz-appearance: textfield;
}

input.no-number-spinner::-webkit-inner-spin-button,
input.no-number-spinner::-webkit-outer-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.sales-order-editor .line-price-hint {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  white-space: normal;
}

.mobile-field-label,
.mobile-selected-value {
  display: none;
}

@media (max-width: 640px) {
  .business-form .line-form-table {
    overflow: visible;
  }

  .business-form .line-form-table table {
    min-width: 0;
    width: 100%;
  }

  .business-form .line-form-table thead {
    display: none;
  }

  .business-form .line-form-table tr {
    display: grid;
    gap: 10px;
    padding: 12px;
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
  }

  .business-form .line-form-table tr.additional-empty-allocation {
    display: none;
  }

  .business-form .line-form-table td {
    display: block;
    border: 0;
    padding: 0;
    min-width: 0;
  }

  .business-form .line-form-table .mobile-field-label {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
  }

  .business-form .line-form-table input,
  .business-form .line-form-table select,
  .business-form .line-form-table textarea,
  .business-form .line-form-table .autocomplete-select,
  .business-form .line-form-table .autocomplete-input {
    width: 100%;
    min-width: 0;
    min-height: 44px;
  }

  .business-form .line-form-table textarea {
    min-height: 72px;
  }

  .sales-order-editor .lines-table-wrap table {
    min-width: 980px;
  }

  .sales-order-editor input,
  .sales-order-editor .autocomplete-input {
    min-height: 44px;
  }

  .detail-section form .table-wrap table {
    min-width: 0;
  }

  .detail-section form .table-wrap thead {
    display: none;
  }

  .detail-section form .table-wrap tr {
    display: grid;
    gap: 10px;
    padding: 12px;
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
  }

  .detail-section form .table-wrap td {
    display: block;
    border: 0;
    padding: 0;
  }

  .detail-section form .table-wrap .mobile-field-label {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
  }

  .detail-section form .table-wrap .mobile-selected-value {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .detail-section form .table-wrap input,
  .detail-section form .table-wrap select,
  .detail-section form .table-wrap textarea,
  .detail-section form .table-wrap .autocomplete-select,
  .detail-section form .table-wrap .autocomplete-input {
    width: 100%;
    min-height: 44px;
    white-space: normal;
  }

  .detail-section form .table-wrap .autocomplete-input {
    text-overflow: clip;
  }

  .detail-section form .table-wrap .mobile-delete-cell label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    color: var(--muted);
  }

  .detail-section form .table-wrap .mobile-delete-cell input[type="checkbox"] {
    width: 18px;
    min-height: 18px;
    height: 18px;
  }

  .detail-section form.business-form .actions button,
  .detail-section form.business-form .actions .button {
    min-height: 44px;
  }
}

/* ── Detail sections ──────────────────────────────────── */

.detail-section {
  margin-bottom: 28px;
}

.detail-section:last-child {
  margin-bottom: 0;
}

.detail-section > h2 {
  font-size: 16px;
  font-weight: 650;
  margin-bottom: 14px;
  color: var(--ink);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.detail-grid > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.detail-grid span {
  color: var(--muted);
  font-size: 12px;
}

.detail-grid strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.detail-grid .wide {
  grid-column: 1 / -1;
}

.detail-grid p {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
}

/* Section headers with actions */
.section-header,
.component-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 28px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
}

.section-header h2 {
  font-size: 16px;
  margin: 0;
  padding: 0;
  border: none;
}

.component-panel {
  margin-bottom: 14px;
  padding: 0;
  overflow: hidden;
}

.component-panel header {
  margin: 0;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.component-panel h3,
.component-panel p {
  margin: 0;
}

/* Detail actions bar */
.detail-actions {
  margin-top: 14px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Messages ─────────────────────────────────────────── */

.messages {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.message {
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--success-soft);
  color: #155b2f;
  border: 1px solid #b8dfc8;
}

/* ── Utility classes ──────────────────────────────────── */

.text-muted {
  color: var(--muted);
  font-size: 13px;
}

.text-warning {
  color: var(--warning);
  font-weight: 500;
}

.text-danger {
  color: var(--danger);
}

.text-success {
  color: var(--success);
}

/* Warning panel */
.danger-panel {
  border-color: #f3b7b2;
}

/* Detail warning box */
.detail-warning {
  background: var(--warning-soft);
  border: 1px solid #f5dfa0;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: #92600a;
  font-size: 13px;
  margin: 8px 0;
}

/* ── Role toggles ─────────────────────────────────────── */

.role-toggles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.role-toggle-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: .2s;
  border-radius: 22px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .2s;
  border-radius: 50%;
}

input:checked + .toggle-slider {
  background-color: var(--accent);
}

/* Role-specific toggle colors (muted) */
.role-toggle-item input[data-role="can_purchase"]:checked + .toggle-slider {
  background-color: #1e6a8a;
}

.role-toggle-item input[data-role="can_sell"]:checked + .toggle-slider {
  background-color: #1a6940;
}

.role-toggle-item input[data-role="can_produce"]:checked + .toggle-slider {
  background-color: #6b3fa0;
}

.role-toggle-item input[data-role="can_formula_input"]:checked + .toggle-slider {
  background-color: #8a5e12;
}

input:checked + .toggle-slider:before {
  transform: translateX(18px);
}

input:disabled + .toggle-slider {
  opacity: 0.5;
  cursor: not-allowed;
}

.toggle-switch.loading .toggle-slider {
  opacity: 0.7;
}

.toggle-label {
  font-size: 13px;
  color: var(--ink);
  user-select: none;
  font-weight: 500;
}

/* Role inactive note */
.role-inactive-note {
  padding: 12px 14px;
  background: var(--panel-soft);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.role-inactive-note p {
  margin: 0;
}

/* ── Formula summary ──────────────────────────────────── */

.formula-summary-box {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.formula-summary-box h3 {
  font-size: 14px;
  margin: 0 0 8px;
  color: var(--ink);
}

.formula-summary {
  padding: 10px 14px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--muted);
}

.component-total {
  padding: 4px 0;
  font-size: 13px;
}

.component-total strong {
  color: var(--ink);
}

.total-value {
  color: var(--accent-dark);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.warning-text {
  color: var(--warning);
  font-size: 13px;
}

.help-text {
  color: var(--muted);
  font-size: 13px;
  margin: 8px 0 0;
}

/* ── Allocation group (shipping) ──────────────────────── */

.shipping-confirm-form {
  max-width: 1040px;
}

.shipping-confirm-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.shipping-confirm-card-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--panel-soft);
}

.shipping-confirm-card-header h2 {
  margin: 2px 0 0;
  font-size: 20px;
  line-height: 1.3;
}

.shipping-confirm-card-header p,
.shipping-product-name p,
.shipping-batch-row p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.shipping-eyebrow {
  display: block;
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.shipping-date-field {
  width: 170px;
  flex: 0 0 170px;
}

.shipping-date-field input {
  min-height: 40px;
}

.shipping-check-item {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line-soft);
}

.shipping-check-item:last-child {
  border-bottom: 0;
}

.shipping-product-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: start;
}

.shipping-product-name h3 {
  margin: 2px 0 0;
  font-size: 16px;
  line-height: 1.35;
}

.shipping-quantity {
  min-width: 118px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.shipping-quantity strong {
  margin-right: 5px;
  color: var(--ink);
  font-size: 22px;
  line-height: 1.25;
}

.shipping-quantity small {
  color: var(--muted);
}

.shipping-batch-result {
  display: grid;
  gap: 6px;
  margin-top: 14px;
}

.shipping-batch-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: var(--success-soft);
}

.shipping-batch-row strong {
  font-weight: 650;
}

.shipping-match-mark {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  font-size: 12px;
  font-weight: 750;
}

.shipping-batch-warning {
  background: var(--warning-soft);
}

.shipping-batch-warning .shipping-match-mark {
  background: var(--warning);
}

.shipping-adjustments,
.shipping-document-more {
  margin-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.shipping-adjustments > summary,
.shipping-document-more > summary {
  min-height: 42px;
  padding: 10px 2px;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.shipping-adjustments[open] > summary,
.shipping-document-more[open] > summary {
  color: var(--ink);
}

.shipping-adjustments-body {
  display: grid;
  gap: 12px;
  padding: 4px 0 2px;
}

.shipping-document-more {
  max-width: 1040px;
  padding: 0 20px 14px;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--panel);
}

.shipping-document-more textarea {
  min-height: 72px;
}

.shipping-confirm-actions {
  align-items: center;
  margin-top: 20px;
}

.shipping-confirm-actions button {
  min-width: 132px;
  min-height: 44px;
  font-weight: 650;
}

.allocation-group {
  margin-bottom: 20px;
}

@media (max-width: 640px) {
  .shipping-confirm-card-header {
    display: grid;
    gap: 14px;
    padding: 16px;
  }

  .shipping-date-field {
    width: 100%;
  }

  .shipping-check-item {
    padding: 16px;
  }

  .shipping-product-summary {
    gap: 12px;
  }

  .shipping-quantity {
    min-width: 88px;
  }

  .shipping-quantity strong {
    font-size: 18px;
  }

  .shipping-document-more {
    padding-right: 16px;
    padding-left: 16px;
  }

  .shipping-confirm-actions button {
    width: 100%;
  }
}

.allocation-group-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding: 10px 14px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.allocation-group-header h3 {
  margin: 0;
  font-size: 14px;
}

.allocation-group-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.untracked-shipping-panel {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--warning);
  border-radius: var(--radius-sm);
  background: var(--warning-soft);
}

.untracked-shipping-confirm {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}

.untracked-shipping-confirm input {
  margin-top: 3px;
}

.untracked-shipping-confirm span {
  display: grid;
  gap: 2px;
}

.untracked-shipping-confirm small {
  color: var(--muted);
}

.handoff-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 16px 0;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
}

.handoff-status p {
  margin: 3px 0 0;
}

/* ── Search select ────────────────────────────────────── */

.search-select {
  position: relative;
  display: inline-block;
  width: 100%;
}

.search-select-input {
  width: 100%;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--panel);
  box-sizing: border-box;
}

.search-select-input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 125, 143, 0.1);
}

.search-select-source {
  display: none;
}

/* ── Formula editor ───────────────────────────────────── */

.formula-editor {
  max-width: 1180px;
}

.formula-doses {
  display: grid;
  gap: 14px;
}

.dose-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fbfcfd;
}

.dose-header {
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: #f9fbfc;
}

.dose-panel .line-form-table {
  background: var(--panel);
}

.dose-addition-control {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  min-height: 38px;
}

.dose-addition-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  white-space: nowrap;
  font-size: 14px;
}

.dose-addition-option input[type="radio"] { margin: 0; }

.dose-percent-input {
  display: inline-flex;
  align-items: stretch;
  width: 118px;
}

.dose-percent-input input {
  min-width: 0;
  width: 84px;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.dose-percent-suffix {
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--panel-soft);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.dose-percent-input input:disabled + .dose-percent-suffix {
  color: var(--text-disabled, #98a2b3);
  background: var(--surface-disabled, #f2f4f7);
}

.dose-addition-legacy {
  flex-basis: 100%;
  color: var(--warning-text, #9a6700);
}

.hidden-cell {
  display: none;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.formula-row-drag-heading,
.formula-row-drag-cell {
  width: 38px;
  min-width: 38px;
  padding-left: 5px !important;
  padding-right: 5px !important;
  text-align: center;
}

.formula-row-drag-handle {
  display: inline-grid;
  place-items: center;
  width: 28px;
  min-height: 34px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: grab;
  touch-action: none;
  font-size: 20px;
  line-height: 1;
}

.formula-row-drag-handle:hover,
.formula-row-drag-handle:focus-visible {
  background: var(--panel-soft);
  color: var(--ink);
}

.formula-row-drag-handle:active { cursor: grabbing; }
.formula-editor tr[data-form-row] { transition: opacity 120ms ease, box-shadow 120ms ease; }
.formula-editor tr[data-form-row].is-dragging {
  opacity: 0.55;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.16);
}

@media (max-width: 640px) {
  .formula-editor .line-form-table tr[data-form-row] {
    position: relative;
    padding-right: 52px;
  }

  .business-form .line-form-table .formula-row-drag-cell {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 36px;
    min-width: 36px;
  }
}

.icon-button {
  min-height: 30px;
  padding: 0 8px;
  background: #f1f5f9;
  color: var(--ink);
  font-size: 12px;
}

/* ── Multi-picker ─────────────────────────────────────── */

.multi-picker {
  position: relative;
  display: grid;
  gap: 8px;
}

.multi-picker-results {
  position: absolute;
  z-index: 25;
  top: 42px;
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-md);
}

.multi-picker-selected {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 32px;
}

.multi-picker-chip {
  min-height: 26px;
  border-radius: 4px;
  padding: 2px 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
}

.material-filter-workbench {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(360px, 2fr) minmax(150px, 0.7fr) auto;
  align-items: end;
  gap: 12px;
  margin: 16px 0;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--panel);
}

.material-filter-workbench label,
.material-role-filter {
  margin: 0;
}

.material-filter-search,
.material-status-filter {
  display: grid;
  gap: 6px;
}

.material-filter-search > span,
.material-status-filter > span,
.material-role-filter legend {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.material-role-filter {
  min-width: 0;
  padding: 0;
  border: 0;
}

.material-role-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.material-role-options label {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  cursor: pointer;
}

.material-role-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.material-role-options label:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.material-role-options label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 600;
}

.material-filter-actions {
  display: flex;
  gap: 8px;
}

.material-filter-workbench.is-submitting {
  opacity: 0.7;
  pointer-events: none;
}

@media (max-width: 900px) {
  .material-filter-workbench {
    grid-template-columns: 1fr;
  }

  .material-filter-actions > * {
    flex: 1;
  }
}

/* ── Workbench ────────────────────────────────────────── */

.workbench-section {
  margin-bottom: 28px;
}

.workbench-section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
}

.workbench-section-header h2 {
  font-size: 16px;
  margin: 0;
  color: var(--ink);
}

.workbench-section-header .workbench-count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.workbench-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.workbench-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.workbench-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.workbench-card-header a {
  font-weight: 600;
  font-size: 14px;
}

.workbench-card-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.workbench-card-meta .tag {
  min-height: 22px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent-dark);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  border: 1px solid transparent;
}

.workbench-card-body {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.workbench-card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.workbench-card-actions form {
  display: inline;
  margin: 0;
}

.workbench-card-actions button,
.workbench-card-actions .button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.workbench-empty {
  color: var(--muted);
  font-style: italic;
  padding: 16px;
  text-align: center;
  background: var(--panel-soft);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--line);
}

.workbench-intro {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 14px;
}

/* ── Compat notice ────────────────────────────────────── */

.compat-notice {
  background: var(--warning-soft);
  border: 1px solid #f5dfa0;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  color: #92600a;
}

.compat-notice strong {
  color: var(--ink);
}

.compat-notice a {
  color: var(--accent);
  text-decoration: underline;
}

/* ── Empty state（解释原因 + 下一步） ─────────────────── */

.empty-state {
  background: var(--panel-soft);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
  color: var(--muted);
}

.empty-state-title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.empty-state-hint {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted);
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}

.empty-state .button {
  margin-top: 4px;
}

/* ── Status pill 语义映射 ─────────────────────────────── */

.pill-status-ops { background: var(--c-ops-soft); color: var(--c-ops); border-color: #c4dede; }
.pill-status-sales { background: var(--c-sales-soft); color: var(--c-sales); border-color: #cdddec; }
.pill-status-purchase { background: var(--c-purchase-soft); color: var(--c-purchase); border-color: #c7dccd; }
.pill-status-produce { background: var(--c-produce-soft); color: var(--c-produce); border-color: #d6cee6; }
.pill-status-research { background: var(--c-research-soft); color: var(--c-research); border-color: #e3d2dd; }
.pill-status-production { background: var(--c-produce-soft); color: #5b4a83; border-color: #cfc4e2; }

/* ── Alert（统一消息：warning/error/info） ────────────── */

.alert {
  margin: 16px 0;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.alert h3 { margin: 0 0 8px; font-size: 14px; font-weight: 600; }
.alert ul { margin: 0; padding-left: 20px; }
.alert-warning { background: var(--c-warning-soft); border-color: var(--c-warning); }
.alert-warning h3 { color: var(--c-warning); }
.alert-error { background: var(--c-danger-soft); border-color: var(--c-danger); }
.alert-error h3 { color: var(--c-danger); }
.alert-info { background: var(--panel-soft); border-color: var(--line); }

/* ── 行内信息（销售订单行等产品摘要） ────────────────── */

.line-info { line-height: 1.4; }
.line-primary { font-weight: 600; }
.line-meta { font-size: 12px; }
.inline-form { display: inline; margin: 0; padding: 0; }

/* ── 销售履约工作台（销售订单详情） ──────────────────── */

.summary-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0 24px;
}

.summary-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 120px;
  flex: 1 1 120px;
  background: var(--panel-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.summary-item span {
  color: var(--muted);
  font-size: 12px;
}

.summary-item strong {
  color: var(--ink);
  font-size: 15px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

/* 状态色变体：让待生产行/待出库行/缺配方 摘要卡带语义底色 */
.summary-item.pill-status-warning { background: var(--warning-soft); border-color: #f5dfa0; }
.summary-item.pill-status-sales { background: var(--c-sales-soft); border-color: #cdddec; }
.summary-item.pill-status-danger { background: var(--danger-soft); border-color: #f0bdb7; }

.status-cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.status-band,
.analytics-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  margin: 14px 0 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--line);
}

.status-band > div,
.analytics-summary > div {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 12px 14px;
  background: #f8fbfc;
}

.status-band span,
.analytics-summary span {
  color: var(--muted);
  font-size: 12px;
}

.status-band strong,
.analytics-summary strong {
  overflow-wrap: anywhere;
  font-size: 15px;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
}

.segmented a {
  padding: 6px 10px;
  border-radius: 4px;
  color: var(--muted);
}

.segmented a.active {
  color: var(--accent-dark);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.formula-content-choice {
  margin-bottom: 12px;
}

.formula-content-choice .field,
.formula-reference-inline .field {
  max-width: 360px;
}

.formula-reference-inline {
  padding: 14px 0 2px;
}

.formula-reference-inline .related-note {
  margin: 8px 0 0;
}

.sidebar-account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 20px;
  padding: 12px 6px 0;
  border-top: 1px solid var(--line-soft);
}

.sidebar-account form { margin: 0; }

.auth-shell {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 64px);
}

.auth-panel { width: min(420px, 100%); }
.auth-panel h1 { margin-top: 0; }

/* 下一步动作卡片网格（卡片本体复用 .workbench-card） */
.next-action-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}

.next-action-list .workbench-card {
  margin-bottom: 0;
}

/* 销售产品明细：先呈现产品、数量和价格，再呈现履约信息 */
.fulfillment-table {
  table-layout: auto;
  min-width: 1190px;
}

.fulfillment-table th {
  white-space: nowrap;
}

.fulfillment-table .sales-product-column { min-width: 280px; }
.fulfillment-table .sales-selection-column { min-width: 108px; text-align: center; }
.fulfillment-table .sales-quantity-column { min-width: 118px; }
.fulfillment-table .sales-price-column { min-width: 128px; }
.fulfillment-table .sales-amount-column { min-width: 140px; }
.fulfillment-table .sales-progress-column { min-width: 126px; }
.fulfillment-table .sales-action-column { min-width: 170px; }

.sales-line-product {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.sales-line-product-main {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: baseline;
  gap: 2px 7px;
  width: 100%;
  color: var(--ink);
  white-space: nowrap;
}

.sales-line-product-main:hover {
  color: var(--accent);
  text-decoration: none;
}

.sales-line-product-code {
  color: var(--c-sales);
  font-size: 16px;
  font-weight: 680;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}

.sales-line-product-name {
  font-size: 16px;
  font-weight: 680;
  line-height: 1.35;
}

.sales-line-product-separator {
  color: var(--muted-2);
  font-size: 14px;
}

.sales-line-product-spec {
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.35;
}

.sales-line-customer-ref {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  color: var(--muted);
  font-size: 12px;
}

.sales-line-customer-ref span {
  color: var(--muted-2);
}

.sales-line-customer-ref strong {
  color: var(--ink);
  font-weight: 600;
}

.sales-line-product-meta {
  border-top: 1px solid var(--line-soft);
  padding-top: 5px;
}

.sales-selection-cell {
  width: 108px;
  text-align: center;
  vertical-align: middle;
}

.production-selection {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 6px 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.production-selection:hover {
  background: var(--panel-soft);
  border-color: var(--line);
  color: var(--ink);
}

.production-selection input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

.production-selection-mark {
  display: grid;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
  box-shadow: inset 0 1px 1px rgba(29, 48, 61, 0.04);
}

.production-selection-mark::after {
  width: 8px;
  height: 4px;
  border: solid transparent;
  border-width: 0 0 2px 2px;
  content: "";
  transform: rotate(-45deg) translate(1px, -1px);
}

.production-selection input:checked + .production-selection-mark {
  border-color: var(--c-produce);
  background: var(--c-produce);
}

.production-selection input:checked + .production-selection-mark::after {
  border-color: #fff;
}

.production-selection:has(input:checked) {
  border-color: #cfc4e2;
  background: var(--c-produce-soft);
  color: var(--c-produce);
}

.production-selection input:focus-visible + .production-selection-mark {
  outline: 3px solid color-mix(in srgb, var(--accent) 28%, transparent);
  outline-offset: 2px;
}

.production-selection-unavailable {
  color: var(--muted-2);
}

.fulfillment-route-decisions {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin: 1px 0 2px;
}

.fulfillment-route-decisions form {
  flex: 1 1 0;
  margin: 0;
}

.paired-route-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.paired-route-actions > a,
.paired-route-actions > form {
  width: 100%;
  min-width: 0;
}

.paired-route-actions > a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.route-decision {
  box-sizing: border-box;
  width: 100%;
  min-height: 44px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.2;
  box-shadow: none;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.12s ease;
}

.route-decision:hover {
  background: var(--panel-soft);
  border-color: var(--muted-2);
  color: var(--ink);
  box-shadow: none;
}

.route-decision:active {
  transform: scale(0.97);
}

.route-decision-production.is-selected {
  background: var(--c-produce-soft);
  border-color: #cfc4e2;
  color: var(--c-produce);
}

.route-decision-primary {
  border-color: var(--c-produce);
  background: var(--c-produce);
  color: #fff;
}

.route-decision-primary:hover {
  border-color: var(--c-produce);
  background: var(--c-produce);
  color: #fff;
  filter: brightness(0.94);
}

.route-decision-warehouse.is-selected {
  background: var(--c-sales-soft);
  border-color: #cdddec;
  color: var(--c-sales);
}

.route-decision:disabled {
  background: var(--panel-soft);
  border-color: var(--line-soft);
  color: var(--muted-2);
  cursor: not-allowed;
  opacity: 0.65;
  transform: none;
}

.action-formula,
.action-formula:hover {
  border-color: #ead39d;
  background: #fff7e6;
  color: #845912;
}

.action-direct-shipping,
.action-direct-shipping:hover {
  border-color: #bcded8;
  background: #edf8f6;
  color: #246c64;
}

.action-warehouse,
.action-warehouse:hover {
  border-color: #c5dceb;
  background: #edf5fb;
  color: #316f99;
}

.action-production,
.action-production:hover {
  border-color: #c8dfd0;
  background: #eef7f1;
  color: #2d7150;
}

.sales-line-metric {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  white-space: nowrap;
}

.sales-line-metric strong {
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

.sales-line-metric span {
  color: var(--muted);
  font-size: 12px;
}

.sales-line-amount strong {
  color: var(--c-sales);
}

/* 行内堆叠：订购/生产/出库 */
.quantity-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
}

.quantity-stack div {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.quantity-stack span {
  color: var(--muted);
  font-size: 12px;
  min-width: 3.5em;
}

.quantity-stack strong {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ink);
}

.sales-line-progress {
  padding-left: 10px;
  border-left: 2px solid var(--line);
}

/* 行内动作堆叠：仅一个强主动作 + 弱化的修改数量 */
.line-action-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

/* 关联与查证区统一降级 */
.related-group {
  margin-top: 36px;
  padding-top: 20px;
  border-top: 1px solid var(--line-soft);
}

.related-group-title {
  font-size: 14px;
  font-weight: 650;
  color: var(--muted);
  margin: 0 0 16px;
  text-transform: none;
  letter-spacing: 0;
}

.related-group .section-header {
  margin-top: 20px;
}

.related-note {
  color: var(--muted);
  font-size: 13px;
  margin: -6px 0 10px;
}

/* ── Global feedback ─────────────────────────────────── */

.feedback-trigger {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  min-width: 104px;
  min-height: 44px;
  border: 1px solid var(--c-ops);
  background: var(--panel);
  color: var(--c-ops);
  box-shadow: var(--shadow-md);
}

.feedback-trigger:hover {
  background: var(--c-ops-soft);
}

.feedback-dialog {
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  margin: auto 20px 20px auto;
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 18px 48px rgba(22, 42, 56, 0.2);
}

.feedback-dialog::backdrop {
  background: rgba(23, 33, 43, 0.28);
}

.feedback-dialog-header,
.feedback-dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
}

.feedback-dialog-header {
  border-bottom: 1px solid var(--line-soft);
}

.feedback-dialog-header h2 {
  margin: 0;
  font-size: 18px;
}

.feedback-dialog-header p {
  margin: 2px 0 0;
  color: var(--muted);
}

.feedback-close {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 26px;
  line-height: 1;
}

.feedback-close:hover {
  background: var(--panel-soft);
  color: var(--ink);
}

.feedback-dialog-body {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.feedback-dialog-body textarea {
  min-height: 132px;
  resize: vertical;
}

.feedback-dialog-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--line-soft);
  background: var(--panel-soft);
}

.feedback-table {
  min-width: 1080px;
}

.feedback-table code {
  color: var(--muted);
  white-space: normal;
  overflow-wrap: anywhere;
}

.feedback-content {
  min-width: 280px;
  max-width: 520px;
  white-space: normal;
}

.feedback-source-detail {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  background: var(--line);
}

.feedback-source-detail > div {
  padding: 14px 16px;
  background: var(--panel);
}

.feedback-source-detail .wide {
  grid-column: 1 / -1;
}

.feedback-source-detail span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.feedback-source-detail p {
  margin: 4px 0 0;
}

/* ── Responsive ───────────────────────────────────────── */

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  /* 侧栏改为离画布菜单：顶栏菜单按钮打开，容纳目录/板块/反馈/账户 */
  .sidebar {
    position: fixed;
    z-index: 60;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(320px, 86vw);
    height: 100dvh;
    transform: translateX(-104%);
    transition: transform 0.22s ease;
  }

  body.mobile-menu-open .sidebar {
    transform: translateX(0);
    box-shadow: 12px 0 40px rgba(22, 42, 56, 0.18);
  }

  .mobile-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(23, 33, 43, 0.32);
  }

  body.mobile-menu-open .mobile-menu-backdrop {
    display: block;
  }

  .sidebar-feedback {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 9px 10px;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
    background: #f2f6f7;
    color: #31424f;
    font-size: 14px;
    text-align: left;
  }

  /* 顶栏单行：GQ + 横滑页签 + 菜单 */
  .workspace-mobile-brand {
    display: grid;
    place-items: center;
    padding-left: 6px;
  }

  .workspace-mobile-brand .brand-mark {
    width: 30px;
    height: 30px;
    font-size: 12px;
  }

  .workspace-menu-button {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    margin-right: 4px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
  }

  .workspace-tabs-bar {
    align-items: center;
    gap: 6px;
    padding: 8px 6px;
  }

  .workspace-tabs-scroll {
    flex: 1 1 auto;
    scrollbar-width: none;
  }

  /* 页签变胶囊芯片 */
  .workspace-tabs {
    align-items: center;
    gap: 6px;
  }

  .workspace-tab {
    width: auto;
    max-width: 150px;
    height: 30px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
  }

  .workspace-tab.active {
    border-color: var(--c-ops);
    border-bottom-color: var(--c-ops);
    background: var(--c-ops-soft);
    color: var(--c-ops);
    box-shadow: none;
  }

  .workspace-tab.workspace-tab-research.active {
    border-color: var(--c-research);
    border-bottom-color: var(--c-research);
    background: var(--c-research-soft);
    color: #5f4051;
  }

  .workspace-tab-main {
    padding: 0 4px 0 12px;
    font-size: 12px;
  }

  .workspace-tab-close {
    flex-basis: 24px;
    width: 24px;
    height: 24px;
  }

  /* 反馈入口在移动端收进菜单，不再悬浮占位 */
  .feedback-trigger {
    display: none;
  }

  .workspace {
    grid-template-rows: 48px minmax(0, 1fr);
  }

  .main {
    padding: 16px;
  }

  .page-header {
    flex-direction: row;
    align-items: flex-start;
  }

  .page-header > div:first-child {
    flex: 1 0 100%;
    width: 100%;
  }

  .page-header > .button:first-of-type,
  .page-header > .actions,
  .page-header > .page-actions {
    margin-left: 0;
  }

  .page-header .actions,
  .page-header .page-actions,
  .page-header .archive-card-actions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .status-toolbar {
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .status-toolbar a:not(.button) {
    flex: 0 0 auto;
    white-space: nowrap;
  }
}

.table-subline {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.4;
}

.sample-complete-form {
  display: grid;
  grid-template-columns: max-content minmax(150px, 1fr);
  align-items: start;
  gap: 8px;
  min-width: 250px;
}

.sample-complete-form details {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface, #fff);
}

.sample-complete-form summary {
  padding: 8px 10px;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}

.sample-complete-form details[open] {
  grid-column: 1 / -1;
  padding-bottom: 10px;
}

.sample-complete-form label {
  display: grid;
  gap: 4px;
  padding: 5px 10px;
  color: var(--muted);
  font-size: 12px;
}

.sample-complete-form textarea,
.sample-complete-form input {
  width: 100%;
  min-width: 0;
  background: var(--surface-inset, #f7f8fa);
}

@media (max-width: 720px) {
  .sample-complete-form {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .sample-complete-form details[open] {
    grid-column: auto;
  }
}

.metric-pair {
  display: inline-grid;
  gap: 1px;
  min-width: 64px;
  margin-right: 10px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.metric-pair small { color: var(--muted); font-weight: 500; }
.status-pending-text { color: #7a5312; }
.status-success-text { color: #1a6940; }
.status-danger-text { color: #9c2920; }

@media (max-width: 768px) {
  .analytics-grid { grid-template-columns: 1fr; }
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .fulfillment-table {
    display: block;
    min-width: 0;
  }

  .fulfillment-table thead {
    display: none;
  }

  .fulfillment-table tbody {
    display: block;
  }

  .fulfillment-table tbody tr {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    padding: 0;
    border-bottom: 1px solid var(--line);
  }

  .fulfillment-table tbody td {
    display: block;
    min-width: 0;
    padding: 12px;
    border-bottom: 0;
    text-align: left;
  }

  .fulfillment-table tbody td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
  }

  .fulfillment-table tbody td:nth-child(1) {
    grid-column: 1 / -1;
    padding: 10px 12px 0;
  }

  .fulfillment-table tbody td:nth-child(1)::before {
    display: none;
  }

  .fulfillment-table tbody td:nth-child(2) {
    grid-column: 1 / -1;
    padding-top: 16px;
    padding-bottom: 14px;
  }

  .fulfillment-table tbody td:nth-child(2)::before {
    display: none;
  }

  .fulfillment-table tbody td:nth-child(3),
  .fulfillment-table tbody td:nth-child(4),
  .fulfillment-table tbody td:nth-child(5) {
    grid-column: span 2;
    background: var(--panel-soft);
    border-top: 1px solid var(--line-soft);
    border-bottom: 1px solid var(--line-soft);
  }

  .fulfillment-table tbody td:nth-child(6) {
    grid-column: span 3;
  }

  .fulfillment-table tbody td:nth-child(7) {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line-soft);
  }

  .fulfillment-table tbody td.empty {
    grid-column: 1 / -1;
  }

  .fulfillment-table tbody td.empty::before {
    display: none;
  }

  .sales-line-metric {
    align-items: flex-start;
  }

  .sales-line-metric strong {
    font-size: 15px;
  }

  .sales-line-progress {
    padding-left: 8px;
  }

  .role-toggles {
    grid-template-columns: 1fr;
  }

  .archive-card-fields {
    grid-template-columns: 1fr 1fr;
  }

  .dose-header {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .brand {
    gap: 8px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .nav a {
    padding: 8px 7px;
  }

  .table-wrap {
    margin-left: -16px;
    margin-right: -16px;
    padding: 0 16px;
    border-radius: 0;
  }

  table {
    font-size: 13px;
  }

  th, td {
    padding: 8px 10px;
  }

  .filter-grid {
    grid-template-columns: 1fr;
  }

  .archive-card {
    padding: 16px;
  }

  .archive-card-fields {
    grid-template-columns: 1fr;
  }

  .toolbar .button {
    width: 100%;
  }

  .feedback-dialog {
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
    margin: auto 12px 12px;
  }

  .feedback-source-detail {
    grid-template-columns: 1fr;
  }

  .feedback-source-detail .wide {
    grid-column: auto;
  }
}

@media print {
  .workspace-tabs-bar,
  .feedback-trigger,
  .feedback-dialog {
    display: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .workspace-tab,
  .workspace-loading {
    transition: none;
  }

  .workspace-spinner {
    animation: none;
  }
}

/* ── Finance workbench ───────────────────────────────── */
.finance-page { max-width: 1440px; margin: 0 auto; }
.finance-header { align-items: center; }
.finance-header .page-lead, .finance-panel-heading p { display: block; margin: 4px 0 0; color: var(--muted); }
.finance-header-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.eyebrow { display: block !important; margin: 0 0 4px !important; color: var(--accent) !important; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.finance-filter-panel, .finance-form-panel { display: flex; flex-wrap: wrap; gap: 14px; align-items: end; margin-bottom: 18px; padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.finance-form-panel { display: block; max-width: 920px; }
.finance-form-grid { display: grid; grid-template-columns: repeat(2, minmax(220px, 1fr)); gap: 16px; }
.finance-field { display: grid; gap: 5px; min-width: 180px; }
.finance-field-wide { grid-column: 1 / -1; }
.finance-field label { color: var(--ink); font-size: 13px; font-weight: 650; }
.finance-field input, .finance-field select, .finance-field textarea, .finance-filter-panel input, .finance-filter-panel select { width: 100%; min-height: 42px; padding: 9px 11px; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); font: inherit; }
.finance-field textarea { min-height: 92px; resize: vertical; }
.finance-field input:focus, .finance-field select:focus, .finance-field textarea:focus, .finance-filter-panel input:focus, .finance-filter-panel select:focus { border-color: var(--accent); box-shadow: var(--shadow-focus); outline: none; }
.finance-customer-field { flex: 1 1 360px; }
.finance-filter-panel > .finance-field:not(.finance-customer-field) { flex: 0 1 180px; }
.finance-form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.required-mark { margin-left: 3px; color: var(--danger); }
.field-error { color: var(--danger); font-size: 12px; }
.finance-metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.finance-metric { min-height: 92px; padding: 16px 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.finance-metric[href] { display: block; color: inherit; transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease; }
.finance-metric[href]:hover { border-color: var(--accent); box-shadow: var(--shadow-md); text-decoration: none; transform: translateY(-1px); }
.finance-metric span { display: block; color: var(--muted); font-size: 12px; }
.finance-metric strong { display: block; margin-top: 6px; color: var(--ink); font-size: 22px; font-variant-numeric: tabular-nums; }
.finance-panel { margin-top: 18px; padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.finance-panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.finance-panel-heading h2 { margin: 0; }
.finance-table { width: 100%; border-collapse: collapse; }
.finance-table th { color: var(--muted); background: var(--panel-soft); font-size: 12px; font-weight: 700; text-align: left; }
.finance-table th, .finance-table td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.finance-table tbody tr:hover { background: var(--panel-tint); }
.finance-table .numeric { text-align: right; font-variant-numeric: tabular-nums; }
.finance-table .emphasis { color: var(--accent-dark); font-weight: 700; }
.finance-table .check-col { width: 42px; }
.finance-table .allocation-input { width: 130px; min-height: 36px; padding: 6px 8px; }
.allocation-summary { display: flex; align-items: center; justify-content: flex-end; gap: 18px; margin-top: 14px; padding: 12px 14px; color: var(--muted); background: var(--panel-soft); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); }
.allocation-summary strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.empty-cell { padding: 28px 12px !important; color: var(--muted); text-align: center; }
.finance-dashboard-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.autocomplete-select { display: block; position: relative; min-width: 0; }
.autocomplete-select .autocomplete-input { width: 100%; min-height: 42px; }
.autocomplete-select .autocomplete-source { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
/* ── In-page tabs (unified finance workspace) ─────────── */
.in-page-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.in-page-tab { padding: 10px 18px; font-size: 14px; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; text-decoration: none; transition: color .15s, border-color .15s; }
.in-page-tab:hover { color: var(--ink); }
.in-page-tab.active { color: var(--accent-dark); border-bottom-color: var(--accent); font-weight: 700; }

/* ── More dropdown menu (CSS-only, details/summary) ──── */
.more-menu { position: relative; display: inline-block; }
.more-menu > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; min-height: 44px; touch-action: manipulation; }
.more-menu > summary::-webkit-details-marker { display: none; }
.more-menu > summary::after { content: "▾"; margin-left: 2px; font-size: 11px; }
.more-menu[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.more-menu-items { position: absolute; top: 100%; right: 0; min-width: 200px; background: var(--panel); border: 1px solid var(--line); border-radius: 0 0 var(--radius-sm) var(--radius-sm); box-shadow: var(--shadow-md); z-index: 50; overflow: hidden; }
.more-menu-items a { display: flex; align-items: center; min-height: 44px; padding: 10px 14px; color: var(--ink); text-decoration: none; font-size: 14px; border-bottom: 1px solid var(--line-soft); touch-action: manipulation; }
.more-menu-items form { margin: 0; }
.more-menu-items form button { width: 100%; min-height: 44px; padding: 10px 14px; justify-content: flex-start; color: var(--ink); background: var(--panel); border: 0; border-radius: 0; box-shadow: none; font-size: 14px; font-weight: 500; }
.more-menu-items form button:hover { color: var(--accent-dark); background: var(--panel-tint); transform: none; }
.more-menu-items a:last-child { border-bottom: none; }
.more-menu-items a:hover { background: var(--panel-tint); color: var(--accent-dark); }

/* ── Empty state guidance ────────────────────────────── */
.empty-guidance { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 48px 24px; text-align: center; color: var(--muted); }
.empty-guidance p { margin: 0; font-size: 15px; }

/* ── Pagination ──────────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 14px 0 4px; }
.pagination-link { padding: 6px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); text-decoration: none; color: var(--ink); font-size: 13px; background: var(--panel); }
.pagination-link:hover { border-color: var(--accent); background: var(--panel-tint); }
.pagination-current { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

/* ── Data check page helpers ──────────────────────────── */
.finance-panel-summary { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.finance-form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 18px; margin-top: 14px; }
.backfill-summary { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.finance-messages { margin-bottom: 18px; }
.finance-message { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 8px; font-size: 14px; }
.finance-message.success { background: #e8f5ee; color: #2a6a3e; }
.finance-message.error { background: #fbeaea; color: #8a3a3a; }
.finance-tools-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.finance-date-shortcuts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; grid-column: 1 / -1; }
.finance-date-shortcuts > span { color: var(--muted); font-size: 13px; }
.finance-date-shortcuts .button { min-height: 44px; }
.finance-filter-error { margin: 10px 0 0; }
.finance-tool-link { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius-sm); text-decoration: none; color: var(--ink); background: var(--panel-soft); transition: border-color .15s, background .15s; }
.finance-tool-link:hover { border-color: var(--accent); background: var(--panel-tint); }
.finance-tool-link strong { font-size: 15px; }
.finance-tool-link span { font-size: 13px; color: var(--muted); }

@media (max-width: 900px) {
  .finance-metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .finance-table { min-width: 760px; }
  .finance-panel .table-wrap { overflow-x: auto; }
  .in-page-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
@media (max-width: 620px) {
  .toolbar > a,
  .status-toolbar > a,
  .segmented > a,
  .pagination-link,
  .workflow-card-table td > a:not(.button) {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }

  .toolbar > a,
  .status-toolbar > a,
  .segmented > a {
    padding-top: 0;
    padding-bottom: 0;
  }

  .finance-page,
  .finance-panel,
  .finance-filter-panel,
  .finance-field,
  .finance-customer-field { width: 100%; min-width: 0; }
  .finance-filter-panel { display: grid; grid-template-columns: 1fr; padding: 14px; }
  .finance-panel { padding: 12px; }
  .finance-panel .table-wrap { width: 100%; max-width: 100%; }
  .finance-form-grid { grid-template-columns: 1fr; }
  .finance-field-wide { grid-column: auto; }
  .finance-metric-grid { grid-template-columns: 1fr 1fr; }
  .finance-dashboard-columns { grid-template-columns: 1fr; }
  .finance-header-actions, .finance-panel-heading { width: 100%; align-items: flex-start; flex-direction: column; }
  .in-page-tab { padding: 8px 14px; font-size: 13px; white-space: nowrap; }
}

/* ── Issue 53：单页收款录入（收款信息 + 同客户多订单核销） ── */
.receipt-entry-page { padding-bottom: 12px; }
.receipt-entry-form { display: block; }
.receipt-entry-fields { min-width: 0; margin: 0; padding: 0; border: 0; }
.receipt-entry-fields:disabled { opacity: .78; }
.receipt-readonly-state { margin-bottom: 10px; color: var(--muted); font-size: 13px; font-weight: 650; }
.receipt-info-panel { display: block; padding: 18px; }
.receipt-info-row { display: grid; grid-template-columns: minmax(260px, 2fr) minmax(170px, 1.1fr) minmax(150px, 1fr) minmax(150px, 1fr); gap: 16px; }
.receipt-info-row + .receipt-info-row { margin-top: 14px; grid-template-columns: minmax(170px, 1fr) minmax(170px, 1fr) minmax(220px, 1.6fr); }
.receipt-amount-field input {
  text-align: right;
  font-size: 20px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  color: var(--accent-dark);
}
.receipt-notes-field textarea { min-height: 44px; resize: vertical; }
.receipt-field-invalid input, .receipt-field-invalid textarea { border-color: #c0392b; }

.receipt-candidates-heading { flex-wrap: wrap; }
.receipt-customer-outstanding { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.receipt-customer-outstanding strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.receipt-candidate-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.receipt-candidate-tools .button { min-height: 44px; }
.receipt-candidate-search { min-height: 40px; min-width: 240px; padding: 8px 11px; border: 1px solid var(--line); border-radius: var(--radius-sm); font: inherit; color: var(--ink); background: var(--panel); }
.receipt-candidate-search:focus { border-color: var(--accent); box-shadow: var(--shadow-focus); outline: none; }
.receipt-candidate-table-wrap { overflow-x: auto; }
.receipt-candidate-table { min-width: 860px; }
.receipt-candidate-table .allocation-input {
  width: 132px;
  min-height: 44px;
  padding: 8px 10px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
/* Issue 53：勾选框触控区至少 44×44px（issue 响应式要求），在表格单元格内居中。 */
.receipt-candidate-table .check-col { width: 56px; }
.receipt-candidate-table .check-col input[type="checkbox"] { width: 44px; height: 44px; margin: 0 auto; display: block; accent-color: var(--accent); cursor: pointer; }
.receipt-candidate-table thead .check-col input[type="checkbox"] { margin: 0 auto; }
.receipt-order-cell { line-height: 1.35; }
.receipt-order-no { display: block; font-weight: 650; color: var(--ink); }
.receipt-record-no-sub { display: block; font-size: 12px; color: var(--muted); }
.receipt-due-cell { white-space: nowrap; }
.receipt-overdue-tag { display: inline-block; margin-left: 8px; padding: 2px 8px; font-size: 12px; color: #8a3a3a; background: #fbeaea; border: 1px solid #e4b9b9; border-radius: var(--radius-sm); }
.receipt-row-invalid td { background: #fdf3f3; }
.receipt-row-error { margin-top: 4px; font-size: 12px; color: #8a3a3a; white-space: normal; }
.receipt-candidate-empty { padding: 34px 16px; text-align: center; color: var(--muted); font-size: 14px; }
.receipt-candidate-error { color: #8a3a3a; }

.receipt-summary-bar {
  position: sticky;
  bottom: 0;
  z-index: 30;
  margin-top: 18px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.receipt-summary-stats { display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.receipt-summary-stats strong { color: var(--ink); font-size: 15px; font-variant-numeric: tabular-nums; margin-left: 4px; }
.receipt-summary-stats .receipt-unapplied-positive strong { color: var(--accent-dark); }
.receipt-summary-errors { margin-top: 8px; font-size: 13px; color: #8a3a3a; }
.receipt-summary-errors:empty { display: none; }
.receipt-summary-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 12px; }
.receipt-summary-actions > .button { min-height: 44px; padding: 10px 22px; }
.receipt-summary-actions .button.text { background: none; border: none; color: var(--muted); min-height: 44px; order: 1; }
.receipt-more-menu { position: relative; order: 2; }
.receipt-more-menu summary { display: inline-flex; align-items: center; min-height: 44px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); cursor: pointer; font-size: 14px; color: var(--ink); list-style: none; }
.receipt-more-menu summary::-webkit-details-marker { display: none; }
.receipt-more-menu-body { position: absolute; right: 0; bottom: calc(100% + 6px); padding: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-md); }
.receipt-more-menu .danger-outline { background: var(--panel); color: #8a3a3a; border: 1px solid #e4b9b9; min-height: 44px; white-space: nowrap; }
.receipt-summary-actions [data-submit-draft] { order: 3; }
.receipt-summary-actions [data-submit-confirm] { order: 4; }

@media (max-width: 900px) {
  .receipt-info-row, .receipt-info-row + .receipt-info-row { grid-template-columns: 1fr 1fr; }
  .receipt-customer-field { grid-column: 1 / -1; }
}
@media (max-width: 620px) {
  .receipt-info-row, .receipt-info-row + .receipt-info-row { grid-template-columns: 1fr; }
  .receipt-candidate-tools { width: 100%; }
  .receipt-candidate-search { flex: 1; min-width: 0; }
  .receipt-summary-bar { border-radius: var(--radius-sm); }
  .receipt-summary-actions { flex-wrap: wrap; justify-content: stretch; }
  .receipt-summary-actions > .button { flex: 1 1 auto; }
  .receipt-summary-actions .button.text { flex: 0 0 auto; }
}

/* Issue 53 审查修复：草稿核销行余额已变化（并发结清/冲销）的异常行 */
.receipt-stale-row td { background: #fdf6ec; }
.receipt-stale-tag { display: block; width: fit-content; margin-top: 3px; padding: 2px 8px; font-size: 12px; color: #8a5a1a; background: #fbf0dd; border: 1px solid #e8cf9f; border-radius: var(--radius-sm); }

/* QR labels and workshop scanning */
.label-copy-form { display: flex; align-items: center; gap: 8px; }
.label-copy-form input { width: 72px; min-height: 40px; }
.material-label-sheet { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 16px; }
.material-qr-label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  min-height: 250px;
  padding: 18px;
  background: #fff;
  border: 1.5px solid #17212b;
  border-radius: var(--radius-sm);
  break-inside: avoid;
}
.material-qr-copy { min-width: 0; padding-right: 16px; }
.material-qr-kicker { margin: 0 0 2px; font-size: 12px; font-weight: 700; color: var(--muted); }
.material-qr-label h1 { margin: 0; font-size: 26px; line-height: 1.15; overflow-wrap: anywhere; }
.material-qr-label h2 { margin: 5px 0 12px; font-size: 17px; line-height: 1.3; }
.material-qr-label dl { margin: 0; }
.material-qr-label dl > div { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 6px; margin-top: 4px; }
.material-qr-label dt { color: var(--muted); }
.material-qr-label dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.material-qr-note { margin: 12px 0 0; }
.material-qr-code { display: flex; flex-direction: column; align-items: center; justify-content: center; border-left: 1px solid var(--line); }
.material-qr-code img { display: block; width: 116px; height: 116px; }
.material-qr-code span { margin-top: 4px; font-size: 12px; font-weight: 700; }
.print-document-qr { width: 78px; height: 78px; float: left; margin-right: 12px; }
.print-qr-caption { margin: -8px 0 8px auto; width: 102px; text-align: center; font-size: 11px; font-weight: 700; }

/* ── Picking material workbench ──────────────────────── */
.picking-workbench-section {
  max-width: 1180px;
  margin-right: auto;
  margin-left: auto;
}

.picking-workbench-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 16px;
}

.picking-workbench-heading h2 {
  margin: 2px 0 2px;
  color: var(--ink);
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.picking-workbench-heading p {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
}

.picking-eyebrow,
.picking-material-index {
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.picking-material-groups {
  display: grid;
  gap: 14px;
}

.picking-workbench { max-width: none; }

.picking-material-card {
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.picking-material-card-new {
  border-color: #bdd7d8;
  box-shadow: 0 0 0 3px rgba(23, 109, 114, 0.06);
}

.picking-material-header {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(420px, 1.25fr);
  gap: 16px 28px;
  padding: 16px 18px 13px;
  background: var(--panel-soft);
  border-bottom: 1px solid var(--line-soft);
}

.picking-material-identity h3 {
  margin: 2px 0 1px;
  font-size: 17px;
  line-height: 1.35;
  font-weight: 700;
}

.picking-material-identity p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.picking-material-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(100px, 1fr));
  align-items: center;
  gap: 8px;
}

.picking-material-summary > div {
  min-width: 0;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.picking-material-summary span,
.picking-material-summary strong {
  display: block;
}

.picking-material-summary span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.picking-material-summary strong {
  margin-top: 2px;
  color: var(--ink);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.picking-material-summary small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 550;
}

.picking-difference.is-complete strong { color: var(--success); }
.picking-difference.is-short strong { color: var(--warning); }
.picking-difference.is-over strong { color: var(--danger); }
.picking-difference.is-extra strong { color: var(--c-produce); }

.picking-progress-track {
  grid-column: 1 / -1;
  height: 3px;
  overflow: hidden;
  background: var(--line-soft);
  border-radius: 2px;
}

.picking-progress-track span {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 160ms cubic-bezier(0.23, 1, 0.32, 1);
}

.picking-batch-table { padding: 0 18px; }

.picking-batch-head,
.picking-batch-row {
  display: grid;
  grid-template-columns: minmax(300px, 1.6fr) minmax(130px, 0.55fr) minmax(180px, 1fr) 68px;
  gap: 12px;
  align-items: start;
}

.picking-batch-head {
  padding: 9px 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.picking-batch-row {
  padding: 10px 0;
  border-top: 1px solid var(--line-soft);
}

.picking-batch-head + .picking-batch-rows .picking-batch-row:first-child {
  border-top: 0;
}

.picking-batch-row input,
.picking-batch-row select,
.picking-batch-row .autocomplete-select,
.picking-batch-row .autocomplete-input {
  min-height: 40px;
}

.picking-batch-row .field-error { margin-top: 4px; }
.picking-row-action { display: flex; justify-content: flex-end; }
.picking-row-action .button { min-width: 56px; min-height: 40px; }

.picking-batch-empty {
  padding: 18px 0;
  color: var(--muted);
  text-align: center;
  border-top: 1px solid var(--line-soft);
}

.picking-material-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 8px 18px;
  color: var(--muted);
  background: var(--panel-tint);
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
}

.picking-material-footer strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.picking-new-material-control label {
  display: block;
  margin: 3px 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.picking-new-material-control .autocomplete-select { max-width: 420px; }
.picking-new-material-control h3 { margin-top: 7px; font-size: 14px; }

.picking-add-material-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 12px 14px;
  color: var(--muted);
  background: var(--panel-soft);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  font-size: 12px;
}

.picking-submit-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.picking-submit-bar > div { display: flex; gap: 8px; }

.picking-theory-details {
  max-width: 1180px;
  margin: 0 auto 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.picking-theory-details > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 10px 14px;
  color: var(--ink);
  cursor: pointer;
  font-weight: 650;
  list-style: none;
}

.picking-theory-details > summary::-webkit-details-marker { display: none; }
.picking-theory-details > summary::before { content: "›"; color: var(--muted); font-size: 20px; transition: transform 140ms ease; }
.picking-theory-details[open] > summary::before { transform: rotate(90deg); }
.picking-theory-details > summary span { flex: 1; }
.picking-theory-details > summary strong { color: var(--muted); font-size: 12px; }
.picking-theory-content { padding: 0 14px 14px; }

@media (max-width: 860px) {
  .picking-material-header { grid-template-columns: 1fr; }
  .picking-material-summary > div:first-child { padding-left: 0; border-left: 0; }
  .picking-batch-head,
  .picking-batch-row { grid-template-columns: minmax(240px, 1.5fr) 130px minmax(160px, 1fr) 64px; }
}

@media (max-width: 640px) {
  .picking-workbench-heading { display: block; }
  .picking-workbench-heading .button { width: 100%; margin-top: 12px; min-height: 44px; }
  .picking-workbench-heading h2 { font-size: 18px; }
  .picking-material-header { padding: 14px; gap: 14px; }
  .picking-material-summary { gap: 0; }
  .picking-material-summary > div { padding: 0 8px; }
  .picking-material-summary > div:first-child { padding-left: 0; }
  .picking-material-summary strong { font-size: 14px; white-space: normal; }
  .picking-batch-table { padding: 0 14px; }
  .picking-batch-head { display: none; }
  .picking-batch-row {
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 0;
    padding: 14px 0;
    border: 0;
    border-top: 1px solid var(--line-soft);
    border-radius: 0;
    background: transparent;
  }
  .picking-batch-row:first-child { border-top: 0; }
  .picking-batch-row .mobile-field-label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; font-weight: 650; }
  .picking-batch-row input,
  .picking-batch-row select,
  .picking-batch-row .autocomplete-select,
  .picking-batch-row .autocomplete-input { width: 100%; min-height: 44px; }
  .picking-batch-row .mobile-selected-value { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.4; }
  .picking-row-action { justify-content: flex-end; }
  .picking-row-action .button { min-height: 44px; }
  .picking-material-footer { padding: 10px 14px; }
  .picking-material-footer .button { min-height: 44px; }
  .picking-add-material-bar { display: grid; }
  .picking-add-material-bar .button { min-height: 44px; }
  .picking-submit-bar { align-items: stretch; flex-direction: column-reverse; }
  .picking-submit-bar > div { display: grid; grid-template-columns: 1fr; }
  .picking-submit-bar .button { width: 100%; min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .picking-progress-track span,
  .picking-theory-details > summary::before { transition: none; }
}

.picking-scan-workbench { max-width: 1040px; margin: 0 auto; }
.picking-scan-workbench [hidden] { display: none !important; }
.picking-scan-header { align-items: flex-end; }
.scan-progress { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0 0 16px; padding: 0; list-style: none; border-bottom: 1px solid var(--line); }
.scan-progress li { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; color: var(--muted); font-weight: 650; }
.scan-progress li span { display: grid; place-items: center; width: 26px; height: 26px; border: 1px solid var(--line); border-radius: 50%; background: var(--panel); }
.scan-progress li.active { color: var(--accent); border-bottom: 3px solid var(--accent); }
.scan-progress li.active span { color: #fff; background: var(--accent); border-color: var(--accent); }
.scan-progress li.complete span { color: var(--c-purchase); background: var(--c-purchase-soft); border-color: #b8d7c5; }
.scan-panel, .scan-document-summary { margin-bottom: 14px; padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.scan-panel > label { display: block; margin-bottom: 7px; font-weight: 650; }
.scan-input-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; }
.scan-input-row input { min-height: 48px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.scan-field-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.scan-field-actions .button { min-height: 48px; }
.scan-document-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 16px; align-items: center; background: var(--c-ops-soft); border-color: #bdd7d8; }
.scan-document-summary span { display: block; color: var(--muted); font-size: 12px; }
.scan-document-summary strong { display: block; font-size: 16px; }
.scan-document-summary .button, .scan-batch-choice button { min-height: 44px; }
.scan-alert { margin-bottom: 14px; padding: 11px 14px; border: 1px solid #bdd7d8; border-radius: var(--radius-sm); background: var(--c-ops-soft); color: var(--accent-dark); }
.scan-alert[data-kind="error"] { color: var(--c-danger); background: var(--c-danger-soft); border-color: #e7bcbc; }
.scan-alert[data-kind="success"] { color: var(--c-purchase); background: var(--c-purchase-soft); border-color: #bfdbc9; }
.scan-section-header { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 12px; }
.scan-section-header h2, .scan-section-header p { margin: 0; }
.scan-requirement-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.scan-requirement { min-height: 96px; padding: 13px; text-align: left; color: var(--ink); background: var(--panel-soft); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.scan-requirement { flex-direction: column; align-items: stretch; justify-content: center; }
.scan-requirement:hover { background: var(--c-ops-soft); border-color: #aacdce; }
.scan-requirement.active { background: var(--c-ops-soft); border: 2px solid var(--accent); box-shadow: var(--shadow-focus); }
.scan-requirement strong, .scan-requirement span, .scan-requirement small { display: block; }
.scan-requirement strong { font-size: 16px; }
.scan-requirement span { margin-top: 2px; }
.scan-requirement small { margin-top: 6px; color: var(--muted); }
.scan-requirement-rows { display: grid; gap: 12px; }
.scan-requirement-row { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); }
.scan-requirement-row > header { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: center; padding: 14px 16px; background: var(--panel-soft); border-bottom: 1px solid var(--line-soft); }
.scan-requirement-row > header h3 { margin: 2px 0 0; font-size: 17px; }
.scan-requirement-row > header span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.scan-requirement-row.complete { border-color: #b8d7c5; }
.scan-requirement-row.complete > header { background: var(--c-purchase-soft); }
.scan-line-metrics { display: grid; grid-template-columns: repeat(3, minmax(74px, auto)); gap: 8px; }
.scan-line-metric { min-width: 76px; padding: 7px 9px; text-align: right; border-left: 1px solid var(--line); }
.scan-line-metric span, .scan-line-metric strong { display: block; }
.scan-line-metric span { margin: 0; font-size: 11px; }
.scan-line-metric strong { margin-top: 2px; font-size: 14px; }
.scan-line-metric.emphasis strong { color: var(--accent); }
.scan-line-batches { display: grid; gap: 6px; padding: 10px 16px 0; }
.scan-line-empty { margin: 0; padding: 9px 11px; color: var(--muted); background: var(--panel-soft); border: 1px dashed var(--line); border-radius: var(--radius-sm); }
.scan-line-batch { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 9px 11px; background: var(--c-ops-soft); border-radius: var(--radius-sm); }
.scan-line-batch span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.scan-line-capture { display: grid; grid-template-columns: minmax(210px, 1.6fr) minmax(140px, .55fr) auto auto; gap: 10px; align-items: end; padding: 12px 16px 16px; }
.scan-line-capture .field { margin: 0; }
.scan-line-capture input, .scan-line-capture button { min-height: 48px; }
.scan-batch-dialog { position: fixed; inset: 0; z-index: 1100; display: grid; place-items: center; padding: 16px; background: rgba(18, 31, 35, .54); }
.scan-batch-dialog-body { width: min(560px, 100%); padding: 20px; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.scan-batch-dialog-body h2 { margin: 0; }
.scan-batch-dialog-body p { margin: 6px 0 14px; color: var(--muted); }
.scan-batch-dialog-body select { width: 100%; min-height: 48px; }
.scan-batch-dialog-body .actions { justify-content: flex-end; }
.scan-capture-panel { border-top: 4px solid var(--accent); }
.scan-capture-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(150px, .7fr) auto; gap: 12px; align-items: end; }
.scan-capture-grid .field { margin: 0; }
.scan-capture-grid input, .scan-capture-grid button { min-height: 48px; }
.scan-batch-choice { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.scan-batch-choice label { grid-column: 1 / -1; font-weight: 650; }
.scan-allocation-list { display: grid; gap: 8px; }
.scan-allocation-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 16px; align-items: center; min-height: 64px; padding: 10px 12px; background: var(--panel-soft); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); }
.scan-allocation-row span, .scan-allocation-row small { display: block; color: var(--muted); }
.scan-allocation-quantity { min-width: 118px; text-align: right; }
.scan-submit-bar { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 10px; margin: 16px -18px -18px; padding: 12px 18px calc(12px + env(safe-area-inset-bottom, 0px)); background: rgba(255,255,255,.96); border-top: 1px solid var(--line); }
.scan-submit-bar button { min-height: 46px; }
.scan-camera { position: fixed; inset: 0; z-index: 1200; display: flex; flex-direction: column; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); color: #fff; background: rgba(13, 24, 27, .96); }
.scan-camera header { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: min(680px, 100%); margin: 0 auto 12px; }
.scan-camera header strong, .scan-camera header span { display: block; }
.scan-camera header strong { font-size: 18px; }
.scan-camera header span { margin-top: 2px; color: rgba(255,255,255,.72); font-size: 13px; }
.scan-camera header .button { min-height: 44px; color: #fff; border-color: rgba(255,255,255,.45); background: transparent; }
.scan-camera-viewport { position: relative; flex: 1; width: min(680px, 100%); min-height: 260px; margin: 0 auto; overflow: hidden; border-radius: var(--radius); background: #000; }
.scan-camera video { width: 100%; height: 100%; object-fit: cover; }
.scan-camera-frame { position: absolute; left: 50%; top: 50%; width: min(68vw, 320px); aspect-ratio: 1; transform: translate(-50%, -50%); border: 3px solid #fff; border-radius: 8px; box-shadow: 0 0 0 999px rgba(0,0,0,.34); }
.scan-camera-frame::before, .scan-camera-frame::after { content: ""; position: absolute; left: 12%; right: 12%; height: 2px; background: rgba(255,255,255,.75); }
.scan-camera-frame::before { top: 33%; }
.scan-camera-frame::after { bottom: 33%; }
.scan-camera > p { width: min(680px, 100%); min-height: 24px; margin: 12px auto 0; text-align: center; }

@media (max-width: 680px) {
  .scan-progress li { font-size: 12px; }
  .scan-document-summary { grid-template-columns: 1fr 1fr; }
  .scan-input-row { grid-template-columns: 1fr 1fr; }
  .scan-input-row input { grid-column: 1 / -1; }
  .scan-field-actions { grid-template-columns: 1fr; }
  .scan-requirement-row > header { grid-template-columns: 1fr; }
  .scan-line-metrics { grid-template-columns: repeat(3, 1fr); }
  .scan-line-metric { min-width: 0; padding-left: 6px; padding-right: 6px; text-align: left; }
  .scan-line-capture { grid-template-columns: 1fr 1fr; padding: 12px; }
  .scan-line-capture .field { grid-column: 1 / -1; }
  .scan-line-capture button { width: 100%; }
  .scan-line-batch { grid-template-columns: minmax(0, 1fr) auto; }
  .scan-line-batch .button { grid-column: 1 / -1; min-height: 44px; }
  .scan-document-summary .button { grid-column: 1 / -1; }
  .scan-capture-grid { grid-template-columns: 1fr; }
  .scan-batch-choice { grid-template-columns: 1fr; }
  .scan-allocation-row { grid-template-columns: minmax(0, 1fr) auto; }
  .scan-allocation-row > .button { grid-column: 1 / -1; min-height: 44px; }
  .scan-submit-bar { flex-direction: column-reverse; }
  .scan-submit-bar button { width: 100%; }
  .material-label-sheet { grid-template-columns: 1fr; }
}

@media print {
  .material-label-sheet { display: block; }
  .material-qr-label { width: 96mm; min-height: 64mm; margin: 0; padding: 5mm; border-radius: 0; page-break-after: always; }
  .material-qr-label:last-child { page-break-after: auto; }
  .material-qr-code img { width: 30mm; height: 30mm; }
}
/* Purchase arrival quality workflow */
.quality-lot-list {
  display: grid;
  gap: 16px;
}

.quality-lot-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #dbe2ea);
  border-radius: 12px;
  padding: 18px;
}

.quality-lot-card > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.quality-lot-card h3 { margin: 0 0 4px; }
.quality-lot-card p { margin: 0; }
.quality-entry-panel { margin-top: 20px; }
.quality-submit { align-self: end; }

.quality-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px 18px;
  margin: 16px 0;
}

.quality-facts div { min-width: 0; }
.quality-facts dt { color: var(--muted); font-size: 13px; }
.quality-facts dd { margin: 4px 0 0; overflow-wrap: anywhere; }

.quality-decision-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border, #dbe2ea);
}

.quality-decision-form button { align-self: end; justify-self: start; min-height: 44px; }

@media (max-width: 680px) {
  .quality-lot-card { padding: 14px; }
  .quality-lot-card > header { flex-direction: column; }
  .quality-decision-form { grid-template-columns: 1fr; }
  .quality-decision-form input,
  .quality-decision-form select,
  .quality-decision-form textarea { width: 100%; min-width: 0; }

  .workflow-card-table {
    overflow: visible;
    background: transparent;
    border: 0;
  }

  .workflow-card-table table,
  .workflow-card-table tbody,
  .workflow-card-table tr,
  .workflow-card-table td { display: block; width: 100%; }
  .workflow-card-table thead { display: none; }
  .workflow-card-table tbody { display: grid; gap: 12px; }
  .workflow-card-table tbody tr {
    padding: 14px;
    background: var(--surface, #fff);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
  }
  .workflow-card-table tbody td {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 7px 0;
    border: 0;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .workflow-card-table tbody td::before {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
  }
  .workflow-card-table tbody td:last-child {
    margin-top: 4px;
    padding-top: 12px;
    border-top: 1px solid var(--line-soft);
  }
  .workflow-card-table tbody td:last-child .button { width: 100%; min-height: 44px; }

  .button,
  button,
  .status-toolbar a:not(.button),
  .pagination-link,
  .in-page-tab { min-height: 44px; touch-action: manipulation; }
  .status-toolbar a:not(.button),
  .pagination-link,
  .in-page-tab { display: inline-flex; align-items: center; }
  .more-menu-items { right: auto; left: 0; max-width: calc(100vw - 32px); }

  .production-task-table td:nth-child(1)::before { content: "生产任务"; }
  .production-task-table td:nth-child(2)::before { content: "成品批号"; }
  .production-task-table td:nth-child(3)::before { content: "来源订单"; }
  .production-task-table td:nth-child(4)::before { content: "客户"; }
  .production-task-table td:nth-child(5)::before { content: "产出物料"; }
  .production-task-table td:nth-child(6)::before { content: "计划日期"; }
  .production-task-table td:nth-child(7)::before { content: "状态"; }
  .production-task-table td:nth-child(8)::before { content: "计划量（kg）"; }
  .production-task-table td:nth-child(9)::before { content: "下一步"; }

  .picking-document-table td:nth-child(1)::before { content: "领料单"; }
  .picking-document-table td:nth-child(2)::before { content: "生产任务"; }
  .picking-document-table td:nth-child(3)::before { content: "配方"; }
  .picking-document-table td:nth-child(4)::before { content: "计划量（kg）"; }
  .picking-document-table td:nth-child(5)::before { content: "计划日期"; }
  .picking-document-table td:nth-child(6)::before { content: "领料日期"; }
  .picking-document-table td:nth-child(7)::before { content: "状态"; }
  .picking-document-table td:nth-child(8)::before { content: "原料行数"; }
  .picking-document-table td:nth-child(9)::before { content: "下一步"; }

  .purchase-order-table td:nth-child(1)::before { content: "采购单"; }
  .purchase-order-table td:nth-child(2)::before { content: "供应商"; }
  .purchase-order-table td:nth-child(3)::before { content: "采购内容"; }
  .purchase-order-table td:nth-child(4)::before { content: "采购员"; }
  .purchase-order-table td:nth-child(5)::before { content: "订单日期"; }
  .purchase-order-table td:nth-child(6)::before { content: "预计到货"; }
  .purchase-order-table td:nth-child(7)::before { content: "状态"; }
  .purchase-order-table td:nth-child(8)::before { content: "金额"; }

  .finance-receipt-table td:nth-child(1)::before { content: "收款单"; }
  .finance-receipt-table td:nth-child(2)::before { content: "客户"; }
  .finance-receipt-table td:nth-child(3)::before { content: "日期"; }
  .finance-receipt-table td:nth-child(4)::before { content: "收款金额"; }
  .finance-receipt-table td:nth-child(5)::before { content: "已核销"; }
  .finance-receipt-table td:nth-child(6)::before { content: "未分配"; }
  .finance-receipt-table td:nth-child(7)::before { content: "状态"; }

  .purchase-progress-table td:nth-child(1)::before { content: "采购单"; }
  .purchase-progress-table td:nth-child(2)::before { content: "物料 / 供应商"; }
  .purchase-progress-table td:nth-child(3)::before { content: "数量进度"; }
  .purchase-progress-table td:nth-child(4)::before { content: "质检数量"; }
  .purchase-progress-table td:nth-child(5)::before { content: "最近到货"; }
  .purchase-progress-table td:nth-child(6)::before { content: "当前状态"; }
  .purchase-progress-table td:nth-child(7)::before { content: "质检结果"; }
  .purchase-progress-table td:nth-child(8)::before { content: "收货 / 批号"; }
  .purchase-progress-table td:nth-child(9)::before { content: "下一步"; }

  .purchase-receipt-pending-table td:nth-child(1)::before { content: "采购单"; }
  .purchase-receipt-pending-table td:nth-child(2)::before { content: "订单日期"; }
  .purchase-receipt-pending-table td:nth-child(3)::before { content: "预计到货"; }
  .purchase-receipt-pending-table td:nth-child(4)::before { content: "供应商"; }
  .purchase-receipt-pending-table td:nth-child(5)::before { content: "物料"; }
  .purchase-receipt-pending-table td:nth-child(6)::before { content: "采购数量"; }
  .purchase-receipt-pending-table td:nth-child(7)::before { content: "已到货"; }
  .purchase-receipt-pending-table td:nth-child(8)::before { content: "未到货"; }
  .purchase-receipt-pending-table td:nth-child(9)::before { content: "下一步"; }
  .purchase-receipt-history-table td:nth-child(1)::before { content: "收货单"; }
  .purchase-receipt-history-table td:nth-child(2)::before { content: "到货日期"; }
  .purchase-receipt-history-table td:nth-child(3)::before { content: "供应商"; }
  .purchase-receipt-history-table td:nth-child(4)::before { content: "物料"; }
  .purchase-receipt-history-table td:nth-child(5)::before { content: "到货数量"; }
  .purchase-receipt-history-table td:nth-child(6)::before { content: "待检"; }
  .purchase-receipt-history-table td:nth-child(7)::before { content: "合格"; }
  .purchase-receipt-history-table td:nth-child(8)::before { content: "不合格"; }
  .purchase-receipt-history-table td:nth-child(9)::before { content: "状态"; }
  .purchase-receipt-history-table td:nth-child(10)::before { content: "下一步"; }

  .purchase-quality-table td:nth-child(1)::before { content: "到货日期"; }
  .purchase-quality-table td:nth-child(2)::before { content: "收货单"; }
  .purchase-quality-table td:nth-child(3)::before { content: "物料"; }
  .purchase-quality-table td:nth-child(4)::before { content: "供应商"; }
  .purchase-quality-table td:nth-child(5)::before { content: "到货"; }
  .purchase-quality-table td:nth-child(6)::before { content: "未分批"; }
  .purchase-quality-table td:nth-child(7)::before { content: "待检"; }
  .purchase-quality-table td:nth-child(8)::before { content: "异常"; }
  .purchase-quality-table td:nth-child(9)::before { content: "状态"; }
  .purchase-quality-table td:nth-child(10)::before { content: "下一步"; }
}
/* Plain, continuous rich documents for formula notes and experiment records. */
.rich-document-field {
  width: 100%;
}

.rich-document-toolbar.ql-toolbar.ql-snow {
  position: sticky;
  top: 0;
  z-index: 2;
  border-color: var(--border, #d7dce2);
  border-radius: 8px 8px 0 0;
  background: #f7f8fa;
}

.rich-document-editor.ql-container.ql-snow {
  min-height: 340px;
  border-color: var(--border, #d7dce2);
  border-radius: 0 0 8px 8px;
  background: #fff;
  font-family: inherit;
  font-size: 15px;
}

.rich-document-editor .ql-editor {
  min-height: 340px;
  padding: 24px 28px;
  line-height: 1.75;
}

.rich-document-editor .ql-editor img,
.rich-document-viewer .ql-editor img {
  display: block;
  max-width: min(100%, 920px);
  height: auto;
  margin: 12px 0;
  border-radius: 6px;
}

.rich-document-status {
  min-height: 20px;
  margin-top: 6px;
  color: var(--text-muted, #667085);
  font-size: 13px;
}

.rich-document-viewer {
  background: #fff;
}

.rich-document-viewer .ql-editor {
  min-height: 0;
  padding: 4px 0;
  overflow: visible;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.75;
}

.dossier-formula-document {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border, #e4e7ec);
}

.dossier-formula-document > span {
  display: block;
  margin-bottom: 8px;
  color: var(--text-muted, #667085);
  font-size: 13px;
}

.research-workflow-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0 0 18px;
  border: 1px solid var(--border, #d7dce2);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.research-workflow-strip a {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 1px 10px;
  padding: 12px 14px;
  color: inherit;
  text-decoration: none;
  border-right: 1px solid var(--border, #d7dce2);
}

.research-workflow-strip a:last-child { border-right: 0; }
.research-workflow-strip a:hover,
.research-workflow-strip a.is-current { background: #f7f8fa; }
.research-workflow-strip a > span {
  grid-row: 1 / span 2;
  align-self: center;
  width: 26px;
  height: 26px;
  line-height: 26px;
  text-align: center;
  border-radius: 50%;
  background: var(--primary, #2457a6);
  color: #fff;
  font-size: 13px;
}
.research-workflow-strip small { color: var(--text-muted, #667085); }

.sample-source-context {
  display: flex;
  gap: 12px;
  align-items: baseline;
  margin: 0 0 16px;
  padding: 10px 14px;
  border-left: 3px solid var(--primary, #2457a6);
  background: #f7f8fa;
}

.sample-source-context span { color: var(--text-muted, #667085); }
.sample-request-document { margin-top: 18px; }

@media (max-width: 720px) {
  .research-workflow-strip { grid-template-columns: 1fr; }
  .research-workflow-strip a { border-right: 0; border-bottom: 1px solid var(--border, #d7dce2); }
  .research-workflow-strip a:last-child { border-bottom: 0; }
  .sample-source-context { display: grid; gap: 4px; }
  .rich-document-toolbar.ql-toolbar.ql-snow {
    position: static;
    padding: 6px;
  }

  .rich-document-editor .ql-editor {
    min-height: 280px;
    padding: 18px 16px;
  }
}

@media print {
  .rich-document-viewer .ql-editor {
    padding: 0;
  }

  .rich-document-viewer .ql-editor img {
    max-height: 220mm;
    break-inside: avoid;
  }
}
