/* ==========================================================================
   元器件管理系统 · 桌面端界面样式
   设计基准: 1280px 及以上电脑浏览器, 不适配手机分辨率
   ========================================================================== */

:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --border: #e5e9f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --primary-border: #bfdbfe;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --success-border: #bbf7d0;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --danger-border: #fecaca;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --warning-border: #fde68a;
  --sidebar: #1e293b;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

h2 { font-size: 18px; font-weight: 600; letter-spacing: .2px; }
h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.muted { color: var(--text-3); font-size: 12.5px; font-weight: 400; }

/* ==================== 应用骨架 / 侧边栏 ==================== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 216px;
  flex: 0 0 216px;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.side-logo {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 7px;
  background: var(--primary);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.side-brand-text {
  display: flex;
  flex-direction: column;
  font-size: 14px;
  font-weight: 600;
  color: #f1f5f9;
  line-height: 1.25;
}
.side-brand-text em {
  font-style: normal;
  font-size: 10px;
  font-weight: 400;
  color: #7c8ba1;
  letter-spacing: .8px;
  text-transform: uppercase;
}
.side-nav { flex: 1; padding: 6px 0 14px; }
.nav-group {
  padding: 14px 18px 5px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .8px;
  color: #64748b;
}
.nav-item {
  display: block;
  position: relative;
  padding: 6px 14px;
  margin: 1px 8px;
  font-size: 13.5px;
  color: #cbd5e1;
  border-radius: var(--radius-sm);
  transition: background .12s, color .12s;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.active { background: rgba(37, 99, 235, .24); color: #fff; font-weight: 500; }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 5px;
  bottom: 5px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--primary);
}
.side-foot {
  border-top: 1px solid rgba(255, 255, 255, .07);
  padding: 12px 16px 14px;
}
.side-user { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.side-avatar {
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 50%;
  background: #334155;
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.side-user-name { font-size: 13px; color: #e2e8f0; }
.side-role {
  margin-left: auto;
  font-size: 10.5px;
  color: #93c5fd;
  background: rgba(37, 99, 235, .2);
  border-radius: 4px;
  padding: 1px 6px;
}
.side-logout { display: block; font-size: 12.5px; color: #94a3b8; padding: 3px 0; }
.side-logout:hover { color: #fca5a5; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.container { flex: 1; width: 100%; padding: 18px 22px 26px; }
.container-guest {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: var(--bg);
}
.footer {
  text-align: center;
  color: var(--text-3);
  font-size: 12px;
  padding: 10px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

/* ==================== 卡片 / 提示 ==================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card > h3 { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.detail-head > div { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.flash { border-radius: var(--radius-sm); padding: 9px 14px; margin-bottom: 12px; font-size: 13.5px; }
.flash-success { background: var(--success-soft); color: #15803d; border: 1px solid var(--success-border); }
.flash-error { background: var(--danger-soft); color: #b91c1c; border: 1px solid var(--danger-border); }
.empty-tip { color: var(--text-3); text-align: center; padding: 28px 8px; line-height: 1.9; font-size: 13.5px; }
.empty-tip a { color: var(--primary); }

/* ==================== 按钮 ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 32px;
  padding: 0 14px;
  font-size: 13.5px;
  font-family: inherit;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-3); color: var(--text); border-color: #b6c2d2; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; border-color: #15803d; color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn-sm { height: 27px; padding: 0 10px; font-size: 12.5px; }
.btn-block { width: 100%; margin-top: 14px; height: 36px; font-size: 14px; }
.btn-copy {
  height: 26px;
  padding: 0 9px;
  font-size: 12px;
  color: var(--primary);
  border-color: var(--primary-border);
  background: var(--primary-soft);
}
.btn-copy:hover { background: #dbeafe; color: var(--primary-dark); }
.btn-export { margin-left: auto; background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-export:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-add-field, .btn-add-attr {
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px dashed var(--primary-border);
}
.btn-add-field:hover, .btn-add-attr:hover:not(:disabled) { background: #dbeafe; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ==================== 表单 ==================== */
input, select, textarea, button { font-family: inherit; font-size: 13.5px; }

.field { margin-bottom: 10px; }
.field label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 4px; }
.field input, .field textarea, .field select,
.inline-add-form input, .inline-add-form select, .cat-add-form select,
.inline-form input {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}
.field textarea { height: auto; padding: 8px 10px; line-height: 1.6; }
.field input:focus, .field textarea:focus, .field select:focus,
.inline-form input:focus, .inline-add-form input:focus, .inline-add-form select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.field-wide { grid-column: 1 / -1; }
.inline-form { display: inline; }
.inline-form input { width: 140px; }

.search-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 14px; }
.search-form .form-actions { grid-column: 1 / -1; display: flex; gap: 8px; margin-top: 10px; }
.form-card .form-actions { display: flex; gap: 8px; margin-top: 14px; }

/* 检索条件按需添加 */
.field-extra { display: none; }
.field-extra.shown { display: block; }
.field-extra label { display: flex; align-items: center; justify-content: space-between; }
.field-remove { color: var(--text-3); font-size: 15px; line-height: 1; padding: 0 2px; }
.field-remove:hover { color: var(--danger); }
.field-add-wrap { position: relative; display: block; }
.field-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 30;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(15, 23, 42, .14);
  min-width: 190px;
  max-height: 280px;
  overflow-y: auto;
  padding: 4px;
}
.field-menu.open { display: block; }
.field-menu .field-menu-title {
  font-size: 11.5px;
  color: var(--text-3);
  padding: 6px 10px 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}
.field-menu a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  font-size: 13.5px;
  color: var(--text-2);
  border-radius: var(--radius-sm);
}
.field-menu a:hover { background: var(--surface-3); color: var(--text); }
.field-menu a.in-use { color: var(--primary); font-weight: 500; }
.field-menu a.in-use::after { content: "✓"; font-size: 12px; }

.form-row { display: flex; gap: 16px; margin-bottom: 10px; flex-wrap: wrap; }
.form-row label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--text-2); }
.form-row label.grow { flex: 1; min-width: 300px; }
.form-row input { max-width: 320px; height: 34px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); }
.form-row label.grow input { max-width: none; }
.check-label { font-size: 13px; color: var(--text-2); display: inline-flex; align-items: center; gap: 5px; }
.radio-item { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; color: var(--text-2); font-size: 13.5px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); width: 14px; height: 14px; cursor: pointer; }

.inline-add-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-add-form input[type="text"], .inline-add-form select { width: auto; min-width: 170px; flex: 1; }
.inline-add-form input[type="file"] { flex: 1; min-width: 200px; font-size: 13px; }
.alt-mode { display: inline-flex; align-items: center; gap: 14px; font-size: 13.5px; white-space: nowrap; }
.alt-mode label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; color: var(--text-2); }

/* ==================== 表格 ==================== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 13px;
  margin-bottom: 12px;
}
.data-table th, .data-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
.data-table thead th {
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-strong);
}
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody tr:last-child td { border-bottom: 1px solid var(--border); }
.data-table tfoot td { background: var(--surface-2); font-weight: 600; color: var(--text-2); }
.data-table td.num, .data-table th.num, .data-table tfoot td.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .op-col { white-space: nowrap; }
.data-table .op-col .inline-form { margin-left: 6px; }
.data-table a { color: var(--primary); }
.data-table a:hover { text-decoration: underline; }

.table-wrap { overflow-x: auto; }
.settings-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 10px; }
.settings-table th, .settings-table td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.settings-table th { color: var(--text-2); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
.settings-table tr:last-child td { border-bottom: none; }

.mono { font-family: Consolas, "Courier New", monospace; font-size: 12.5px; }
.trunc { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.ok-text { color: var(--success); }

/* 标签 */
.tag {
  display: inline-block;
  padding: 1px 8px;
  font-size: 11.5px;
  border-radius: 4px;
  border: 1px solid var(--primary-border);
  background: var(--primary-soft);
  color: var(--primary);
  white-space: nowrap;
}
.tag-in { background: var(--success-soft); color: #15803d; border-color: var(--success-border); }
.tag-out { background: var(--warning-soft); color: #b45309; border-color: var(--warning-border); }
.tag-open { background: var(--primary-soft); color: var(--primary); border-color: var(--primary-border); }
.tag-alt { background: var(--warning-soft); color: #b45309; border-color: var(--warning-border); }

/* ==================== 分类页 ==================== */
.cat-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; margin-bottom: 14px; }
.cat-card { padding: 14px 16px; margin-bottom: 0; }
.cat-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.cat-top { font-size: 14.5px; font-weight: 600; color: var(--text); }
.cat-top:hover { color: var(--primary); }
.cat-count {
  font-size: 11.5px;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  border-radius: 4px;
  padding: 1px 8px;
}
.cat-head .inline-form { margin-left: auto; }
.cat-subs { display: flex; flex-wrap: wrap; gap: 6px; }
.cat-sub {
  font-size: 12.5px;
  color: var(--text-2);
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-2);
}
.cat-sub:hover { border-color: var(--primary-border); color: var(--primary); background: var(--primary-soft); }
.cat-sub b { color: var(--primary); font-weight: 500; }
.cat-subsub { background: var(--surface-3); font-size: 12px; }
.cat-subsubs { margin-top: 6px; padding-left: 14px; border-left: 2px solid var(--border); }
.cat-set-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 10px 0 2px; }
.cat-set-row label { font-size: 12px; color: var(--text-3); }
.cat-set-row select, .cat-set-row input { max-width: 200px; }
.cat-set-row input[type="text"], .cat-set-row input[type="number"] {
  width: 150px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}
.cat-add-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cat-add-form input { width: 220px; }
.cat-add-form select { width: 260px; }
.cat-add-form input[type="number"] { width: 160px; }
.cat-add-hint { font-size: 12px; margin-top: 8px; }
.cat-sub-row { border-top: 1px dashed var(--border); margin-top: 10px; padding-top: 6px; }
.cat-rule-tip { font-size: 12px; margin: 2px 0 0; }
.cat-card > h3 { margin-bottom: 4px; }

.rule-hint { font-size: 12px; color: var(--success); margin-top: 5px; }

/* ==================== 检索页 / 元器件卡片 ==================== */
.list-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 12px; }
.result-count {
  font-size: 13px;
  color: var(--text-2);
  padding: 3px 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
}
.result-count b { color: var(--primary); font-size: 14px; }
.toggle-hint { font-size: 12px; }
.sort-label { font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.sort-select {
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
}
.sort-select:focus { outline: none; border-color: var(--primary); }

.part-card .part-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; margin-bottom: 8px; }
.part-code { font-weight: 600; font-size: 15px; color: var(--primary); font-family: Consolas, "Courier New", monospace; }
.part-name { font-size: 14px; color: var(--text); }
.head-attr { font-size: 13px; }
.head-model .attr-value { font-size: 14px; font-weight: 600; color: var(--text); word-break: keep-all; overflow-wrap: anywhere; }
.part-body { display: flex; flex-wrap: wrap; gap: 2px 18px; }
.part-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.part-list .attr-extra { display: none; }
.part-list.show-extra .attr-extra { display: flex; }

.attr { display: flex; gap: 6px; font-size: 13px; padding: 1px 0; }
.attr-label { color: var(--text-3); flex-shrink: 0; }
.attr-label::after { content: ":"; }
.attr-value { word-break: break-all; color: var(--text); }
.attr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 2px 18px; }
.attr-inline {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 26px;
  padding: 2px 0;
}
.attr-inline .attr { padding: 2px 0; }
.attr-inline .attr-model .attr-value { font-size: 14px; font-weight: 600; color: var(--text); }
.attr-block {
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--surface-2);
  border-left: 3px solid var(--border-strong);
  border-radius: 4px;
  align-items: flex-start;
  line-height: 1.7;
}
.attr-block .attr-label { font-weight: 600; color: var(--text-2); }
.attr-factory .attr-label { color: #92400e; }
.attr-factory .attr-value { color: #78350f; }

.part-desc {
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--surface-2);
  border-left: 3px solid var(--border-strong);
  border-radius: 4px;
  display: flex;
  gap: 6px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-2);
}
.part-desc .attr-label { flex-shrink: 0; font-weight: 600; color: var(--text-2); }
.part-desc .attr-value { overflow-wrap: anywhere; word-break: break-word; }

/* 行式列表(替代料/附件/用户) */
.alt-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.alt-row:last-child { border-bottom: none; }
.alt-code { color: var(--primary); font-weight: 600; font-family: Consolas, "Courier New", monospace; }
.alt-checkbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
  padding: 8px 12px;
  margin-bottom: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
}
.alt-check-title { color: var(--text-2); font-weight: 600; }
.alt-attr { color: var(--text-2); overflow-wrap: anywhere; }
.alt-tag { color: var(--text-3); font-style: normal; }
.alt-desc-val { color: var(--text-2); }
.alt-attr.muted { color: var(--text-3); }

/* 照片墙 */
.photo-wall { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0 14px; }
.photo-item { width: 186px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px; background: var(--surface); }
.photo-item img { width: 100%; height: 136px; object-fit: cover; border-radius: 4px; display: block; cursor: zoom-in; }
.photo-meta { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-top: 6px; font-size: 11.5px; }
.photo-meta span { max-width: 116px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo-meta .inline-form { display: inline; }

/* 分页 */
.pagination { display: flex; align-items: center; gap: 14px; justify-content: center; margin: 18px 0; font-size: 13.5px; color: var(--text-2); }
.pagination a { color: var(--primary); }

/* ==================== 元器件表单: 属性字段 ==================== */
.form-section-label {
  display: flex;
  align-items: center;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  margin: 6px 0 12px;
  padding-left: 9px;
  border-left: 3px solid var(--primary);
  line-height: 1.3;
}
.attr-box {
  margin: 16px 0 6px;
  padding: 14px 16px 12px;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.attr-box-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--border);
}
.attr-box-title { font-size: 13.5px; font-weight: 600; color: var(--text); }
.attr-box-title::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 7px;
  vertical-align: 2px;
  background: var(--primary);
  border-radius: 50%;
}
.attr-box-count {
  min-width: 22px;
  height: 19px;
  padding: 0 7px;
  font-size: 11.5px;
  line-height: 17px;
  text-align: center;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  border-radius: 4px;
}
.attr-box-hint { font-size: 12px; color: var(--text-3); }
.attr-box .empty-tip { padding: 10px 4px; font-size: 12.5px; text-align: center; }

.attr-rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px 12px; }
.attr-empty {
  grid-column: 1 / -1;
  padding: 16px 10px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-3);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
}
.attr-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 24px;
  align-items: center;
  gap: 8px;
  padding: 4px 5px 4px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color .15s;
}
.attr-row:hover { border-color: var(--primary-border); }
.attr-row-label { font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attr-row input {
  width: 100%;
  height: 30px;
  padding: 0 8px;
  font-size: 13px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
}
.attr-row input::placeholder { color: #b6c0ce; }
.attr-row input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .10);
}
.attr-row-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 15px;
  line-height: 1;
  color: var(--text-3);
  background: var(--surface-3);
  border: 1px solid transparent;
  border-radius: 50%;
}
.attr-row-remove:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.attr-add-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.attr-add-row select {
  min-width: 180px;
  max-width: 240px;
  height: 32px;
  padding: 0 10px;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.attr-add-row select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .10); }

/* ==================== 库存管理 ==================== */
.stock-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.stock-tabs a {
  padding: 7px 16px;
  font-size: 13.5px;
  color: var(--text-2);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.stock-tabs a:hover { color: var(--primary); }
.stock-tabs a.active { color: var(--primary); font-weight: 600; border-bottom-color: var(--primary); }

.toolbar-right { margin-left: auto; display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stock-num { color: var(--primary); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.stock-badge {
  background: var(--success-soft);
  color: #15803d;
  border: 1px solid var(--success-border);
  border-radius: 4px;
  font-size: 11.5px;
  padding: 1px 8px;
  white-space: nowrap;
}
.stock-badge:hover { background: #dcfce7; color: #15803d; }
.stock-filter { margin-bottom: 12px; }
.stock-filter .field input { width: 220px; }

.stock-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border);
}
.stock-row:last-child { border-bottom: none; }
.stock-row input, .stock-row select {
  height: 32px;
  padding: 0 9px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.stock-row input:focus, .stock-row select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .1); }
.stock-row .sr-code { width: 190px; }
.stock-row .sr-wh { width: 130px; }
.stock-row .sr-batch { width: 170px; }
.stock-row .sr-qty { width: 96px; }
.sr-del { height: 32px; padding: 0 10px; }
.sr-avail { flex-basis: 100%; margin: 4px 0 2px; }
.sr-avail .data-table { margin-bottom: 4px; font-size: 12.5px; }
.avail-total { margin-top: 4px; font-size: 12.5px; color: var(--text-2); }

.doc-head-fields { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; margin-bottom: 8px; }
.doc-remark { flex: 1; min-width: 280px; margin-bottom: 0; }
.opening-check { font-size: 13.5px; }
.file-input { padding: 8px 0; }
#inForm h3, #outForm h3 { margin-top: 18px; }

.wh-row { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.wh-edit { display: flex; flex: 1; gap: 8px; align-items: center; flex-wrap: wrap; }
.wh-edit input { height: 30px; padding: 0 8px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); }
.wh-name { width: 180px; }
.wh-remark { width: 220px; }
.wh-meta { font-size: 12px; white-space: nowrap; color: var(--text-3); }
.wh-del { margin-left: 4px; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; font-size: 13px; color: var(--text-2); }

/* ==================== BOM 项目 / 导入 ==================== */
body.bom-page .container { max-width: none; }
.bom-search-form { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.bom-search-form input {
  flex: 1;
  min-width: 220px;
  max-width: 400px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}
.bom-title-cell { max-width: 320px; font-size: 12px; color: var(--text-3); word-break: break-all; }
.bom-desc-cell { font-size: 12.5px; color: var(--text-2); word-break: break-word; overflow-wrap: break-word; }
.bom-skip-row td { color: var(--text-3); background: var(--surface-2); }
.bom-code-input { width: 150px; }
.bom-name-input { width: 200px; }
.bom-pc-bar {
  margin: 0 0 14px;
  padding: 10px 14px;
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}
.bom-pc-bar input { height: 30px; padding: 0 9px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); }
.bom-batch-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.bom-batch-bar .muted { font-size: 12.5px; }
.mr-conflict { margin: 0 0 18px; }
.mr-conflict h4 { margin: 0 0 8px; font-size: 13.5px; color: var(--text); }
.bom-alt-row td { background: #fffdf7; }
.bom-mini-input { width: 100%; min-width: 70px; font-size: 12px; height: 26px; padding: 0 5px; border: 1px solid var(--border-strong); border-radius: 4px; }

.import-tips { margin: 0 0 14px 18px; font-size: 13.5px; line-height: 2; color: var(--text-2); }
.import-warn { color: var(--danger); font-size: 12.5px; }
.import-stat { font-size: 14px; margin-bottom: 8px; }
.import-stat b { color: var(--primary); }
.exist-mode {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 18px;
  width: 100%;
  margin-bottom: 6px;
  padding: 9px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}
.exist-mode-label { color: var(--text-2); font-weight: 600; }
.import-inline { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.import-inline input[type="file"] { font-size: 12.5px; max-width: 260px; }

/* BOM 明细表 */
.bom-table { table-layout: fixed; }
.bom-table thead th { white-space: normal; line-height: 1.45; }
.bom-table tbody td {
  vertical-align: top;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
  line-height: 1.55;
}
.bom-table tbody td.bom-code-cell { font-family: Consolas, "Courier New", monospace; font-size: 12.5px; color: var(--primary); }
.bom-table tbody td.pos-cell { font-size: 12.5px; color: var(--text); }
.bom-table tbody td.bom-remark-cell { font-size: 12.5px; color: var(--text-2); }
.bom-table tbody td.bom-qty-cell { white-space: nowrap; }

/* 通用列宽拖拽柄 */
.pm-th-drag { position: relative; padding-right: 18px; }
.pm-resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 9px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
  z-index: 3;
}
.pm-resizer::before {
  content: "";
  position: absolute;
  top: 22%;
  left: 4px;
  width: 2px;
  height: 56%;
  border-radius: 2px;
  background: var(--border-strong);
  transition: background .12s;
}
.pm-resizer:hover::before, .pm-resizer.pm-resizing::before { background: var(--primary); }
.pm-resizing-active, .pm-resizing-active * { cursor: col-resize !important; user-select: none !important; }
.tbl-resize-tip { margin: 0 0 10px; font-size: 12px; color: var(--text-3); }

/* ==================== BOM 检查 ==================== */
.chk-upload-form { display: flex; flex-direction: column; gap: 12px; max-width: 820px; }
.chk-file-row { display: flex; align-items: center; gap: 12px; }
.chk-file-row label { min-width: 110px; font-size: 13.5px; color: var(--text-2); text-align: right; }
.chk-file-row input[type=file] { flex: 1; font-size: 12.5px; }
.chk-pick { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.chk-pick label { font-size: 13.5px; font-weight: 600; color: var(--text); }
.chk-pick select {
  min-width: 260px;
  height: 32px;
  padding: 0 10px;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}
.chk-stats { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.chk-pick-fields { align-items: flex-start; }
.chk-pick-fields > label { padding-top: 6px; }
.chk-fields { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.chk-field-opt {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  font-size: 12.5px;
  font-weight: 400;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  cursor: pointer;
  user-select: none;
}
.chk-field-opt:hover { border-color: var(--primary-border); background: var(--primary-soft); }
.chk-field-opt input { margin: 0; cursor: pointer; }
.chk-field-opt:has(input:checked) { color: var(--primary); background: var(--primary-soft); border-color: var(--primary-border); font-weight: 600; }
.chk-fixed {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  font-size: 12.5px;
  color: var(--text-3);
  background: var(--surface-3);
  border: 1px dashed var(--border-strong);
  border-radius: 5px;
}
.chk-fixed i { padding: 1px 6px; font-size: 11px; font-style: normal; color: var(--text-3); background: var(--surface); border-radius: 3px; }
.chk-fields-line { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 2px 0 10px; font-size: 12.5px; color: var(--text-2); }

.chk-stat {
  padding: 5px 13px;
  font-size: 12.5px;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
}
.chk-stat b { font-size: 14px; color: var(--primary); }
.chk-stat.chk-bad { background: var(--danger-soft); border-color: var(--danger-border); }
.chk-stat.chk-bad b { color: var(--danger); }
.chk-stat.chk-warn { background: var(--warning-soft); border-color: var(--warning-border); }
.chk-stat.chk-warn b { color: var(--warning); }

.chk-ok {
  margin: 6px 0;
  padding: 10px 14px;
  font-size: 12.5px;
  color: #15803d;
  background: var(--success-soft);
  border: 1px solid var(--success-border);
  border-left: 3px solid var(--success);
  border-radius: var(--radius-sm);
}
.chk-note {
  margin: 6px 0;
  padding: 10px 14px;
  font-size: 12.5px;
  color: #92400e;
  background: var(--warning-soft);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-sm);
}
.chk-note code { padding: 1px 6px; margin-right: 4px; font-size: 12px; background: var(--surface); border: 1px solid var(--warning-border); border-radius: 3px; }
.chk-bad-text { color: var(--danger); font-weight: 600; }
.chk-ok-text { color: var(--success); font-weight: 600; }

.chk-card-head { justify-content: flex-start; }
.chk-card-head small { margin-left: auto; }
.chk-badge { padding: 1px 10px; font-size: 11.5px; font-weight: 600; border: 1px solid transparent; border-radius: 4px; }
.chk-badge-bad { color: #b91c1c; background: var(--danger-soft); border-color: var(--danger-border); }
.chk-badge-ok { color: #15803d; background: var(--success-soft); border-color: var(--success-border); }

.chk-table {
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  border-color: var(--border);
  font-size: 13px;
  overflow: visible;
}
.chk-table col.chk-c-line { width: 62px; }
.chk-table col.chk-c-seq { width: 52px; }
.chk-table col.chk-c-code { width: 158px; }
.chk-table col.chk-c-field { width: 96px; }
.chk-table col.chk-c-ccl { width: 86px; }
.chk-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-2);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
.chk-table thead th.chk-th-drag { padding-right: 17px; }
.chk-resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 9px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
  z-index: 3;
}
.chk-resizer::before {
  content: "";
  position: absolute;
  top: 22%;
  left: 4px;
  width: 2px;
  height: 56%;
  border-radius: 2px;
  background: var(--border-strong);
  transition: background .12s;
}
.chk-resizer:hover::before, .chk-resizer.chk-resizing::before { background: var(--primary); }
.chk-resizing-active, .chk-resizing-active * { cursor: col-resize !important; user-select: none !important; }
.chk-table tbody td { word-break: break-word; overflow-wrap: break-word; }
.chk-table thead th:first-child { border-top-left-radius: var(--radius); }
.chk-table thead th:last-child { border-top-right-radius: var(--radius); }
.chk-table thead th.chk-th-std { color: #15803d; background: var(--success-soft); }
.chk-table tbody td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.chk-table tbody tr:last-child > td { border-bottom: none; }
.chk-table tbody tr:last-child > td:first-child { border-bottom-left-radius: var(--radius); }
.chk-table tbody tr:last-child > td:last-child { border-bottom-right-radius: var(--radius); }
.chk-row.chk-alt > td { background: #f8fafc; }
.chk-row:hover > td { background: #f1f7ff; }
.chk-table tbody tr.chk-grp-first > td { border-top: 1px solid var(--border-strong); }
.chk-table tbody tr:first-child.chk-grp-first > td { border-top: none; }
.chk-row-miss > td { background: #fffaf3; }
.chk-row-miss.chk-alt > td { background: #fff6ea; }
.chk-row-miss:hover > td { background: #fff3e2; }
.chk-line { color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chk-seq { color: var(--text-3); font-size: 12px; white-space: nowrap; }
.chk-code {
  font-family: Consolas, "Courier New", monospace;
  font-size: 14px;
  line-height: 1.5;
  font-weight: 600;
  color: var(--primary);
  overflow-wrap: break-word;
}
.chk-code-copy { cursor: copy; }
.chk-code-copy:hover { text-decoration: underline; }
.chk-copy-toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translate(-50%, -10px);
  padding: 7px 18px;
  font-size: 12.5px;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 22px rgba(37, 99, 235, .32);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 999;
  max-width: 70vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chk-copy-toast.show { opacity: 1; transform: translate(-50%, 0); }
.chk-table thead th.chk-th-code { font-size: 13px; }
.chk-fcell { white-space: nowrap; }
.chk-ftag {
  display: inline-block;
  padding: 1px 9px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.chk-row-miss .chk-ftag { color: #b91c1c; background: var(--danger-soft); border-color: var(--danger-border); }
.chk-val { line-height: 1.6; color: var(--text); overflow-wrap: break-word; word-break: break-word; }
.chk-val-bom { border-right: 1px solid var(--border); }
.chk-val-std { color: var(--text); }
.chk-empty { color: var(--text-3); font-size: 12px; }
.chk-mark { padding: 0 2px; font-weight: 600; border-radius: 3px; }
.chk-val-bom .chk-mark { color: #b91c1c; background: #fee2e2; }
.chk-val-std .chk-mark { color: #15803d; background: #dcfce7; }
.chk-ccl { white-space: normal; }
.chk-tag { display: inline-block; padding: 1px 9px; font-size: 11.5px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; border-radius: 4px; }
.chk-tag-diff { color: #b91c1c; background: var(--danger-soft); border-color: var(--danger-border); }
.chk-tag-miss { color: #b45309; background: var(--warning-soft); border-color: var(--warning-border); }

/* ==================== BOM 比对 ==================== */
.bc-cols { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 4px; }
.bc-col { flex: 1 1 420px; min-width: 320px; }
.bc-col h4 { margin: 0 0 6px; font-size: 13.5px; color: var(--text); }
.bc-col h4 small { font-weight: 400; }
.bc-sheet-title { font-size: 12px; color: var(--text-3); margin-top: 2px; overflow-wrap: anywhere; }
.bc-sheet-table { font-size: 13px; }
.bc-sheet-table td:first-child, .bc-sheet-table th:first-child { width: 54px; text-align: center; }
.bc-sheet-table td:nth-child(2) { word-break: break-all; }
.bc-radio { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--text); }
.bc-sep {
  width: 64px;
  height: 30px;
  padding: 0 8px;
  font-size: 13px;
  text-align: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: Consolas, "Courier New", monospace;
}
.bc-h4 { margin: 14px 0 6px; font-size: 13px; color: var(--text-2); }
.bc-h4 small { font-weight: 400; }
.bc-map-table { font-size: 13px; }
.bc-map-table th:first-child, .bc-map-table td:first-child { width: 150px; }
.bc-map-table select {
  width: 100%;
  max-width: 260px;
  height: 30px;
  padding: 0 8px;
  font-size: 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}
.bc-map-table tr.bc-map-off { background: var(--surface-2); }
.bc-map-table tr.bc-map-off td { color: var(--text-3); }
.bc-table { margin-top: 4px; }
.bc-table col.bc-c-code { width: 152px; }
.bc-table col.bc-c-ref { width: 108px; }
.bc-table col.bc-c-kind { width: 112px; }
.bc-table col.bc-c-field { width: 90px; }
.bc-table col.bc-c-side { width: 86px; }
.bc-table col.bc-c-codes { width: 210px; }
.bc-tag { display: inline-block; padding: 1px 10px; font-size: 11.5px; font-weight: 600; border: 1px solid transparent; border-radius: 4px; white-space: nowrap; }
.bc-tag-miss { color: #b91c1c; background: var(--danger-soft); border-color: var(--danger-border); }
.bc-tag-extra { color: #b45309; background: var(--warning-soft); border-color: var(--warning-border); }
.bc-tag-diff { color: #a21caf; background: #fdf4ff; border-color: #f5d0fe; }
.bc-tag-issue { color: #b45309; background: var(--warning-soft); border-color: var(--warning-border); }
.bc-tag-high { color: #b91c1c; background: var(--danger-soft); border-color: var(--danger-border); }
.bc-tag-mid { color: #b45309; background: var(--warning-soft); border-color: var(--warning-border); }
.bc-tag-note { color: var(--text-2); background: var(--surface-3); border-color: var(--border-strong); }
.bc-codes { font-family: Consolas, "Courier New", monospace; font-size: 12.5px; color: var(--primary); font-weight: 600; overflow-wrap: anywhere; }
.bc-issue-note { margin-top: 3px; font-size: 12px; color: var(--text-3); }

/* ==================== 物料需求单 ==================== */
.mr-mode-box {
  margin: 0 0 14px;
  padding: 12px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.mr-mode-title { font-weight: 600; color: var(--text); margin-bottom: 6px; font-size: 13.5px; }
.mr-mode-opt {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 4px;
  cursor: pointer;
  line-height: 1.6;
  font-size: 13.5px;
  color: var(--text-2);
  border-radius: 4px;
}
.mr-mode-opt:hover { background: var(--primary-soft); color: var(--text); }
.mr-mode-opt input[type="radio"] { margin-top: 4px; flex: none; }

.mr-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.mr-match-form { display: flex; gap: 8px; align-items: center; }
.mr-wh-select {
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  min-width: 140px;
  background: var(--surface);
  color: var(--text);
}

.mr-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  align-items: center;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  margin: 0 0 12px;
  font-size: 13.5px;
}
.mr-sum-bad { background: var(--danger-soft); border: 1px solid var(--danger-border); color: #991b1b; }
.mr-sum-ok { background: var(--success-soft); border: 1px solid var(--success-border); color: #166534; }
.mr-summary .muted { color: var(--text-2); font-size: 12px; }

.mr-short-list {
  margin: 0 0 14px;
  padding: 12px 16px;
  background: #fffbfb;
  border: 1px solid var(--danger-border);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius-sm);
}
.mr-short-list h4 { margin: 0 0 8px; font-size: 13px; color: #991b1b; }
.mr-short-list ul { margin: 0; padding-left: 20px; }
.mr-short-list li { line-height: 1.9; color: var(--text-2); font-size: 13px; }

.mr-scroll { overflow-x: auto; padding-bottom: 4px; }
.mr-table { table-layout: fixed; width: 100%; min-width: 1420px; }
.mr-table th, .mr-table td { word-break: break-all; overflow-wrap: anywhere; }
.mr-table td.num, .mr-table th.num { word-break: keep-all; white-space: nowrap; }
.mr-table .mr-status { word-break: keep-all; white-space: nowrap; }
.mr-table td.mr-status .muted { white-space: normal; font-size: 11.5px; }
.mr-table td.bom-desc-cell { line-height: 1.55; }
.mr-table td.mr-group-cell { line-height: 1.6; }
.mr-short-row { background: #fff8f8; }
.mr-short-row:hover { background: #fff1f1 !important; }
.mr-short-badge { color: #b91c1c; font-weight: 600; }
.mr-ok-badge { color: #15803d; font-weight: 600; }
.mr-group-cell { font-size: 12px; color: var(--text-2); line-height: 1.6; }
.mr-group-cell .muted { color: var(--text-3); }
.mr-cell-note {
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-3);
  margin-top: 2px;
  white-space: normal;
  word-break: keep-all;
}
.mr-table td.mr-status .mr-cell-note { color: var(--text-3); }

/* ==================== 登录页 ==================== */
.login-card {
  width: 360px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 30px 28px;
  box-shadow: 0 8px 30px rgba(15, 23, 42, .08);
}
.login-card h2 { text-align: center; margin-bottom: 20px; font-size: 17px; }
.login-card label { display: block; font-size: 12.5px; color: var(--text-2); margin: 12px 0 4px; }
.login-card input {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.login-card input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.login-tip { text-align: center; color: var(--text-3); font-size: 12px; margin-top: 16px; line-height: 1.8; }

/* ==================== 侧边栏: 折叠 / 展开 ==================== */
.sidebar { transition: width .16s ease, flex-basis .16s ease; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px;
}
.nav-ico {
  width: 16px;
  height: 16px;
  flex: none;
  opacity: .82;
}
.nav-item.active .nav-ico { opacity: 1; }
.nav-txt { white-space: nowrap; overflow: hidden; }

.side-logout {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 3px 2px;
}
.side-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  margin-top: 8px;
  padding: 6px 8px;
  font-size: 12.5px;
  color: #94a3b8;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.side-toggle:hover { background: rgba(37, 99, 235, .22); color: #fff; border-color: rgba(37, 99, 235, .45); }
.side-toggle svg { width: 13px; height: 13px; flex: none; transition: transform .16s; }

/* --- 折叠态: 收成 64px 图标窄栏 --- */
html.side-collapsed .sidebar { width: 64px; flex: 0 0 64px; }
html.side-collapsed .side-brand { padding: 16px 0; justify-content: center; }
html.side-collapsed .side-brand-text { display: none; }
html.side-collapsed .nav-group {
  height: 0;
  margin: 8px 14px 4px;
  padding: 0;
  overflow: hidden;
  font-size: 0;
  border-top: 1px solid rgba(255, 255, 255, .1);
}
html.side-collapsed .nav-item {
  justify-content: center;
  gap: 0;
  padding: 9px 0;
  margin: 2px 9px;
}
html.side-collapsed .nav-txt { display: none; }
html.side-collapsed .nav-item.active::before { left: -9px; top: 6px; bottom: 6px; }
html.side-collapsed .nav-ico { width: 17px; height: 17px; opacity: .9; }
html.side-collapsed .side-foot { padding: 12px 8px; }
html.side-collapsed .side-user { justify-content: center; margin-bottom: 8px; }
html.side-collapsed .side-user-name,
html.side-collapsed .side-role { display: none; }
html.side-collapsed .side-logout { justify-content: center; padding: 4px 0; }
html.side-collapsed .side-toggle { padding: 6px 0; margin-top: 10px; }
html.side-collapsed .side-toggle svg { transform: rotate(180deg); }

/* ==================== 需求单: 缺料提醒折叠 / 只看缺料 ==================== */
.mr-short-head { margin: 0 0 8px; font-size: 13px; }
.mr-collapse-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0;
  font-size: 13px;
  font-weight: 600;
  color: #991b1b;
  background: none;
  border: none;
  cursor: pointer;
}
.mr-collapse-btn:hover { color: #b91c1c; }
.mr-caret { font-size: 11px; line-height: 1; width: 10px; }
.mr-toggle-tip {
  font-weight: 400;
  font-size: 11.5px;
  color: var(--text-3);
  padding: 1px 7px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
}
.mr-short-body { max-height: 320px; overflow-y: auto; }
.mr-short-list.is-folded { padding-bottom: 10px; }

.mr-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin: 0 0 10px;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.mr-only-short {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.mr-only-short input { margin: 0; cursor: pointer; }
.mr-only-short .muted { font-size: 12px; }
.mr-filter-info { font-size: 12.5px; color: var(--text-3); }
.mr-filter-info.is-on { color: var(--primary); font-weight: 600; }

/* ---------- 物料出入库明细(流水账) ---------- */
.lg-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  align-items: center;
  padding: 10px 16px;
  margin: 0 0 12px;
  font-size: 13.5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
}
.lg-summary b { color: var(--primary); font-size: 14px; }
.lg-summary .muted { color: var(--text-2); font-size: 12px; }
.lg-in { color: #15803d; }
.lg-out { color: #b91c1c; }
.lg-table td.lg-qty { font-weight: 600; }
.lg-table tr.lg-row-in td.lg-qty { color: #15803d; }
.lg-table tr.lg-row-out td.lg-qty { color: #b91c1c; }
.lg-table tr.lg-row-in > td:first-child { box-shadow: inset 3px 0 0 #86efac; }
.lg-table tr.lg-row-out > td:first-child { box-shadow: inset 3px 0 0 #fca5a5; }
.lg-table .nowrap { white-space: nowrap; }
.lg-table tfoot td { background: var(--surface-2); font-weight: 600; }

/* ---------- 邮件通知设置 ---------- */
.mail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px 16px;
  margin-bottom: 10px;
}
.mail-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  color: var(--text-2);
}
.mail-grid input[type="text"],
.mail-grid input[type="password"],
.mail-grid input[type="number"] {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  background: var(--surface);
  color: var(--text);
}
.mail-grid input[type="checkbox"] { width: auto; }

/* ---------- 用户管理: 角色 / 所属仓库 ---------- */
.u-list { display: flex; flex-direction: column; gap: 10px; }
.u-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  background: var(--surface);
}
.u-head {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 8px; margin-bottom: 8px;
}
.u-name { font-weight: 600; font-size: 14.5px; }
.u-role {
  font-size: 12px; padding: 1px 8px; border-radius: 10px;
  background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--border);
}
.u-role.is-admin { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.u-role.is-keeper { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.u-ops { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.u-wh-form {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
  margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.u-wh-label { font-size: 12.5px; color: var(--text-2); }
.u-wh-list { display: flex; flex-wrap: wrap; gap: 6px 8px; }
.wh-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 13px; padding: 4px 10px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface-2); color: var(--text);
}
.wh-chip:hover { border-color: var(--primary); }
.wh-chip:has(input:checked) {
  border-color: var(--primary); color: var(--primary);
  background: #eff6ff; font-weight: 600;
}
.wh-chip input { margin: 0; }
.u-wh-hint { font-size: 12px; color: var(--text-2); }

/* ==================== App 内顶栏(手机打开电脑端页面时) ==================== */
.app-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 46px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 10px rgba(15, 23, 42, .2);
}
.app-bar-back, .app-bar-link {
  flex: 0 0 auto;
  color: #fff;
  font-size: 13px;
  opacity: .95;
}
.app-bar-back { font-size: 14px; }
.app-bar-link { opacity: .85; }
.app-bar-title {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
body.has-appbar { padding-top: 46px; }
body.has-appbar .sidebar { top: 46px; height: calc(100vh - 46px); }

/* 窄屏宽表格横向滚动(JS 包裹) */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ==================== 手机窄屏: 电脑端页面适配 ==================== */
@media (max-width: 820px) {
  /* ---- 骨架: 侧栏 => 顶部横向滑动导航 ---- */
  .app-shell { display: block; }
  .sidebar {
    width: auto;
    flex: none;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 40;
    overflow: visible;
    flex-direction: column;
    box-shadow: 0 3px 10px rgba(15, 23, 42, .18);
  }
  body.has-appbar .sidebar { height: auto; }
  .side-brand, .side-foot, .side-toggle { display: none; }
  .side-nav {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .side-nav::-webkit-scrollbar { display: none; }
  .nav-group { display: none; }
  .nav-item {
    flex: 0 0 auto;
    margin: 0;
    padding: 7px 11px;
    gap: 6px;
    background: rgba(255, 255, 255, .08);
    border-radius: 999px;
    color: #dbe3ee;
    font-size: 12.5px;
    white-space: nowrap;
  }
  .nav-item .nav-ico { width: 14px; height: 14px; }
  .nav-txt { display: inline; white-space: nowrap; overflow: visible; }
  .nav-item.active::before { display: none; }
  /* 折叠态在窄屏无意义, 全部还原成胶囊 */
  html.side-collapsed .sidebar { width: auto; flex: none; }
  html.side-collapsed .nav-group { display: none; }
  html.side-collapsed .nav-item { padding: 7px 11px; margin: 0; gap: 6px; justify-content: flex-start; }
  html.side-collapsed .nav-txt { display: inline; }
  html.side-collapsed .nav-ico { width: 14px; height: 14px; }

  .app-main { display: block; }
  .container { padding: 12px 12px 22px; }
  .container-guest { padding: 18px 14px; }
  .footer { display: none; }

  /* ---- 标题 / 卡片 / 工具条 ---- */
  .page-head { flex-wrap: wrap; gap: 8px; padding-bottom: 8px; }
  .page-head h1, .container > h1 { font-size: 18px; }
  .card { padding: 12px; border-radius: 10px; }
  .card > h3 { font-size: 14.5px; }
  .list-toolbar { gap: 8px; }
  .toolbar-right { margin-left: 0; width: 100%; }
  .form-actions { flex-wrap: wrap; gap: 8px; }

  /* ---- 表格: 横向滚动, 不压缩文字 ---- */
  .table-scroll { margin-bottom: 10px; }
  .data-table { min-width: 100%; width: auto; }
  .data-table th, .data-table td { white-space: nowrap; padding: 7px 9px; }
  .data-table td .trunc { max-width: 160px; }
  .table-scroll > .data-table { width: auto; }

  /* ---- 表单 ---- */
  .form-row { gap: 10px; }
  .form-row label { width: 100%; }
  .form-row label.grow { min-width: 0; }
  .form-row input, .form-row select { max-width: none; width: 100%; }
  .mail-grid { grid-template-columns: 1fr; }
  .attr-grid { grid-template-columns: 1fr; }
  .stock-row { flex-wrap: wrap; gap: 8px; }
  .stock-row .sr-code, .stock-row .sr-wh,
  .stock-row .sr-batch, .stock-row .sr-qty,
  .stock-row input, .stock-row select { width: 100%; }
  .stock-row .sr-del { width: 100%; height: 38px; font-size: 15px; }
  .inline-add-form input[type="text"], .inline-add-form select { min-width: 0; width: 100%; }
  .inline-add-form input[type="file"] { min-width: 0; }
  /* 输入框字号 16px, 避免 iOS/安卓聚焦时自动放大 */
  input[type="text"], input[type="number"], input[type="password"],
  input[type="search"], input[type="date"], select, textarea { font-size: 16px; }
}

/* ==================== 检索页: 筛选条件可折叠 ==================== */
.filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin-bottom: 10px;
}
.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.filter-toggle:active { transform: translateY(1px); }
.filter-toggle .ft-ico { font-size: 15px; line-height: 1; color: var(--primary); }
.filter-toggle .ft-caret { font-size: 11px; color: var(--text-3); transition: transform .18s; }
.filter-bar.open .filter-toggle {
  border-color: var(--primary);
  background: #eff6ff;
  color: var(--primary);
}
.filter-bar.open .filter-toggle .ft-caret { transform: rotate(180deg); }
.filter-on {
  font-size: 12px;
  padding: 2px 9px;
  border-radius: 999px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #b45309;
  white-space: nowrap;
}
.filter-clear { font-size: 12.5px; color: var(--text-2); text-decoration: underline; white-space: nowrap; }
.filter-tip { font-size: 12px; color: var(--text-3); }
.filter-add { margin-left: auto; }
.search-form.is-collapsed { display: none; }

@media (max-width: 820px) {
  .filter-bar { gap: 8px; }
  .filter-toggle { padding: 9px 15px; font-size: 13.5px; }
  .filter-tip { font-size: 11.5px; }
  .filter-add { margin-left: auto; }
  .search-form { grid-template-columns: 1fr; }
}

/* ==================== 分类浏览: 分类筛选 + 下级折叠 ==================== */
.cat-search { padding: 12px 14px; margin-bottom: 12px; }
.cat-search.is-collapsed { display: none; }
.cat-search-row { display: flex; align-items: center; gap: 10px; }
.cat-search-row input {
  flex: 1 1 auto;
  min-width: 0;
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.cat-search-row input:focus { outline: none; border-color: var(--primary); }
.cat-kw-clear { font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.cat-search-tip { font-size: 11.5px; color: var(--text-3); margin-top: 7px; }
.cat-expand-all { white-space: nowrap; margin-left: auto; }
.cat-toggle {
  font-size: 11.5px;
  color: var(--text-2);
  padding: 2px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  cursor: pointer;
  white-space: nowrap;
}
.cat-toggle:hover { border-color: var(--primary-border); color: var(--primary); }
.cat-caret { font-size: 10px; margin-left: 3px; display: inline-block; transition: transform .18s; }
.cat-card:not(.is-collapsed) .cat-caret { transform: rotate(180deg); }
.cat-card.is-collapsed .cat-subs { display: none; }
.cat-card.is-collapsed .cat-head { margin-bottom: 0; }
.cat-sub.is-hide, .cat-card.is-hide { display: none; }
.cat-no-match { margin-bottom: 12px; }

@media (max-width: 820px) {
  .cat-list { grid-template-columns: 1fr; gap: 10px; }
  .cat-card { padding: 12px 13px; }
  .cat-head { flex-wrap: wrap; gap: 8px; }
  .cat-head .inline-form { margin-left: 0; }
  .cat-search-row input { height: 40px; font-size: 16px; }
  .cat-sub { font-size: 13px; padding: 5px 11px; }
  .cat-toggle { padding: 4px 11px; }
}

/* ==================== 检索页: 手机上「检索」按钮置顶 ==================== */
.form-actions.form-actions-top {
  grid-column: 1 / -1;
  margin: 0 0 12px;
  padding: 0 0 12px;
  border-bottom: 1px dashed var(--border);
  align-items: stretch;
}
.form-actions.form-actions-top .btn { padding: 11px 16px; font-size: 15px; }
.form-actions.form-actions-top .btn-primary { flex: 1 1 60%; font-weight: 600; }
/* 顶部已有筛选条上的「+ 录入」入口, 避免三个按钮互相挤 */
.form-actions.form-actions-top .btn-success { display: none; }

/* ==================== 检索页: 扫码查询 ==================== */
.btn-scan-q {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 600;
  white-space: nowrap;
}
.btn-scan-q:hover { background: #dbeafe; border-color: #93c5fd; color: #1d4ed8; }
.btn-scan-q .sq-ico { font-size: 15px; line-height: 1; }
.filter-scan {
  max-width: 46vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
}
.scan-q-tip {
  display: none;
  font-size: 12.5px;
  color: var(--text-2);
  margin: -4px 2px 10px;
  line-height: 1.5;
}
.scan-q-tip.show { display: block; }

@media (max-width: 820px) {
  .filter-scan { max-width: 100%; }
  .btn-scan-q { padding: 9px 14px; font-size: 13.5px; }
}

/* ==================== 发料单「暂扣 -> 完成」 ==================== */
.tag-draft { background: var(--warning-soft); color: #b45309; border-color: var(--warning-border); }
.tag-done { background: var(--success-soft); color: #15803d; border-color: var(--success-border); }

/* 库存「可用/实存」: 有暂扣时高亮提示 */
.stock-num.has-hold, .stock-badge.has-hold {
  color: #b45309;
  font-weight: 700;
}
.stock-badge.has-hold {
  background: var(--warning-soft);
  border-color: var(--warning-border);
}
.stock-num.has-hold::after { content: " *"; font-size: 11px; color: #b45309; }

/* 单据详情的暂扣提示卡 */
.doc-hold-tip {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  border-left: 4px solid #f59e0b;
  background: #fffbeb;
}
.doc-hold-tip .dh-main { display: flex; gap: 10px; align-items: flex-start; flex: 1 1 320px; min-width: 0; }
.doc-hold-tip .dh-ico { font-size: 18px; line-height: 1.2; }
.doc-hold-tip form { margin: 0; }
.doc-hold-tip .btn { padding: 9px 18px; font-size: 14px; }

/* 新建发料单: 订单绑定 */
.field.doc-order select { max-width: 420px; }

@media (max-width: 820px) {
  .doc-hold-tip { padding: 12px; gap: 10px; }
  .doc-hold-tip .btn { width: 100%; }
  .field.doc-order select { max-width: none; width: 100%; }
}

/* ---------- 通知邮箱列表 ---------- */
.notify-to-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  color: var(--text-2);
  margin-bottom: 6px;
}
.notify-to-label textarea {
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  width: 100%;
  max-width: 640px;
  box-sizing: border-box;
  resize: vertical;
  line-height: 1.6;
}
.notify-to-label textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.notify-hint { margin-top: 0; }

/* ---------- 库存结余: 按批次/合并物料 切换 ---------- */
.view-toggle {
  display: inline-flex;
  margin-right: 8px;
}
.view-toggle .btn {
  border-radius: 0;
}
.view-toggle .btn:first-child {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.view-toggle .btn:last-child {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-left: -1px;
}

/* ---------- 列宽可拖拽表格: 窄屏(App 内)回退为内容自适应 + 横向滚动 ---------- */
@media (max-width: 820px) {
  table.stock-docs-table col,
  table.doc-items-table col,
  table.lg-main-table col,
  table.bom-table col,
  table.bom-edit-table col,
  table.mr-table col {
    width: auto !important;
  }
  table.stock-docs-table,
  table.doc-items-table,
  table.lg-main-table,
  table.bom-edit-table {
    min-width: 620px;
  }
  .tbl-resize-tip { display: none; }
}

/* ---------- BOM 编辑表: 列宽可拖拽(输入框随列宽伸缩) ---------- */
.bom-edit-table { table-layout: fixed; }
.bom-edit-table thead th { white-space: normal; line-height: 1.45; }
.bom-edit-table tbody td { vertical-align: middle; padding: 4px 6px; }
.bom-edit-table .bom-mini-input { min-width: 0; }

/* ---------- 收料通知 ---------- */
.ship-head-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.ship-head-grid .field label { display: block; font-size: 13px; color: var(--text-2, #374151); margin-bottom: 5px; }
.ship-head-grid textarea, .ship-head-grid input, .ship-head-grid select {
  width: 100%; box-sizing: border-box; padding: 7px 10px; font-size: 13.5px;
  border: 1px solid var(--border, #cbd5e1); border-radius: 6px; font-family: inherit; }
.ship-head-grid textarea { resize: vertical; font-family: inherit; line-height: 1.5; }
.ship-head-grid .ship-head-remark { grid-column: 1 / -1; }
.ship-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.ship-info h3 { margin: 0 0 6px; }
.ship-info-text { margin: 0; font-family: inherit; font-size: 13.5px; line-height: 1.7;
  white-space: pre-wrap; color: var(--text-1, #1f2937); }
.factory-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; flex: 1; }
.factory-form input { padding: 7px 10px; font-size: 13px; border: 1px solid var(--border, #cbd5e1);
  border-radius: 6px; width: auto; min-width: 120px; flex: 1; }
.factory-form .factory-addr { min-width: 200px; }
.factory-used { font-size: 12px; }
.notify-form { align-items: flex-start; }
.notify-form textarea { flex: 1; min-width: 260px; box-sizing: border-box; padding: 7px 10px;
  font-size: 13px; border: 1px solid var(--border, #cbd5e1); border-radius: 6px;
  font-family: inherit; resize: vertical; }
@media (max-width: 820px) {
  .ship-head-grid, .ship-info-grid { grid-template-columns: 1fr; }
  table.ship-docs-table, table.ship-items-table { min-width: 620px; }
}

/* ---------- 待办入库单(收料通知自动生成, 办理中) ---------- */
.tag-pending { background: #fef3c7; color: #b45309; border-color: #fcd34d; }
.tag-ship { background: var(--info-soft, #e0f2fe); color: #0369a1; border-color: #bae6fd; }
.row-pending td { background: #fffdf5; }
.row-pending td:first-child { box-shadow: inset 3px 0 0 #f59e0b; }

.doc-view-toggle { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 0 0 12px; }
.doc-view-toggle .dv-item { display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; font-size: 13.5px; border-radius: 999px; text-decoration: none;
  border: 1px solid var(--border, #cbd5e1); color: var(--text-2, #374151);
  background: #fff; }
.doc-view-toggle .dv-item.on { background: var(--primary, #2563eb);
  border-color: var(--primary, #2563eb); color: #fff; }
.doc-view-toggle .dv-badge { display: inline-block; min-width: 18px; padding: 0 5px;
  font-size: 11.5px; line-height: 17px; text-align: center; border-radius: 9px;
  background: #dc2626; color: #fff; }
.doc-view-toggle .dv-item.on .dv-badge { background: #fff; color: var(--primary, #2563eb); }
.doc-view-toggle .dv-tip { font-size: 12.5px; color: var(--text-3, #6b7280); }

.doc-pending-card { border: 1px solid #fcd34d; background: #fffdf5; }
.dp-head { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px;
  line-height: 1.7; color: #78350f; margin-bottom: 14px; }
.dp-head .dp-ico { font-size: 20px; line-height: 1.2; }
.dp-grid { display: grid; grid-template-columns: 260px 1fr; gap: 12px 16px;
  margin-bottom: 12px; }
.dp-grid .field label { display: block; font-size: 13px; color: var(--text-2, #374151);
  margin-bottom: 5px; }
.dp-grid select, .dp-grid input[type=text] { width: 100%; box-sizing: border-box;
  padding: 7px 10px; font-size: 13.5px; border: 1px solid var(--border, #cbd5e1);
  border-radius: 6px; font-family: inherit; }
.dp-photo-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 14px; font-size: 13px; }
.dp-photo-row input[type=file] { font-size: 13px; }
.dp-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* 通用确认弹窗(照片提醒等) */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center; z-index: 999; }
.modal-mask[hidden] { display: none; }
.modal-box { background: #fff; border-radius: 12px; padding: 20px 22px;
  width: min(440px, 92vw); box-shadow: 0 18px 50px rgba(15, 23, 42, .25); }
.modal-box h3 { margin: 0 0 8px; font-size: 16px; }
.modal-box p { margin: 0 0 8px; font-size: 13.5px; line-height: 1.7; color: #374151; }
.modal-btns { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
  margin-top: 14px; }
@media (max-width: 820px) {
  .dp-grid { grid-template-columns: 1fr; }
}

/* 设置页: 收料通知卡片右侧(默认收货仓库) */
.notify-form .notify-side { display: flex; flex-direction: column; gap: 8px;
  align-items: flex-start; }
.notify-form .notify-wh-label { font-size: 13px; color: var(--text-2, #374151); }
.notify-form .notify-side select { padding: 7px 10px; font-size: 13.5px;
  border: 1px solid var(--border, #cbd5e1); border-radius: 6px; min-width: 220px; }

/* 侧边栏待办角标 */
.nav-item .nav-badge { margin-left: auto; min-width: 18px; padding: 0 5px;
  font-size: 11px; line-height: 17px; text-align: center; border-radius: 9px;
  background: #dc2626; color: #fff; flex: none; }
html.side-collapsed .nav-item .nav-badge { display: none; }

/* ---------- 来料 Excel 导入 ---------- */
.tag-import { background: #ede9fe; color: #6d28d9; border-color: #ddd6fe; }
.imp-fields { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: flex-start; }
.imp-fields .field { flex: 1 1 240px; min-width: 200px; }
.imp-fields .field label { display: block; font-size: 13px; color: var(--text-2, #374151); margin-bottom: 5px; }
.imp-fields select, .imp-fields input[type=text] { width: 100%; box-sizing: border-box;
  padding: 7px 10px; font-size: 13.5px; border: 1px solid var(--border, #cbd5e1);
  border-radius: 6px; font-family: inherit; }
.imp-fields .file-input { width: 100%; box-sizing: border-box; font-size: 13px; }
.imp-tip { margin: 10px 0 0; font-size: 12.5px; }
.imp-help ul { margin: 8px 0 0; padding-left: 20px; font-size: 13px; line-height: 1.9; }

.imp-warn { color: #b45309; }
.imp-error { border-color: #fca5a5; background: #fef2f2; color: #b91c1c; }
.imp-sheet-form { display: inline-flex; align-items: center; gap: 6px; margin-right: 10px; }
.imp-sheet-form select { padding: 6px 9px; font-size: 13px; border: 1px solid var(--border, #cbd5e1);
  border-radius: 6px; }
.imp-opt { padding: 14px 16px; }
.imp-groups { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.imp-group { padding: 12px 14px; }
.imp-group-done { background: #f8fafc; opacity: .82; }
.imp-g-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.imp-g-head .check-label { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.imp-g-meta { font-size: 12.5px; color: var(--text-3, #6b7280); }
.imp-batch-wrap { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.imp-batch-wrap .muted { font-size: 12.5px; }
.imp-batch { width: 210px; padding: 5px 8px; font-size: 13px;
  border: 1px solid var(--border, #cbd5e1); border-radius: 6px; font-family: inherit; }
.imp-lines { margin-top: 8px; }
.imp-lines > summary { cursor: pointer; font-size: 12.5px; color: var(--primary, #2563eb); }
.imp-table { margin-top: 8px; font-size: 13px; }
.imp-table th, .imp-table td { padding: 5px 8px; }
.imp-actions { margin-top: 4px; }
.imp-skip { border-color: #fcd34d; background: #fffdf5; }
@media (max-width: 820px) {
  .imp-batch-wrap { margin-left: 0; }
  .imp-batch { width: 100%; }
  table.imp-table { min-width: 560px; }
}

/* ==================== 元器件照片(缩略图网格 + 放大灯箱) ==================== */
.ph-block { display: flex; flex-direction: column; gap: 10px; }
.ph-grid { display: flex; flex-wrap: wrap; gap: 14px; }
.ph-item {
  position: relative; margin: 0; width: 150px; padding: 6px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); box-shadow: var(--shadow);
}
.ph-item .ph-link { display: block; }
.ph-item img {
  display: block; width: 100%; height: 128px; object-fit: cover;
  border-radius: var(--radius-sm); background: var(--surface-3); cursor: zoom-in;
}
.ph-item img:hover { opacity: .92; }
.ph-cap {
  margin-top: 4px; font-size: 12px; color: var(--text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ph-item .ph-del { position: absolute; top: -8px; right: -8px; margin: 0; }
.ph-item .ph-del button {
  display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; padding: 0; border-radius: 50%;
  border: 1px solid var(--border-strong); background: #fff; color: var(--danger);
  font-size: 15px; line-height: 1; cursor: pointer; box-shadow: var(--shadow);
}
.ph-item .ph-del button:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.ph-upload { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }
.ph-upload input[type=file] { font-size: 13px; max-width: 320px; }
.ph-upload input[type=text] {
  flex: 1 1 180px; min-width: 160px; padding: 6px 9px; font-size: 13px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-family: inherit; color: var(--text); background: #fff;
}
.ph-tip { font-size: 12.5px; color: var(--text-3); }
.ph-msg { font-size: 12.5px; }
.ph-msg.ok { color: var(--success); }
.ph-msg.err { color: var(--danger); }

/* 灯箱 */
.ph-lightbox {
  position: fixed; inset: 0; z-index: 9998; padding: 24px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15, 23, 42, .88);
}
.ph-lightbox[hidden] { display: none; }
.lb-stage { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 92vw; }
.lb-img {
  max-width: 92vw; max-height: 82vh; border-radius: 6px; background: #fff;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
}
.lb-cap { color: #e2e8f0; font-size: 13px; text-align: center; }
.lb-close {
  position: absolute; top: 14px; right: 20px; width: 40px; height: 40px;
  border: 0; border-radius: 50%; background: rgba(255, 255, 255, .14);
  color: #fff; font-size: 26px; line-height: 1; cursor: pointer;
}
.lb-close:hover { background: rgba(255, 255, 255, .3); }
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 44px; height: 72px; border: 0; border-radius: 8px;
  background: rgba(255, 255, 255, .12); color: #fff;
  font-size: 34px; line-height: 1; cursor: pointer;
}
.lb-nav:hover { background: rgba(255, 255, 255, .28); }
.lb-prev { left: 12px; }
.lb-next { right: 12px; }
body.lb-open { overflow: hidden; }

@media (max-width: 820px) {
  .ph-grid { gap: 10px; }
  .ph-item { width: calc(50% - 5px); }
  .ph-item img { height: 112px; }
  .ph-upload input[type=file] { max-width: 100%; }
  .ph-upload input[type=text] { flex: 1 1 120px; min-width: 0; }
  .lb-nav { width: 34px; height: 56px; font-size: 26px; }
}

/* ==================== 元器件详情页: 双栏紧凑布局 ==================== */
.page-part-detail .card { padding: 14px 16px; margin-bottom: 0; }
.page-part-detail .card > h3 { margin-bottom: 8px; padding-bottom: 6px; }
.page-part-detail .card > h3.sub-h3 { margin: 12px 0 6px; padding-bottom: 4px; font-size: 13px; color: var(--text-2); }
.page-part-detail .empty-tip { padding: 8px 6px; line-height: 1.7; }
.page-part-detail .attr-grid { gap: 2px 16px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.page-part-detail .attr-block { margin-top: 6px; padding: 6px 9px; }
.page-part-detail .data-table th, .page-part-detail .data-table td { padding: 6px 8px; }
.page-part-detail .detail-head { margin-bottom: 14px; }

.detail-cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 14px;
  align-items: start;
}
.detail-main, .detail-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.detail-side { position: sticky; top: 14px; }
body.has-appbar .detail-side { top: 60px; }
/* 窄内容区(<1100px, 侧栏放不下)退回单列 */
@media (max-width: 1100px) {
  .detail-cols { grid-template-columns: minmax(0, 1fr); }
  .detail-side { position: static; }
}

/* ---- 手机端(≤820px): 单列 + 按内容重排顺序 + 紧凑 ---- */
@media (max-width: 820px) {
  .page-part-detail .detail-head {
    flex-direction: column; align-items: flex-start;
    gap: 8px; margin-bottom: 10px;
  }
  .page-part-detail .detail-head > div { width: 100%; gap: 6px; }
  .page-part-detail .detail-cols { display: flex; flex-direction: column; gap: 10px; }
  .page-part-detail .detail-main, .page-part-detail .detail-side { display: contents; }
  /* 手机端阅读顺序: 参数 → 照片 → 库存 → 替代料 → BOM → 附件 */
  .page-part-detail .dg-info  { order: 1; }
  .page-part-detail .dg-photos{ order: 2; }
  .page-part-detail .dg-stock { order: 3; }
  .page-part-detail .dg-alts  { order: 4; }
  .page-part-detail .dg-bom   { order: 5; }
  .page-part-detail .dg-atts  { order: 6; }
  .page-part-detail .card { padding: 12px; }
  .page-part-detail .card > h3 { margin-bottom: 6px; padding-bottom: 4px; }
  .page-part-detail .attr-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 2px 12px; }
  .page-part-detail .attr-block { padding: 6px 8px; }
  .page-part-detail .data-table th, .page-part-detail .data-table td { padding: 5px 6px; font-size: 12.5px; }
  .page-part-detail .empty-tip { padding: 6px 4px; font-size: 12.5px; }
  .page-part-detail .ph-tip { display: none; }
}
