/* =========================================================
   食品出入库管理系统 · 车间工位卡 v4（里多食品牌 VI 精修）
   主操作色 #C72627（白字 5.6:1）· 点缀亮红 #EA3637 · 酱酒黑 #300000
   兼容基线：Chrome/Edge ≥60 · iOS ≥12 · Android WebView ≥7
   规约：flex 间距一律 margin；grid gap 写旧名前置声明；
        核心颜色选择器必带字面量回退；不用 inset()/clamp()/min()/dialog。
   层级表：topbar 50 · flashes 60 · 滚动表头 th 内 5-7 · 模态 100
   ========================================================= */
:root {
  /* 台面与卡片 */
  --bg: #f5f1ec;
  --surface: #ffffff;
  --surface-2: #faf6f1;
  --surface-3: #f0e9e2;
  --border: #e8dfd6;
  --border-strong: #d5c7bb;
  /* 文字三级（全部 AA 以上） */
  --text: #291b16;
  --text-2: #56453d;
  --muted: #75635a;
  /* 品牌：主按钮加深保证可读，亮红只做点缀 */
  --brand: #c72627;
  --brand-dark: #a81f20;
  --accent: #ea3637;
  --ink: #300000;
  --primary: #300000;          /* 兼容旧令牌名 */
  --primary-2: #4d0b0b;
  --primary-soft: #fdeae8;
  --accent-2: #a81f20;
  --accent-soft: #fdebea;
  /* 状态四色（全系统只允许这四种表达状态） */
  --ok: #0e7a4b;      --ok-bg: #e6f5ec;
  --warn: #8a6400;    --warn-bg: #fdf4dd;
  --danger: #b3261e;  --danger-bg: #fbeae9;
  --info: #1e5aa8;    --info-bg: #e9f1fb;
  --danger-soft: #fbeae9;   /* 兼容旧令牌名 */
  --ok-soft: #e6f5ec;
  --warn-soft: #fdf4dd;
  /* 形状与深度 */
  --radius-s: 8px;
  --radius: 12px;
  --shadow-1: 0 1px 2px rgba(48,0,0,.06), 0 2px 8px rgba(48,0,0,.05);
  --shadow-2: 0 8px 28px rgba(48,0,0,.16);   /* 仅浮层使用 */
  /* 间距（4px 基准） */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  /* 字体（老系统回退链） */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI",
          "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", Arial, sans-serif;
  --mono: Consolas, "Courier New", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; }
body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: #291b16;   color: var(--text);
  background: #f5f1ec; background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: #c72627; color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: rgba(234,54,55,.16); color: inherit; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d5c7bb; border-radius: 6px; border: 2px solid #f5f1ec; }
::-webkit-scrollbar-thumb:hover { background: #c2b0a2; }
:focus-visible { outline: 2px solid #ea3637; outline-offset: 2px; border-radius: 4px; }
input, select, textarea { caret-color: #ea3637; caret-color: var(--accent); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------------- 顶部导航 ---------------- */
.topbar {
  background: linear-gradient(180deg, #300000, #1f0606);
  background: linear-gradient(180deg, var(--mode, #300000), var(--mode-dark, #1f0606));
  color: #fff;
  display: flex; align-items: center; flex-wrap: wrap;
  padding: 10px 22px;
  position: -webkit-sticky;   /* iOS Safari ≤12 前缀 */
  position: sticky; top: 0; z-index: 50;
  border-bottom: 3px solid #c72627;
  border-bottom-color: var(--mode, #c72627);   /* 同色系底边：不再残留品牌红 */
  box-shadow: 0 2px 10px rgba(48,0,0,.25);
}
.brand {
  display: flex; align-items: center;
  font-weight: 700; font-size: 16px; letter-spacing: .02em;
  margin-right: 18px;
}
.brand-icon { width: 26px; height: 26px; object-fit: contain; margin-right: 8px; vertical-align: middle; }
/* 顶栏内的模式徽章：半透明白底融入深色导航（页内徽章仍是模式色实底） */
.brand .mode-badge { background: rgba(255,255,255,.18); color: inherit; box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); }
.nav { display: flex; flex-wrap: wrap; }
.nav a {
  color: #fff; color: var(--mode-ink, #fff); opacity: .88;
  padding: 7px 13px; border-radius: 999px;
  font-size: 14px; white-space: nowrap; margin-left: 2px;
  transition: background .15s, opacity .15s;
}
.nav a:hover { opacity: 1; background: rgba(120,120,120,.18); text-decoration: none; }
/* 激活项 = 白色胶囊 + 固定深字（与模式色无关，任何模式下都可读） */
.nav a.active { background: #fff; color: #300000; font-weight: 600; opacity: 1; box-shadow: 0 1px 4px rgba(0,0,0,.22); }
.top-right { margin-left: auto; display: flex; align-items: center; }
.userbox { display: flex; align-items: center; color: inherit; font-size: 13px; }
.userbox > * { margin-left: 12px; }
.userbox a { color: inherit; text-decoration: underline; text-decoration-color: rgba(128,128,128,.5); }

/* 模式徽章：跟随当前业务模式色（--mode 注入在 body 上），浅色底自动换深字 */
.mode-badge {
  display: inline-block; padding: 1px 12px;
  line-height: 18px; min-height: 22px; border-radius: 999px;
  background: #300000; background: var(--mode, #300000);
  color: #fff; color: var(--mode-ink, #fff);
  font-size: 12px; font-weight: 600; vertical-align: 2px;
}

/* 模式切换条（第二行）：文字用「模式色加深后」的可读对比色（--mode-ink2 由服务端计算） */
.mode-bar {
  background: #24100f; background: var(--mode-dark, #24100f);
  color: #f0e6df; color: var(--mode-ink2, #f0e6df);
  display: flex; align-items: center; flex-wrap: wrap;
  padding: 5px 22px; font-size: 13px;
}
.mode-label { opacity: .72; margin-right: 10px; letter-spacing: .06em; }
.mode-bar .inline { display: inline-block; margin: 2px 6px 2px 0; }
.mode-btn {
  background: transparent; border: 1px solid transparent; border-bottom: 2px solid rgba(128,128,128,.6);
  color: inherit; border-radius: 6px; padding: 3px 12px; cursor: pointer;
  font: inherit; font-size: 13px;
  transition: background .15s;
}
.mode-btn:hover:not([disabled]) { background: rgba(120,120,120,.22); }
.mode-btn[disabled] { opacity: .38; cursor: not-allowed; }
/* 激活项 = 白底胶囊 + 固定深字：修复"白底白字看不见" */
.mode-btn.active {
  background: #fff; background: var(--surface, #fff);
  color: #291b16;
  font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}

/* ---------------- 页面骨架 ---------------- */
.container { max-width: 1240px; margin: 22px auto 40px; padding: 0 22px; }
h1 { font-size: 20px; font-weight: 800; margin: 6px 0 18px; letter-spacing: .01em; display: flex; align-items: baseline; flex-wrap: wrap; }
h1 > * { margin-right: 10px; }
h2 { font-size: 16px; font-weight: 700; margin: 14px 0 10px; color: #291b16; color: var(--text); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; }
h2 > * + * { margin-left: 8px; }
.sub { font-size: 12.5px; color: #75635a; color: var(--muted); font-weight: 400; }
.hint { font-size: 12.5px; color: #75635a; color: var(--muted); margin-top: 4px; }   /* 全站提示文字统一弱化 */
.card {
  background: #fff; background: var(--surface);
  border: 1px solid #e8dfd6; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 18px; box-shadow: var(--shadow-1);
}
.two-col { display: grid; grid-template-columns: 1fr 1fr; grid-gap: 18px; gap: 18px; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* 统计卡 */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
              grid-column-gap: 14px; grid-row-gap: 14px; column-gap: 14px; row-gap: 14px; margin-bottom: 20px; }
.stat {
  position: relative; overflow: hidden; border-radius: var(--radius);
  display: block; color: inherit;
  text-align: center;            /* 统计卡数字与标签居中 */
  padding-left: 8px;             /* 给左缘状态色条留位 */
}
.stat.striped::before, .stat.striped-out::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
}
.stat.striped::before { background: #0e7a4b; background: var(--ok, #0e7a4b); }
.stat.striped-out::before { background: #c72627; background: var(--brand, #c72627); }
.stat .num { font-size: 30px; font-weight: 800; color: #300000; color: var(--ink); font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; letter-spacing: -.01em; }
.stat .lbl { color: #75635a; color: var(--muted); margin-top: 4px; font-size: 13px; }
.stat-finish .num { color: #8a6400; color: var(--warn); }
.stat-key .num { color: #b3261e; color: var(--danger); }
.prod-flow { display: flex; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.prod-node { background: #faf6f1; background: var(--surface-2); border: 1px solid #e8dfd6; border: 1px solid var(--border); border-radius: var(--radius-s); padding: 12px 22px; text-align: center; }
.prod-node .num { font-size: 24px; font-weight: 800; color: #300000; color: var(--ink); font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.prod-node:first-child .num { color: #8a6400; color: var(--warn); }
.prod-node:nth-child(3) .num { color: #0e7a4b; color: var(--ok); }
.prod-arrow { font-size: 24px; color: #ea3637; color: var(--accent); font-weight: 700; margin: 0 14px; }
.alert-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
              grid-column-gap: 14px; grid-row-gap: 14px; column-gap: 14px; row-gap: 14px; }
.alert-panel h3 { margin-top: 0; color: #300000; color: var(--ink); }
.cat-dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
                 grid-column-gap: 14px; grid-row-gap: 14px; column-gap: 14px; row-gap: 14px; }
.cat-nums { display: flex; flex-wrap: wrap; font-size: 12.5px; color: #75635a; color: var(--muted); margin: 6px 0 8px; }
.cat-nums > * { margin-right: 16px; }
.cat-nums b { color: #291b16; color: var(--text); font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* 设置导航与品类页签 */
.settings-nav { display: flex; flex-wrap: wrap; padding: 10px 14px; }
.settings-nav a { padding: 6px 14px; border-radius: 999px; color: #56453d; color: var(--text-2); font-size: 13.5px; margin-right: 6px; transition: background .15s, color .15s; }
.settings-nav a:hover { background: #f0e9e2; background: var(--surface-3); text-decoration: none; }
.settings-nav a.active { background: #300000; background: var(--ink); color: #fff; }
.cat-tabs { display: flex; flex-wrap: wrap; margin-bottom: 16px; }
.cat-tabs a {
  display: inline-block; padding: 8px 20px; border-radius: 999px; background: #fff; background: var(--surface);
  border: 1px solid #d5c7bb; border: 1px solid var(--border-strong); color: #56453d; color: var(--text-2);
  font-weight: 600; font-size: 13.5px; margin: 0 6px 6px 0;
}
.cat-tabs a:hover { text-decoration: none; border-color: #ea3637; border-color: var(--accent); color: #ea3637; color: var(--accent); }
.cat-tabs a.active { background: #300000; background: var(--ink); color: #fff; border-color: #300000; border-color: var(--ink); }

/* ---------------- 表单 ---------------- */
label { display: block; font-size: 12.5px; color: #56453d; color: var(--text-2); margin: 10px 0 5px; font-weight: 500; }
label > em.req { color: #b3261e; color: var(--danger); font-style: normal; }
input, select, textarea {
  width: 100%;
  border: 1px solid #d5c7bb; border: 1px solid var(--border-strong); border-radius: var(--radius-s);
  font-size: 14px; font-family: inherit; color: #291b16; color: var(--text); background: #fff; background: var(--surface);
  padding: 8px 12px; min-height: 38px;
  transition: border-color .15s, box-shadow .15s;
}
select { height: 38px; }
textarea { line-height: 1.6; }
/* 行内小控件回到自然宽度 */
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: #c72627; }
.filter-bar select, .filter-bar input { width: auto; min-width: 130px; }
.inline input.small-input { width: 110px; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: #ea3637; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(234,54,55,.15);
}
.input.is-error, input.is-error { border-color: #b3261e; border-color: var(--danger); box-shadow: 0 0 0 3px rgba(179,38,30,.12); }
.err-msg { color: #b3261e; color: var(--danger); font-size: 12.5px; margin-top: 4px; }
input[readonly], input[disabled] { background: #faf6f1; background: var(--surface-2); color: #56453d; color: var(--text-2); }
.entry-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
              grid-column-gap: 16px; grid-row-gap: 0; column-gap: 16px; row-gap: 0; }
.entry-grid .wide { grid-column: span 2; }
.form-actions { margin-top: 18px; display: flex; align-items: center; flex-wrap: wrap; }
.form-actions > * { margin: 4px 8px 4px 0; }
.form-section { margin-top: 20px; padding-top: 18px; border-top: 1px solid #e8dfd6; border-top: 1px solid var(--border); }
.section-title {
  display: inline-block; font-size: 14px; font-weight: 700; color: #300000; color: var(--ink);
  margin: 0 0 12px; padding-bottom: 6px; border-bottom: 2px solid #ea3637; border-bottom-color: var(--accent);
}
.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; }
.filter-bar > * { margin: 4px 12px 4px 0; }
.field-box { background: #faf6f1; background: var(--surface-2); border: 1px dashed #d5c7bb; border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 14px 16px; margin-top: 14px; }
.hint-box { background: #faf6f1; background: var(--surface-2); border-radius: var(--radius-s); padding: 8px 12px; }
.chk { display: inline-flex; align-items: center; font-size: 13px; margin: 0 10px 0 0; }
.chk-row { display: flex; flex-wrap: wrap; padding: 6px 0; }
.chk-row > * { margin: 2px 18px 2px 0; }
.unit-set { display: inline-flex; align-items: center; font-size: 13px; margin: 0; }
.unit-set > * { margin-right: 6px; }
.field-cfg-form { display: flex; flex-wrap: wrap; align-items: center; }
.field-cfg-form > * { margin: 6px 18px 6px 0; }
.item-add-grid { display: grid; grid-template-columns: 2fr 1fr;
                 grid-column-gap: 14px; grid-row-gap: 0; column-gap: 14px; row-gap: 0; }
@media (max-width: 720px) { .item-add-grid { grid-template-columns: 1fr; } }

/* 计量/批次/上传区：三种语义三套底色，不再共用一种粉色盒 */
.weight-box { margin-top: 14px; background: #fdf4dd; background: var(--warn-bg, #fdf4dd); border: 1px solid #ecdcb4; border-radius: var(--radius); padding: 14px 16px; }
.batch-zone { margin-top: 14px; background: #e9f1fb; background: var(--info-bg, #e9f1fb); border: 1px solid #c5d9f2; border-radius: var(--radius); padding: 14px 16px; }
.upload-zone { margin-top: 14px; background: #faf6f1; background: var(--surface-2); border: 1px solid #e8dfd6; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.zone-title { font-size: 12px; font-weight: 700; letter-spacing: .04em; color: #56453d; color: var(--text-2); margin-bottom: 8px; }
.weight-remind { color: #8a6400; color: var(--warn); font-weight: 600; margin-bottom: 10px; }
.weight-box textarea { font-family: Consolas, "Courier New", monospace; font-family: var(--mono); }
.weight-row { display: flex; align-items: center; margin-bottom: 8px; }
.weight-row > * { margin-right: 10px; }
.w-row-label { min-width: 70px; color: #56453d; color: var(--text-2); font-size: 13px; }
.doc-row { display: flex; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.doc-row > * { margin-right: 10px; }
.batch-info { background: #e6f5ec; background: var(--ok-bg); border: 1px solid #bfe0cd; border-radius: var(--radius-s); padding: 10px 12px; margin-top: 10px; font-size: 13px; line-height: 1.9; }
.batch-info b { color: #0e7a4b; color: var(--ok); }
.w-summary-ok { color: #0e7a4b; color: var(--ok); font-weight: 700; }
.w-summary-bad { color: #b3261e; color: var(--danger); font-weight: 700; }

.perm-box { display: flex; flex-wrap: wrap; padding: 8px 0; }
.perm-box > * { margin-right: 16px; }
.perm-form { display: flex; flex-wrap: wrap; align-items: center; max-width: 360px; }
.perm-form > * { margin: 4px 10px 4px 0; }
.color-presets { display: flex; margin-top: 6px; }
.color-presets > * { margin-right: 6px; }
.color-dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #d5c7bb; box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; }
.mode-edit-form { display: flex; flex-wrap: wrap; align-items: center; }
.mode-edit-form > * { margin: 6px 6px 6px 0; }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid #e8dfd6; border: 1px solid var(--border); border-radius: var(--radius-s); margin-bottom: 6px; }
.table-scroll { max-height: 68vh; overflow: auto; -webkit-overflow-scrolling: touch; border: 1px solid #e8dfd6; border: 1px solid var(--border); border-radius: var(--radius-s); margin-bottom: 6px; }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th, .table td {
  border: none; border-bottom: 1px solid #e8dfd6; border-bottom: 1px solid var(--border);
  padding: 9px 12px; text-align: left; vertical-align: middle;
}
.table th { background: #f0e9e2; background: var(--surface-3); color: #56453d; color: var(--text-2); font-weight: 600; white-space: nowrap; }
.table td { background: #fff; background: var(--surface); }
.table td.num, .table th.num {
  text-align: right; font-variant-numeric: tabular-nums; font-feature-settings: "tnum";
}
/* 粘性表头：渐进增强；不支持时随页面滚动（同旧行为），安全降级 */
.table-scroll th, .table-wrap th { position: -webkit-sticky; position: sticky; top: 0; z-index: 5; box-shadow: inset 0 -1px 0 #d5c7bb; box-shadow: inset 0 -1px 0 var(--border-strong); }
.sticky-col { position: -webkit-sticky; position: sticky; left: 0; z-index: 4; }
.table-scroll .sticky-col { z-index: 6; }          /* 滚动容器内压过普通表头 */
.table-scroll thead th.sticky-col { z-index: 7; }  /* 左上角单元格最高 */
th.sticky-col { background: #f0e9e2; background: var(--surface-3); }
td.sticky-col { background: #fff; background: var(--surface); }
tbody tr:nth-child(even) td { background: #faf6f1; background: var(--surface-2); }
tbody tr:nth-child(even) td.sticky-col { background: #faf6f1; background: var(--surface-2); }
tbody tr:hover td { background: #f0e9e2; background: var(--surface-3); }
.table-dense { text-align: left; }
.table-dense th, .table-dense td { padding: 7px 10px; }
.row-danger td { background: #fbeae9 !important; background: var(--danger-bg) !important; color: #b3261e; color: var(--danger); }
.row-warn td { background: #fdf4dd !important; background: var(--warn-bg) !important; }
.row-total td { background: #f0e9e2 !important; background: var(--surface-3) !important; font-weight: 700; border-top: 2px solid #d5c7bb; }
.empty { color: #75635a; color: var(--muted); text-align: center; padding: 24px !important; }
details.stock-fold > summary { cursor: pointer; font-weight: 600; color: #56453d; color: var(--text-2); padding: 6px 0; }

/* ---------------- 徽章 / Tag ---------------- */
.tag { display: inline-block; padding: 1px 10px; line-height: 18px; min-height: 22px;
       border-radius: 999px; font-size: 12px; font-weight: 600;
       border: 1px solid transparent; vertical-align: middle; }
.tag-in     { background: #e6f5ec; background: var(--ok-bg); color: #0e7a4b; color: var(--ok); }
.tag-out    { background: #fbeae9; background: var(--danger-bg); color: #b3261e; color: var(--danger); }
.tag-ok     { background: #e6f5ec; background: var(--ok-bg); color: #0e7a4b; color: var(--ok); }
.tag-warn   { background: #fdf4dd; background: var(--warn-bg); color: #8a6400; color: var(--warn); }
.tag-danger { background: #fbeae9; background: var(--danger-bg); color: #b3261e; color: var(--danger); }
.tag-info   { background: #e9f1fb; background: var(--info-bg); color: #1e5aa8; color: var(--info); }
.tag-plain  { background: #f0e9e2; background: var(--surface-3); color: #56453d; color: var(--text-2); }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-block; padding: 9px 18px; min-height: 38px;
  border: 1px solid #d5c7bb; border: 1px solid var(--border-strong); border-radius: var(--radius-s);
  background: #fff; background: var(--surface); color: #291b16; color: var(--text);
  font: inherit; font-size: 14px; cursor: pointer; text-align: center; vertical-align: middle;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { background: #faf6f1; background: var(--surface-2); border-color: #bfae9f; text-decoration: none; }
.btn:active { background: #f0e9e2; background: var(--surface-3); transform: translateY(1px); }
.btn-primary { background: #c72627; background: var(--brand); border-color: #c72627; border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: #a81f20; background: var(--brand-dark); border-color: #a81f20; border-color: var(--brand-dark); box-shadow: 0 2px 8px rgba(199,38,39,.3); }
.btn-primary:active { background: #96191a; }
.btn-danger { background: #b3261e; background: var(--danger); border-color: #b3261e; border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #9a1f18; }
.btn-danger:active { background: #851a14; }
.btn[disabled], .btn.loading { opacity: .55; cursor: not-allowed; transform: none; }
.btn-sm { padding: 5px 12px; min-height: 32px; font-size: 13px; }
.btn-block { display: block; width: 100%; margin-top: 14px; }
.linklike { background: none; border: none; color: #c72627; color: var(--brand); cursor: pointer; font-size: 13.5px; padding: 4px 6px; min-height: 32px; }
.linklike:hover { text-decoration: underline; }
.linklike.danger { color: #b3261e; color: var(--danger); }

/* ---------------- Flash 提示 ---------------- */
.flashes { margin-bottom: 12px; }
.flash { display: flex; align-items: center; padding: 10px 14px;
         border-radius: var(--radius-s); border: 1px solid transparent;
         margin-bottom: 10px; font-size: 13.5px; animation: flash-in .3s ease; }
.flash-text { flex: 1; }
.flash-success { background: #e6f5ec; background: var(--ok-bg); color: #0e7a4b; color: var(--ok); border-color: #bfe0cd; }
.flash-error   { background: #fbeae9; background: var(--danger-bg); color: #b3261e; color: var(--danger); border-color: #f0c4c1; }
.flash-warning { background: #fdf4dd; background: var(--warn-bg); color: #8a6400; color: var(--warn); border-color: #ecdcb4; }
.flash-info    { background: #e9f1fb; background: var(--info-bg); color: #1e5aa8; color: var(--info); border-color: #c5d9f2; }
.flash-close { margin-left: 12px; border: none; background: none; cursor: pointer;
               font-size: 18px; line-height: 1; color: inherit; opacity: .55; padding: 2px 6px; }
.flash-close:hover { opacity: 1; }
@keyframes flash-in { from { opacity: 0; transform: translateY(-4px); } }

/* ---------------- 其他组件 ---------------- */
.status-strip { display: flex; flex-wrap: wrap; margin-bottom: 16px; }
.status-strip > * { margin: 0 8px 8px 0; }
.status-chip { background: #fff; background: var(--surface); border: 1px solid #e8dfd6; border: 1px solid var(--border); border-radius: 999px; padding: 5px 14px; font-size: 13px; color: #75635a; color: var(--muted); box-shadow: var(--shadow-1); }
.status-chip.chip-on { background: #e6f5ec; background: var(--ok-bg); border-color: #bfe0cd; color: #0e7a4b; color: var(--ok); font-weight: 600; }
.steps { display: flex; align-items: center; flex-wrap: wrap; margin: 4px 0 18px; }
.steps > * { margin-right: 10px; }
.step-item { display: flex; align-items: center; font-size: 13px; color: #75635a; color: var(--muted); }
.step-item > * { margin-right: 7px; }
.step-item.on { color: #300000; color: var(--ink); font-weight: 700; }
.step-num { width: 22px; height: 22px; border-radius: 50%; background: #f0e9e2; background: var(--surface-3); color: #75635a; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }
.step-item.on .step-num { background: #300000; background: var(--ink); color: #fff; }
.step-line { flex: 1; min-width: 24px; height: 2px; background: #d5c7bb; background: var(--border-strong); border-radius: 1px; }
.method-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
                grid-column-gap: 10px; grid-row-gap: 10px; column-gap: 10px; row-gap: 10px; }
.method-card { display: block; border: 1.5px solid #e8dfd6; border: 1.5px solid var(--border); border-radius: var(--radius); padding: 13px 15px; cursor: pointer; transition: border-color .18s, box-shadow .18s; background: #fff; background: var(--surface); }
.method-card:hover { border-color: #e3b5b2; box-shadow: var(--shadow-1); }
.method-card.sel { border-color: #ea3637; border-color: var(--accent); background: #fdebea; background: var(--accent-soft); box-shadow: 0 3px 12px rgba(234,54,55,.16); }
.method-card b { display: block; font-size: 14px; color: #291b16; color: var(--text); margin-bottom: 4px; }
.method-card .rec { display: inline-block; background: #e6f5ec; background: var(--ok-bg); color: #0e7a4b; color: var(--ok); font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 8px; margin-left: 4px; vertical-align: 1px; }
.method-card span { font-size: 12.5px; color: #75635a; color: var(--muted); line-height: 1.5; }
.mini-card { background: #faf6f1; background: var(--surface-2); border: 1px solid #e8dfd6; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.mini-card h4 { margin: 0 0 10px; font-size: 14px; color: #300000; color: var(--ink); }
.ops-bar { display: flex; align-items: flex-end; flex-wrap: wrap; }
.ops-bar > * { margin: 4px 10px 4px 0; }
.inline-action { display: flex; align-items: center; flex-wrap: wrap; padding: 10px 12px; margin: 0; }
.inline-action > * { margin-right: 8px; }
.set-hint, .need { font-style: normal; font-size: 11px; color: #0e7a4b; color: var(--ok); background: #e6f5ec; background: var(--ok-bg); border-radius: 999px; padding: 1px 8px; margin-left: 4px; }
.need { color: #8a6400; color: var(--warn); background: #fdf4dd; background: var(--warn-bg); }
.log-view { background: #1e0a0a; color: #e6d5cc; border-radius: var(--radius); padding: 14px; font-size: 12px; line-height: 1.7; overflow-x: auto; width: 100%; max-height: 340px; font-family: Consolas, "Courier New", monospace; font-family: var(--mono); }
hr { border: none; border-top: 1px solid #e8dfd6; border-top: 1px solid var(--border); margin: 18px 0; }
.float-right { float: right; }
.ops { display: flex; align-items: center; }
.ops > * { margin-right: 8px; }
.ops:last-child > *:last-child { margin-right: 0; }
.pager { display: flex; align-items: center; justify-content: center; margin-top: 14px; }
.pager > * { margin: 0 6px; }
.small-input { width: 110px; padding: 4px 8px; min-height: 32px; display: inline-block; }
.lbl { font-size: 12px; color: #75635a; color: var(--muted); }
.emoji { font-size: 22px; line-height: 1; }
.icon-preview { display: flex; align-items: center; background: #faf6f1; background: var(--surface-2); border: 1px solid #e8dfd6; border: 1px solid var(--border); color: #291b16; color: var(--text); border-radius: var(--radius-s); padding: 8px 12px; margin-top: 4px; min-height: 40px; }
.icon-preview > * { margin-right: 10px; }

/* ---------------- 登录页 ---------------- */
.login-body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% -8%, rgba(234,54,55,.28), rgba(234,54,55,0) 42%),
    radial-gradient(circle at 105% 108%, rgba(180,83,9,.25), rgba(180,83,9,0) 45%),
    linear-gradient(135deg,#200505,#300000 55%,#4d0d0d);
}
.login-main { min-height: 100vh; display: flex; align-items: center; justify-content: center; flex-direction: column; padding: 24px 0; }
.login-card {
  width: 92%; max-width: 380px; padding: 34px 30px;
  background: #fff; background: var(--surface);
  border-radius: 16px; box-shadow: 0 18px 48px rgba(0,0,0,.42);
}
.login-card h1 { justify-content: center; font-size: 21px; color: #291b16; color: var(--text); margin-top: 14px; }
/* 品牌logo为横版组合标(约4.5:1)：按宽度缩放、高度自适应，绝不能用正方形框约束 */
.login-brand { display: block; width: 86%; max-width: 300px; height: auto; margin: 0 auto; }
.login-logo-sm { height: 26px; vertical-align: -5px; margin-right: 8px; }
.login-card .sub { text-align: center; margin: 6px 0 18px; letter-spacing: .08em; }
.login-card input { width: 100%; }
.login-foot { width: 92%; max-width: 380px; margin: 14px auto 0; text-align: center; font-size: 12px; color: #bfae9f; opacity: .85; }

/* ---------------- 移动端 ---------------- */
@media (max-width: 767px) {
  input, select, textarea { font-size: 16px; }   /* 防 iOS 聚焦自动放大 */
}
@media (max-width: 720px) {
  .container { padding: 0 12px; margin-top: 14px; }
  h1 { font-size: 19px; margin: 4px 0 14px; }
  h2 { font-size: 15px; }
  .topbar { padding: 8px 12px; }
  .brand { margin-right: 0; width: 100%; }
  .nav {
    display: flex; flex-wrap: nowrap; overflow-x: auto;
    -webkit-overflow-scrolling: touch; width: 100%;
    scrollbar-width: none; margin-top: 4px;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { flex: 0 0 auto; padding: 8px 12px; margin-left: 0; margin-right: 2px; }
  .nav a:first-child { margin-left: 0; }
  .top-right { margin-left: 0; width: 100%; margin-top: 4px; }
  .userbox > * { margin-left: 0; margin-right: 12px; }
  .userbox > *:last-child { margin-right: 0; }
  .mode-bar { padding: 5px 12px; }
  .card { padding: 14px; border-radius: 10px; margin-bottom: 14px; }
  .entry-grid { grid-template-columns: 1fr; }
  .entry-grid .wide { grid-column: span 1; }
  .form-actions .btn { flex: 1 1 100%; text-align: center; }
  .filter-bar select, .filter-bar input { width: 100%; min-width: 0; }
  .stat-cards { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .stat .num { font-size: 24px; }
  .prod-flow .prod-node { margin: 0 8px 8px 0; }
  .weight-row { flex-wrap: wrap; }
  .w-row-input { width: 100%; }
  .doc-row select { width: 100%; flex: 1 1 100%; margin-right: 0; }
  .method-cards { grid-template-columns: 1fr 1fr; }
  .table th, .table td { padding: 7px 9px; font-size: 13px; }
}
@media (max-width: 480px) {
  body { font-size: 13.5px; }
  .table th, .table td { font-size: 12px; padding: 6px 7px; }
  .section-title { font-size: 13px; }
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .cat-dash-grid { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .method-cards { grid-template-columns: 1fr; }
}

/* ---------------- 打印 ---------------- */
@media print {
  .topbar, .mode-bar, .nav, .filter-bar, .form-actions, .cat-tabs, .settings-nav,
  .pager, .btn, .linklike, .flash, .flashes, .steps, .status-strip { display: none !important; }
  body { background: #fff; color: #000; font-size: 12px; }
  .card, .table-wrap, .table-scroll { border: 1px solid #999; box-shadow: none; max-height: none; overflow: visible; }
  .table th, .table td { border-bottom: 1px solid #999; }
}

/* =========================================================
   老浏览器兜底一：无 flex/grid gap 的布局（html.no-flexgap）
   由 app.js 以"真实布局测量"探测后挂类，覆盖 Chrome<84、
   Chrome 57-83（认识 gap 但不用于 flex 的探测盲区）、iOS≤14 等
   ========================================================= */
.no-flexgap .topbar > * { margin: 4px 8px 4px 0; }
.no-flexgap .nav a { margin: 2px; }
.no-flexgap .userbox > * { margin-left: 8px; }
.no-flexgap .mode-bar .inline { margin-right: 8px; }
.no-flexgap .prod-flow > * { margin: 0 12px 0 0; }
.no-flexgap .weight-row > * { margin-right: 10px; }
.no-flexgap .doc-row > * { margin-right: 10px; }
.no-flexgap .perm-form > * { margin: 4px 10px 4px 0; }
.no-flexgap .field-cfg-form > * { margin: 6px 18px 6px 0; }
.no-flexgap .mode-edit-form > * { margin: 6px 6px 6px 0; }
.no-flexgap .color-presets > * { margin-right: 6px; }
.no-flexgap .inline-action > * { margin-right: 8px; }
.no-flexgap .unit-set > * { margin-right: 6px; }
.no-flexgap .chk { margin-right: 10px; }
.no-flexgap .settings-nav a { margin: 2px 4px 2px 0; }
.no-flexgap .cat-tabs a { margin: 2px 4px 2px 0; }
.no-flexgap .stat-cards > * { margin: 7px; }
.no-flexgap .two-col > * { margin-bottom: 12px; }
.no-flexgap .alert-grid > * { margin: 7px; }
.no-flexgap .cat-dash-grid > * { margin-bottom: 12px; }
.no-flexgap .method-cards > * { margin: 5px; }
.no-flexgap .entry-grid > * { margin-bottom: 10px; }
.no-flexgap .item-add-grid > * { margin-bottom: 10px; }
.no-flexgap .chk-row > * { margin: 2px 12px 2px 0; }
.no-flexgap .cat-nums > * { margin-right: 10px; }

/* =========================================================
   老浏览器兜底二：不支持 CSS 变量（IE 全系 / Chrome<49）
   —— 核心颜色的字面量完整回退，色相一致但不再动态换肤
   ========================================================= */
@supports not (color: var(--text)) {
  body { color: #291b16; background: #f5f1ec; }
  a { color: #c72627; }
  h2, .mini-card h4 { color: #291b16; }
  .sub, .hint, .lbl { color: #75635a; }
  .card, .mini-card, .method-card { background: #fff; border-color: #e8dfd6; }
  .topbar { background: linear-gradient(180deg, #300000, #1f0606); border-bottom: 3px solid #c72627; }
  .nav a { color: #fff; }
  .nav a.active { background: #fff; color: #300000; }
  .userbox { color: #efe2da; }
  .userbox a { color: #fff; }
  .mode-badge { background: #300000; color: #fff; }
  .mode-bar { background: #24100f; color: #f0e6df; }
  .mode-btn { color: #f0e6df; }
  .mode-btn.active { background: #fff; color: #291b16; }
  .btn { border-color: #d5c7bb; background: #fff; color: #291b16; }
  .btn-primary { background: #c72627; border-color: #c72627; color: #fff; }
  .btn-danger { background: #b3261e; border-color: #b3261e; color: #fff; }
  .linklike { color: #c72627; }
  input, select, textarea { border-color: #d5c7bb; background: #fff; color: #291b16; }
  input[readonly] { background: #faf6f1; color: #56453d; }
  label { color: #56453d; }
  .table th { background: #f0e9e2; color: #56453d; }
  .table td { background: #fff; }
  .table tbody tr:nth-child(even) td { background: #faf6f1; }
  .tag-in, .tag-ok { background: #e6f5ec; color: #0e7a4b; }
  .tag-out, .tag-danger { background: #fbeae9; color: #b3261e; }
  .tag-warn { background: #fdf4dd; color: #8a6400; }
  .tag-info { background: #e9f1fb; color: #1e5aa8; }
  .tag-plain { background: #f0e9e2; color: #56453d; }
  .flash-success { background: #e6f5ec; color: #0e7a4b; }
  .flash-error { background: #fbeae9; color: #b3261e; }
  .flash-warning { background: #fdf4dd; color: #8a6400; }
  .flash-info { background: #e9f1fb; color: #1e5aa8; }
  .stat .num, .prod-node .num { color: #300000; }
  .stat-finish .num { color: #8a6400; }
  .stat-key .num { color: #b3261e; }
  .weight-box { background: #fdf4dd; }
  .batch-zone { background: #e9f1fb; }
  .upload-zone { background: #faf6f1; }
  .batch-info { background: #e6f5ec; }
  .settings-nav a { color: #56453d; }
  .settings-nav a.active { background: #300000; color: #fff; }
  .cat-tabs a { background: #fff; border-color: #d5c7bb; color: #56453d; }
  .cat-tabs a.active { background: #300000; color: #fff; }
  .status-chip { background: #fff; border-color: #e8dfd6; color: #75635a; }
  .log-view { background: #1e0a0a; color: #e6d5cc; }
}
