:root {
  --green: #15803d;
  --green-dark: #14532d;
  --green-soft: #dcfce7;
  --bg: #f3f5f3;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-2: #f1f5f9;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .04);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--green); text-decoration: none; }
button { font-family: inherit; }
img { max-width: 100%; }
h1, h2, h3, p { margin: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt4 { margin-top: 4px; } .mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; }
.neg { color: var(--danger); }
.danger-text { color: var(--danger); }
.boot { min-height: 100vh; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; color: var(--muted); }

/* ---------------- 布局 ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.tb-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo {
  width: 38px; height: 38px; border-radius: 12px; flex: none;
  background: linear-gradient(135deg, var(--green), #166534);
  color: #fff; font-weight: 800; font-size: 19px;
  display: flex; align-items: center; justify-content: center;
}
.logo.big { width: 56px; height: 56px; border-radius: 18px; font-size: 28px; }
.tb-title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-sub { font-size: 11px; color: var(--muted); }
.tb-right { display: flex; align-items: center; gap: 8px; }
.role-tag { font-size: 11px; color: var(--green); background: var(--green-soft); padding: 2px 8px; border-radius: 999px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; border: 0;
  background: #e8f5ec; color: var(--green-dark); font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.avatar.big { width: 46px; height: 46px; font-size: 18px; }

.layout { max-width: 1240px; margin: 0 auto; }
main { padding: 14px 14px calc(76px + var(--safe-bottom)); }
.sidebar { display: none; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; background: rgba(255, 255, 255, .97);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
  backdrop-filter: blur(10px);
}
.bn-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 6px; color: var(--muted); font-size: 10px;
}
.bn-item svg { width: 22px; height: 22px; }
.bn-item.active { color: var(--green); }

@media (min-width: 900px) {
  .layout { display: grid; grid-template-columns: 200px 1fr; gap: 0; min-height: calc(100vh - 60px); }
  .sidebar {
    display: flex; flex-direction: column; gap: 4px;
    padding: 18px 12px; border-right: 1px solid var(--line);
    position: sticky; top: 60px; height: calc(100vh - 60px);
  }
  .nav-item {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    border-radius: 10px; color: #374151; font-size: 14px;
  }
  .nav-item svg { width: 20px; height: 20px; }
  .nav-item:hover { background: #f3f4f6; }
  .nav-item.active { background: var(--green-soft); color: var(--green-dark); font-weight: 600; }
  .side-foot { margin-top: auto; font-size: 11px; color: #9ca3af; padding: 8px 12px; }
  .bottomnav { display: none; }
  main { padding: 20px 24px 40px; }
}

/* ---------------- 页头 ---------------- */
.page { max-width: 1180px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; font-weight: 800; letter-spacing: -.3px; }
.page-head .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-head b { font-size: 15px; }
.card-foot { border-top: 1px dashed var(--line); margin-top: 10px; padding-top: 8px; font-size: 12px; }
.table-card { overflow-x: auto; }
.mt12 { margin-top: 12px; }
.grid2col { display: grid; grid-template-columns: 1fr; gap: 12px; }
.grid3col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-main-side { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 900px) {
  .grid2col { grid-template-columns: 1fr 1fr; }
  .grid3col { grid-template-columns: repeat(3, 1fr); }
  .grid-main-side { grid-template-columns: 1fr 340px; align-items: start; }
  .grid-main-side .side { position: sticky; top: 76px; }
}

/* ---------------- 首页 ---------------- */
.hero {
  background: linear-gradient(135deg, #14532d 0%, #15803d 55%, #16a34a 100%);
  color: #fff; border-radius: 20px; padding: 20px 18px 16px;
  margin-bottom: 12px; box-shadow: 0 8px 24px rgba(20, 83, 45, .18);
}
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; }
.hero-date { font-size: 11.5px; opacity: .75; }
.hero h1 { font-size: 22px; margin-top: 2px; }
.hero-badge { font-size: 11px; background: rgba(255, 255, 255, .18); padding: 4px 10px; border-radius: 999px; }
.hero-stats { display: flex; gap: 26px; margin: 18px 0 14px; }
.hero-stats b { font-size: 28px; font-weight: 800; letter-spacing: -.5px; }
.hero-stats span { font-size: 11px; opacity: .72; margin-left: 3px; }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.light { background: #fff; color: var(--green-dark); font-weight: 700; }
.btn.ghost-light { background: rgba(255, 255, 255, .14); color: #fff; border: 1px solid rgba(255, 255, 255, .25); }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.stat.warn { border-color: #fcd34d; background: #fffbeb; }
.stat-label { font-size: 11.5px; color: var(--muted); }
.stat-value { font-size: 24px; font-weight: 800; margin-top: 2px; letter-spacing: -.5px; }
.stat-value small { font-size: 11px; font-weight: 500; color: var(--muted); margin-left: 3px; }

.row-link {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 2px; border-bottom: 1px solid var(--line-2); color: inherit;
}
.row-link:last-child { border-bottom: 0; }
.row-link .right { text-align: right; flex: none; }
.bar-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px dashed var(--line-2); }
.bar-rank { width: 18px; height: 18px; border-radius: 6px; background: var(--green-soft); color: var(--green-dark); font-size: 11px; display: flex; align-items: center; justify-content: center; flex: none; }
.bar-name { flex: 1; font-size: 13.5px; }
.bar-val { font-size: 12px; color: var(--muted); }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  border-radius: 10px; border: 1px solid var(--line); background: #fff; color: #1f2937;
  font-size: 13.5px; padding: 8px 13px; cursor: pointer; white-space: nowrap;
  transition: transform .06s ease, background .15s ease;
  line-height: 1.4;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #166534; }
.btn.ghost { background: #fff; }
.btn.ghost:hover { background: #f9fafb; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.xs { padding: 4px 9px; font-size: 12px; border-radius: 8px; }
.btn.sm { padding: 6px 10px; font-size: 12.5px; }
.btn.lg { padding: 12px 16px; font-size: 15px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.link-btn { border: 0; background: none; color: var(--green); padding: 0; cursor: pointer; font-size: 13px; }
.icon-btn { border: 0; background: #f3f4f6; color: #6b7280; width: 28px; height: 28px; border-radius: 8px; cursor: pointer; }
.icon-btn:hover { background: #e5e7eb; }

/* ---------------- 表单 ---------------- */
.field { display: flex; flex-direction: column; gap: 5px; }
.field .label { font-size: 12px; color: #4b5563; font-weight: 600; }
.field .hint { font-size: 11px; color: #9ca3af; }
.input {
  width: 100%; border: 1px solid #d1d5db; border-radius: 10px; background: #fff;
  padding: 9px 11px; font-size: 14px; color: var(--text); outline: none; min-height: 40px;
}
.input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(21, 128, 61, .12); }
.input:disabled, .input[disabled] { background: #f9fafb; color: #4b5563; }
.input.sm { padding: 6px 8px; font-size: 12.5px; min-height: 34px; border-radius: 8px; }
textarea.input { resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.form-grid.one { grid-template-columns: 1fr; }
@media (min-width: 700px) { .form-grid { grid-template-columns: 1fr 1fr; } .form-grid.one { grid-template-columns: 1fr; } }
.check-field { flex-direction: row; align-items: center; gap: 8px; font-size: 13.5px; }
.check-field input { width: 18px; height: 18px; accent-color: var(--green); }
.toolbar-row { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.input.search { max-width: 260px; }
.input.date { max-width: 150px; }
.col { display: flex; flex-direction: column; }
.gap12 { gap: 12px; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; }

/* ---------------- 表格 ---------------- */
.table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 560px; }
.table th { text-align: left; font-size: 11.5px; color: #6b7280; font-weight: 600; padding: 8px 8px; border-bottom: 1px solid var(--line); background: #fafafa; white-space: nowrap; }
.table td { padding: 9px 8px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; }
.table .ops { text-align: right; white-space: nowrap; }
.table .cell-main { display: flex; align-items: center; gap: 9px; }
.thumb { width: 38px; height: 38px; border-radius: 9px; object-fit: cover; flex: none; }
.thumb.ph { display: flex; align-items: center; justify-content: center; background: #eef2ef; color: #6b7280; font-weight: 700; font-size: 14px; }
.table.items-table { min-width: 720px; }
.cost-bar { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); font-size: 13px; color: #4b5563; }
.cost-bar b { color: var(--text); font-size: 15px; }

/* ---------------- 标签 / 状态 ---------------- */
.chip { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #f3f4f6; color: #4b5563; white-space: nowrap; }
.chip.draft { background: #fef3c7; color: #92400e; }
.chip.skewered { background: #dbeafe; color: #1d4ed8; }
.chip.stocked { background: var(--green-soft); color: var(--green-dark); }
.chip.cancelled { background: #f3f4f6; color: #9ca3af; text-decoration: line-through; }
.chip.ok { background: var(--green-soft); color: var(--green-dark); }
.chip.off { background: #f3f4f6; color: #9ca3af; }
.chip.tiny { font-size: 10px; padding: 1px 6px; }

/* ---------------- 标签页 ---------------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 10px; }
.tab {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 6px 14px; font-size: 13px; color: #4b5563; cursor: pointer; white-space: nowrap;
}
.tab.active { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }

/* ---------------- 溯源列表 ---------------- */
.summary-bar {
  display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted);
  padding: 10px 12px; background: #fff; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px;
}
.summary-bar b { color: var(--text); font-size: 14px; }
.trace-list { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 760px) { .trace-list { grid-template-columns: 1fr 1fr; } }
.trace-card {
  display: block; background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; color: inherit; box-shadow: var(--shadow);
}
.trace-card:hover { border-color: #bbf7d0; }
.tc-top { display: flex; justify-content: space-between; align-items: center; font-size: 12px; }
.tc-top .mono { color: #6b7280; }
.tc-main { display: flex; align-items: baseline; gap: 8px; margin: 6px 0 8px; }
.tc-main b { font-size: 16px; }
.tc-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.tc-meta b { color: var(--text); }
.tc-hint { margin-top: 8px; font-size: 12px; color: var(--green); font-weight: 600; }

/* ---------------- 新建向导 ---------------- */
.wizard { max-width: 1080px; }
.steps-ind { display: flex; gap: 6px; margin-bottom: 12px; }
.si { flex: 1; text-align: center; font-size: 12px; padding: 7px 4px; border-radius: 999px; background: #e9ece9; color: #6b7280; }
.si.active { background: var(--green); color: #fff; font-weight: 600; }
.si.done { background: var(--green-soft); color: var(--green-dark); }
.product-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 760px) { .product-grid { grid-template-columns: repeat(4, 1fr); } }
.prod-card {
  background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 0 0 10px;
  cursor: pointer; text-align: left; overflow: hidden; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.prod-card img { width: 100%; height: 86px; object-fit: cover; }
.prod-ph { height: 86px; background: linear-gradient(135deg, #f0fdf4, #dcfce7); display: flex; align-items: center; justify-content: center; font-size: 30px; font-weight: 800; color: #86efac; }
.prod-card b { font-size: 14.5px; margin: 8px 10px 0; }
.prod-card span { font-size: 12px; color: var(--green-dark); margin: 1px 10px 0; font-weight: 600; }
.prod-card small { margin: 2px 10px 0; }
.prod-card:hover { border-color: #86efac; }
.selected-product { padding: 4px 2px 12px; border-bottom: 1px dashed var(--line); margin-bottom: 12px; }
.sp-name { font-size: 20px; font-weight: 800; }
.proc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.proc { background: #f9fafb; border-radius: 10px; padding: 9px 10px; display: flex; flex-direction: column; gap: 1px; }
.proc span { font-size: 10.5px; color: var(--muted); }
.proc b { font-size: 13.5px; }
.proc small { font-size: 10.5px; color: #6b7280; }
.mini-gallery { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.mini-gallery img { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; cursor: pointer; }
.sticky { position: sticky; top: 76px; }
.cost-line { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line-2); font-size: 13px; }
.cost-line span { color: var(--muted); }
.cost-line.total { border-bottom: 0; margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--line); }
.cost-line.total b { font-size: 18px; color: var(--green-dark); }
.cost-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cost-grid > div { background: #f9fafb; border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; }
.cost-grid span { font-size: 10.5px; color: var(--muted); }
.cost-grid b { font-size: 14px; }
.cost-grid .total { background: var(--green-soft); }
.cost-grid .total b { color: var(--green-dark); }

/* ---------------- 溯源详情 ---------------- */
.trace-head { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; }
@media (min-width: 760px) { .trace-head { grid-template-columns: repeat(6, 1fr); } }
.trace-head b { font-size: 14px; }
.stage-bar { display: flex; gap: 6px; margin-bottom: 12px; }
.stage { flex: 1; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; }
.stage b { font-size: 11.5px; color: #6b7280; }
.stage small { font-size: 10.5px; color: #9ca3af; }
.stage.done { border-color: #bbf7d0; background: #f0fdf4; }
.stage.done b { color: var(--green-dark); }
.steps { margin: 0; padding-left: 20px; }
.steps li { margin-bottom: 8px; font-size: 13.5px; }
.steps li b { color: var(--green-dark); }
.upload-row { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 12px; }
@media (min-width: 760px) { .upload-row { grid-template-columns: repeat(3, 1fr); } }
.phase-upload { border: 1px dashed var(--line); border-radius: 10px; padding: 8px; }
.phase-label { font-size: 11.5px; color: #4b5563; margin-bottom: 6px; font-weight: 600; }
.compare { border-bottom: 1px solid var(--line-2); padding: 8px 0; }
.cmp-col { display: inline-flex; flex-direction: column; gap: 6px; width: 49%; vertical-align: top; padding-right: 6px; }
.cmp-title { font-size: 10.5px; color: #6b7280; }
.cmp-col img { height: 86px; object-fit: cover; border-radius: 6px; cursor: pointer; }
.log-row { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line-2); font-size: 12.5px; }
.log-row .muted { flex: none; width: 62px; font-family: ui-monospace, monospace; }

/* ---------------- 图片上传 ---------------- */
.upload-list { display: flex; flex-wrap: wrap; gap: 8px; }
.upload-item { position: relative; width: 82px; height: 82px; border-radius: 9px; overflow: hidden; background: #f3f4f6; }
.upload-item img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; }
.upload-item .cap { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, .5); color: #fff; font-size: 9px; padding: 1px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-item .del { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .55); color: #fff; font-size: 10px; cursor: pointer; }
.upload-add {
  width: 82px; height: 82px; border: 1px dashed #cbd5e1; border-radius: 9px; background: #fafafa;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: #6b7280; cursor: pointer; font-size: 11px;
}
.upload-add span { font-size: 18px; }
.uploader.drag { outline: 2px dashed var(--green); outline-offset: 4px; }
.uploader-block, .phase-upload { }
.up-title { font-size: 12.5px; font-weight: 600; color: #374151; }
.sub-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.sub-title { font-size: 12px; color: #4b5563; margin-bottom: 8px; font-weight: 600; }

/* ---------------- 弹窗 / 轻提示 ---------------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 80; display: flex; align-items: flex-end; justify-content: center; padding: 0; }
@media (min-width: 700px) { .modal-mask { align-items: center; padding: 20px; } }
.modal {
  background: #fff; width: 100%; max-width: 560px; max-height: 92vh; border-radius: 18px 18px 0 0;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
@media (min-width: 700px) { .modal { border-radius: 18px; } }
.modal.wide { max-width: 820px; }
.modal.small { max-width: 400px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 14px 16px; overflow-y: auto; }
.modal-foot { padding: 10px 16px calc(12px + var(--safe-bottom)); border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.confirm-text { font-size: 14px; }
.user-card { display: flex; gap: 12px; align-items: center; }
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(88px + var(--safe-bottom)); z-index: 120; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
@media (min-width: 900px) { #toasts { bottom: 30px; } }
.toast { background: #111827; color: #fff; font-size: 13px; padding: 8px 14px; border-radius: 999px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); transition: opacity .25s, transform .25s; }
.toast.err { background: #991b1b; }
.toast.out { opacity: 0; transform: translateY(6px); }
.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .9); z-index: 130; display: flex; align-items: center; justify-content: center; }
.lightbox img { max-width: 94vw; max-height: 82vh; object-fit: contain; border-radius: 6px; }
.lb-close, .lb-prev, .lb-next { position: absolute; border: 0; background: rgba(255, 255, 255, .14); color: #fff; width: 40px; height: 40px; border-radius: 50%; font-size: 20px; cursor: pointer; }
.lb-close { top: 16px; right: 16px; }
.lb-prev { left: 12px; top: 50%; }
.lb-next { right: 12px; top: 50%; }
.lb-cap { position: absolute; bottom: 20px; left: 0; right: 0; text-align: center; color: #e5e7eb; font-size: 12px; }

/* ---------------- 登录 ---------------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(circle at 20% 10%, #e8f5ec, #f4f6f4 60%); }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 20px; padding: 26px 22px; box-shadow: 0 20px 60px rgba(20, 83, 45, .12); }
.auth-brand { text-align: center; margin-bottom: 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.auth-brand h1 { font-size: 20px; }
.auth-brand p { font-size: 12px; }
.auth-foot { text-align: center; margin-top: 16px; font-size: 11px; }

/* ---------------- 更多 / 人员 / 空状态 ---------------- */
.link-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 900px) { .link-grid { grid-template-columns: repeat(4, 1fr); } }
.link-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 3px; color: inherit; box-shadow: var(--shadow); }
.link-card b { font-size: 14.5px; }
.link-card span { font-size: 11.5px; color: var(--muted); }
.link-card:hover { border-color: #bbf7d0; }
.user-row { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--line-2); }
.user-row:last-child { border-bottom: 0; }
.user-main { flex: 1; min-width: 0; }
.user-main .chip { margin-left: 6px; }
.perm-box { max-height: 320px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.perm-row { padding: 6px 0; border-bottom: 1px dashed var(--line-2); }
.perm-row:last-child { border-bottom: 0; }
.perm-check { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; margin-right: 12px; }
.perm-check input { accent-color: var(--green); width: 16px; height: 16px; }
.perm-items { display: flex; flex-wrap: wrap; gap: 2px 10px; padding-left: 21px; margin-top: 3px; }
.line-row { display: grid; grid-template-columns: 1fr 100px 56px; gap: 8px; margin-bottom: 8px; }
.step-card { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 10px; background: #fcfcfc; }
.step-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.step-no { width: 22px; height: 22px; border-radius: 50%; background: var(--green-soft); color: var(--green-dark); font-size: 11px; display: flex; align-items: center; justify-content: center; flex: none; }
.step-meta { display: flex; gap: 10px; margin-top: 6px; }
.step-meta label { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--muted); }
.step-meta .input { width: 90px; }
.step-imgs { margin-top: 8px; }
.empty { text-align: center; color: #9ca3af; font-size: 13px; padding: 26px 10px; }
.loading { display: flex; align-items: center; justify-content: center; gap: 8px; color: #9ca3af; padding: 30px; font-size: 13px; }
.loading .dot { width: 14px; height: 14px; border: 2px solid #d1d5db; border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 明细表列宽与数字输入 */
.qty-cell { width: 110px; }
.qty-cell .input { text-align: right; }
.table .num input.input { text-align: right; }
.compare-head { font-size: 12px; font-weight: 700; color: #374151; padding: 6px 0 2px; }
.cmp-col { width: 49%; }
.cmp-col img { width: 118px; height: 88px; margin-right: 6px; margin-bottom: 4px; }
.toolbar-row select.input { max-width: 220px; }
@media (max-width: 520px) { .toolbar-row select.input { max-width: none; } }

/* ---------------- 手机端：表格转卡片 ---------------- */
@media (max-width: 760px) {
  .table.cards { min-width: 0; width: 100%; }
  .table.cards thead { display: none; }
  .table.cards tbody { display: block; }
  .table.cards tr {
    display: block; border: 1px solid var(--line); border-radius: 12px;
    padding: 9px 12px; margin-bottom: 8px; background: #fff;
  }
  .table.cards tr:last-child { margin-bottom: 0; }
  .table.cards td {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    border: 0; padding: 3px 0; text-align: right; font-size: 13px;
  }
  .table.cards td::before {
    content: attr(data-label); color: var(--muted); font-size: 11.5px;
    flex: none; text-align: left; font-weight: 500;
  }
  .table.cards td:first-child {
    display: block; text-align: left; padding: 0 0 7px; margin-bottom: 5px;
    border-bottom: 1px dashed var(--line-2); font-size: 15px;
  }
  .table.cards td:first-child::before { display: none; }
  .table.cards td.ops {
    justify-content: flex-end; flex-wrap: wrap; padding-top: 8px; margin-top: 5px;
    border-top: 1px dashed var(--line-2);
  }
  .table.cards td.ops::before { display: none; }
  .table.cards td > .input, .table.cards td > select, .table.cards td > input { flex: 1 1 auto; width: auto; }
  .table-card { overflow-x: visible; }
  .table:not(.cards) { min-width: 0; }
  .table:not(.cards) th, .table:not(.cards) td { padding: 7px 5px; font-size: 12px; }
  .grid-main-side .side { order: -1; }
  .grid-main-side { display: flex; flex-direction: column; }
  .page-head h1 { font-size: 20px; }
  .hero { padding: 18px 15px 14px; }
  .hero-stats { gap: 18px; }
  .hero-stats b { font-size: 24px; }
  .trace-head { grid-template-columns: 1fr 1fr; }
  .summary-bar { gap: 8px 12px; }
  .field .input, select.input, textarea.input { font-size: 16px; } /* 防止 iOS 自动放大 */
  .line-row { grid-template-columns: 1fr 88px 50px; }
  .modal-body { padding: 12px; }
  .modal-foot { padding: 10px 12px calc(12px + var(--safe-bottom)); }
  .modal-foot .btn { flex: 1 1 auto; }
}

/* 配方编辑明细：手机端两列卡片 */
@media (max-width: 760px) {
  .table.items-table.cards tr { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 10px; padding: 10px 12px; }
  .table.items-table.cards td { display: block; text-align: left; padding: 0; border: 0; min-width: 0; }
  .table.items-table.cards td::before {
    display: block; content: attr(data-label); color: var(--muted);
    font-size: 10.5px; margin-bottom: 1px;
  }
  .table.items-table.cards td:first-child { border: 0; margin: 0; padding: 0; }
  .table.items-table.cards td:nth-child(2) { grid-column: 2; }
  .table.items-table.cards td:nth-child(7) { grid-column: 1 / -1; }
  .table.items-table.cards td:nth-child(8) { grid-column: 2; justify-self: end; align-self: end; }
  .table.items-table.cards td:nth-child(8)::before { display: none; }
  .table.items-table.cards .input { width: 100%; }
  .table.items-table.cards .mt4 { margin-top: 4px; }
}

@media (max-width: 760px) {
  .table.cards td.qty-cell { width: auto; }
  .table.cards td.qty-cell .input { width: 100%; }
}

/* 可点击统计卡 */
a.stat { color: inherit; text-decoration: none; display: block; }
a.stat:hover { border-color: #86efac; }
a.stat.stat-link::after { content: ""; }

/* 标准图缩略图 */
.std-imgs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.std-imgs img { width: 58px; height: 40px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); cursor: pointer; }
.std-row { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.std-label { flex: none; width: 56px; font-size: 11px; color: var(--muted); padding-top: 4px; }
.std-row .std-imgs { margin-top: 0; }
.std-row .std-imgs img { width: 64px; height: 44px; }
@media (max-width: 760px) {
  .trace-head { grid-template-columns: 1fr 1fr; }
}

/* 出库单操作区 */
.issue-row { align-items: center; }
.issue-ops { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.issue-ops .btn { padding: 4px 8px; }

/* 配方修改红色对照 */
.change-banner { border: 1px solid #fecaca; background: #fef2f2; border-radius: 12px; padding: 9px 12px; margin-bottom: 10px; }
.change-banner b { color: #b91c1c; font-size: 12.5px; }
.change-line { color: #b91c1c; font-size: 12px; margin-top: 3px; }
.diff-old { color: #b91c1c; text-decoration: line-through; }
.diff-new { color: #b91c1c; font-weight: 700; }
.chip.warn { background: #fee2e2; color: #b91c1c; }

/* 确认页投料修改实时标红 */
.row-edited .input { border-color: #f87171; background: #fff7f7; }
.pct-cell .diff-old { text-decoration: line-through; margin-right: 4px; }
.edited-hint { color: #b91c1c; font-size: 10.5px; margin-top: 2px; text-align: right; }

/* 单串成本突出显示 */
b.unit-cost { color: #15803d; font-size: 16px; }
.cost-grid .highlight { background: #f0fdf4; border: 1px solid #bbf7d0; }
.cost-grid .highlight b { color: #15803d; font-size: 17px; }
@media (min-width: 760px) {
  .trace-head { grid-template-columns: repeat(auto-fit, minmax(108px, 1fr)); }
}

/* 手机端配料明细：紧凑表格（不转卡片） */
.unit-inline { display: none; }
@media (max-width: 760px) {
  .table.compact-m { display: table; width: 100%; min-width: 0; table-layout: fixed; }
  .table.compact-m thead { display: table-header-group; }
  .table.compact-m tbody { display: table-row-group; }
  .table.compact-m tr { display: table-row; border: 0; padding: 0; margin: 0; background: transparent; }
  .table.compact-m th, .table.compact-m td {
    display: table-cell; width: auto; padding: 6px 3px; font-size: 10.8px;
    border-bottom: 1px solid var(--line-2); text-align: left; white-space: normal;
  }
  .table.compact-m th { background: #fafafa; font-size: 10px; }
  .table.compact-m th.num, .table.compact-m td.num { text-align: right; white-space: nowrap; }
  .table.compact-m td:first-child {
    display: table-cell; border-bottom: 1px solid var(--line-2);
    padding: 6px 3px; margin: 0; font-size: 10.8px;
  }
  .table.compact-m td::before { display: none; }
  .table.compact-m .hide-m { display: none; }
  .table.compact-m .unit-inline { display: inline; }
  .table.compact-m .chip { font-size: 9px; padding: 0 3px; }
  .table.compact-m .c-name { width: 31%; }
  .table.compact-m .c-pct { width: 15%; }
  .table.compact-m .c-qty { width: 18%; }
  .table.compact-m .c-price { width: 21%; }
  .table.compact-m .c-amount { width: 15%; }
  .table.compact-m td.c-price, .table.compact-m td.c-amount { padding-left: 5px; white-space: nowrap; }
  .table.compact-m td.c-qty { white-space: nowrap; }
}

/* 作废单删除按钮 */
.tc-actions { display: inline-flex; align-items: center; gap: 6px; }
.tc-actions .btn { padding: 2px 7px; }

/* 配方批量管理 */
.chk-col { width: 34px; text-align: center; }
.chk-col input { width: 16px; height: 16px; accent-color: #15803d; }
.batch-bar {
  position: sticky; top: 64px; z-index: 5;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: #ecfdf5; border: 1px solid #bbf7d0; color: #14532d;
  border-radius: 12px; padding: 8px 12px; margin-bottom: 10px;
}
.batch-bar b { font-size: 15px; }

.batch-bar[hidden] { display: none !important; }

.change-banner.ok { border-color: #bbf7d0; background: #f0fdf4; }
.change-banner.ok b { color: #15803d; }
.change-banner.ok .change-line { color: #b45309; }
