:root {
  --primary: #2f5597;
  --primary-light: #e8eef7;
  --accent: #1a9f8a;
  --danger: #c0392b;
  --warn: #e67e22;
  --ok: #27ae60;
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #1f2733;
  --text-sub: #6b7684;
  --border: #e3e8ef;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(20, 30, 50, 0.08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  padding-bottom: 78px;   /* 70px 给底栏 tabbar，多出的 8px 给页脚备案号留位置 */
}

.appbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(135deg, #2f5597, #3d6bb5);
  color: #fff; padding: 14px 16px 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.appbar-title { font-size: 18px; font-weight: 700; letter-spacing: 0.5px; }
.appbar-sub { font-size: 12px; opacity: 0.85; margin-top: 2px; }
.appbar-top { display: flex; justify-content: space-between; align-items: center; }
.appbar-user { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.appbar-user .uname { opacity: 0.95; }
.appbar-user .btn { background: rgba(255,255,255,0.18); color: #fff; padding: 4px 10px; font-size: 12px; border-radius: 8px; }

/* 登录页 */
.login-mask {
  position: fixed; inset: 0; z-index: 200;
  background: linear-gradient(160deg, #2f5597, #3d6bb5);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card {
  background: #fff; border-radius: 18px; padding: 28px 24px; width: 100%; max-width: 360px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25); text-align: center;
}
.login-logo { font-size: 40px; color: var(--primary); }
.login-title { font-size: 20px; font-weight: 800; margin: 8px 0 4px; color: var(--text); }
.login-sub { font-size: 12px; color: var(--text-sub); margin-bottom: 20px; }
.login-card input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 15px; outline: none; margin-bottom: 10px; background: #fbfcfe;
}
.login-card input:focus { border-color: var(--primary); }
.login-err { color: var(--danger); font-size: 12px; min-height: 18px; margin-top: 6px; }
/* 登录页「忘记密码？」帮助区 */
.login-help { margin-top: 10px; text-align: center; font-size: 12px; }
.login-help > button {
  background: none; border: none; color: var(--text-sub); cursor: pointer;
  font-size: 12px; text-decoration: underline; padding: 2px 4px;
}
.login-help > button:hover { color: var(--primary); }
.login-help #loginHelpBox {
  text-align: left; background: #f6f8fa; border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; margin-top: 8px; line-height: 1.7;
}
.login-help #loginHelpBox p { margin: 0 0 4px; color: var(--text-sub); }
.login-help #loginHelpBox p:last-child { margin-bottom: 0; }

/* 模块切换（钢板/型材） */
.modbar { display: flex; gap: 6px; margin-top: 10px; }
.modbar button {
  flex: 1; border: 1px solid rgba(255,255,255,0.35); background: rgba(255,255,255,0.12);
  color: #fff; padding: 7px 0; border-radius: 8px; font-size: 13px; font-weight: 700;
  cursor: pointer; transition: 0.15s;
}
.modbar button.active { background: #fff; color: var(--primary); border-color: #fff; }

#views { padding: 12px; max-width: 960px; margin: 0 auto; }

.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 14px; margin-bottom: 10px;
}
.card-title { font-size: 13px; font-weight: 700; color: var(--text-sub); margin: 0 0 8px; }

/* 搜索/筛选 */
.toolbar { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.toolbar input[type=search], .toolbar input[type=text] {
  flex: 1; min-width: 120px; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 10px; font-size: 14px; outline: none; background: #fff;
}
.toolbar select {
  padding: 9px 8px; border: 1px solid var(--border); border-radius: 10px; font-size: 13px; background: #fff;
}
.toolbar input:focus, .toolbar select:focus { border-color: var(--primary); }
.toolbar label.rng { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text-sub); background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 3px 6px; }
.toolbar label.rng input { width: 70px; padding: 4px 6px; border: 0; background: transparent; font-size: 13px; text-align: center; outline: none; }
.toolbar label.rng span { font-size: 12px; color: var(--text-sub); }
.split-card { border: 1px solid var(--border); border-radius: 8px; padding: 6px; margin-bottom: 8px; }
.split-card .split-box .fld { margin-bottom: 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px; border-radius: 10px; border: 1px solid transparent;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: 0.15s;
  background: var(--primary); color: #fff; white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn.secondary { background: #fff; color: var(--primary); border-color: var(--primary); }
.btn.ghost { background: #f1f4f8; color: var(--text); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.accent { background: var(--accent); color: #fff; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* 列表 */
.list-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-check { margin-top: 2px; }
.list-body { flex: 1; min-width: 0; }
.list-title { font-weight: 600; font-size: 14px; word-break: break-all; }
.list-meta { font-size: 12px; color: var(--text-sub); margin-top: 2px; }
.list-num { text-align: right; font-size: 13px; font-weight: 700; }
.list-num .unit { font-size: 11px; color: var(--text-sub); font-weight: 400; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px;
  background: var(--primary-light); color: var(--primary); margin: 3px 4px 0 0;
}
.badge.occupy { background: #fdece2; color: var(--warn); }
.badge.stock { background: #e3f4ef; color: var(--accent); }
.badge.zero { background: #f1f4f8; color: var(--text-sub); }
.badge.ok { background: #e3f4ef; color: var(--accent); font-weight: 600; }

/* 表单 */
.form-row { margin-bottom: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid.three { grid-template-columns: 1fr 1fr 1fr; }
label.fld { display: block; font-size: 12px; color: var(--text-sub); margin-bottom: 4px; }
.fld input, .fld select, .fld textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; outline: none; background: #fff; font-family: inherit;
}
.fld input:focus, .fld select:focus, .fld textarea:focus { border-color: var(--primary); }
.fld .auto { font-size: 11px; color: var(--accent); }

.seg { display: flex; background: #eef1f6; border-radius: 10px; padding: 3px; margin-bottom: 10px; }
.seg button {
  flex: 1; border: none; background: transparent; padding: 8px; font-size: 13px;
  border-radius: 8px; cursor: pointer; color: var(--text-sub); font-weight: 600;
}
.seg button.active { background: #fff; color: var(--primary); box-shadow: var(--shadow); }

/* 页脚备案号（工信部硬性要求：网站底部须展示备案号并链到 beian.miit.gov.cn） */
.site-foot {
  padding: 2px 12px 4px; text-align: center; font-size: 11px; color: var(--text-sub);
  display: flex; justify-content: center; align-items: center; gap: 8px; flex-wrap: wrap;
}
.site-foot a { color: var(--text-sub); text-decoration: none; }
.site-foot a:hover { color: var(--primary); text-decoration: underline; }
/* 登录页是全屏遮罩，看不到页面页脚 → 登录卡片里补一行 */
.login-foot { margin-top: 12px; font-size: 11px; color: var(--text-sub); }
.login-foot a { color: var(--text-sub); text-decoration: none; }
.login-foot a:hover { color: var(--primary); text-decoration: underline; }

/* 底栏 */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: #fff; border-top: 1px solid var(--border);
  display: flex; justify-content: space-around; padding: 6px 0 8px;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}
.tabbar button {
  border: none; background: transparent; cursor: pointer; padding: 4px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; color: var(--text-sub); font-weight: 600;
}
.tabbar button.active { color: var(--primary); }
.tabbar .ico { font-size: 20px; line-height: 1; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: rgba(20,30,50,0.9); color: #fff; padding: 10px 18px; border-radius: 22px;
  font-size: 13px; z-index: 100; opacity: 0; pointer-events: none; transition: 0.25s;
  max-width: 85vw; text-align: center;
}
.toast.show { opacity: 1; }

/* modal */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-sheet {
  background: #fff; width: 100%; max-width: 560px; max-height: 82vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 16px; animation: slideup 0.2s;
}
@keyframes slideup { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h3 { margin: 0; font-size: 16px; }

/* 动态创建的浮层弹窗（新增/编辑物料、批量导入等）
   必须 position:fixed，否则会以流式块挂在 body 末尾，切换任何 Tab 都能看到 */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.5); z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay > .modal {
  background: #fff; width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  border-radius: 14px; padding: 18px; box-shadow: 0 20px 50px rgba(0,0,0,0.28);
  animation: slideup 0.18s;
}

table.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl th, .tbl td { padding: 7px 6px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.tbl th { color: var(--text-sub); font-weight: 600; background: #f7f9fc; position: sticky; top: 0; }
.tbl tr:hover td { background: #fafbfd; }
/* 日报底部的「合计」行：白天要拿它跟 Excel 日报对账，得一眼能扫到 */
.tbl tfoot td { background: #eaf0f8; font-weight: 700; border-bottom: none; border-top: 2px solid #9fb2cc; white-space: nowrap; }
.tbl tfoot td.neg { color: #c0392b; }

.empty { text-align: center; color: var(--text-sub); padding: 40px 10px; font-size: 13px; }

.float-btn {
  position: fixed; right: 16px; bottom: 84px; z-index: 25;
  background: var(--accent); color: #fff; border: none; border-radius: 50%;
  width: 54px; height: 54px; font-size: 22px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(26,159,138,0.4);
}

.stat-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.stat { background: #fff; border-radius: 10px; padding: 10px; box-shadow: var(--shadow); text-align: center; }
.stat .v { font-size: 18px; font-weight: 800; color: var(--primary); }
.stat .k { font-size: 11px; color: var(--text-sub); margin-top: 2px; }

.checkbox-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.checkbox-row input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--primary); }

@media (max-width: 480px) {
  .form-grid.three { grid-template-columns: 1fr 1fr; }
}

/* 可搜索下拉选择 */
.combo-wrap { position: relative; }
.combo-wrap input { width: 100%; }
.combo-drop {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 30;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  max-height: 280px; overflow-y: auto; box-shadow: 0 6px 18px rgba(0,0,0,0.14);
  display: none; margin-top: 2px;
}
.combo-item {
  padding: 9px 12px; font-size: 13px; cursor: pointer; line-height: 1.4;
  border-bottom: 1px solid #f0f2f5;
}
.combo-item:last-child { border-bottom: none; }
.combo-item:hover { background: #f2f7f6; color: var(--primary); }
.combo-item .sub { color: var(--text-sub); font-size: 11px; }

/* ===== 2026-09-24 字典模糊候选：编码框里直接敲「碳钢 4」「304 3mm」「花纹板」 =====
   插在 .form-grid 里，必须 grid-column:1/-1 独占一行，否则会挤掉一个表单格子 */
.dict-pick {
  grid-column: 1 / -1;
  display: none;
  max-height: 220px; overflow-y: auto;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,.08); margin: 2px 0 4px; z-index: 60;
}
.dict-pick .dp-item {
  padding: 7px 11px; cursor: pointer; font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-bottom: 1px solid #f0f2f5;
}
.dict-pick .dp-item:last-child { border-bottom: none; }
.dict-pick .dp-item:hover, .dict-pick .dp-item.on { background: #f2f7f6; color: var(--primary); font-weight: 600; }

/* 2026-09-24：用户「亲手敲进去」的字段标绿 —— 一眼区分「系统带出的」和「自己填的」。
   这类字段不会被编码带出覆盖（按实际录入的信息登记）。 */
.fld input.user-typed, .fld select.user-typed, .fld textarea.user-typed {
  border-color: var(--accent);
  background: #f1fbf9;
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* 2026-09-29：单据清单最右边的「操作」列（改 / 删）在横向滚动时钉在右侧。
   以前表格一宽，按钮就被挤出屏幕，必须横向拖滚动条才点得到 —— 现在永远在最右边看得见。
   ⚠️ 背景必须是不透明色（var(--card)），否则滚动时下面的单元格会透上来。 */
.tbl th.act, .tbl td.act {
  position: sticky; right: 0; background: var(--card);
  box-shadow: -2px 0 4px rgba(0, 0, 0, .07);
}
.tbl th.act { background: #f7f9fc; z-index: 4; }
.tbl td.act { z-index: 2; }
.tbl tr:hover td.act { background: #fafbfd; }
