
  * { margin: 0; padding: 0; box-sizing: border-box; }
  :root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --bg: #f5f7fa;
    --card: #ffffff;
    --border: #e5e7eb;
    --text: #1f2937;
    --text-light: #6b7280;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --sidebar-w: 220px;
  }
  body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
  }
  /* 布局 */
  .app { display: flex; min-height: 100vh; }
  .sidebar {
    width: var(--sidebar-w);
    background: #1e293b;
    color: #cbd5e1;
    position: fixed; top: 0; left: 0; bottom: 0;
    display: flex; flex-direction: column;
    z-index: 10;
  }
  .sidebar-header {
    padding: 20px;
    color: #fff;
    font-size: 16px; font-weight: 600;
    border-bottom: 1px solid #334155;
  }
  .sidebar-header small { display: block; font-size: 11px; color: #94a3b8; font-weight: 400; margin-top: 4px; }
  .nav { flex: 1; padding: 12px 0; overflow-y: auto; }
  .nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 20px;
    cursor: pointer;
    color: #cbd5e1;
    border-left: 3px solid transparent;
    transition: all .15s;
    user-select: none;
  }
  .nav-item:hover { background: #334155; color: #fff; }
  .nav-item.active { background: #0f172a; color: #fff; border-left-color: var(--primary); }
  .nav-item .icon { width: 18px; text-align: center; }
  .nav-section { padding: 14px 20px 6px; font-size: 11px; color: #64748b; text-transform: uppercase; letter-spacing: 1px; }
  .main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); padding: 24px 28px; }
  .page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
  .page-header h1 { font-size: 20px; font-weight: 600; }
  .page-header .desc { color: var(--text-light); font-size: 13px; margin-top: 4px; }
  /* 手机端仪表盘右上角同步状态（桌面默认隐藏，移动端显示） */
  .sync-status-mobile { display: none; }
  /* 首屏加载占位（JS 渲染前避免白屏） */
  .page-loading {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 12px; padding: 100px 0; color: var(--text-light); font-size: 13px;
  }
  .loading-spinner {
    width: 28px; height: 28px;
    border: 3px solid var(--border); border-top-color: var(--primary);
    border-radius: 50%; animation: spin .8s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }
  /* 仪表盘最近列表：固定 3 行高度，超出滚动，表头固定不随滚动 */
  .dash-list-wrap { max-height: 172px; overflow-y: auto; }
  .dash-list-wrap thead th { position: sticky; top: 0; background: #f9fafb; z-index: 1; }
  /* 出入库统计报表 */
  .rp-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; align-items: center; }
  .rp-tab {
    display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 12px;
    background: #f1f5f9; color: #475569; cursor: pointer; border: 1px solid transparent; user-select: none;
  }
  .rp-tab.active { background: var(--primary); color: #fff; }
  .rp-custom { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; color: var(--text-light); }
  .rp-custom input[type="date"] { padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; }
  .rp-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-bottom: 14px; }
  .rp-stat { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; background: #f8fafc; }
  .rp-stat .rp-label { display: block; font-size: 11px; color: var(--text-light); margin-bottom: 2px; }
  .rp-stat b { display: block; font-size: 18px; line-height: 1.2; }
  .rp-stat i { display: block; font-style: normal; font-size: 11px; color: var(--text-light); margin-top: 2px; }
  .rp-pos { color: var(--success); }
  .rp-neg { color: var(--danger); }
  .rp-chart-head, .rp-detail-head { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-light); margin-bottom: 8px; }
  .rp-detail-head { margin-top: 6px; }
  .rp-export { margin-left: auto; }
  .rp-chart-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; max-width: 100%; }
  .rp-chart-inner { min-width: 100%; }
  .rp-chart-svg { display: block; width: 100%; }
  .rp-detail-tbl td, .rp-detail-tbl th { white-space: normal; }
  .rp-more td { text-align: center; color: var(--text-light); font-size: 11px; }
  /* 卡片 */
  .card {
    background: var(--card);
    border-radius: 8px;
    border: 1px solid var(--border);
    padding: 20px;
    margin-bottom: 16px;
  }
  /* 统计卡片 */
  .stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
  .stat-card {
    background: var(--card); border-radius: 8px; padding: 18px 20px;
    border: 1px solid var(--border); position: relative; overflow: hidden;
  }
  .stat-card .label { color: var(--text-light); font-size: 12px; }
  .stat-card .value { font-size: 26px; font-weight: 600; margin-top: 6px; }
  .stat-card .trend { font-size: 12px; margin-top: 4px; color: var(--text-light); }
  .stat-card.primary { border-left: 3px solid var(--primary); }
  .stat-card.success { border-left: 3px solid var(--success); }
  .stat-card.warning { border-left: 3px solid var(--warning); }
  .stat-card.danger { border-left: 3px solid var(--danger); }
  /* 按钮 */
  .btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border: 1px solid var(--border);
    background: #fff; border-radius: 6px; cursor: pointer;
    font-size: 13px; color: var(--text);
    transition: all .15s;
  }
  .btn:hover { background: #f9fafb; }
  .btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
  .btn-primary:hover { background: var(--primary-dark); }
  .btn-danger { color: var(--danger); border-color: #fecaca; }
  .btn-danger:hover { background: #fef2f2; }
  .btn-sm { padding: 4px 10px; font-size: 12px; }
  .btn:disabled { opacity: .5; cursor: not-allowed; }
  /* 表格 */
  .table-wrap { overflow-x: auto; }
  table { width: 100%; border-collapse: collapse; font-size: 13px; }
  th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
  th { background: #f9fafb; color: var(--text-light); font-weight: 600; font-size: 12px; }
  tbody tr:hover { background: #f9fafb; }
  .tag {
    display: inline-block; padding: 2px 8px; border-radius: 4px;
    font-size: 11px; font-weight: 500;
  }
  .tag-blue { background: #dbeafe; color: #1e40af; }
  .tag-green { background: #d1fae5; color: #065f46; }
  .tag-yellow { background: #fef3c7; color: #92400e; }
  .tag-gray { background: #f3f4f6; color: #4b5563; }
  .tag-red { background: #fee2e2; color: #991b1b; }
  /* 表单 */
  .form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .form-grid .full { grid-column: 1 / -1; }
  .form-group label { display: block; font-size: 12px; color: var(--text-light); margin-bottom: 4px; }
  .field-hint { font-size: 12px; color: var(--text-light); margin-top: 4px; }
  .form-group label .req { color: var(--danger); }
  input, select, textarea {
    width: 100%; padding: 8px 10px; border: 1px solid var(--border);
    border-radius: 6px; font-size: 13px; font-family: inherit;
    background: #fff;
  }
  input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
  /* 弹窗 */
  .modal-mask {
    position: fixed; inset: 0; background: rgba(0,0,0,.5);
    display: none; align-items: center; justify-content: center;
    z-index: 100;
  }
  .modal-mask.show { display: flex; }
  .modal {
    background: #fff; border-radius: 10px; width: 640px; max-width: 92vw;
    max-height: 88vh; overflow: hidden; display: flex; flex-direction: column;
  }
  .modal.lg { width: 880px; }
  .modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
  .modal-header h3 { font-size: 16px; }
  .modal-close { cursor: pointer; color: var(--text-light); font-size: 22px; line-height: 1; }
  .modal-body { padding: 20px; overflow-y: auto; flex: 1; }
  .modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
  /* 工具栏 */
  .toolbar { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; flex-wrap: wrap; }
  .toolbar .search { flex: 1; min-width: 200px; max-width: 320px; }
  /* 提示 */
  .empty { text-align: center; padding: 40px 20px; color: var(--text-light); }
  .empty .icon { font-size: 36px; margin-bottom: 8px; opacity: .5; }
  .toast {
    position: fixed; top: 20px; right: 20px; z-index: 200;
    padding: 12px 18px; border-radius: 6px; color: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
    opacity: 0; transform: translateY(-10px); transition: all .25s;
    font-size: 13px;
  }
  .toast.show { opacity: 1; transform: translateY(0); }
  .toast.success { background: var(--success); }
  .toast.error { background: var(--danger); }
  .toast.info { background: var(--primary); }
  .mats-cell { font-weight: 500; }
  /* 单据明细行 */
  .detail-row { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 8px; align-items: end; margin-bottom: 8px; }
  /* 出库明细行：物料/批次/数量/售价/成本 */
  .detail-row.ob { grid-template-columns: 2fr 1.1fr 0.9fr 0.9fr 1fr auto; }
  /* 入库明细行：物料/袋数/每袋kg/总重量kg/单价/生产日期 */
  .detail-row.in { grid-template-columns: 2fr 0.9fr 0.9fr 1fr 1fr 1fr auto; }
  .detail-row .del-btn { background: none; border: none; color: var(--danger); cursor: pointer; padding: 8px; }
  /* 字段标签：明细行内始终显示（跟随 .form-group label 样式），避免不知道该填什么 */
  .add-detail { margin-top: 8px; }
  .info-box { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 6px; padding: 12px; font-size: 13px; color: #1e40af; margin-bottom: 14px; }
  .info-box.warn { background: #fef3c7; border-color: #fde68a; color: #92400e; }
  .trace-chain { padding: 10px 0; }
  .trace-node { padding: 10px 14px; border-left: 2px solid var(--primary); margin-left: 8px; position: relative; }
  .trace-node::before { content: ''; width: 10px; height: 10px; background: var(--primary); border-radius: 50%; position: absolute; left: -6px; top: 14px; }
  .trace-node .title { font-weight: 600; }
  /* 追溯节点信息：紧凑的标签-值对齐列表 */
  .trace-kv { grid-template-columns: 3.5em 1fr; gap: 3px 10px; font-size: 12px; margin-top: 4px; }
  .trace-kv dt { color: #94a3b8; }
  .trace-kv dd { word-break: break-all; }
  .kv-list { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; font-size: 13px; }
  .kv-list dt { color: var(--text-light); }
  /* 更多菜单 & 遮罩（默认隐藏，移动端才显示） */
  .more-menu, .mask-layer { display: none; }
  .more-menu { position: fixed; bottom: 66px; right: 12px; background: #fff; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.15); padding: 8px 0; min-width: 140px; z-index: 60; }
  .more-menu.show { display: block; }
  .more-menu-item { padding: 10px 18px; font-size: 13px; cursor: pointer; color: var(--text); display: flex; align-items: center; gap: 8px; }
  .more-menu-item:active { background: #f3f4f6; }
  .mask-layer { position: fixed; inset: 0; background: rgba(0,0,0,.2); z-index: 55; }
  .mask-layer.show { display: block; }
  /* ========== 移动端适配 ========== */
  @media (max-width: 768px) {
    .sidebar { display: none !important; }
    .main { margin-left: 0 !important; padding: 16px 14px 80px 14px; }
    .stats-grid { grid-template-columns: 1fr 1fr !important; gap: 10px; }
    /* 恰好 3 张卡片 → 同一行三列 */
    .stats-grid:has(> .stat-card:last-child:nth-child(3)) { grid-template-columns: repeat(3, 1fr) !important; gap: 8px; }
    .stats-grid:has(> .stat-card:last-child:nth-child(3)) > .stat-card:last-child { grid-column: auto; }
    /* 卡片总数为奇数（5 张等）时，最后一张跨整行 */
    .stat-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
    .stat-card { padding: 12px 16px; }
    .stat-card .value { font-size: 22px; }
    /* 报表：汇总 2 列、自定义日期换行、明细卡间距 */
    .rp-summary { grid-template-columns: 1fr 1fr; }
    .rp-custom { flex-wrap: wrap; }
    .rp-detail-tbl.cards-2col tbody tr { margin-bottom: 8px; }
    .rp-chart-wrap { max-width: 100%; min-width: 0; }
    .rp-export { padding: 4px 10px; font-size: 12px; }
    .form-grid { grid-template-columns: 1fr !important; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 10px; position: relative; }
    /* 刷新按钮固定到页面标题右上角 */
    .page-header .header-refresh { position: absolute; top: 0; right: 0; }
    .sync-status-mobile {
      display: inline-block;
      position: absolute; top: 6px; right: 0;
      font-size: 12px; white-space: nowrap;
      background: var(--card); border: 1px solid var(--border);
      border-radius: 12px; padding: 3px 10px;
    }
    /* 移动端卡片更高，最近列表放宽到约 3 张卡片高度 */
    .dash-list-wrap { max-height: 360px; }
    .toolbar { flex-wrap: wrap; }
    .toolbar .search { max-width: none; min-width: 0; width: 100%; }
    table { font-size: 12px; }
    th, td { padding: 8px 6px; white-space: nowrap; }
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    /* 所有表格 → 卡片（手机不缩放、不横滑）：每行一个字段竖向排列 */
    .table-cards, .table-cards thead, .table-cards tbody, .table-cards tfoot { display: block; }
    .table-cards thead { display: none; }
    .table-cards tr {
      display: grid; grid-template-columns: 1fr; align-items: center;
      border: 1px solid var(--border); border-radius: 10px;
      padding: 4px 12px; margin-bottom: 8px; background: var(--card);
    }
    .table-cards td {
      display: flex; justify-content: space-between; align-items: center;
      border: none; padding: 5px 6px; white-space: normal; text-align: right; font-size: 12px; min-width: 0;
    }
    .table-cards td::before {
      content: attr(data-label) "："; color: var(--text-light); font-size: 11px;
      flex-shrink: 0; margin-right: 4px;
    }
    /* 操作按钮行：独占卡片底部一行，按钮靠右横排，上边框分隔 */
    .table-cards tr.has-actions > td:last-child {
      grid-column: 1 / -1; grid-row: auto; margin-top: 4px;
      display: flex; flex-direction: row; justify-content: flex-end; align-items: center; gap: 8px;
      border-top: 1px solid var(--border); padding-top: 8px;
    }
    /* 仅隐藏操作列（带按钮的行）的标签，数据表末列标签正常显示 */
    .table-cards tr.has-actions > td:last-child::before { content: none; }
    .table-cards tfoot { display: block; }
    .table-cards tfoot tr { display: flex; border: none; padding: 8px 0 2px; background: none; }
    .table-cards tfoot td { border: none; padding: 0; }
    .table-cards tfoot td:first-child { flex: 1; justify-content: flex-end; }
    /* 空状态/合并单元格：跨满所有 grid 列，不显示 data-label */
    .table-cards td[colspan] {
      grid-column: 1 / -1; display: block; text-align: center; padding: 20px 12px;
    }
    .table-cards td[colspan]::before { content: none; }
    /* 空状态行 tr 本身不要卡片边框（和外面的 .card 不要双层套娃） */
    .table-cards tr.is-empty {
      border: none; background: transparent; padding: 0; margin-bottom: 0; border-radius: 0;
    }
    /* 双列卡片：入库/出库/库存 手机端卡片两两并排（其他页面保持单列） */
    .table-cards.cards-2col tbody { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
    .table-cards.cards-2col tbody tr {
      margin-bottom: 0; padding: 9px 11px 7px; border-radius: 12px;
      box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
    }
    .table-cards.cards-2col tbody tr.is-empty { grid-column: 1 / -1; }
    /* 字段行：标签固定在左（浅灰小字），值紧跟其后自然换行，不再两端分散 */
    .table-cards.cards-2col td {
      display: flex; justify-content: flex-start; align-items: baseline; gap: 6px;
      padding: 2.5px 0; text-align: left; font-size: 12px; line-height: 1.45;
      word-break: break-all;
    }
    .table-cards.cards-2col td::before {
      content: attr(data-label); width: var(--label-w, 30px); flex-shrink: 0; margin-right: 0;
      color: #94a3b8; font-size: 11px; white-space: nowrap;
    }
    /* 单号作为卡片标题行：加粗，超长自动省略号 */
    .table-cards.cards-2col td:first-child {
      display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
      font-weight: 600; font-size: 12.5px; padding-top: 2px; padding-bottom: 4px;
    }
    .table-cards.cards-2col td:first-child::before { font-weight: 400; }
    /* 出库卡片定制：单号隐藏、物料作标题（黑色加粗标签紧贴信息，信息不加粗）、状态左下角与操作按钮同行 */
    #obTable.cards-2col tr { grid-template-columns: 1fr 1fr; }
    /* 标签按实际文字宽度，不留保留列宽 */
    #obTable.cards-2col td::before { width: auto; }
    #obTable.cards-2col td:first-child {
      grid-column: 1 / -1; display: flex; gap: 4px; align-items: baseline;
      font-size: 13px; line-height: 1.5;
    }
    #obTable.cards-2col td:first-child::before {
      content: attr(data-label); width: auto; flex-shrink: 0;
      color: #1e293b; font-size: 13px; font-weight: 700;
    }
    #obTable.cards-2col .ob-mats {
      flex: 1; white-space: pre-line; font-weight: 400; word-break: break-all;
    }
    #obTable.cards-2col td:nth-child(2) { display: none; }
    #obTable.cards-2col td:nth-child(3),
    #obTable.cards-2col td:nth-child(4),
    #obTable.cards-2col td:nth-child(5),
    #obTable.cards-2col td:nth-child(6) { grid-column: 1 / -1; }
    /* 状态：放在售价下方，占整行，显示「状态」标签 + 徽章 */
    #obTable.cards-2col td:nth-child(7) {
      grid-column: 1 / -1; margin-top: 0; padding-top: 2.5px; border-top: none;
    }
    /* 操作按钮独占底部一行，靠右 */
    #obTable.cards-2col tr.has-actions > td:last-child { grid-column: 1 / -1; justify-content: flex-end; }
    /* 入库卡片定制：隐藏单号、物料作标题（黑色加粗标签紧贴信息，信息不加粗）、多物料换行 */
    #inTable.cards-2col tr { grid-template-columns: 1fr 1fr; }
    /* 标签按实际文字宽度，不留保留列宽 */
    #inTable.cards-2col td::before { width: auto; }
    #inTable.cards-2col td:first-child { display: none; }
    #inTable.cards-2col td:nth-child(2) {
      grid-column: 1 / -1; display: flex; gap: 4px; align-items: baseline;
      font-size: 13px; line-height: 1.5;
    }
    #inTable.cards-2col td:nth-child(2)::before {
      content: attr(data-label); width: auto; flex-shrink: 0;
      color: #1e293b; font-size: 13px; font-weight: 700;
    }
    #inTable.cards-2col .in-mats {
      flex: 1; white-space: pre-line; font-weight: 400; word-break: break-all;
    }
    #inTable.cards-2col td:nth-child(3),
    #inTable.cards-2col td:nth-child(4),
    #inTable.cards-2col td:nth-child(5),
    #inTable.cards-2col td:nth-child(6) { grid-column: 1 / -1; }
    /* 库存查询卡片定制：隐藏物料编码/批次号、物料作标题（黑色加粗标签紧贴信息，信息不加粗）、多物料换行 */
    #stockSummaryTable.cards-2col tr,
    #stockDetailTable.cards-2col tr { grid-template-columns: 1fr 1fr; }
    /* 标签按实际文字宽度，不留保留列宽 */
    #stockSummaryTable.cards-2col td::before,
    #stockDetailTable.cards-2col td::before { width: auto; }
    /* 隐藏物料编码列 / 批次号列 */
    #stockSummaryTable.cards-2col td:first-child,
    #stockDetailTable.cards-2col td:first-child { display: none; }
    /* 物料标题行 */
    #stockSummaryTable.cards-2col td:nth-child(2),
    #stockDetailTable.cards-2col td:nth-child(2) {
      grid-column: 1 / -1; display: flex; gap: 4px; align-items: baseline;
      font-size: 13px; line-height: 1.5;
    }
    #stockSummaryTable.cards-2col td:nth-child(2)::before,
    #stockDetailTable.cards-2col td:nth-child(2)::before {
      content: attr(data-label); width: auto; flex-shrink: 0;
      color: #1e293b; font-size: 13px; font-weight: 700;
    }
    #stockSummaryTable.cards-2col .in-mats,
    #stockDetailTable.cards-2col .in-mats {
      flex: 1; white-space: pre-line; font-weight: 400; word-break: break-all;
    }
    /* 其余字段各占整行 */
    #stockDetailTable.cards-2col td:nth-child(3),
    #stockDetailTable.cards-2col td:nth-child(4),
    #stockDetailTable.cards-2col td:nth-child(5),
    #stockDetailTable.cards-2col td:nth-child(6) { grid-column: 1 / -1; }
    /* 汇总卡片：库存数量放在单位前面，隐藏批次数 */
    #stockSummaryTable.cards-2col td:nth-child(3) { grid-column: 1 / -1; grid-row: 3; }
    #stockSummaryTable.cards-2col td:nth-child(4) { grid-column: 1 / -1; grid-row: 2; }
    #stockSummaryTable.cards-2col td:nth-child(5) { display: none; }
    #stockSummaryTable.cards-2col td:nth-child(6) { grid-column: 1 / -1; grid-row: 4; }
    /* 操作按钮独占底部一行，靠右 */
    #stockSummaryTable.cards-2col tr.has-actions > td:last-child,
    #stockDetailTable.cards-2col tr.has-actions > td:last-child {
      grid-column: 1 / -1; justify-content: flex-end;
    }
    /* 物料管理卡片定制：名称作标题（黑色加粗标签紧贴信息，信息不加粗）放在编码上方，编码取消加粗 */
    #matTable.cards-2col tr { grid-template-columns: 1fr 1fr; }
    #matTable.cards-2col td::before { width: auto; }
    /* 编码：普通字重，位于名称下方 */
    #matTable.cards-2col td:first-child { grid-column: 1 / -1; grid-row: 2; font-weight: 400; }
    /* 名称：标题行，标签加粗 */
    #matTable.cards-2col td:nth-child(2) {
      grid-column: 1 / -1; grid-row: 1; display: flex; gap: 4px; align-items: baseline;
      font-size: 13px; line-height: 1.5;
    }
    #matTable.cards-2col td:nth-child(2)::before {
      content: attr(data-label); width: auto; flex-shrink: 0;
      color: #1e293b; font-size: 13px; font-weight: 700;
    }
    #matTable.cards-2col .mat-name {
      flex: 1; white-space: pre-line; font-weight: 400; word-break: break-all;
    }
    /* 类型/单位/属性/母料各占整行 */
    #matTable.cards-2col td:nth-child(3),
    #matTable.cards-2col td:nth-child(4),
    #matTable.cards-2col td:nth-child(5),
    #matTable.cards-2col td:nth-child(6) { grid-column: 1 / -1; }
    /* 操作按钮独占底部一行，靠右 */
    #matTable.cards-2col tr.has-actions > td:last-child { grid-column: 1 / -1; justify-content: flex-end; }
    /* 厂家管理卡片定制：与物料管理一致，名称作标题放在编码上方，编码取消加粗 */
    #supTable.cards-2col tr { grid-template-columns: 1fr 1fr; }
    #supTable.cards-2col td::before { width: auto; }
    /* 编码：普通字重，位于名称下方 */
    #supTable.cards-2col td:first-child { grid-column: 1 / -1; grid-row: 2; font-weight: 400; }
    /* 名称：标题行，标签加粗 */
    #supTable.cards-2col td:nth-child(2) {
      grid-column: 1 / -1; grid-row: 1; display: flex; gap: 4px; align-items: baseline;
      font-size: 13px; line-height: 1.5;
    }
    #supTable.cards-2col td:nth-child(2)::before {
      content: attr(data-label); width: auto; flex-shrink: 0;
      color: #1e293b; font-size: 13px; font-weight: 700;
    }
    #supTable.cards-2col .mat-name {
      flex: 1; white-space: pre-line; font-weight: 400; word-break: break-all;
    }
    /* 联系人/电话/地址各占整行 */
    #supTable.cards-2col td:nth-child(3),
    #supTable.cards-2col td:nth-child(4),
    #supTable.cards-2col td:nth-child(5) { grid-column: 1 / -1; }
    /* 操作按钮独占底部一行，靠右 */
    #supTable.cards-2col tr.has-actions > td:last-child { grid-column: 1 / -1; justify-content: flex-end; }
    /* 加工/分装卡片定制：母料作标题（黑色加粗标签紧贴信息，信息不加粗）放在单号上方，单号取消加粗 */
    #prTable.cards-2col tr { grid-template-columns: 1fr 1fr; }
    #prTable.cards-2col td::before { width: auto; }
    /* 单号：普通字重，位于母料下方 */
    #prTable.cards-2col td:first-child { grid-column: 1 / -1; grid-row: 2; font-weight: 400; }
    /* 母料：标题行，标签加粗 */
    #prTable.cards-2col td:nth-child(2) {
      grid-column: 1 / -1; grid-row: 1; display: flex; gap: 4px; align-items: baseline;
      font-size: 13px; line-height: 1.5;
    }
    #prTable.cards-2col td:nth-child(2)::before {
      content: attr(data-label); width: auto; flex-shrink: 0;
      color: #1e293b; font-size: 13px; font-weight: 700;
    }
    #prTable.cards-2col .mat-name {
      flex: 1; white-space: pre-line; font-weight: 400; word-break: break-all;
    }
    /* 产出/损耗/日期/状态各占整行 */
    #prTable.cards-2col td:nth-child(3),
    #prTable.cards-2col td:nth-child(4),
    #prTable.cards-2col td:nth-child(5),
    #prTable.cards-2col td:nth-child(6) { grid-column: 1 / -1; }
    /* 操作按钮独占底部一行，靠右 */
    #prTable.cards-2col tr.has-actions > td:last-child { grid-column: 1 / -1; justify-content: flex-end; }
    /* 批次追溯卡片定制：物料作标题（黑色加粗标签紧贴信息，信息不加粗）放在批次号上方 */
    #batchTable.cards-2col tr { grid-template-columns: 1fr 1fr; }
    #batchTable.cards-2col td::before { width: auto; }
    /* 批次号：位于物料下方 */
    #batchTable.cards-2col td:first-child { grid-column: 1 / -1; grid-row: 2; }
    /* 物料：标题行，标签加粗 */
    #batchTable.cards-2col td:nth-child(2) {
      grid-column: 1 / -1; grid-row: 1; display: flex; gap: 4px; align-items: baseline;
      font-size: 13px; line-height: 1.5;
    }
    #batchTable.cards-2col td:nth-child(2)::before {
      content: attr(data-label); width: auto; flex-shrink: 0;
      color: #1e293b; font-size: 13px; font-weight: 700;
    }
    #batchTable.cards-2col .mat-name {
      flex: 1; white-space: pre-line; font-weight: 400; word-break: break-all;
    }
    /* 来源/入库日期/初始数量/剩余各占整行 */
    #batchTable.cards-2col td:nth-child(3),
    #batchTable.cards-2col td:nth-child(4),
    #batchTable.cards-2col td:nth-child(5),
    #batchTable.cards-2col td:nth-child(6) { grid-column: 1 / -1; }
    /* 操作按钮独占底部一行，靠右 */
    #batchTable.cards-2col tr.has-actions > td:last-child { grid-column: 1 / -1; justify-content: flex-end; }
    /* 操作行：细分隔线 + 按钮靠右（不显示“操作”标签） */
    .table-cards.cards-2col tr.has-actions > td:last-child {
      margin-top: 6px; padding-top: 7px; gap: 6px;
      border-top: 1px solid #f1f5f9;
    }
    /* 仅隐藏操作列（带按钮的行）的标签，数据表末列标签正常显示 */
    .table-cards.cards-2col tr.has-actions > td:last-child::before { content: none; }
    /* 操作按钮：柔和底色小胶囊（删=红 / 改=灰黑 / 查=蓝），flex 居中 */
    .table-cards.cards-2col td:last-child .op-btn {
      padding: 5px 13px; border: none; border-radius: 999px; background: #f1f5f9;
      display: inline-flex; align-items: center; justify-content: center;
      line-height: 1;
    }
    /* 隐藏完整文字，只显示 ::before 的单字（不再用 font-size:0，避免个别浏览器最小字号把单字挤偏） */
    .table-cards.cards-2col td:last-child .op-btn .op-t { display: none; }
    .table-cards.cards-2col td:last-child .op-btn::before {
      content: attr(data-short);
      font-size: 12px; line-height: 1; font-weight: 500;
    }
    .table-cards.cards-2col td:last-child .btn-danger.op-btn { background: #fef2f2; }
    .table-cards.cards-2col td:last-child .btn-danger.op-btn::before { color: var(--danger); }
    .table-cards.cards-2col td:last-child .op-view { background: #eff6ff; }
    .table-cards.cards-2col td:last-child .op-view::before { color: var(--primary); }
    .table-cards.cards-2col td:last-child .op-edit { background: #f1f5f9; }
    .table-cards.cards-2col td:last-child .op-edit::before { color: #475569; }
    /* 查看批次/追溯：保留文字的浅色胶囊 */
    .table-cards.cards-2col td:last-child .op-btn-text {
      font-size: 12px; width: auto; height: auto;
      padding: 4px 10px; border-radius: 999px;
      background: #f8fafc; border-color: var(--border);
    }
    .table-cards.cards-2col td:last-child .op-btn-text::before { content: none; }
    /* 明细行（入库 + 出库）：移动端卡片式布局，每行独立卡片 */
    .detail-row {
      position: relative;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
      padding: 12px 12px 10px;
      border: 1px solid var(--border);
      border-radius: 8px;
      margin-bottom: 10px;
      background: #fff;
      align-items: stretch;
    }
    .detail-row.ob { grid-template-columns: 1fr 1fr; }
    .detail-row > .del-btn {
      grid-column: 1 / -1;
      justify-self: end;
      width: 28px; height: 28px; border-radius: 50%;
      display: flex; align-items: center; justify-content: center;
      background: #fef2f2; color: var(--danger); font-size: 18px;
      margin-top: 4px;
    }
    /* 入库明细：手机端单列布局，每个字段独占一行 */
    .detail-row.in { grid-template-columns: 1fr; }
    /* 出库明细：物料和批次各跨整行 */
    .detail-row:not(.in):not(.proc) > .form-group:nth-child(1) { grid-column: 1 / -1; }
    .detail-row:not(.in):not(.proc) > .form-group:nth-child(2) { grid-column: 1 / -1; }
    /* 加工/分装明细(.proc)：物料跨整行，其余两两并排 */
    .detail-row.proc > .form-group:nth-child(1) { grid-column: 1 / -1; }
    .modal { max-width: 92vw; max-height: 85vh; border-radius: 12px; }
    .modal-body { padding: 14px; }
    .modal-header, .modal-footer { padding: 12px 14px; }
    .kv-list { grid-template-columns: 90px 1fr; font-size: 12px; }
    .card { padding: 14px; margin-bottom: 12px; }
    .btn { padding: 10px 14px; font-size: 14px; }
    input, select, textarea { font-size: 16px; }
    .tabbar { display: flex !important; position: fixed; bottom: 0; left: 0; right: 0; height: 58px; background: #fff; border-top: 1px solid var(--border); z-index: 50; box-shadow: 0 -2px 8px rgba(0,0,0,.06); }
    .tabbar-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--text-light); font-size: 10px; cursor: pointer; user-select: none; padding-bottom: env(safe-area-inset-bottom); }
    .tabbar-item.active { color: var(--primary); }
    .tabbar-item .t-icon { font-size: 20px; line-height: 1; }
  }
  /* 首次使用：填名字弹窗 */
  .login-mask { position: fixed; inset: 0; z-index: 100; background: rgba(15,23,42,.75); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; }
  .login-card { width: 340px; max-width: 90vw; background: var(--card); border-radius: 12px; padding: 26px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
  .login-title { font-size: 18px; font-weight: 600; text-align: center; margin-bottom: 14px; }
  .login-tip { font-size: 12px; color: var(--text-light); text-align: center; margin-bottom: 16px; line-height: 1.6; }
  .login-form input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 15px; box-sizing: border-box; }
  .login-form input:focus { outline: none; border-color: var(--primary); }
  .btn-block { width: 100%; margin-top: 14px; }
  .login-err { color: var(--danger); font-size: 12px; min-height: 18px; margin-top: 8px; text-align: center; }
