:root {
  --bg: #eef2f6;
  --panel: #ffffff;
  --text: #1f2d3d;
  --muted: #6b7280;
  --brand: #0f766e;
  --brand-ink: #0b4f4a;
  --warn: #c2410c;
  --border: #d9e1ea;
  --shadow: 0 10px 26px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; width: 100%; min-height: 100dvh; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 90%;
  color: var(--text);
  background:
    radial-gradient(1000px 500px at 100% -10%, #d9f5ef 0%, transparent 60%),
    radial-gradient(900px 400px at -10% -10%, #dbeafe 0%, transparent 50%),
    var(--bg);
  min-height: 100dvh;
}

.app-shell {
  min-height: 100dvh;
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
}

.mobile-header {
  background: linear-gradient(130deg, #0f766e 0%, #0e7490 100%);
  color: #fff;
  padding: calc(18px + env(safe-area-inset-top)) 18px 18px;
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 18px;
  box-shadow: var(--shadow);
}
.mobile-header h1 { margin: 0; font-size: 20px; letter-spacing: 0.5px; }
.mobile-subtitle { margin: 0 0 4px; font-size: 11px; opacity: 0.88; }

main {
  padding: 14px;
  max-width: 1200px;
  margin: 0 auto;
}

h2, h3 {
  margin: 10px 0 12px;
  color: #12263a;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
}
.card p { margin: 0; color: var(--muted); font-size: 12px; }
.card strong { display: block; margin-top: 6px; font-size: 23px; color: var(--brand-ink); }

.grid { display: grid; gap: 10px; }
.cols-2 { grid-template-columns: 1fr; }
.cols-4 { grid-template-columns: 1fr 1fr; }
.cols-5 { grid-template-columns: 1fr 1fr; }

/* KPI cards (报表/统计用) */
.kpi-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi-card { padding: 16px; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.kpi-card .kpi-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.kpi-card .kpi-value { font-size: 26px; font-weight: 700; color: #0f172a; }
.kpi-card .kpi-sub { font-size: 11px; color: var(--muted); margin-top: 4px; }
.kpi-card.kpi-warn { border-color: #f59e0b; background: #fffbeb; }
.kpi-card.kpi-warn .kpi-value { color: #92400e; }
@media (max-width: 720px) { .kpi-row { grid-template-columns: 1fr 1fr; } }
/* 中屏（iPad 竖屏 ~768px）此前直接从 5 列掉到 2 列，卡片过宽、行数翻倍；补 3 列档。 */
@media (min-width: 721px) and (max-width: 1099px) {
  .kpi-row { grid-template-columns: repeat(3, 1fr); }
}
.cols-3 { grid-template-columns: 1fr; }

.card small { font-size: 14px; font-weight: 400; }

.card-list { display: grid; gap: 12px; }
.card-list-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 720px) { .card-list-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .card-list-3 { grid-template-columns: 1fr; } }

.card[data-href]:hover { box-shadow: 0 8px 22px rgba(15, 23, 42, 0.10); transform: translateY(-2px); }
.card[data-href]:hover h3 { color: var(--brand-ink, #0f766e); }
.card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.card-actions form { margin: 0; }

.land-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr 1fr;
  margin-top: 16px;
}
@media (max-width: 600px) {
  .land-grid { grid-template-columns: 1fr; }
}
.land-card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 18px 14px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
  color: inherit;
}
.land-card h3 { margin: 0 0 4px; color: var(--brand-ink); font-size: 18px; }
.land-card p { margin: 0 0 10px; color: var(--muted); font-size: 13px; }

/* 模块卡内的子页链接（2026-10-13）：一个模块含多页，卡片本身不再是链接，
   改由卡内链接列表承载（块级大热区，桌面与移动端都够点）。 */
.land-links { list-style: none; margin: 0; padding: 0; }
.land-links li + li { margin-top: 2px; }
.land-links a {
  display: block;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--brand-ink);
  text-decoration: none;
  font-size: 14px;
}
.land-links a:hover { background: rgba(15, 118, 110, 0.08); }

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 14px;
}
.table-scroll table { display: table; min-width: 100%; }

label span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
label input,
label select {
  width: 100%;
}

.form-inline,
form.grid {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 12px;
}

.form-inline { display: flex; gap: 10px; flex-wrap: wrap; }

input, select, button {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 13px;
}

button {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
}
.btn-danger {
  background: #b91c1c;
  border-color: #b91c1c;
}
.btn-secondary {
  display: inline-block;
  background: transparent;
  color: var(--brand);
  border: 1px solid var(--brand);
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  padding: 11px 12px;
  border-radius: 10px;
  font-size: 13px;
  white-space: nowrap;
}
/* 小号按钮（表格行内 / 次要操作）
   2026-10-17：原本只有 a/button 双选择器 + 11px 字，且 button 未覆盖全局
   `width:100%` → 同一行的 <a class="btn-sm"> 与 <button class="btn-sm">
   宽度天差地别（前者内容宽，后者撑满整格）。这里统一成 32px 高、
   13px 字、内容宽，a 与 button 外观一致。 */
a.btn-sm,
button.btn-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  text-align: center;
  white-space: nowrap;
  border: 1px solid var(--border);
  background: #fff;
  color: #374151;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
a.btn-sm.btn-edit {
  background: transparent;
  color: var(--brand);
  border-color: var(--brand);
}
a.btn-sm.btn-edit:hover {
  background: var(--brand);
  color: #fff;
}
button.btn-sm.btn-delete {
  background: transparent;
  color: #b91c1c;
  border-color: #b91c1c;
  width: auto;
}
button.btn-sm.btn-delete:hover {
  background: #b91c1c;
  color: #fff;
}
/* 小号主操作变体（「新建」「筛选」这类要显眼的 32px 按钮） */
a.btn-sm.primary,
button.btn-sm.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
a.btn-sm.primary:hover,
button.btn-sm.primary:hover {
  background: var(--brand-ink);
  border-color: var(--brand-ink);
}

/* === 通用按钮体系（2026-10-17）===
   此前 .btn / .btn-link / .form-actions / .form-section 只在模板里当语义名
   用，样式表里根本没有定义 → `<button class="btn">` 落入全局
   `button{background:品牌绿; width:100%}`，旁边的 `<a class="btn-link">`
   则是裸文字链接，同一行按钮比例完全失控。这里补齐成套定义。 */

/* 主操作按钮：40px 实心品牌色，a 与 button 通用 */
.btn,
a.btn,
button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: 40px;
  padding: 0 20px;
  border: 1px solid var(--brand);
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn:hover,
a.btn:hover,
button.btn:hover {
  background: var(--brand-ink);
  border-color: var(--brand-ink);
  color: #fff;
}

/* 次要操作：文字按钮（取消 / 返回），与主按钮同高保证基线对齐 */
.btn-link,
a.btn-link,
button.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: 40px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}
.btn-link:hover,
a.btn-link:hover,
button.btn-link:hover {
  background: #f1f5f9;
  color: var(--brand-ink);
  text-decoration: none;
}

/* 表单底部的按钮组：右对齐、等高、换行不散架 */
.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}
.form-actions .btn,
.form-actions .btn-link { flex: 0 0 auto; }
/* 放在 .grid 表单里时跨满整行，避免挤在单列里 */
.grid > .form-actions { grid-column: 1 / -1; }

/* 表单区块卡片（批量导入 / 扇出 / 批量修改都用它） */
.form-section {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}
.form-section > h3:first-child,
.form-section > p:first-child { margin-top: 0; }

/* 页头右侧按钮组：与标题垂直居中，间距统一，窄屏自动换行 */
.page-header-actions,
.page-header > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
/* 窄屏：标题与按钮组上下堆叠，避免标题被挤成竖排单字 */
@media (max-width: 720px) {
  .page-header { flex-direction: column; align-items: stretch; gap: 10px; }
  .page-header h2 { margin: 0; }
  .page-header-actions,
  .page-header > div { justify-content: flex-start; }
}

/* 表格行内操作按钮组（div 用 flex；td 不能改 display，否则破坏表格布局） */
.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.row-actions form { margin: 0; display: inline-flex; }
td.inline {
  display: table-cell;   /* 抵消 .inline{display:flex}，否则单元格脱离表格布局 */
  white-space: nowrap;
}
td.inline > * { vertical-align: middle; }
td.inline > * + * { margin-left: 6px; }
td.inline form { margin: 0; display: inline-flex; }
.btn-cancel {
  display: inline-block;
  background: #f1f5f9;
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  padding: 11px 12px;
  border-radius: 10px;
  font-size: 13px;
}

.warn { color: var(--warn); font-weight: 700; }
.danger { color: #b91c1c; font-weight: 700; }
.warn-row { background: #fef9c3; }
.danger-row { background: #fef9c3; }

/* 表格布局（2026-10-20 修复）：此前用 display:block 换取 overflow-x 横滚。
   实测（Chrome / 768px 受控用例）block 化的真实后果是：
     ① 表格不再吃 width:100%，收缩到内容自然宽度（464px vs 容器 739px），右侧留白；
     ② table-layout:fixed 失效（bom-table 的定宽列依赖它）；
     ③ border-radius 圆角裁切失效。
   列对齐本身不会错位 —— thead/tbody 仍被放进同一个匿名表。
   现恢复 table 布局；横滚交给 .table-scroll 包装层（base.html 脚本负责补包）。 */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: table;
}

thead, tbody, tr { width: 100%; }
th, td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 12px;
  white-space: nowrap;
}

.inline { display: flex; gap: 8px; align-items: center; }
.inline select { min-width: 104px; }
/* 行内表单：表格单元格里的「数量输入 + 更新/删除」组合。
   历史包袱（2026-10-18 修）：模板写的是 .inline-form，样式表只定义过
   .inline —— 于是输入框吃全局 `input{width:100%}` 撑满整格，
   td 又是 nowrap，32px 小按钮被挤出单元格、压在后一列金额文字上。 */
.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0;
}
.inline-form input:not([type="hidden"]):not([type="checkbox"]):not([type="number"]),
.inline-form select {
  width: 150px;
  min-width: 0;
  flex: 0 0 auto;
  height: 32px;
  padding: 0 10px;
  font-size: 13px;
  border-radius: 8px;
}
.inline-form input[type="number"] {
  width: 96px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.inline-form button,
.inline-form .btn-sm {
  width: auto;
  flex: 0 0 auto;
}
/* 起订倍数提示 / 违规单元格（2026-10-18） */
.qty-hint {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.qty-hint.warn { color: #b45309; font-weight: 600; }
td.qty-bad { color: #b91c1c; font-weight: 600; }
.status-pill.multiple {
  background: #eef2ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
}
/* 禁用态按钮（提交页在存在校验错误时置灰，避免点了没反应） */
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.3);
}
/* 行内表单控件与 32px 小按钮对齐（2026-10-17）：此前沿用全局 11px 内边距，
   和 btn-sm 并排时一高一矮。 */
.inline input:not([type="hidden"]):not([type="checkbox"]),
.inline select {
  width: auto;
  height: 32px;
  padding: 0 10px;
  font-size: 13px;
  border-radius: 8px;
}

.flash-list { list-style: none; padding: 0; margin: 0 0 10px; }
.flash-list li {
  background: #ecfeff;
  border: 1px solid #a5f3fc;
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
  color: #0f172a;
}

/* context bar (user / warehouse / logout) */
.ctx-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  padding: 8px 14px;
  background: #f7f8fa;
  border-bottom: 1px solid #e5e7eb;
  font-size: 13px;
}
.ctx-warehouse { font-weight: 600; }
.ctx-warehouse small { color: #6b7280; font-weight: 400; }
.ctx-user { margin-left: auto; color: #374151; }
.ctx-user small { color: #6b7280; font-weight: 400; }
.ctx-link { color: #0f766e; text-decoration: none; }
.ctx-link:hover { text-decoration: underline; }

/* auth pages */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f3f4f6;
  padding: 20px;
}
.auth-card {
  background: #fff;
  border-radius: 12px;
  padding: 28px 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}
.auth-card h1 { margin-top: 0; font-size: 20px; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.auth-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #374151; }
.auth-card input {
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 15px;
}
.auth-card .btn.primary {
  margin-top: 8px;
  background: #0f766e;
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.warehouse-list { list-style: none; padding: 0; display: grid; gap: 10px; }
.warehouse-list .btn.block {
  display: block;
  width: 100%;
  text-align: left;
  background: #fff;
  color: #1f2d3d;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  font-size: 15px;
}
.warehouse-list .btn.block strong { display: block; margin-bottom: 4px; color: #1f2d3d; }
.warehouse-list .btn.block .muted { color: #6b7280; font-size: 12px; }

.mobile-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  gap: 8px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
}
.mobile-nav a {
  flex: 1;
  min-width: 0;
  text-align: center;
  text-decoration: none;
  color: #334155;
  font-size: 11px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px 4px;
}

.sidebar {
  background: #0f172a;
  color: #fff;
  padding: 22px 12px;
}
.sidebar h1 { margin: 0 0 14px; font-size: 18px; }
.sidebar a {
  display: block;
  color: #cbd5e1;
  text-decoration: none;
  padding: 7px 10px;
  margin-bottom: 2px;
  border-radius: 10px;
}
.sidebar a:hover { background: #1e293b; color: #fff; }

/* nav-groups — 2026-10-13 导航模块化：模块标题 + 组内链接 */
.nav-group { margin-bottom: 12px; }
.nav-group-title {
  margin: 0 0 4px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: #94a3b8;
}

/* Nav badge — small red dot with count, used by the 通知 link */
.nav-badge {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  margin-left: 6px;
  background: #dc2626;
  color: #fff;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 600;
  line-height: 16px;
  text-align: center;
  vertical-align: middle;
}

.mobile-only { display: block; }
.desktop-only { display: none; }

@media (min-width: 961px) {
  body {
    display: grid;
    grid-template-columns: 240px 1fr;
  }
  .app-shell {
    padding-bottom: 20px;
  }
  main {
    padding: 22px;
  }
  .cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .mobile-only { display: none; }
  .desktop-only { display: block; }
  /* Pages that override sidebar (e.g. /land, /select-warehouse) collapse
     the grid to one full-width column so main isn't squeezed into 240px. */
  body.no-sidebar { grid-template-columns: 1fr; }
  body.no-sidebar .app-shell { max-width: 1200px; margin: 0 auto; width: 100%; }
  body.no-sidebar .ctx-bar { padding: 10px 22px; }
  body.no-sidebar .mobile-header { padding: 16px 22px; }
}

@media (max-width: 960px) {
  .cols-5 { grid-template-columns: 1fr 1fr; }
  .cols-5 .card:last-child:nth-child(5) { grid-column: 1 / -1; }
}

/* tag chips (categories, role badges) */
.tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: #ecfeff;
  border: 1px solid #a5f3fc;
  color: #0f172a;
  font-size: 13px;
}
.tag.admin { background: #fef3c7; border-color: #fbbf24; color: #92400e; font-weight: 600; }
.tag.user { background: #f3f4f6; border-color: #e5e7eb; color: #374151; }

/* grid-table for admin lists */
.grid-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.grid-table th, .grid-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: top;
}
.grid-table th {
  background: #f9fafb;
  font-weight: 600;
  color: #374151;
}
.grid-table details { font-size: 13px; }
.grid-table details input {
  padding: 4px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
}

.muted { color: #6b7280; }
code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: #374151;
}
.btn-sm {
  display: inline-block;
  padding: 4px 10px;
  font-size: 13px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  background: #fff;
  cursor: pointer;
  color: #374151;
  text-decoration: none;
}
.btn-sm:hover { background: #f9fafb; }
.btn-edit { border-color: #0f766e; color: #0f766e; }
.btn-delete { border-color: #dc2626; color: #dc2626; }

/* /users responsive card layout ----------------------------------------- */

/* role matrix inside the create-user form */
.role-matrix { width: 100%; font-size: 14px; }
.role-matrix th, .role-matrix td {
  text-align: center;
  padding: 6px 4px;
  border-bottom: 1px solid #f0f0f0;
}
.role-matrix th:first-child, .role-matrix td:first-child { text-align: left; }

/* each user becomes a card */
.user-cards { display: grid; gap: 12px; margin-bottom: 24px; }
.user-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.user-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.user-card-meta {
  font-size: 12px;
  line-height: 1.5;
  text-align: right;
}
.user-card-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #f3f4f6;
  font-size: 14px;
}
.user-card-section > summary {
  cursor: pointer;
  font-weight: 600;
  color: #0f766e;
  list-style: none;
}
.user-card-section > summary::-webkit-details-marker { display: none; }
.user-card-section > summary::before {
  content: "▸ ";
  font-size: 11px;
}
.user-card-section[open] > summary::before { content: "▾ "; }
.user-card-label {
  font-weight: 600;
  color: #374151;
  display: block;
  margin-bottom: 6px;
}
.user-card-actions {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #f3f4f6;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* role-row used inside edit-permissions details */
.role-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  border-bottom: 1px dashed #f0f0f0;
}
.role-row:last-child { border-bottom: 0; }
.role-row-label {
  min-width: 110px;
  font-size: 13px;
}
.role-row-form {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.role-row-form select {
  width: auto;
  padding: 4px 6px;
  font-size: 13px;
}
.role-row-form input[type="password"] {
  width: auto;
  padding: 4px 8px;
  font-size: 13px;
}

/* warehouse cards */
.warehouse-cards { display: grid; gap: 12px; }
.warehouse-card {
  background: #fff;
  border: 1px solid #fecaca;
  border-radius: 12px;
  padding: 14px 16px;
}
.warehouse-card > header {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.warehouse-card details > summary {
  list-style: none;
  cursor: pointer;
}
.warehouse-card details > summary::-webkit-details-marker { display: none; }

/* === inventory view (mobile + pad) === */
.inv-search {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.inv-search input { flex: 1; }
.inv-search button { width: auto; min-width: 100px; }

.inv-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  background: linear-gradient(135deg, #0f766e 0%, #0e7490 100%);
  color: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.inv-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: center;
}
.inv-stat-label {
  font-size: 11px;
  opacity: 0.85;
}
.inv-stat-value {
  font-size: 16px;
  font-weight: 700;
}

.inv-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}

.inv-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.inv-card.is-warn {
  background: #fffaf0;
  border-color: #fde68a;
}
.inv-card.is-danger {
  background: #fef2f2;
  border-color: #fecaca;
}

.inv-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.inv-card-name {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  min-width: 0;
}
.inv-cat {
  font-size: 11px;
  color: var(--muted);
  background: #eef2f6;
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}
.inv-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.status-pill {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
  display: inline-block;
  flex-shrink: 0;
  line-height: 1.4;
}
.status-pill.ok { background: #ecfdf5; color: #047857; border: 1px solid #6ee7b7; }
.status-pill.warn { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.status-pill.danger { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }

.inv-card-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
}
.inv-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.metric-label {
  font-size: 11px;
  color: var(--muted);
}
.metric-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.metric-value.small {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.metric-value.highlight {
  color: var(--brand-ink);
  font-size: 18px;
}
.inv-metric-consume .metric-value {
  color: #b45309;
}
.metric-value small {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
  margin-left: 3px;
}

.inv-card-foot {
  font-size: 11px;
  color: var(--muted);
  border-top: 1px dashed var(--border);
  padding-top: 6px;
}

/* pad landscape: 2 columns */
@media (min-width: 720px) {
  .inv-grid { grid-template-columns: 1fr 1fr; }
  .inv-card-body { grid-template-columns: repeat(3, 1fr); }
  .inv-summary { grid-template-columns: repeat(3, 1fr); }
}
/* desktop: 3 columns */
@media (min-width: 1100px) {
  .inv-grid { grid-template-columns: 1fr 1fr 1fr; }
  .inv-summary { grid-template-columns: repeat(6, 1fr); }
  .inv-summary .inv-stat-value { font-size: 14px; }
}

/* === restock / outbound / adjustment / stocktake session (pad-first) === */

.session-form {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px 88px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
}
.session-head {
  /* not sticky — chip bar owns the top slot */
  background: var(--panel);
  margin: -14px -16px 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 14px;
  align-items: center;
}
.session-head h2 { margin: 0; font-size: 18px; }
.session-head .hint {
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}
.session-head .session-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.session-head .session-actions input {
  width: 280px;
  max-width: 100%;
}
.session-head .session-actions button { width: auto; min-width: 140px; }

/* entry-grid + entry-row — 2026-06-23 UI update D: 3 排垂直堆叠 */
.entry-grid {
  display: grid;
  gap: 10px;
}
.entry-row {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto auto auto;
  align-items: stretch;
  gap: 8px 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fafbfd;
  min-height: 0;
  cursor: pointer;
}
.entry-row.is-warn { background: #fef9c3; border-color: #fde68a; }
.entry-row.is-low { background: #fee2e2; border-color: #fca5a5; }
.entry-row .er-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.entry-row .er-stock {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 13px;
  color: var(--muted);
}
.entry-row .er-input {
  display: flex;
  align-items: center;
  gap: 8px;
}
.entry-row .er-input input { max-width: 200px; }
.entry-row .er-cell {
  display: grid;
  grid-template-columns: auto auto auto;
  align-items: baseline;
  gap: 2px 6px;
  padding: 6px 10px;
  border-radius: 10px;
  min-width: 96px;
}
.entry-row .er-cell-label {
  grid-column: 1 / -1;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
}
.entry-row .er-cell-num {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.entry-row .er-cell-unit {
  font-size: 11px;
  color: var(--muted);
}
.entry-row .er-stock-cell { background: #eef2f6; }
.entry-row .er-planned-cell.er-planned-pill {
  background: #ccfbf1;
  border: 1px solid #5eead4;
}
.entry-row .er-planned-cell .er-planned-num { color: #0f766e; }

/* 生产录入: 左配方 / 右录入 */
.session-grid {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 720px) { .session-grid { grid-template-columns: 1fr; } }
.recipe-pane {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  position: sticky;
  top: 12px;
  height: 500px;
  overflow-y: auto;
}
/* 手机单列后 sticky 失去意义，且固定 500px 高度会吃掉半屏 —— 改为流式面板。 */
@media (max-width: 720px) {
  .recipe-pane {
    position: static;
    height: auto;
    max-height: 260px;
  }
}
.recipe-pane h3 { margin: 0 0 4px; font-size: 16px; }
.recipe-pane .recipe-hint { margin: 0 0 12px; font-size: 12px; }
.recipe-list { list-style: none; margin: 0; padding: 0; }
.recipe-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}
.recipe-list li:last-child { border-bottom: none; }
.recipe-list .recipe-name { font-size: 14px; color: var(--text); }
.recipe-list .recipe-qty { font-size: 13px; color: var(--muted); }
.recipe-list .recipe-qty strong { font-size: 15px; color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }

.materials-pane .session-head { margin-bottom: 14px; }
.materials-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

/* 产出量选择: 1/2/3 预设按钮 + 自定义数字输入 */
.qty-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.qty-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-right: 4px;
}
.qty-presets {
  display: inline-flex;
  gap: 4px;
}
.qty-preset {
  min-width: 36px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.qty-preset:hover { border-color: var(--brand-ink, #0f766e); }
.qty-preset.is-active {
  background: var(--brand-ink, #0f766e);
  color: #fff;
  border-color: var(--brand-ink, #0f766e);
}

/* 时间筛选 chips (生产记录页) — 2026-06-23 UI update C: 复刻 qty-preset 视觉 */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  align-items: center;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 36px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.filter-chip:hover { border-color: var(--brand-ink, #0f766e); }
.filter-chip input[type=radio] {
  appearance: none;
  -webkit-appearance: none;
  width: 0;
  height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
}
.filter-chip input[type=date] {
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  padding: 0;
  width: auto;
  min-width: 0;
  flex-shrink: 0;
  color: inherit;
}
.filter-chip.is-active {
  background: var(--brand-ink, #0f766e);
  color: #fff;
  border-color: var(--brand-ink, #0f766e);
}
.filter-chip.is-active input { color: #fff; }

/* 生产记录页紧凑表格 */
.runs-table { display: grid; gap: 8px; }
.runs-row {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
}
.runs-row.is-rolled-back { opacity: 0.7; }
.runs-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  font-size: 13px;
}
.runs-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.runs-product { font-weight: 600; }
.runs-actions { margin-left: auto; display: flex; gap: 6px; }
.runs-actions form { margin: 0; display: inline; }
.runs-note {
  font-size: 12px;
  margin-top: 4px;
  margin-bottom: 4px;
}
.runs-bom {
  width: 100%;
  border-collapse: collapse;
  margin-top: 6px;
}
.runs-bom td {
  padding: 3px 8px;
  font-size: 13px;
  border-bottom: 1px dashed var(--border);
}
.runs-bom tr:last-child td { border-bottom: none; }
.runs-bom .bom-name { color: var(--text); }
.runs-bom .bom-qty {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

/* category quick-filter chips (restock/outbound/stocktake/adjustment) */
.cat-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--panel);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 0 12px;
  margin: 0 0 8px;
  border-bottom: 1px dashed var(--border);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
}
.cat-chip {
  width: auto;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #334155;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  display: inline-block;
}
.cat-chip:hover { background: #e2e8f0; }
.cat-chip.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
}
.entry-row.is-hidden { display: none; }

/* pad: 768-1180, two-column card grid */
@media (min-width: 720px) {
  .entry-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1100px) {
  .entry-grid { grid-template-columns: 1fr 1fr 1fr; }
}

/* list cards for inbound/outbound/adjustment history */
.record-list { display: grid; gap: 10px; margin-top: 14px; }
.record-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 14px;
  align-items: center;
}
.record-card .rc-main { min-width: 0; }
.record-card .rc-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 4px;
}
.record-card .rc-meta {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.record-card .rc-meta .sep { color: #cbd5e1; }
.record-card .rc-right {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.record-card .rc-qty {
  font-size: 20px;
  font-weight: 700;
  color: var(--brand-ink);
}
.record-card .rc-qty small { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.record-card .rc-status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #ecfeff;
  border: 1px solid #a5f3fc;
  color: #0e7490;
  font-weight: 600;
}
.record-card .rc-status.done { background: #ecfdf5; border-color: #6ee7b7; color: #047857; }
.record-card .rc-status.rollback { background: #fef3c7; border-color: #fde68a; color: #92400e; }
.record-card .rc-actions { display: flex; gap: 6px; }
.record-card .rc-actions form { display: inline; }

@media (min-width: 960px) {
  .record-list { grid-template-columns: 1fr 1fr; }
  .record-card { padding: 14px 18px; }
}

/* list header (date group) */
.record-day {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin: 18px 4px 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.record-day::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* list-page header row (new button + title) */
.list-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.list-head h2 { margin: 0; }
.list-head form { margin: 0; }
.list-head form button { width: auto; min-width: 140px; }

/* mobile layout: stack everything vertically */
@media (max-width: 720px) {
  .user-card-head { flex-direction: column; }
  .user-card-meta { text-align: left; }
  .role-matrix { font-size: 12px; }
  .role-matrix th, .role-matrix td { padding: 4px 2px; }
  .role-row-label { min-width: 100%; }
  .role-row-form { width: 100%; }
  .role-row-form select,
  .role-row-form input[type="password"] { flex: 1; }
  .session-head {
    grid-template-columns: 1fr;
  }
  .session-head .session-actions { width: 100%; }
  .session-head .session-actions input { width: 100%; }
  .session-head .session-actions button { width: 100%; }
  .session-head h2 { font-size: 17px; }
  .record-card { grid-template-columns: 1fr; }
  .record-card .rc-right { align-items: flex-start; text-align: left; }
  .record-card .rc-qty { font-size: 22px; }
}

/* 2026-06-23 UI update — A: recipe note block */
.recipe-note {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.recipe-note-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.recipe-note p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

/* 2026-06-23 UI update — B: production submit button ~2x height */
#submit-btn {
  padding: 22px 24px;
  min-height: 84px;
  font-size: 16px;
}

/* 2026-06-23 UI update — E: inventory client-side hide */
.inv-card.is-hidden { display: none; }
tr.is-hidden { display: none; }

/* Summary time-range + turnover card */
.summary-range { margin: 8px 0 14px; }
.turnover-card { background: #ecfdf5; border-color: #0f766e; }
.turnover-card p { color: #0f766e; }
.turnover-card strong { color: #0f766e; }
.turnover-card .muted { color: #047857; }

/* Page-header: layout row with title + action button */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

/* 出入库/盘点单位选择 segment + 换算提示 */
.seg {
  display: inline-flex;
  background: #eef2f6;
  border-radius: 999px;
  padding: 2px;
  gap: 2px;
  margin-bottom: 6px;
}
.seg button {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.seg button.active { background: var(--brand); color: #fff; }
.calc-hint {
  margin-top: 6px;
  font-size: 11px;
  color: var(--brand-ink);
  background: #d9f5ef;
  padding: 4px 8px;
  border-radius: 8px;
  display: inline-block;
}
.calc-hint[hidden] { display: none; }

/* Modal overlay + dialog */
.modal-overlay {
  position: fixed; inset: 0; z-index: 999;
  background: rgba(0,0,0,0.35);
  display: flex; align-items: center; justify-content: center;
}
.modal-overlay[hidden] { display: none !important; }
.modal {
  background: #fff; border-radius: 16px;
  width: 360px; max-width: 90vw;
  padding: 20px; box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  position: relative;
}
.modal h3 { margin: 0 0 4px; font-size: 16px; }
.modal .modal-stock { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.modal-close {
  position: absolute; top: 12px; right: 16px;
  background: none; border: none; font-size: 18px;
  color: var(--muted); cursor: pointer; padding: 4px;
}

/* 反馈悬浮窗（Issue #108）：表单比数字键盘弹层宽，纵向可滚，窄屏占满宽度 */
.modal.modal--feedback {
  width: 520px; max-width: 92vw;
  max-height: 88vh; overflow-y: auto;
}
.modal--feedback label {
  display: block; font-size: 13px; color: var(--muted);
  margin-bottom: 12px;
}
.modal--feedback input[type="text"],
.modal--feedback select,
.modal--feedback textarea {
  width: 100%; margin-top: 5px;
  font-family: inherit; font-size: 14px; color: var(--text);
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 11px;
}
.modal--feedback textarea { resize: vertical; }
.modal--feedback input[type="text"]:focus,
.modal--feedback select:focus,
.modal--feedback textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}
.modal--feedback .fb-error {
  margin: 0 0 12px; font-size: 13px; color: #b91c1c;
}
.modal--feedback .modal-actions {
  display: flex; justify-content: flex-end; gap: 8px;
}

/* Pill group — separate rounded pills */
.pill-group {
  display: flex; gap: 12px; margin-bottom: 14px;
}
.pill {
  border: 1.5px solid var(--border); border-radius: 999px;
  background: transparent; color: var(--muted);
  font-size: 13px; padding: 6px 18px; cursor: pointer;
}
.pill--active {
  border-color: var(--brand); background: var(--brand); color: #fff;
}

/* Filled card state */
.card--filled { background: #ecfdf5 !important; }
.card-summary {
  font-size: 11px; color: #0f766e; text-align: right;
  margin-top: 4px;
}

/* --- recipe-cost module ----------------------------------------------- */

.checkbox-label {
  display: inline-flex;
  align-items: center;     /* vertical-center checkbox with text */
  gap: 0.4rem;
  cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
  width: auto;             /* override global 100% width */
  margin: 0;
  vertical-align: middle;
}
.checkbox-label span { line-height: 1; }

/* BOM table: fixed layout so the row width matches the table, and
   columns don't squish on mobile. Numeric columns stay narrow. */
table.bom-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}
table.bom-table th,
table.bom-table td {
  padding: 8px;
  vertical-align: middle;
  overflow-wrap: anywhere; /* long item names wrap instead of overflowing */
}
table.bom-table td .bom-qty,
table.bom-table td .bom-temp-price {
  width: 100%;
  box-sizing: border-box;
}

/* Compact del-flag label so delete checkbox + word don't overflow */
.del-flag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}
.del-flag input[type="checkbox"] { width: auto; margin: 0; }

/* Recipe card (ic_recipes) — full recipe + cost + margin, redesigned for clarity.
   2-col grid; BOM table stays readable. Sale price is the hero of each card. */
.recipe-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
@media (max-width: 760px) { .recipe-cards { grid-template-columns: 1fr; } }

.recipe-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 16px 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
  overflow: hidden;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.recipe-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 4px;
  background: linear-gradient(90deg, #0f766e, #0e7490);
}
.recipe-card:hover { box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12); transform: translateY(-2px); }

.recipe-card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.recipe-card__title { min-width: 0; }
.recipe-card__title h3 { margin: 0; font-size: 18px; font-weight: 700; color: var(--brand-ink); letter-spacing: 0.3px; }
.recipe-card__title p { margin: 4px 0 0; font-size: 12px; color: var(--muted); }

.recipe-card__price {
  flex-shrink: 0;
  text-align: right;
  background: linear-gradient(135deg, #0f766e, #0e7490);
  color: #fff;
  border-radius: 12px;
  padding: 8px 14px;
  min-width: 96px;
}
.rc-price-label { display: block; font-size: 11px; opacity: 0.88; letter-spacing: 1px; }
.rc-price-val { display: block; font-size: 21px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 2px; }

.recipe-card__actions { display: flex; gap: 6px; }
.recipe-card__actions form { margin: 0; }

.recipe-card__section { display: flex; flex-direction: column; gap: 8px; }
.rc-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 1px;
  padding-left: 9px;
  border-left: 3px solid var(--brand);
}

.recipe-card__bom {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.rc-bom-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 10px;
  padding: 8px 12px;
  font-size: 12.5px;
  align-items: center;
  border-bottom: 1px solid #eef2f6;
}
.rc-bom-row:last-child { border-bottom: none; }
.rc-bom-row:nth-child(even) { background: #f8fafc; }
.rc-bom-head {
  background: linear-gradient(90deg, #f1f5f9, #eef2f6);
  font-weight: 600;
  color: var(--muted);
  font-size: 11.5px;
  border-bottom: 1px solid #e2e8f0;
}
.rc-bom-row:hover:not(.rc-bom-head) { background: #f0f9f6; }
.rc-bom-name { overflow-wrap: anywhere; font-weight: 500; color: var(--text); }
.rc-bom-empty { color: var(--muted); padding: 14px 12px; }
.rc-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--text); }

.recipe-card__summary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
/* 窄屏两列会把数值挤成竖排换行，降到单列。 */
@media (max-width: 560px) {
  .recipe-card__summary { grid-template-columns: 1fr; }
}
.rc-sum {
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
  border: 1px solid #eef2f6;
  border-radius: 12px;
  padding: 10px 12px;
}
.rc-sum-label { display: block; font-size: 11px; color: var(--muted); }
.rc-sum-val { display: block; font-size: 17px; font-weight: 800; color: var(--brand-ink); margin-top: 3px; font-variant-numeric: tabular-nums; }

.recipe-card__margin { display: flex; flex-direction: column; gap: 11px; }
.rc-margin { display: flex; flex-direction: column; gap: 5px; }
.rc-margin--purchase { --c: #10b981; --ct: #047857; }
.rc-margin--selling  { --c: #3b82f6; --ct: #1d4ed8; }
.rc-margin--profit   { --c: #f59e0b; --ct: #b45309; }
.rc-margin-top { display: flex; align-items: baseline; gap: 8px; }
.rc-margin-label { font-size: 12.5px; color: var(--text); font-weight: 500; }
.rc-margin-val { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ct); }
.rc-margin-pct { margin-left: auto; font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ct); }
.rc-margin-pct.is-neg { color: #dc2626; }
.rc-bar { height: 7px; border-radius: 99px; background: #eef2f6; overflow: hidden; }
.rc-bar-fill { height: 100%; border-radius: 99px; background: var(--c); transition: width 0.2s ease; }

/* 编辑页：售价「原价 vs 调整价」对比 + 负利润醒目提示（与现有风格一致） */
/* ===== 原料销售单价试算 ===== */
/* 调整列——编辑页中原料销售单价的覆写输入 */
.sp-adj-col { width: 100px; }
.bom-sp-adj {
  width: 100%;
  padding: 4px 6px;
  font-size: 12px;
  text-align: right;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  background: #fafbfd;
  transition: border-color 0.15s, background 0.15s;
}
.bom-sp-adj:focus {
  outline: none;
  border-color: var(--brand);
  background: #fff;
}
/* 调整值与品项原价不同时，高亮背景提示 */
.bom-sp-adj.is-adjusted {
  border-color: var(--brand);
  background: #f0fdf9;
}

/* 表后浮动影响汇总 */
.bom-delta-note {
  margin: 10px 0 4px;
  padding: 8px 12px;
  border-radius: 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* 负利润警告：紧贴影响汇总下方 */
.margin-warning {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  font-size: 13px;
  font-weight: 600;
}
.margin-warning .mw-icon { font-size: 16px; line-height: 1; }

/* footer 净利润为负标红 */
#footer-profit.is-neg { color: #dc2626; font-weight: 800; }

/* === 门店订货 v3 增量（A4/A6/A8） === */
.info-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 14px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px 18px;
  align-items: start;
}
.info-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 14px;
  font-size: 12px;
  color: var(--muted);
  min-width: 0;
}
.info-card-grid > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.info-card-grid strong { color: var(--text); font-weight: 600; margin-right: 4px; }
@media (max-width: 720px) {
  .info-card { grid-template-columns: 1fr; }
  .info-card-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .info-card-grid { grid-template-columns: 1fr; }
}
/* nowrap + ellipsis 在窄屏会把字段截成「…」，中屏起允许换行。 */
@media (max-width: 960px) {
  .info-card-grid > div { white-space: normal; }
}
.info-card-totals {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 200px;
}
/* 拆分项（货品金额 / 运费）：浅底深字，与大号总计形成层级对比 */
.info-card-fee {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 12px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
}
.info-card-fee-label { font-size: 12px; color: var(--muted); }
.info-card-fee-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.info-card-total {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  background: linear-gradient(135deg, #0f766e 0%, #0e7490 100%);
  color: #fff;
  border-radius: 12px;
  padding: 12px 18px;
  min-width: 180px;
  align-self: stretch;
  justify-content: center;
}
.info-card-total-label {
  font-size: 11px;
  opacity: 0.88;
  letter-spacing: 0.5px;
}
.info-card-total-value {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
}
.dc-stock {
  display: inline-block;
  font-variant-numeric: tabular-nums;
  padding: 1px 8px;
  border-radius: 999px;
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  color: #047857;
  font-weight: 600;
  font-size: 12px;
}
.dc-stock.negative {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}
/* order_detail 内已有 .status-pill.pending/.approved/.shipped/.delivered 等
   配色，沿用 inventory.css / restock 的命名。这里补几个状态色保证 pill
   文本可读。 */
.status-pill.pending { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.status-pill.approved { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.status-pill.shipped { background: #ede9fe; color: #5b21b6; border: 1px solid #c4b5fd; }
.status-pill.delivered { background: #ecfdf5; color: #047857; border: 1px solid #6ee7b7; }
.status-pill.rejected { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.status-pill.suggested { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.status-pill.cancelled { background: #f3f4f6; color: #4b5563; border: 1px solid #e5e7eb; }

/* === 订单操作条（order_detail 底部审批/发货/取消区）===
   统一按钮高度 40px + 同字号 + 同圆角，避免 .btn-sm（11px 字/4px padding）
   与全局 input（11px padding）混排时高低不齐、主次不分。
   注意：作用域限定在 .order-actions 内，不改全站 .btn-sm 行为。 */
.order-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
}
.order-actions form {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  width: auto;
}
/* 表单内的输入框与按钮同高；宽度自适应但仍可分到空间 */
.order-actions form input:not([type="hidden"]) {
  width: auto;
  flex: 1 1 160px;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
}
.order-actions form input:not([type="hidden"]):focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

/* 按钮基类：统一尺寸，主次靠配色区分 */
.order-actions .btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: 40px;
  min-width: 104px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.order-actions .btn-action:active { transform: translateY(1px); }

/* 主操作（通过）：实心品牌色 */
.order-actions .btn-action.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.order-actions .btn-action.primary:hover {
  background: var(--brand-ink);
  border-color: var(--brand-ink);
}

/* 危险操作（拒绝 / 取消订单）：默认描边，hover 实心 */
.order-actions .btn-action.danger {
  background: #fff;
  border-color: #fca5a5;
  color: #b91c1c;
}
.order-actions .btn-action.danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
  color: #fff;
}

/* 次要操作（一次性收货 / 返回）：中性描边 */
.order-actions .btn-action.ghost {
  background: #fff;
  border-color: var(--border);
  color: var(--brand-ink);
}
.order-actions .btn-action.ghost:hover {
  background: rgba(15, 118, 110, 0.08);
  border-color: var(--brand);
}

/* 移动端：竖排满宽，输入框独占一行 */
@media (max-width: 640px) {
  .order-actions { flex-direction: column; align-items: stretch; }
  .order-actions form { width: 100%; }
  .order-actions form input:not([type="hidden"]) { flex: 1 1 100%; }
  .order-actions .btn-action { width: 100%; }
}

/* 表格行内操作按钮（订货审批列表「详情/审批」等）：
   32px 高 + 13px 字，比 .btn-sm（11px 字）好点，又不撑破紧凑表格。 */
a.btn-table,
button.btn-table {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: 32px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--brand);
  background: #fff;
  color: var(--brand-ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
a.btn-table:hover,
button.btn-table:hover {
  background: var(--brand);
  color: #fff;
}

/* 键盘可达性：两类新按钮统一 focus 轮廓 */
.order-actions .btn-action:focus-visible,
a.btn-table:focus-visible,
button.btn-table:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ajax-form.js 成功提示浮窗。
   跟随 .is-show 类做淡入淡出；超时后自动消失。 */
.ajax-flash {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  background: #047857;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
  /* 长提示（品项名 + 数量）在窄屏会撑出视口，限宽并允许折行。 */
  max-width: calc(100vw - 32px);
  text-align: center;
}
.ajax-flash.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== recipe_cost 模块升级（2026-10-16）：tab 导航 + 成本总览 ===== */
.recipe-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.recipe-tabs a {
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
}
.recipe-tabs a:hover { color: var(--brand-ink); }
.recipe-tabs a.is-active {
  color: var(--brand-ink);
  border-bottom-color: var(--brand);
}

.ov-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.ov-kpis .kpi-card span { font-size: 12px; color: var(--muted); }
.ov-kpis .kpi-card.is-warn { border-color: #f59e0b; }
.ov-kpis .kpi-card.is-warn strong { color: #b45309; }
.ov-kpis .kpi-card.is-bad { border-color: #ef4444; }
.ov-kpis .kpi-card.is-bad strong { color: #b91c1c; }

.ov-filter { display: flex; gap: 10px; margin-bottom: 12px; }

.ov-table th a { color: inherit; text-decoration: none; }
.ov-table th a.is-sorted { color: var(--brand); }
.ov-table td.num, .ov-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.ov-table td.is-neg { color: #b91c1c; font-weight: 700; }
.ov-row-neg { background: #fef2f2; }
.ov-row-unpriced { background: #fffbeb; }

.ov-kind {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.ov-kind--ic_recipe { background: #e0f2fe; color: #075985; }
.ov-kind--recipe { background: #dcfce7; color: #166534; }

.ov-tag-unpriced {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: #fef3c7;
  color: #92400e;
  font-size: 11px;
}

.ov-legend { margin-top: 10px; font-size: 12px; line-height: 1.7; }

/* 门店配方导入 */
.ov-import-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.ov-import-card { padding: 14px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; }
.ov-import-card h3 { margin: 0 0 6px; font-size: 15px; }
.ov-import-card .muted { font-size: 12px; }
.imp-unmatched { color: #b91c1c; font-weight: 600; }
.imp-matched { color: #166534; }
.imp-conflict { background: #fffbeb; }

.imp-toolbar { display: flex; gap: 8px; align-items: center; margin: 10px 0; }
.imp-bom { margin: 6px 0 10px; border: none; box-shadow: none; }
.imp-bom th, .imp-bom td { border-bottom: 1px dashed var(--border); font-size: 11px; padding: 4px 8px; }
.imp-bom td.num, .imp-bom th.num { text-align: right; }

/* 付款凭证（Issue #135）：图片缩略图 + PDF 卡片，自适应列宽 */
.proof-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 10px 0 18px; }
.proof-item { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); text-decoration: none; color: inherit; }
.proof-item:hover { border-color: var(--primary); }
.proof-thumb { width: 100%; height: 120px; object-fit: cover; border-radius: 6px; background: #f1f5f9; }
.proof-pdf { display: flex; align-items: center; justify-content: center; height: 120px; border-radius: 6px; background: #fef2f2; color: #b91c1c; font-weight: 700; letter-spacing: 1px; }
.proof-name { font-size: 12px; color: #64748b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Whole-order changes: single-column forms and comparisons on narrow phones. */
.order-change { max-width: 46rem; margin-inline: auto; overflow-wrap: anywhere; }
.order-change form { display: grid; gap: .85rem; margin-block: 1.25rem; min-width: 0; }
.order-change fieldset { min-width: 0; margin: 0; }
.order-change label { display: grid; gap: .35rem; min-width: 0; }
.order-change input, .order-change select, .order-change textarea,
.order-change button { box-sizing: border-box; width: 100%; min-width: 0; max-width: 100%; }
.order-change select { white-space: normal; }
.order-change textarea { min-height: 5rem; }
.order-change legend { max-width: 100%; white-space: normal; }
/* Proposal inbox links stay inside a scroll container even with JS disabled. */
main > table:has(a[href^="/store-ordering/orders/"][href*="/changes/"]) {
  display: block; max-width: 100%; overflow-x: auto;
}
@media (max-width: 600px) {
  .order-change button.danger { color: #b91c1c; background: #fff; border: 1px solid #fca5a5; }
}
