:root {
  --primary: #07c160;     /* 微信绿 */
  --primary-dark: #06ad56;
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1a1a1a;
  --text-sub: #888;
  --border: #ebedf0;
  --danger: #ee0a24;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
.wrap { max-width: 820px; margin: 0 auto; padding: 16px; }
header.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--primary);
  color: #fff;
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 1px 6px rgba(0,0,0,.08);
}
header.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; }
header.topbar .sub { font-size: 12px; opacity: .85; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 4px; border: none; cursor: pointer;
  padding: 10px 16px; border-radius: var(--radius);
  font-size: 15px; font-weight: 500; text-decoration: none;
  transition: opacity .15s, transform .05s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #f2f3f5; color: var(--text); }
.btn-ghost:hover { background: #e8e9eb; }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid #ffd1d6; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.empty {
  text-align: center; color: var(--text-sub); padding: 40px 0;
}
.empty .big { font-size: 40px; margin-bottom: 8px; }

.material-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.material-item .info { min-width: 0; flex: 1; }
.material-item .name {
  font-weight: 600; font-size: 16px; margin-bottom: 2px;
  display: flex; align-items: center; gap: 8px;
}
.material-item .meta {
  color: var(--text-sub); font-size: 13px;
  display: flex; flex-wrap: wrap; gap: 4px 12px;
}
.material-item .meta span { white-space: nowrap; }
.qty { color: var(--primary-dark); font-weight: 600; }
.actions { display: flex; gap: 8px; flex-shrink: 0; }

.field { margin-bottom: 14px; }
.field label {
  display: block; margin-bottom: 6px; font-size: 14px; font-weight: 500;
}
.field label .req { color: var(--danger); margin-left: 2px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 15px; font-family: inherit; background: #fff;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--primary); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .field-row { grid-template-columns: 1fr; } }

.detail-grid { display: grid; grid-template-columns: 1fr; gap: 6px; }
.detail-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.detail-row:last-child { border-bottom: none; }
.detail-row .k { color: var(--text-sub); }
.detail-row .v { font-weight: 500; text-align: right; word-break: break-all; }

.qr-box { text-align: center; }
.qr-box img {
  width: 220px; height: 220px; border: 1px solid var(--border); border-radius: 8px;
}
.qr-box .scan-hint { color: var(--text-sub); font-size: 13px; margin-top: 10px; }
.qr-box .url {
  font-size: 12px; color: var(--text-sub); word-break: break-all;
  background: #f7f8fa; padding: 6px 8px; border-radius: 6px; margin-top: 8px;
}
.scan-banner {
  background: #fff8e6; color: #b88200; border: 1px solid #ffe08a;
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px;
  font-size: 13px; display: flex; gap: 8px; align-items: flex-start;
}
.toast {
  position: fixed; left: 50%; top: 30%; transform: translateX(-50%);
  background: rgba(0,0,0,.78); color: #fff; padding: 10px 18px;
  border-radius: 8px; font-size: 14px; z-index: 100; opacity: 0;
  transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }
.tool-bar { display: flex; gap: 10px; margin-top: 8px; }
a { color: inherit; }

/* 物料图片 */
.material-img {
  width: 100%; max-width: 260px; border-radius: 10px;
  border: 1px solid var(--border); display: block; margin: 8px auto;
}
.img-empty {
  width: 100%; max-width: 260px; aspect-ratio: 4/3; margin: 8px auto;
  background: #f7f8fa; border: 1px dashed var(--border); border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-sub); font-size: 13px;
}
.upload-row { display: flex; gap: 8px; margin-top: 8px; }
.upload-row input[type=file] { flex: 1; font-size: 13px; }

/* 盘点流水 */
.logs { margin-top: 4px; }
.log-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 13px;
}
.log-item:last-child { border-bottom: none; }
.log-item .when { color: var(--text-sub); }
.log-item .chg { font-weight: 600; }
.chg-up { color: var(--primary-dark); }
.chg-down { color: var(--danger); }
.log-note { color: var(--text-sub); font-size: 12px; }

/* 导出按钮 */
.export-bar { display: flex; justify-content: flex-end; margin-bottom: 12px; }

/* ============ 物料卡片（清单内） ============ */
.mat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.mat-card {
  display: flex; flex-direction: column;
  background: var(--card); border-radius: var(--radius);
  padding: 12px; text-decoration: none; color: inherit;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  transition: transform .1s, box-shadow .15s;
  cursor: pointer;
}
.mat-card:active { transform: scale(.97); }
.mat-card-img {
  width: 100%; aspect-ratio: 4/3; border-radius: 8px; overflow: hidden;
  background: #f7f8fa; margin-bottom: 10px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
}
.mat-card-img img { width: 100%; height: 100%; object-fit: cover; }
.mat-card-img-empty { font-size: 40px; }
.mat-card-info { display: flex; flex-direction: column; gap: 2px; }
.mat-card-name { font-weight: 600; font-size: 15px; line-height: 1.25; }
.mat-card-code { font-size: 12px; color: var(--text-sub); }
.mat-card-spec { font-size: 12px; color: var(--text-sub); }
.mat-card-qty {
  font-size: 13px; color: var(--primary-dark); margin-top: 4px;
  display: flex; align-items: baseline; gap: 2px;
}
.mat-card-qty .qty-num { font-size: 17px; font-weight: 700; }
