:root {
  --gov-blue: #1a4d8f;
  --gov-blue-dark: #143a6b;
  --gov-blue-light: #e8f0fa;
  --gov-red: #c0392b;
  --line: #d6dde6;
  --text: #1f2937;
  --text-sub: #5b6b7c;
  --bg: #f4f6f9;
  --ok: #1f8a52;
  --warn: #c77700;
  --err: #c0392b;
  --radius: 8px;
  --font: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Source Han Sans SC", sans-serif;
  --label-font: "SimSun", "宋体", "Songti SC", serif;
}

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

html, body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ============ 顶栏 ============ */
.app-header {
  background: linear-gradient(135deg, var(--gov-blue) 0%, var(--gov-blue-dark) 100%);
  color: #fff;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 10px rgba(20,58,107,.18);
}
.header-left { display: flex; align-items: center; gap: 12px; }
.logo-mark {
  width: 38px; height: 38px; border-radius: 8px;
  background: #fff; color: var(--gov-blue);
  display: grid; place-items: center;
  font-weight: 800; font-size: 17px; flex-shrink: 0;
}
.header-title h1 { font-size: 17px; font-weight: 700; letter-spacing: .5px; }
.header-title p { font-size: 11.5px; opacity: .85; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============ 按钮 ============ */
.btn {
  border: 1px solid var(--line);
  background: #fff; color: var(--text);
  padding: 8px 14px; border-radius: 6px;
  cursor: pointer; font-size: 13px;
  transition: all .16s; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: var(--gov-blue-light); border-color: var(--gov-blue); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--gov-blue); color: #fff; border-color: var(--gov-blue); }
.btn-primary:hover { background: var(--gov-blue-dark); color: #fff; }
.btn-ghost-light { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.45); }
.btn-ghost-light:hover { background: rgba(255,255,255,.25); border-color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { color: var(--gov-red); border-color: #f0c6c0; }
.btn-danger:hover { background: #fdecea; border-color: var(--gov-red); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ============ 主体布局 ============ */
.app-body {
  display: grid;
  grid-template-columns: minmax(320px, 460px) 1fr;
  gap: 18px;
  padding: 18px;
  max-width: 1600px;
  margin: 0 auto;
  align-items: start;
}
.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #fafbfc;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
}
.panel-head h2 { font-size: 14.5px; font-weight: 700; color: var(--gov-blue-dark); display: flex; align-items: center; gap: 8px; }
.panel-head h2::before { content: ""; width: 4px; height: 15px; background: var(--gov-blue); border-radius: 2px; }
.panel-body { padding: 16px; }

/* 左侧表单区 */
.form-panel { position: sticky; top: 78px; }
.form-scroll { max-height: calc(100vh - 190px); overflow-y: auto; padding: 16px; }

/* 标签类型选择 */
.type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }

/* ---------- 三步递进选择向导 ---------- */
.wizard { margin-bottom: 12px; }
.wiz-step { border: 1px solid var(--line); border-radius: 7px; margin-bottom: 8px; overflow: hidden; background: #fff; }
.wiz-step.disabled { opacity: .45; pointer-events: none; }
.wiz-head {
  padding: 8px 11px; background: #f2f6fb; font-size: 12.5px; font-weight: 700;
  color: var(--gov-blue-dark); display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--line);
}
.wiz-step.pending .wiz-head { background: #f7f9fc; color: var(--text-sub); }
.wiz-num {
  width: 18px; height: 18px; border-radius: 50%; background: var(--gov-blue); color: #fff;
  font-size: 11px; display: grid; place-items: center; flex-shrink: 0; font-weight: 700;
}
.wiz-step.pending .wiz-num { background: #b8c4d4; }
.wiz-opts { padding: 9px; display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.wiz-opt {
  border: 1.5px solid var(--line); border-radius: 6px; padding: 8px 9px;
  cursor: pointer; transition: all .15s; background: #fff;
}
.wiz-opt:hover { border-color: var(--gov-blue); background: var(--gov-blue-light); }
.wiz-opt.active { border-color: var(--gov-blue); background: var(--gov-blue-light); box-shadow: 0 0 0 2px rgba(26,77,143,.12); }
.wiz-opt .wo-name { font-size: 12px; font-weight: 600; color: var(--gov-blue-dark); line-height: 1.35; }
.wiz-opt .wo-desc { font-size: 10.5px; color: var(--text-sub); margin-top: 3px; line-height: 1.4; }
.wiz-opt.active .wo-name::after { content: " ✓"; color: var(--gov-blue); }

.type-result {
  background: linear-gradient(135deg, #e8f0fa, #f2f7fc);
  border: 1px solid #c5d8ee; border-radius: 7px; padding: 10px 12px;
  font-size: 12.5px; margin-bottom: 12px; line-height: 1.6;
}
.type-result .tr-name { font-weight: 700; color: var(--gov-blue-dark); }
.type-result .tr-chapter { font-size: 11px; color: var(--text-sub); margin-top: 3px; }
.type-result .tr-items { font-size: 11px; color: var(--text-sub); margin-top: 5px; }
.type-result .tr-items b { color: var(--gov-red); }

/* 营养成分编辑区的依据提示与必标/选填标签 */
.ne-hint {
  font-size: 10.5px; color: var(--text-sub); background: #f4f8fd;
  border-radius: 5px; padding: 6px 9px; margin-bottom: 6px; line-height: 1.5;
}
.tag {
  display: inline-block; font-size: 9.5px; font-weight: 600; padding: 0 4px;
  border-radius: 3px; margin-left: 4px; vertical-align: middle; line-height: 1.5;
}
.tag-req { background: #fdecec; color: var(--gov-red); }
.tag-opt { background: #eef2f7; color: var(--text-sub); }

/* 简易标签说明（≤20cm²，GB 7718-2025 10.3） */
.simple-notice {
  font-size: 10.5px; color: var(--text-sub); background: #f6f8fb;
  border: 1px dashed #c5d3e3; border-radius: 5px; padding: 6px 9px;
  margin-top: 8px; line-height: 1.55;
}

/* ---------- 语种判别 / 翻译对照面板 ---------- */
.lang-panel {
  border: 1px solid #c5d8ee; border-radius: 7px; background: #f6faff;
  padding: 10px 11px; margin-bottom: 12px;
}
.lang-panel-title { font-size: 12.5px; font-weight: 700; color: var(--gov-blue-dark); margin-bottom: 8px; }
.ts-item { border-top: 1px dashed #d5e2f2; padding-top: 8px; margin-top: 8px; }
.ts-item:first-of-type { border-top: none; margin-top: 0; padding-top: 0; }
.ts-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 5px; }
.lang-badge {
  font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 10px; color: #fff;
}
.lang-badge.zh { background: #2e7d32; }
.lang-badge.foreign { background: #c0392b; }
.ts-file { font-size: 11px; color: var(--text-sub); }
.ts-detail { font-size: 10.5px; color: #8a97a8; margin-left: auto; }
.ts-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 640px) { .ts-cols { grid-template-columns: 1fr; } }
.ts-col { background: #fff; border: 1px solid #e2ecf7; border-radius: 5px; padding: 6px 8px; }
.ts-title { font-size: 10.5px; font-weight: 600; color: var(--text-sub); margin-bottom: 3px; }
.ts-text { font-size: 11.5px; color: var(--text); line-height: 1.5; white-space: pre-wrap; word-break: break-word; max-height: 150px; overflow: auto; }
.ts-text.orig { color: #b0483c; }
.ts-text.zh { color: #1a6b32; }
.ts-warn { font-size: 10.5px; color: #a66300; background: #fff7e6; border-radius: 4px; padding: 4px 7px; margin-top: 6px; line-height: 1.5; }
.type-card {
  border: 1.5px solid var(--line); border-radius: 6px;
  padding: 9px 10px; cursor: pointer; transition: all .16s;
  background: #fff; position: relative;
}
.type-card:hover { border-color: var(--gov-blue); background: var(--gov-blue-light); }
.type-card.active { border-color: var(--gov-blue); background: var(--gov-blue-light); box-shadow: 0 0 0 2px rgba(26,77,143,.12); }
.type-card.active::after { content: "✓"; position: absolute; top: 6px; right: 8px; color: var(--gov-blue); font-weight: 700; font-size: 12px; }
.type-card .tc-name { font-size: 12.5px; font-weight: 600; color: var(--gov-blue-dark); line-height: 1.35; }
.type-card .tc-desc { font-size: 10.5px; color: var(--text-sub); margin-top: 3px; line-height: 1.4; display: none; }
.type-card.active .tc-desc { display: block; }

/* 折叠区块 */
.section { border: 1px solid var(--line); border-radius: 6px; margin-bottom: 10px; overflow: hidden; }
.section-head {
  padding: 10px 12px; background: #f7f9fc; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; font-size: 13px; color: var(--gov-blue-dark);
  user-select: none;
}
.section-head:hover { background: var(--gov-blue-light); }
.section-head .arrow { transition: transform .2s; font-size: 11px; color: var(--text-sub); }
.section.open .section-head .arrow { transform: rotate(90deg); }
.section-body { display: none; padding: 12px; border-top: 1px solid var(--line); }
.section.open .section-body { display: block; }
.section-head .badge { font-size: 10.5px; background: var(--gov-red); color: #fff; border-radius: 8px; padding: 1px 6px; font-weight: 500; }

/* 表单控件 */
.field { margin-bottom: 11px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: 12px; color: var(--text-sub); margin-bottom: 4px; font-weight: 500; }
.field label .req { color: var(--gov-red); margin-left: 2px; }
.field input[type=text], .field input[type=date], .field input[type=number], .field select, .field textarea {
  width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 5px;
  background: #fff; transition: border .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--gov-blue); box-shadow: 0 0 0 2px rgba(26,77,143,.1);
}
.field textarea { resize: vertical; min-height: 58px; line-height: 1.5; }
.field .hint { font-size: 10.5px; color: #93a1b0; margin-top: 3px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 9px; }
.checkline { display: flex; align-items: center; gap: 7px; font-size: 12.5px; margin: 6px 0; cursor: pointer; }
.checkline input { width: 15px; height: 15px; accent-color: var(--gov-blue); }

/* 营养成分表编辑 */
.nutri-edit { width: 100%; border-collapse: collapse; font-size: 12px; }
.nutri-edit th { background: #f0f4f9; padding: 6px 4px; font-weight: 600; font-size: 11px; border: 1px solid var(--line); }
.nutri-edit td { border: 1px solid var(--line); padding: 2px; }
.nutri-edit td:first-child { padding: 4px 6px; font-size: 11.5px; white-space: nowrap; }
.nutri-edit input { width: 100%; border: none; padding: 5px 4px; text-align: center; background: transparent; }
.nutri-edit input:focus { outline: 2px solid var(--gov-blue-light); }
.nutri-edit .mand { color: var(--gov-red); }

/* ============ 右侧预览区 ============ */
.preview-panel { min-width: 0; }
.preview-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: #fafbfc;
}
.preview-toolbar .spacer { flex: 1; }
.zoom-ctrl { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-sub); }
.zoom-ctrl button { width: 26px; height: 26px; border: 1px solid var(--line); background: #fff; border-radius: 5px; cursor: pointer; }
.zoom-ctrl button:hover { background: var(--gov-blue-light); }

.preview-stage {
  background: #eef1f5;
  padding: 24px;
  min-height: 560px;
  display: flex; justify-content: center; align-items: flex-start;
  overflow: auto;
}

/* ---------- 标签纸张 ----------
 * 实际尺寸由 app 通过 --pw / --ph（mm）设定，打印输出即该物理尺寸；
 * 内部全部使用 em 相对字号：--k = 档位宽度 / 90（以 S4 90mm 为基准版面），
 * 换档后整版内容按比例缩放，与真实标签一致。
 */
.label-paper {
  background: #fff;
  box-shadow: 0 4px 22px rgba(0,0,0,.12);
  width: var(--pw, 90mm);
  height: var(--ph, auto);
  overflow: hidden;
  padding: 1.2em 1.35em;
  border: .44em solid #000;             /* ≈1.5mm 黑色外框（随档位等比） */
  box-sizing: border-box;
  display: flex; flex-direction: column; gap: .22em;
  font-family: var(--label-font);
  color: #000;
  transform-origin: top center;
  transition: transform .2s;
  /* 字号基准：90mm 版面下 13.5px ≈ 3.57mm，由 --k 等比缩放 */
  font-size: calc(var(--k, 1) * 13.5px);
  line-height: 1.3;
}
.label-paper.simple-mode { /* 简易档不再改尺寸，由 --pw/--ph 决定 */ }

/* —— 头部：中文品名 + 英文品名，居中，双线分隔 —— */
.lp-head {
  text-align: center;
  padding-bottom: .15em;
  margin-bottom: .15em;
}
.lp-title {
  font-size: 1.16em; font-weight: 800; text-align: center;   /* 食品名称较其他项目大一号 */
  letter-spacing: .12em; line-height: 1.3; font-family: var(--font);
}
.lp-subtitle {
  text-align: center; font-size: .96em; color: #222; margin-top: .37em;
  letter-spacing: .03em; font-family: Georgia, 'Times New Roman', serif; font-style: italic;
}
/* 品名前缀（中文名称：/英文名称：） */
.lp-label-prefix { font-weight: 700; letter-spacing: .07em; font-style: normal; }
.lp-subtitle .lp-label-prefix { font-family: var(--font); font-size: .89em; color: #000; }
/* 食品分类号（GB 2760）——醒目徽标 */
.lp-category {
  display: inline-block; margin-top: .6em; padding: .22em .89em;
  border: .15em solid #000; border-radius: .22em;
  font-size: 1em; font-weight: 800; letter-spacing: .04em;
  font-family: var(--font); background: #000; color: #fff;
}
.lp-category .lp-cat-src { font-weight: 600; font-size: .81em; opacity: .85; }
/* 净含量副行：沥干物（固形物）含量 */
.net-sub {
  font-size: 1em; font-weight: 700; letter-spacing: .02em;
  margin-top: .15em; white-space: normal; font-family: var(--font);
}

.lp-block { margin-bottom: .1em; }
.lp-block .sec-title {
  font-weight: 700; font-size: 1em; font-family: var(--font);
  display: inline; white-space: nowrap;   /* 引导词不跨行断开 */
}
.lp-text { font-size: 1em; text-align: justify; word-break: break-word; }
.lp-text strong { font-weight: 700; }

.lp-divider { border: none; border-top: 1px dashed #bbb; margin: .4em 0; }

/* —— 底部行：日期（左）+ 净含量（右下角，字高按 GB 分档突出） —— */
.lp-bottom {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 1em; margin-top: .3em; padding-top: .1em;   /* 紧随内容、版面饱满不割裂 */
}
.lp-bottom > :only-child { margin-left: auto; }
.lp-bottom .date-block { margin-top: 0; flex-shrink: 0; font-size: 1em; }
/* 净含量：GB 7718-2025 4.5 同一展示版面；字高按《定量包装商品计量监督管理办法》分档（内联 font-size） */
.spec-content {
  text-align: left; font-weight: 700; letter-spacing: .04em;
  font-family: var(--font); line-height: 1.25; white-space: nowrap;
  font-size: 1.16em;
}

.codes-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1em; margin-top: .25em; padding: .1em 0;
}
.codes-row .code-qr { flex: 0 0 auto; width: 4.4em; height: 4.4em; }
.codes-row .code-qr svg { width: 100%; height: 100%; display: block; }
.codes-row .code-bar { flex: 1 1 auto; min-width: 0; max-width: 50%; height: 4.4em; object-fit: contain; object-position: right center; }

/* S8 简易标签码区：等高 mm 尺寸 */
.label-paper.compact .codes-row { margin: 0.1mm 0; gap: 1mm; }
.label-paper.compact .code-qr { width: 3.6mm; height: 3.6mm; }
.label-paper.compact .code-bar { height: 3.6mm; max-width: 60%; }

.net-content {
  text-align: right; font-weight: 700; letter-spacing: .04em;
  font-family: var(--font); line-height: 1.25; white-space: nowrap;
  font-size: 1.16em;   /* 净含量较其他项目大一号 */
}
.net-content .net-spec { font-size: .86em; font-weight: 600; letter-spacing: 0; }

/* 营养成分表（缩小版：缩小字号确保列完整显示） */
.nutri-table { border-collapse: collapse; width: 50%; min-width: 0; margin: .1em 0 0 auto; font-size: .78em; }

/* —— 双栏主体：左信息 / 右营养表，窄纸自动单栏 —— */
.lp-main { display: flex; flex-direction: column; gap: .3em; flex: 1 0 auto; min-height: 0; }   /* 可伸展填满但不压缩，防止内容重叠 */
.lp-main.cols { flex-direction: row; gap: .7em; align-items: flex-start; }
.lp-main.cols .lp-col-left { flex: 1 1 auto; min-width: 0; }
.lp-main.cols .lp-col-right { flex: 0 0 47%; max-width: 47%; }
.lp-main.cols .lp-col-right .nutri-table { width: 100%; margin: 0; }
.nutri-table th, .nutri-table td { border: 1px solid #000; padding: .04em .18em; white-space: nowrap; line-height: 1.25; }
.nutri-table th { background: #f2f2f2; font-weight: 700; text-align: center; font-family: var(--font); font-size: 1em; }
.nutri-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.nutri-table td.nrv { text-align: right; }
.nutri-table .rowlabel { font-family: var(--font); }
/* "1+6"（或特殊膳食 5 项）以外的选填项目：小一号斜体，突出强制项目 */
.nutri-table tr.optrow td { font-size: .88em; font-style: italic; }
.nutri-caption { font-size: .78em; color: #333; margin-top: .1em; line-height: 1.25; }

/* —— 责任主体信息块：无边框纯文本，短字段自动同行、长地址自动换行 —— */
.import-info {
  font-size: 1em; line-height: 1.3; margin-top: 0;
  display: flex; flex-wrap: wrap; column-gap: 1.1em; row-gap: .05em;
  align-items: baseline;
}
.import-info .ii-entity { min-width: 0; max-width: 100%; }
.import-info .ii-row { margin-bottom: 0; text-align: left; }
.import-info .ii-row b { font-weight: 700; font-family: var(--font); white-space: nowrap; }
.import-info .ii-sub { padding-left: 0; color: #111; }   /* 换行内容左对齐，不缩进 */

.lp-company {
  display: flex; flex-wrap: wrap; column-gap: 1.2em; row-gap: .05em;
  align-items: baseline; margin-top: .25em; font-size: 1em; line-height: 1.3;
}
.lp-company .ii-entity { min-width: 0; max-width: 100%; }
.lp-company .ii-row { text-align: left; }
.lp-company .ii-row b { font-weight: 700; font-family: var(--font); white-space: nowrap; }
.lp-company .ii-sub { padding-left: 0; }

.nonretail-stamp {
  display: inline-block; border: none; background: none; padding: 0;
  color: #000; font-weight: 700; font-size: 1em;
  font-family: var(--font); margin-bottom: .5em;
}

.children-tip {
  background: transparent; border: none; padding: 0;
  font-size: .78em; margin-top: .1em; font-family: var(--font);
  text-align: left; line-height: 1.25;
}

.date-block {
  border: 1.5px solid #000; padding: 6px 10px; margin-top: 9px;
  font-family: var(--font); font-size: 13px;
}
.date-block .db-line { margin-bottom: 2px; }
.date-block .db-strong { font-weight: 700; }

/* ============ 合规校验面板 ============ */
.compliance-panel { margin-top: 0; }
.compliance-summary {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.cs-item { text-align: center; padding: 8px 4px; border-radius: 6px; }
.cs-item .cs-num { font-size: 22px; font-weight: 800; line-height: 1.1; }
.cs-item .cs-lbl { font-size: 11px; color: var(--text-sub); margin-top: 2px; }
.cs-item.err { background: #fdecea; } .cs-item.err .cs-num { color: var(--err); }
.cs-item.warn { background: #fff5e5; } .cs-item.warn .cs-num { color: var(--warn); }
.cs-item.ok { background: #e9f7ef; } .cs-item.ok .cs-num { color: var(--ok); }

.issue-list { max-height: 320px; overflow-y: auto; padding: 10px 16px 16px; }
.issue {
  border-left: 3px solid var(--line); background: #fafbfc;
  padding: 8px 11px; margin-bottom: 7px; border-radius: 0 5px 5px 0;
}
.issue.error { border-left-color: var(--err); background: #fdf2f1; }
.issue.warning { border-left-color: var(--warn); background: #fff9f0; }
.issue.info { border-left-color: var(--gov-blue); background: var(--gov-blue-light); }
.issue .issue-msg { font-size: 12.5px; font-weight: 600; }
.issue .issue-ref { font-size: 11px; color: var(--text-sub); margin-top: 3px; }
.issue .issue-tag {
  display: inline-block; font-size: 10px; padding: 0 6px; border-radius: 3px;
  color: #fff; margin-right: 6px; vertical-align: 1px;
}
.issue.error .issue-tag { background: var(--err); }
.issue.warning .issue-tag { background: var(--warn); }
.issue.info .issue-tag { background: var(--gov-blue); }
.no-issue { text-align: center; padding: 24px; color: var(--ok); font-size: 13px; }

/* ============ OCR 区域 / 弹窗 ============ */
.upload-zone {
  border: 2px dashed #b8c4d4; border-radius: var(--radius);
  padding: 22px 16px; text-align: center; cursor: pointer;
  transition: all .18s; background: #fafcff; margin-bottom: 12px;
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--gov-blue); background: var(--gov-blue-light); }
.upload-zone .uz-icon { font-size: 30px; color: var(--gov-blue); }
.upload-zone .uz-main { font-size: 13px; font-weight: 600; margin-top: 6px; }
.upload-zone .uz-sub { font-size: 11px; color: var(--text-sub); margin-top: 3px; }

.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; margin-bottom: 12px; }
.thumb {
  position: relative; border: 1px solid var(--line); border-radius: 6px;
  overflow: hidden; aspect-ratio: 3/4; background: #f4f6f9;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .th-del {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: rgba(192,57,43,.9); color: #fff;
  border: none; cursor: pointer; font-size: 12px; line-height: 1; display: grid; place-items: center;
}
.thumb .th-label {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,.6); color: #fff; font-size: 9.5px; padding: 2px 4px; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.thumb.doc { display: flex; align-items: center; justify-content: center; background: #f0f4f9; }
.th-doc { text-align: center; }
.th-doc .th-ico { font-size: 30px; line-height: 1; }
.th-doc .th-ext { font-size: 10px; font-weight: 700; color: var(--gov-blue-dark); margin-top: 3px; letter-spacing: .5px; }

.parse-sum {
  background: var(--gov-blue-light); border-radius: 6px; padding: 8px 12px;
  font-size: 12px; color: var(--gov-blue-dark); margin-bottom: 10px;
}

.raw-text-box {
  background: #f7f9fc; border: 1px solid var(--line); border-radius: 6px;
  padding: 9px 11px; font-size: 11.5px; line-height: 1.7;
  max-height: 160px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  font-family: "Consolas", "Monaco", monospace;
}

.progress-bar { height: 6px; background: #e6ebf1; border-radius: 4px; overflow: hidden; margin: 10px 0; }
.progress-bar .pb-fill { height: 100%; background: var(--gov-blue); width: 0; transition: width .3s; }
.progress-text { font-size: 12px; color: var(--text-sub); text-align: center; }

.modal-mask {
  position: fixed; inset: 0; background: rgba(20,35,55,.5);
  display: none; align-items: center; justify-content: center; z-index: 1000; padding: 16px;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 10px; width: 100%; max-width: 860px;
  max-height: 90vh; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 18px 50px rgba(0,0,0,.3);
}
.modal-head {
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head h3 { font-size: 15px; color: var(--gov-blue-dark); }
.modal-head .close-x { border: none; background: none; font-size: 22px; cursor: pointer; color: var(--text-sub); line-height: 1; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; background: #fafbfc; }

/* 识别结果校对表 */
.ocr-review table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ocr-review th { background: #f0f4f9; padding: 7px; text-align: left; border: 1px solid var(--line); font-size: 11.5px; }
.ocr-review td { border: 1px solid var(--line); padding: 5px 7px; vertical-align: top; }
.ocr-review td:first-child { width: 110px; font-weight: 600; color: var(--text-sub); background: #fafbfc; }
.ocr-review input, .ocr-review textarea { width: 100%; border: 1px solid transparent; padding: 4px 5px; border-radius: 4px; background: #fcfcfd; }
.ocr-review input:focus, .ocr-review textarea:focus { outline: none; border-color: var(--gov-blue); background: #fff; }
.ocr-review .lang-tag { font-size: 10px; background: var(--gov-blue-light); color: var(--gov-blue-dark); padding: 0 5px; border-radius: 3px; margin-left: 5px; }

/* 说明/标准清单 */
.std-list { display: grid; gap: 8px; }
.std-item { border: 1px solid var(--line); border-radius: 6px; padding: 9px 11px; background: #fafbfc; }
.std-item .std-code { font-weight: 700; color: var(--gov-blue-dark); font-size: 12.5px; }
.std-item .std-name { font-size: 12px; margin-top: 1px; }
.std-item .std-note { font-size: 11px; color: var(--text-sub); margin-top: 3px; }
.std-item .std-effect { font-size: 10.5px; color: var(--warn); font-weight: 600; }

/* Toast */
.toast-wrap { position: fixed; top: 70px; right: 18px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #fff; border-left: 4px solid var(--gov-blue); border-radius: 6px;
  padding: 10px 15px; box-shadow: 0 6px 20px rgba(0,0,0,.15);
  font-size: 13px; min-width: 200px; max-width: 330px;
  animation: slideIn .25s ease;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
.toast.warn { border-left-color: var(--warn); }
@keyframes slideIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }

/* 分段控制器 */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: none; background: #fff; padding: 6px 12px; cursor: pointer; font-size: 12.5px; color: var(--text-sub); border-right: 1px solid var(--line); }
.seg button:last-child { border-right: none; }
.seg button.active { background: var(--gov-blue); color: #fff; }

/* 免责 */
.disclaimer {
  font-size: 11px; color: var(--text-sub); background: #fff8e9;
  border: 1px solid #f0e0bd; border-radius: 6px; padding: 9px 12px; margin: 0 16px 16px;
  line-height: 1.6;
}

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #c3cedb; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #a8b6c7; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 响应式 ============ */
@media (max-width: 1024px) {
  .app-body { grid-template-columns: 1fr; }
  .form-panel { position: static; }
  .form-scroll { max-height: none; }
}
@media (max-width: 640px) {
  .app-header { padding: 11px 13px; }
  .header-title h1 { font-size: 14.5px; }
  .header-title p { display: none; }
  .app-body { padding: 11px; gap: 12px; }
  .type-grid { grid-template-columns: 1fr; }
  .row2, .row3 { grid-template-columns: 1fr; }
  .preview-stage { padding: 12px; }
  .label-paper { width: 100% !important; padding: 18px; }
  .compliance-summary { grid-template-columns: repeat(3, 1fr); }
  .header-actions .btn span.txt { display: none; }
}

/* 打印：只输出标签纸张 */
@media print {
  .app-header, .app-body > .form-panel, .preview-toolbar, .app-footer,
  .compliance-panel, .toast-wrap, .disclaimer { display: none !important; }
  .app-body { display: block; padding: 0; }
  .preview-stage { padding: 0; background: #fff; min-height: auto; }
  .label-paper { box-shadow: none; width: 100%; }
}

/* ============ 食品分类号检索下拉（GB 2760） ============ */
.cat-combo { position: relative; }
.cat-drop {
  position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 3px);
  max-height: 300px; overflow-y: auto; background: #fff;
  border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 10px 28px rgba(15, 40, 80, .18);
}
.cat-opt {
  display: flex; align-items: baseline; gap: 9px;
  padding: 8px 12px; cursor: pointer; font-size: 13px; line-height: 1.45;
  border-bottom: 1px solid #f1f4f8;
}
.cat-opt:last-child { border-bottom: none; }
.cat-opt:hover, .cat-opt.active { background: #eaf2fc; }
.cat-code {
  font-family: Consolas, Monaco, monospace; font-weight: 700; color: var(--gov-blue-dark);
  white-space: nowrap; font-size: 12.5px; flex-shrink: 0;
}
.cat-name { color: var(--text-main); }
.cat-opt mark { background: #ffe9a8; padding: 0 1px; border-radius: 2px; }
.cat-empty { padding: 12px; font-size: 12.5px; color: var(--text-sub); }

/* ============ 标签规格档位选择栏 ============ */
.tier-bar {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 8px;
}
.tier-card {
  border: 1.5px solid var(--line); border-radius: 9px; background: #fff;
  padding: 8px 9px; cursor: pointer; text-align: center;
  transition: all .15s; position: relative;
}
.tier-card:hover { border-color: var(--gov-blue); box-shadow: 0 3px 10px rgba(30,90,168,.15); }
.tier-card.active { border-color: var(--gov-blue); background: #eaf2fc; box-shadow: 0 0 0 1.5px var(--gov-blue) inset; }
.tier-card .tc-id { font-size: 11px; color: var(--gov-blue-dark); font-weight: 800; }
.tier-card .tc-name { font-size: 13px; font-weight: 700; margin: 1px 0 3px; }
.tier-card .tc-size { font-size: 12.5px; font-weight: 700; color: var(--gov-blue-dark); font-family: Consolas,Monaco,monospace; }
.tier-card .tc-range { font-size: 10.5px; color: var(--text-sub); margin-top: 2px; }
.tier-card .tc-area { font-size: 10px; color: var(--text-sub); }
.tier-card .tc-reco { position: absolute; top: -7px; right: -4px; background: var(--gov-red); color: #fff;
  font-size: 10px; padding: 1px 6px; border-radius: 8px; display: none; }
.tier-card.reco .tc-reco { display: block; }
.tier-card.active .tc-reco { background: var(--gov-blue); }
.tier-info { font-size: 12px; color: var(--text-sub); margin-top: 9px; line-height: 1.7; }
.tier-info b { color: var(--gov-blue-dark); }
.tier-info .warn { color: var(--gov-red); font-weight: 600; }

/* ============ 打印校准弹窗 ============ */
.calib-box { display:flex; gap:10px; align-items:center; margin-bottom:10px; }
.calib-box label { font-size:13px; white-space:nowrap; color:var(--text-main); }
.calib-box input { width:110px; }
.print-tip {
  background:#e8f0fa; border-radius:6px; padding:8px 10px; font-size:12px;
  line-height:1.7; color:#333; margin-top:8px;
}

/* ============ 食品分类中文本体名称（品名下方小字括号样式，纯黑无底纹） ============ */
.lp-cat-name {
  text-align: center; font-size: 1.16em; font-weight: 800; color: #000;   /* 与食品名称、净含量字号一致且大于其他文字 */
  background: none; border: none; margin-top: 4px;
  letter-spacing: .12em; font-family: var(--font); line-height: 1.3;
}

/* ============ 日期行（紧随贮存条件之后；短字段自动同行；标签加粗、日期值不加粗） ============ */
.date-inline .db-flex { display: flex; flex-wrap: wrap; column-gap: 1.1em; row-gap: .05em; align-items: baseline; }
.date-inline .db-line { font-size: 1em; font-family: var(--font); line-height: 1.35; max-width: 100%; white-space: nowrap; }
.date-inline .db-line b { font-weight: 700; white-space: nowrap; }
.date-inline .db-line .db-val { white-space: nowrap; }

/* 单行项目：引导词与内容同处一行（放不下由脚本缩小本行字号） */
.one { white-space: nowrap; }

/* ============ S8 简易标签：最大表面面积计算方法 ============ */
.area-calc {
  margin-top: 8px; padding: 9px 12px; background: #f4f7fb;
  border: 1px solid var(--line); border-radius: 8px;
  font-size: 12px; line-height: 1.75; color: #333;
}
.area-calc b { color: var(--gov-blue-dark); }
.area-calc ol { margin: 5px 0 0 0; padding-left: 20px; }
.area-calc li { margin-bottom: 3px; }
.area-calc li:last-child { margin-bottom: 0; }

/* ============ S8 简易标签专用紧凑版式（GB 7718-2025 10.3 八项） ============
 * 采用 mm 绝对字号（--cf 由脚本自动微调至恰好铺满），保证 30×20mm 纸面不裁切。
 */
.label-paper.compact {
  display: flex;
  flex-direction: column;
  border-width: 0.5mm;
  padding: 0.45mm 0.7mm;
  gap: 0;
  --cf: 1.36mm;
  --cn: 1.75mm;
  font-size: var(--cf);
  line-height: 1.26;
  letter-spacing: 0;
}
.label-paper.compact .cs-name {
  font-size: var(--cn); font-weight: 800; text-align: center; line-height: 1.2;
  margin-bottom: 0.2mm;
}
.label-paper.compact .cs-line {
  font-size: var(--cf); line-height: 1.28; margin: 0.05mm 0;
  word-break: break-word; text-align: left;
}
.label-paper.compact .cs-line b { font-weight: 700; }
.label-paper.compact .cs-net { font-size: calc(var(--cf) * 1.36); font-weight: 800; line-height: 1.25; margin-top: auto; text-align: right; }
.label-paper.compact .cs-nonretail { font-size: calc(var(--cf) * 1.1); font-weight: 700; margin-bottom: 0.15mm; }

/* ============ ① 基本要求（只读，GB 7718-2025 第3章） ============ */
.req-list { margin: 0; padding: 0; list-style: none; counter-reset: req; font-size: 11.5px; line-height: 1.55; color: var(--text-main); }
.req-list li {
  counter-increment: req; position: relative;
  padding: 3px 6px 3px 30px; text-align: justify; word-break: break-word;
  border-bottom: 1px dashed #e8eef5;
}
.req-list li:last-child { border-bottom: none; }
.req-list li::before {
  content: counter(req, lower-latin) ".";
  position: absolute; left: 8px; top: 5px;
  font-weight: 700; color: var(--gov-blue-dark);
}

/* ============ 配料表悬浮提示 ============ */
.tip { position: relative; cursor: help; }
.tip .tip-mark {
  display: inline-block; margin-left: 4px; width: 14px; height: 14px; line-height: 14px;
  text-align: center; border-radius: 50%; background: var(--gov-blue); color: #fff;
  font-size: 10px; font-weight: 700; cursor: help;
}
.tip::after {
  content: attr(data-tip);
  display: none; position: absolute; left: 0; top: calc(100% + 5px);
  background: #1f2d3d; color: #fff; padding: 9px 11px; border-radius: 7px;
  font-size: 11.5px; line-height: 1.7; width: 320px; z-index: 95;
  box-shadow: 0 8px 22px rgba(0,0,0,.28); font-weight: 400;
  letter-spacing: .2px; white-space: pre-line;
}
/* 所有悬浮提示改用 JS 生成 fixed 定位的 .float-tip（.section overflow:hidden 会裁切原生 ::after） */
.tip::after { display: none !important; }
.float-tip {
  display: none; position: fixed; z-index: 9999;
  background: #1f2d3d; color: #fff; padding: 8px 10px; border-radius: 7px;
  font-size: 10px; line-height: 1.6; width: 400px;
  box-shadow: 0 8px 22px rgba(0,0,0,.28); white-space: pre-line; pointer-events: none;
  letter-spacing: .2px;
}

/* 分类专属标示项区块 */
.cat-rule { border: 1px solid var(--line, #e3e8ef); border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; background: #f8fafc; }
.cat-rule .std-note { font-size: 12px; color: var(--text-sub, #5b6b7c); margin-bottom: 6px; }
.cat-rule .field + .field { margin-top: 8px; }
.cat-rule .checkline { font-size: 12px; line-height: 1.5; color: var(--text-main, #233242); }

/* 配料表行布局：textarea 在左，致敏检出提示栏在右侧同行等高（致敏字段在配料表下方） */
.ing-row { display: flex; gap: 8px; align-items: stretch; }
.ing-main { flex: 1 1 auto; min-width: 0; display: flex; }
.ing-main textarea { flex: 1 1 auto; width: 100%; min-height: 72px; }

/* 合并栏内的小节标题 */
.sub-hd { font-size: 12px; font-weight: 700; color: var(--gov-blue-dark, #14508c); margin: 10px 0 6px; padding-top: 8px; border-top: 1px dashed var(--line, #e3e8ef); }

/* 分类专属标示项小节标题旁的建议提示 */
.sub-hd-tip { font-weight: 400; font-size: 11px; color: #b06a00; margin-left: 4px; }

/* ============ 页脚：免责声明 ============ */
.app-footer {
  border-top: 1px solid var(--line);
  background: #fbfcfd;
  padding: 13px 18px 16px;
}
.af-inner {
  max-width: 1600px; margin: 0 auto;
  display: flex; gap: 20px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap;
}
.af-text { font-size: 11.5px; line-height: 1.75; color: var(--text-sub, #5b6b7c); max-width: 940px; }
.af-text strong { color: var(--gov-red, #c0392b); }
.af-sub { margin-top: 4px; color: #8b98a6; font-size: 11px; }
.af-links { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-sub, #5b6b7c); white-space: nowrap; padding-top: 2px; }
.af-link { border: none; background: none; padding: 0; cursor: pointer; color: var(--gov-blue, #14508c); font-size: 11.5px; text-decoration: underline; font-family: inherit; }
.af-link:hover { color: var(--gov-blue-dark, #103c6b); }
.af-dot { color: #c9d2dc; }
.af-ver { color: #93a0ae; }

/* ============ 规则库版本 / 使用须知 文档 ============ */
.modal-sm { max-width: 680px; }
.doc-meta { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; color: var(--text-sub, #5b6b7c); margin-bottom: 14px; }
.doc-meta .doc-ver { background: #eaf2fb; color: var(--gov-blue-dark, #103c6b); padding: 2px 8px; border-radius: 4px; font-weight: 700; }
.doc-sec { font-size: 13px; font-weight: 700; color: var(--gov-blue-dark, #103c6b); margin: 16px 0 8px; padding-left: 8px; border-left: 3px solid var(--gov-blue, #14508c); }
.doc-table { width: 100%; border-collapse: collapse; font-size: 12px; line-height: 1.6; }
.doc-table th { background: #f0f4f9; padding: 6px 8px; text-align: left; border: 1px solid var(--line); font-size: 11.5px; color: var(--gov-blue-dark, #103c6b); }
.doc-table td { padding: 6px 8px; border: 1px solid var(--line); vertical-align: top; }
.doc-table td:first-child { white-space: nowrap; font-weight: 600; }
.doc-list { margin: 0; padding-left: 20px; font-size: 12px; line-height: 1.8; color: var(--text-main, #233242); }
.doc-ol { margin: 0; padding-left: 20px; font-size: 12.5px; line-height: 1.85; color: var(--text-main, #233242); }
.doc-ol li, .doc-list li { margin-bottom: 7px; }
.doc-note { margin-top: 14px; background: #f7f9fc; border: 1px solid var(--line); border-radius: 6px; padding: 9px 11px; font-size: 11.5px; line-height: 1.7; color: var(--text-sub, #5b6b7c); }

/* ============ 导出前复核弹窗 ============ */
.rv-lead { font-size: 12.5px; line-height: 1.75; margin-bottom: 10px; }
.rv-summary { font-size: 12px; color: var(--text-sub, #5b6b7c); background: #f7f9fc; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; margin-bottom: 10px; }
.rv-summary b { color: var(--text-main, #233242); }
.rv-summary .rv-err { color: var(--gov-red, #c0392b); font-weight: 700; }
.rv-summary .rv-warn { color: #b06a00; font-weight: 700; }
.rv-list { margin: 0 0 10px; padding-left: 20px; font-size: 12px; line-height: 1.8; color: var(--text-main, #233242); }
.rv-note { font-size: 11.5px; line-height: 1.7; color: var(--gov-red, #c0392b); background: #fdf6f5; border: 1px solid #f3d8d3; border-radius: 6px; padding: 8px 10px; margin-bottom: 10px; }

/* ===== 返回主页按钮（与首页/其他功能页统一风格） ===== */
.homebtn{
  background:#fff;color:#1e5bb8;border:none;border-radius:8px;
  padding:8px 14px;font-size:13.5px;font-weight:700;cursor:pointer;
  white-space:nowrap;text-decoration:none;display:inline-block;flex-shrink:0;
}
.homebtn:hover{background:#eef3fb}
