/* 章鱼先生 · 视觉基础
   字体、颜色、圆角和阴影只在 :root 定义；页面与组件只引用语义变量。
   完整使用规则见 docs/DESIGN_SYSTEM.md。 */

:root {
  /* 字体 */
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --text-display: 22px;
  --text-title: 16px;
  --text-section: 14px;
  --text-body: 13.5px;
  --text-support: 12px;
  --text-micro: 11px;
  --leading-tight: 1.35;
  --leading-body: 1.6;
  --leading-relaxed: 1.75;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;

  /* 中性色 */
  --surface-canvas: #f6f7f9;
  --surface-card: #ffffff;
  --surface-subtle: #fafbfc;
  --surface-muted: #f0f2f5;
  --surface-media: #eceff3;
  --surface-disabled: #eceae4;
  --border-default: #e3e7ec;
  --border-subtle: #eef0f3;
  --border-strong: #cfd6de;
  --border-hover: #c2ccd8;
  --text-primary: #1a1a1a;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;
  --text-inverse: #ffffff;

  /* 品牌与状态色 */
  --brand: #1f5c8f;
  --brand-hover: #17496f;
  --brand-soft: #eaf2f9;
  --brand-border: #cfe0ef;
  --brand-on-dark: #c9dcec;
  --success: #0f6e56;
  --success-soft: #e1f5ee;
  --warning: #8a6100;
  --warning-soft: #fdf3e3;
  --danger: #a02b2b;
  --danger-soft: #fbeaea;

  /* 叠层与控件 */
  --control-disabled: #b9c6d3;
  --overlay: rgba(15, 23, 32, .42);
  --toast-bg: #22303c;
  --shadow-popover: 0 6px 20px rgba(20, 30, 45, .1);
  --brand-overlay: rgba(31, 92, 143, .92);
  --brand-border-alpha: rgba(31, 92, 143, .45);
  --success-overlay: rgba(15, 110, 86, .92);
  --neutral-overlay: rgba(107, 114, 128, .8);

  /* 兼容现有组件的短变量名；新代码优先使用上面的语义变量。 */
  --bg: var(--surface-canvas);
  --card: var(--surface-card);
  --line: var(--border-default);
  --line-soft: var(--border-subtle);
  --txt: var(--text-primary);
  --mut: var(--text-secondary);
  --faint: var(--text-tertiary);
  --accent: var(--brand);
  --accent-hover: var(--brand-hover);
  --accent-soft: var(--brand-soft);
  --ok: var(--success);
  --ok-soft: var(--success-soft);
  --warn: var(--warning);
  --warn-soft: var(--warning-soft);
  --radius: 10px;
  --radius-sm: 7px;
  /* 图墙节奏：卡片最小宽度与间距。views/styles.js 用它推算每页条数
     （每页 = 列数 × 2 行），改这里页面会自动跟随，不要只改一处。 */
  --card-min: 170px;
  --card-gap: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: var(--weight-regular);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }

button {
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card);
  padding: 7px 14px;
  color: var(--txt);
  transition: border-color .15s, background .15s;
}
button:hover { border-color: var(--border-hover); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--text-inverse); border-color: var(--accent); }
button.primary:disabled { background: var(--control-disabled); border-color: var(--control-disabled); color: var(--text-inverse); opacity: 1; }
button.primary:hover { background: var(--accent-hover); }
button.ghost { background: transparent; border-color: transparent; color: var(--mut); }
button.ghost:hover { background: var(--line-soft); }

input, select, textarea {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  background: var(--card);
  color: var(--txt);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--brand-border);
  outline-offset: 2px;
}

/* ---------- 顶栏 ---------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .brand { font-size: 16px; font-weight: 600; letter-spacing: -.2px; white-space: nowrap; }
.topbar .brand span { color: var(--faint); font-weight: 400; font-size: 12.5px; margin-left: 6px; }
.topbar .grow { flex: 1; }
.topbar .stat { font-size: 12.5px; color: var(--mut); white-space: nowrap; }
.topbar .stat b { color: var(--txt); font-weight: 600; }

/* 模块页的返回条 */
.subbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 19;
}
.subbar h2 { margin: 0; font-size: 15px; font-weight: 600; }
.subbar .desc { font-size: 12.5px; color: var(--faint); }

/* ---------- 布局 ---------- */
.page { max-width: 1280px; margin: 0 auto; padding: 20px; }
.page.narrow { max-width: 720px; }
/* 款式资源库：图墙铺满整宽、从左侧起排，不居中留白。 */
.page.wide { max-width: none; margin: 0; padding: 20px 20px 44px; }

.section-label {
  font-size: 11.5px;
  color: var(--faint);
  letter-spacing: .06em;
  margin: 22px 0 10px;
}
.section-label:first-child { margin-top: 4px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--card-min), 1fr)); gap: var(--card-gap); }

/* ---------- 快捷入口 ---------- */
.quick {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.quick .q {
  border-radius: var(--radius);
  padding: 14px 15px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--card);
  transition: border-color .15s, transform .15s;
}
.quick .q:hover { border-color: var(--border-hover); transform: translateY(-1px); }
.quick .q.primary { background: var(--accent); border-color: var(--accent); }
.quick .q.primary .t { color: var(--text-inverse); }
.quick .q.primary .d { color: var(--brand-border); }
.quick .q .t { font-size: 13.5px; font-weight: 600; margin-bottom: 4px; }
.quick .q .d { font-size: 11.5px; color: var(--faint); }

/* ---------- 模块卡片 ---------- */
.mod {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--card);
  cursor: pointer;
  transition: border-color .15s, transform .15s;
  display: flex;
  flex-direction: column;
  min-height: 132px;
}
.mod:hover { border-color: var(--border-hover); transform: translateY(-2px); }
.mod.off { cursor: default; background: var(--bg); border-style: dashed; }
.mod.off:hover { transform: none; border-color: var(--line); }
.mod .ico {
  width: 30px; height: 30px; border-radius: 7px;
  background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
  color: var(--accent);
}
.mod.off .ico { background: var(--surface-disabled); color: var(--mut); }
.mod .name { font-size: 14px; font-weight: 600; margin-bottom: 3px; }
.mod.off .name { color: var(--mut); }
.mod .meta { font-size: 11.5px; color: var(--faint); margin-top: auto; }
.mod .badge {
  font-size: 10.5px; padding: 1px 7px; border-radius: 9px;
  background: var(--ok-soft); color: var(--ok);
  align-self: flex-start; margin-bottom: 10px;
}
.mod .badge.off { background: var(--surface-disabled); color: var(--faint); }

/* ---------- 工具栏 ---------- */
.toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar input[type=search] { flex: 1; min-width: 160px; max-width: 340px; }
.toolbar .spacer { flex: 1; }

/* ---------- 款卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--border-hover); transform: translateY(-2px); }
.card .cover {
  aspect-ratio: 3/4;
  background: var(--surface-media);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-tertiary); font-size: var(--text-support); overflow: hidden;
}
.card .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .meta { padding: 10px 12px; }
.card .no { font-size: 13px; font-weight: 600; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .name { font-size: 12.5px; color: var(--mut); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .tags { margin-top: 7px; display: flex; gap: 5px; flex-wrap: wrap; min-height: 18px; }

.tag { font-size: 11px; padding: 1px 7px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); }
.tag.gray { background: var(--surface-muted); color: var(--mut); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }

/* ---------- 分页 ---------- */
/* 分页：跟着工具栏走，紧凑到与筛选器同处一行 */
.pager { display: flex; align-items: center; gap: 3px; margin-left: 4px; }
.pager button { padding: 4px 7px; min-width: 26px; font-size: 12.5px; line-height: 1.5; }
.pager button.cur { background: var(--accent); color: var(--text-inverse); border-color: var(--accent); }
.pager button:disabled { opacity: .35; cursor: not-allowed; }
.pager .gap { color: var(--text-tertiary); padding: 0 1px; user-select: none; font-size: 12.5px; }
.pager .info { font-size: 12px; color: var(--faint); margin-left: 5px; white-space: nowrap; }

/* ---------- 空状态 / 建设中 ---------- */
.empty { text-align: center; padding: 70px 20px; color: var(--mut); font-size: 14px; }
.building {
  text-align: center;
  padding: 60px 24px;
  color: var(--mut);
}
.building .box {
  display: inline-block;
  max-width: 440px;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}
.building h3 { margin: 0 0 8px; font-size: 15px; color: var(--txt); }
.building p { margin: 8px 0; font-size: 13.5px; line-height: 1.75; }
.building ul { margin: 10px 0 0; padding-left: 20px; font-size: 13.5px; }
.building li { margin: 5px 0; }

/* ---------- 抽屉 / 弹窗 ---------- */
#drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(560px, 100%);
  background: var(--card);
  border-left: 1px solid var(--line);
  z-index: 40;
  transform: translateX(100%);
  transition: transform .22s ease;
  display: flex; flex-direction: column;
}
#drawer.open { transform: translateX(0); }
#drawer .head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; gap: 12px; }
#drawer .head .t { flex: 1; min-width: 0; }
#drawer .head h2 { margin: 0; font-size: 16px; }
#drawer .head p { margin: 3px 0 0; font-size: 13px; color: var(--mut); }
#drawer .body { flex: 1; overflow-y: auto; padding: 18px 20px; }

#modal {
  position: fixed; inset: 0;
  background: var(--overlay);
  display: none; align-items: center; justify-content: center;
  z-index: 60; padding: 20px;
}
#modal.open { display: flex; }
#modal .panel {
  background: var(--card); border-radius: 12px; padding: 22px;
  width: min(460px, 100%); max-height: 90vh; overflow-y: auto;
}
#modal h3 { margin: 0 0 14px; font-size: 16px; }

.field { margin-bottom: 11px; }
.field label { display: block; font-size: 12.5px; color: var(--mut); margin-bottom: 4px; }
.field input, .field select { width: 100%; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ---------- 口令门 ---------- */
#gate {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); z-index: 50;
}
#gate .box {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 28px; width: 320px; text-align: center;
}
#gate h2 { font-size: 17px; margin: 0 0 6px; }
#gate p { font-size: 13px; color: var(--mut); margin: 0 0 16px; }
#gate input { width: 100%; margin-bottom: 10px; text-align: left; }
#gate button { width: 100%; }
#gate .err { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ---------- 提示条 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 32px;
  transform: translateX(-50%) translateY(14px);
  background: var(--toast-bg); color: var(--text-inverse);
  padding: 9px 18px; border-radius: 8px; font-size: 13.5px;
  opacity: 0; transition: .2s; z-index: 80; pointer-events: none;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 识款：拖拽区 ---------- */
.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--card);
  min-height: 300px;
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover { border-color: var(--border-hover); }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .ico { margin-bottom: 12px; color: var(--text-tertiary); }
.dropzone .t { font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.dropzone .d { font-size: 12.5px; color: var(--faint); line-height: 1.8; }

.preview {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  gap: 14px;
  align-items: center;
}
.preview img {
  width: 84px; height: 106px; object-fit: cover;
  border-radius: var(--radius-sm); background: var(--surface-media); flex-shrink: 0;
}
.preview .info { flex: 1; min-width: 0; }
.preview .fn { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview .fs { font-size: 12px; color: var(--faint); margin-top: 3px; }

/* ---------- 筛选芯片 ---------- */
.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  font-size: 12.5px;
  padding: 5px 13px;
  border-radius: 15px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--mut);
  cursor: pointer;
  transition: all .12s;
}
.chip:hover { border-color: var(--border-hover); color: var(--txt); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--text-inverse); }

/* ---------- 识款：左右布局 ---------- */
.search-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.search-side {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  position: sticky;
  top: 74px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
}
.fgroup { margin-bottom: 18px; }
.fgroup:last-child { margin-bottom: 0; }
.fgroup .flabel {
  font-size: 11.5px;
  color: var(--faint);
  margin-bottom: 8px;
  letter-spacing: .02em;
}
.fgroup .chips { gap: 6px; }
.fgroup .chip {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 13px;
}

.filter-toggle { display: none; }

@media (max-width: 860px) {
  .search-layout { grid-template-columns: 1fr; gap: 14px; }
  /* 手机端筛选默认收起，避免把拖拽区挤到屏幕外 */
  .filter-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 11px 15px;
    margin-bottom: 12px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: 13.5px;
  }
  .filter-toggle .sum { font-size: 12.5px; color: var(--faint); }
  .filter-toggle.active { border-color: var(--accent); color: var(--accent); }
  .search-side {
    display: none;
    position: static;
    max-height: 46vh;
    overflow-y: auto;
    padding: 15px;
    margin-bottom: 12px;
  }
  .search-side.open { display: block; }
  .dropzone { min-height: 220px; padding: 30px 20px; }
}

/* ---------- 结果卡片 ---------- */
.result-card { position: relative; }
.result-card .sim {
  position: absolute; top: 8px; right: 8px;
  color: var(--text-inverse); font-size: 11px; font-weight: 500;
  padding: 2px 8px; border-radius: 10px;
  background: var(--brand-overlay);
}
/* 按可信度分级：高=绿，中=蓝，低=灰，让人一眼判断能不能直接用 */
.result-card .sim.high { background: var(--success-overlay); }
.result-card .sim.low  { background: var(--neutral-overlay); }

/* ---------- 首页工作台 ---------- */
.page.wide { max-width: 1320px; margin: 0 auto; padding: 18px 22px 40px; }

.hero-row {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 8px;
}
.hero-card {
  background: var(--accent);
  border-radius: var(--radius);
  padding: 22px 24px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 118px;
  transition: background .15s;
}
.hero-card:hover { background: var(--accent-hover); }
.hero-card .t { font-size: 19px; font-weight: 600; color: var(--text-inverse); letter-spacing: -.2px; }
.hero-card .d { font-size: 13px; color: var(--brand-on-dark); margin-top: 6px; line-height: 1.65; max-width: 420px; }
.hero-card .cta { font-size: 13px; color: var(--text-inverse); margin-top: 12px; opacity: .85; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.stat-card b { font-size: 22px; font-weight: 600; line-height: 1.1; letter-spacing: -.5px; }
.stat-card span { font-size: 12px; color: var(--faint); margin-top: 5px; }
.stat-card.warn b { color: var(--warn); }

.mod-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.recent-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 10px; }
.recent-grid .card .meta { padding: 8px 10px; }

@media (max-width: 1180px) {
  .mod-grid { grid-template-columns: repeat(2, 1fr); }
  .recent-grid { grid-template-columns: repeat(5, 1fr); }
}
@media (max-width: 900px) {
  .hero-row { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 760px) {
  .page.wide { padding: 14px 14px 32px; }
  .mod-grid { grid-template-columns: 1fr; }
  .recent-grid { grid-template-columns: repeat(3, 1fr); }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .hero-card { min-height: auto; padding: 18px; }
  .hero-card .t { font-size: 17px; }
  /* 手机端资源库卡片横向压扁，一屏能看到三个 */
  .mod {
    min-height: auto;
    padding: 12px 14px;
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    align-items: center;
    gap: 11px;
  }
  .mod .ico { margin-bottom: 0; width: 28px; height: 28px; }
  .mod .name { margin-bottom: 0; }
  .mod .badge { margin-bottom: 0; }
  .mod .meta { display: none; }
}

/* ---------- 移动端 ---------- */
@media (max-width: 640px) {
  :root { --card-min: 140px; --card-gap: 10px; }
  .topbar { padding: 11px 14px; gap: 10px; }
  .topbar .brand span { display: none; }
  .topbar .stat { display: none; }
  .subbar { padding: 9px 14px; }
  .page { padding: 14px; }
  .page.wide { padding: 14px 14px 40px; }
  .quick { grid-template-columns: 1fr 1fr; }
  .quick .q:first-child { grid-column: 1 / -1; }
  .grid-2 { grid-template-columns: 1fr; }
  .mod { min-height: 120px; padding: 14px; }
  .pager .info { display: none; }
}

/* ---------------- 用料清单（BOM） ---------------- */
.bom { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 16px; }
.bom-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.bom-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.bom-sum { font-size: 12.5px; color: var(--mut); text-align: right; }
.bom-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.bom-table { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 430px; }
.bom-table th {
  text-align: left; font-weight: 600; color: var(--mut); font-size: 12px;
  padding: 7px 9px; background: var(--surface-subtle); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.bom-table td { padding: 7px 9px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.bom-table tr:last-child td { border-bottom: 0; }
.bom-table .seq { color: var(--faint); width: 26px; }
.bom-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bom-table .m-name { font-weight: 500; }
.bom-table .m-sub { color: var(--faint); font-size: 11.5px; margin-top: 1px; }
.bom-table .m-spec { color: var(--mut); white-space: nowrap; }
.bom-table .m-sup { color: var(--mut); white-space: nowrap; }
.bom-wrap.folded tr.fold { display: none; }
.bom .more { margin-top: 10px; width: 100%; font-size: 13px; }
.empty-mini { color: var(--mut); font-size: 13px; padding: 12px 0; }

@media (max-width: 600px) {
  .bom-table { min-width: 380px; font-size: 12px; }
  .bom-sum { font-size: 12px; }
}

/* 首页资源库卡片在手机上的横向紧凑形态。
   必须放在文件最后：上面的通用移动端规则会给 .mod 重新加回 min-height，顺序在前会被盖掉。 */
@media (max-width: 640px) {
  .mod {
    min-height: auto;
    padding: 12px 14px;
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    align-items: center;
    gap: 11px;
  }
  .mod .ico { margin-bottom: 0; width: 28px; height: 28px; }
  .mod .name { margin-bottom: 0; }
  .mod .badge { margin-bottom: 0; }
  .mod .meta { display: none; }
}

/* ---------------- 面辅料库 ---------------- */
.mat-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 16px; }
.mat-stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px;
}
.mat-stat b { display: block; font-size: 21px; font-weight: 600; line-height: 1.15; letter-spacing: -.4px; }
.mat-stat span { display: block; font-size: 11.5px; color: var(--faint); margin-top: 4px; }
.mat-stat.warn b { color: var(--warn); }

.mat-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.mat-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mat-table th {
  text-align: left; font-size: 11.5px; font-weight: 600; color: var(--mut);
  background: var(--surface-subtle); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.mat-table td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.mat-table tbody tr { cursor: pointer; }
.mat-table tbody tr:hover { background: var(--surface-subtle); }
.mat-table tbody tr:last-child td { border-bottom: 0; }
.mat-table .m-title { font-weight: 600; }
.mat-table .m-no { margin-left: 7px; font-size: 11px; color: var(--faint); font-weight: 400; }
.mat-table .m-sub { font-size: 11.5px; color: var(--faint); margin-top: 2px; }
.mat-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mat-table .m-sup { color: var(--mut); white-space: nowrap; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.mat-table .more { font-size: 11px; color: var(--faint); }
.chip-mini {
  display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 4px;
  background: var(--surface-muted); color: var(--mut); margin: 1px 3px 1px 0;
}
.chip-mini.muted { color: var(--text-tertiary); }

.mat-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.muted-sm { font-size: 12px; color: var(--faint); }
.sec-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; margin: 20px 0 9px; padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}
.sec-title .n { font-size: 11.5px; font-weight: 400; color: var(--faint); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.form-grid .field input, .form-grid .field select { width: 100%; }
.mat-foot { margin-top: 22px; padding-top: 12px; border-top: 1px solid var(--line-soft); font-size: 11.5px; color: var(--faint); }
button.sm { padding: 4px 10px; font-size: 12px; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }

.chips .chip-del {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12.5px; padding: 4px 6px 4px 10px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--card); color: var(--txt);
}
.chip-del.is-default { border-color: var(--brand-border); background: var(--accent-soft); }
.chip-del i { font-style: normal; font-size: 10px; color: var(--accent); }
.chip-del em { font-style: normal; font-size: 10.5px; color: var(--faint); }
.chip-del b { cursor: pointer; font-weight: 400; color: var(--text-tertiary); padding: 0 3px; border-radius: 4px; }
.chip-del b:hover { background: var(--danger-soft); color: var(--danger); }

@media (max-width: 1080px) {
  .mat-stats { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .mat-table .col-sup, .mat-table .col-price, .mat-table .col-status { display: none; }
  .mat-table th, .mat-table td { padding: 8px 10px; }
}
@media (max-width: 640px) {
  .mat-stats { grid-template-columns: 1fr 1fr; }
  .mat-stat:last-child { grid-column: 1 / -1; }
  .mat-table { font-size: 12.5px; }
  .mat-table .m-dim { max-width: 118px; }
  .form-grid { grid-template-columns: 1fr; }
}

/* BOM 里点物料名跳到面辅料库 */
.bom-table .m-link { color: var(--accent); border-bottom: 1px dotted var(--brand-border-alpha); }
.bom-table .m-link:hover { border-bottom-style: solid; }

/* 面辅料库移动端：表格只保留「物料 / 类别 / 规格 / 款数」，其余进详情看 */
@media (max-width: 640px) {
  .subbar .desc { display: none; }
  .subbar { gap: 6px; padding: 9px 12px; }
  .subbar h2 { font-size: 14px; }
  .subbar button { white-space: nowrap; padding: 5px 9px; font-size: 12.5px; }
  .mat-table .tag { white-space: nowrap; padding: 1px 6px; }
  .mat-table .col-color { display: none; }
  .mat-table .col-spec { white-space: nowrap; }
  .mat-table .col-spec .chip-mini:nth-of-type(n+3) { display: none; }
  .mat-table th, .mat-table td { padding: 8px 7px; }
  .mat-table .m-no { margin-left: 4px; }
}

/* 详情里的用料记录：5 列刚好放进 560px 抽屉，长品名截断不撑破 */
.mat-use td { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mat-use td.m-spec { max-width: 130px; }

/* 用料记录定宽，避免品名过长把「单耗」挤到最右 */
.mat-use { table-layout: fixed; }
.mat-use th:nth-child(1) { width: 74px; }
.mat-use th:nth-child(3) { width: 118px; }
.mat-use th:nth-child(4) { width: 74px; }

/* ---------------- 工艺库（按款） ---------------- */
.proc-style { display: flex; align-items: center; gap: 10px; }
.proc-style .thumb {
  width: 44px; height: 58px; flex-shrink: 0; border-radius: 6px; overflow: hidden;
  background: var(--surface-media); display: flex; align-items: center; justify-content: center;
  color: var(--text-tertiary); font-size: 11px;
}
.proc-style .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.proc-style .info { min-width: 0; }
.proc-style-table .m-title { font-weight: 600; }

.proc-detail { table-layout: fixed; }
.proc-detail th:nth-child(1) { width: 28px; }
.proc-detail th:nth-child(3) { width: 56px; }
.proc-detail th:nth-child(4) { width: 86px; }
.proc-detail th:nth-child(5) { width: 54px; }
.proc-detail th:nth-child(6) { width: 48px; }

@media (max-width: 900px) {
  .proc-style-table .col-part { display: none; }
}
@media (max-width: 640px) {
  .proc-style-table .col-cat, .proc-style-table .col-avg { display: none; }
  .proc-style-table th, .proc-style-table td { padding: 8px 7px; }
  .proc-style .thumb { width: 32px; height: 44px; }
  .proc-style .m-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
  .mat-wrap { overflow-x: auto; }
}

/* ---------- 管理后台表格 ---------- */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.tbl th, .tbl td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.tbl th {
  font-size: 12px;
  color: var(--mut);
  font-weight: 400;
  background: var(--bg);
  white-space: nowrap;
}
.tbl tr:last-child td { border-bottom: none; }
.tbl td button { padding: 4px 10px; font-size: 12.5px; margin-right: 4px; }
@media (max-width: 760px) {
  .tbl th:nth-child(3), .tbl td:nth-child(3),
  .tbl th:nth-child(6), .tbl td:nth-child(6) { display: none; }
  .tbl th, .tbl td { padding: 9px 10px; }
}

/* ---------- 用户菜单 ---------- */
.user-menu { position: relative; }
.user-menu > button {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--card);
  font-size: 13px; color: var(--txt);
}
.user-menu > button:hover { border-color: var(--border-hover); }
.user-menu .avatar {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  font-size: 11px; display: flex; align-items: center; justify-content: center;
  font-weight: 500; flex-shrink: 0;
}
.user-menu .dropdown {
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 210px; z-index: 60;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 6px;
  box-shadow: var(--shadow-popover);
}
.user-menu .dropdown[hidden] { display: none; }
.user-menu .who { padding: 9px 11px 10px; border-bottom: 1px solid var(--line-soft); margin-bottom: 5px; }
.user-menu .who .n { font-size: 13.5px; font-weight: 500; }
.user-menu .who .m { font-size: 11.5px; color: var(--faint); margin-top: 3px; line-height: 1.5; }
.user-menu .dropdown button {
  display: block; width: 100%; text-align: left;
  padding: 8px 11px; font-size: 13px;
  border: none; background: transparent; border-radius: 6px;
}
.user-menu .dropdown button:hover { background: var(--line-soft); }
.user-menu .dropdown button.danger { color: var(--danger); }

/* 工序分类维护 */
#categoryForm[hidden] { display: none; }
.category-parts {
  flex: 1 0 100%;
  min-width: 0;
  margin: 0;
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
}
#categoryPartOptions { display: flex; flex-wrap: wrap; gap: 8px 16px; }
#categoryPartOptions label { display: inline-flex; gap: 6px; align-items: center; }
