/* ===== 彩盒报价器 — Teal 青绿配色体系 ===== */
/* 基于 UI/UX Pro Max 设计系统：主色 #0D9488 / 强调 #EA580C / 背景 #F0FDFA */

/* ===== 全局 ===== */
*{margin:0;padding:0;box-sizing:border-box}
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');
:root{
  --brand:#0D9488; --brand-2:#14B8A6; --brand-deep:#0F766E; --brand-ink:#134E4A;
  --accent:#EA580C; --accent-2:#F97316;
  --bg-1:#F0FDFA; --bg-2:#E8F5F3; --bg-3:#F5FFFE;
  --border:#E0F2EF; --border-2:#CCEBE7; --border-soft:#ECF8F5;
  --ink:#134E4A; --ink-2:#0F2A28; --muted:#5B8A87; --muted-2:#7A9C99; --muted-3:#99B5B2;
  --card-bg:rgba(255,255,255,.78); --card-bg-solid:#fff;
  --shadow-sm:0 1px 2px rgba(13,148,136,.04),0 1px 3px rgba(0,0,0,.03);
  --shadow-md:0 4px 16px rgba(13,148,136,.08),0 2px 6px rgba(0,0,0,.04);
  --shadow-lg:0 12px 32px rgba(13,148,136,.12),0 4px 12px rgba(0,0,0,.05);
  --shadow-glow:0 8px 24px rgba(13,148,136,.18);
  --shadow-accent:0 6px 20px rgba(234,88,12,.28);
  --radius-sm:8px; --radius:12px; --radius-lg:16px; --radius-xl:20px;
}
body{font-family:'Plus Jakarta Sans','PingFang SC','Microsoft YaHei',sans-serif;
  background:
    radial-gradient(1200px 600px at 10% -10%,rgba(20,184,166,.18),transparent 60%),
    radial-gradient(900px 500px at 100% 0%,rgba(234,88,12,.10),transparent 55%),
    radial-gradient(700px 700px at 50% 110%,rgba(13,148,136,.10),transparent 60%),
    linear-gradient(180deg,#F0FDFA 0%,#E8F5F3 100%);
  background-attachment:fixed;
  min-height:100vh;padding:24px 20px 40px;color:var(--ink);position:relative;
}
body::before{content:'';position:fixed;inset:0;pointer-events:none;z-index:0;opacity:.4;
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.05 0 0 0 0 0.45 0 0 0 0 0.4 0 0 0 .04 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>")}
.container{max-width:880px;margin:0 auto;position:relative;z-index:1}

/* 暗色模式全局色彩平滑过渡（仅过渡颜色，不动布局/动画） */
body,body *{transition:background-color .3s ease,color .3s ease,border-color .3s ease,box-shadow .3s ease}

/* ===== 悬浮按钮组（置顶/置底/清空） ===== */
.fab-group{position:fixed;right:20px;bottom:22px;display:flex;flex-direction:column;gap:10px;z-index:9999}
.fab-btn{width:42px;height:42px;border-radius:50%;border:none;background:linear-gradient(135deg,#EA580C,#F97316);color:#fff;font-size:1.15rem;line-height:1;display:flex;align-items:center;justify-content:center;cursor:pointer;box-shadow:0 6px 18px rgba(234,88,12,.38),0 2px 6px rgba(0,0,0,.08);transition:transform .18s cubic-bezier(.34,1.56,.64,1),box-shadow .18s,background .15s;font-family:inherit;user-select:none;animation:fabFloat 3.6s ease-in-out infinite}
.fab-btn:nth-child(2){animation-delay:.4s}
.fab-btn:nth-child(3){animation-delay:.8s}
.fab-btn:hover{background:linear-gradient(135deg,#D4520A,#EA580C);transform:scale(1.1) translateY(-2px);box-shadow:0 10px 26px rgba(234,88,12,.48),0 4px 10px rgba(0,0,0,.12)}
.fab-btn:active{transform:scale(.94)}
.fab-btn.fab-reset{background:linear-gradient(135deg,#0D9488,#14B8A6);box-shadow:0 6px 18px rgba(13,148,136,.38),0 2px 6px rgba(0,0,0,.08)}
.fab-btn.fab-reset:hover{background:linear-gradient(135deg,#0F766E,#0D9488);box-shadow:0 10px 26px rgba(13,148,136,.48),0 4px 10px rgba(0,0,0,.12)}
@keyframes fabFloat{0%,100%{transform:translateY(0)}50%{transform:translateY(-4px)}}

/* ===== 卡片 ===== */
.card{background:var(--card-bg);backdrop-filter:blur(12px) saturate(140%);-webkit-backdrop-filter:blur(12px) saturate(140%);border-radius:var(--radius);padding:22px;margin-bottom:14px;
  box-shadow:var(--shadow-md);border:1px solid rgba(224,242,239,.85);
  transition:transform .25s cubic-bezier(.34,1.56,.64,1),box-shadow .25s,background-color .3s ease,color .3s ease,border-color .3s ease;
  position:relative;animation:cardFadeIn .5s cubic-bezier(.22,.61,.36,1) both}
.card:nth-child(1){animation-delay:.02s}
.card:nth-child(2){animation-delay:.06s}
.card:nth-child(3){animation-delay:.10s}
.card:nth-child(4){animation-delay:.14s}
.card:nth-child(5){animation-delay:.18s}
.card:nth-child(6){animation-delay:.22s}
.card:nth-child(7){animation-delay:.26s}
.card:nth-child(8){animation-delay:.30s}
.card:nth-child(9){animation-delay:.34s}
.card:nth-child(10){animation-delay:.38s}
.card:hover{transform:translateY(-2px);box-shadow:var(--shadow-lg);border-color:rgba(13,148,136,.25)}
.card h2{font-size:1rem;color:var(--brand-deep);margin-bottom:14px;padding-bottom:10px;border-bottom:1px solid var(--border);font-weight:700;letter-spacing:.2px;display:flex;align-items:center;gap:6px}
.card h2::before{content:'';display:inline-block;width:3px;height:14px;background:linear-gradient(180deg,var(--brand),var(--brand-2));border-radius:2px;flex:0 0 auto}
.card h2[style*="display:flex"]::before{margin-right:2px}
.row{display:flex;flex-wrap:wrap;gap:10px}
/* .row 的 gap 只管行内/换行，两个相邻 .row 之间没有竖距 —— 这里统一兜住，防止新加行贴死上一行 */
.card .row + .row{margin-top:10px}
/* 隐藏行（如数码模式专用行）用 .row-alt：样式同 .row，但不触发上面的相邻间距（隐藏行不该撑出一格空） */
.row-alt{display:flex;flex-wrap:wrap;gap:10px}
.field{flex:1;min-width:100px}
.field label{display:block;font-size:0.78rem;color:var(--muted);margin-bottom:4px;font-weight:500;letter-spacing:.1px;line-height:1.05rem;min-height:1.05rem}
.req::after{content:' *';color:var(--accent);font-weight:700}
.req-x2{color:#e74c3c;font-weight:700}
.req-x2::after{content:' *';color:#e74c3c;font-weight:700}
@keyframes cardFadeIn{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:none}}

/* ===== 输入框 / 下拉框 ===== */
.field input,.field select{width:100%;padding:11px 12px;border:1.5px solid var(--border-2);border-radius:var(--radius-sm);font-size:0.9rem;text-align:center;background:rgba(255,255,255,.7);color:var(--ink);transition:border-color .18s,box-shadow .18s,background .18s;font-family:inherit}
.field input:hover,.field select:hover{border-color:rgba(13,148,136,.45);background:rgba(255,255,255,.9)}
.field input:focus,.field select:focus{outline:none;border-color:var(--brand);box-shadow:0 0 0 4px rgba(13,148,136,.14),0 2px 8px rgba(13,148,136,.1);background:#fff}
.field input[readonly]{background:linear-gradient(135deg,rgba(240,253,250,.85),rgba(230,247,245,.85));color:var(--brand);cursor:default;border-style:dashed}
/* 预估总体积只写在「其他」卡标题副标题里，主页不设只读输入框（2026-11-09 第三轮） */
.field input::placeholder{color:#B0C8C5}
/* 下拉框统一青绿箭头 */
.field select,.toolbar-input,.unit-select,.set-input,.panel select{appearance:none;-webkit-appearance:none;-moz-appearance:none;background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%230D9488' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");background-repeat:no-repeat;background-position:right 10px center;padding-right:28px}
/* 主表单数字框隐藏原生上下箭头（不影响 stepper 内的数字框） */
.field input[type=number]::-webkit-inner-spin-button,.field input[type=number]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}
.field input[type=number]{-moz-appearance:textfield}
/* 「其他成本/优惠」单位下拉框：Teal 语义色（去掉原蓝色） */
.unit-select{flex:0 0 auto;width:auto;min-width:76px;padding:10px 26px 10px 12px!important;text-align:center;font-weight:600;font-size:0.78rem;border-radius:8px;cursor:pointer;box-sizing:border-box;appearance:none;-webkit-appearance:none;-moz-appearance:none;background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%230D9488' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");background-repeat:no-repeat;background-position:right 10px center}
/* 必须在 .field select 的 width:100% 之下覆盖回 auto（.field select 优先级更高） */
.field select.unit-select{width:auto}
/* 外加工-运费：运费格内「输入框 / 单位下拉」两等分。
   用 grid 1fr 1fr 按边框盒均分（flex 会按内容宽分配，两者 padding 不同就等不了宽）；
   input 补 border-box，否则 content-box 下与 select 的 padding 叠加后仍不等宽 */
#freightPair{display:grid;grid-template-columns:1fr 1fr;gap:4px;align-items:stretch}
#outsourceFreight,#outsourceFreightUnit{min-width:0;width:auto;box-sizing:border-box}
.unit-select.unit-green{border:1.5px solid #0D9488;background-color:#F0FDFA;color:#0D9488}
.unit-select.unit-orange{border:1.5px solid #EA580C;background-color:#FFF7ED;color:#EA580C}
.unit-input{height:auto!important;padding:10px;box-sizing:border-box}
/* 其他成本/优惠 的 input+select 并排容器：等高对齐 */
.field > div[style*="display:flex"]{align-items:stretch}
/* 并排容器内的 input：用 flex 填充剩余空间（覆盖通用 width:100%） */
.field > div[style*="display:flex"] > input{flex:1;min-width:0;width:auto}
/* 搜索/筛选排统一输入框 */
.toolbar-input{flex:0 0 auto;padding:10px 14px;border:1.5px solid #CCEBE7;border-radius:8px;font-size:0.85rem;background:#FBFEFD;color:#134E4A;font-family:inherit;transition:border-color .15s,box-shadow .15s,background .15s;box-sizing:border-box}
.toolbar-input:focus{outline:none;border-color:#0D9488;box-shadow:0 0 0 3px rgba(13,148,136,.12);background:#fff}
#searchInput.toolbar-input{flex:1}
/* 必填项即时反馈 */
.field input.input-ok{border-color:#0D9488;box-shadow:0 0 0 2px rgba(13,148,136,.14);background:#FBFEFD}
.field input.input-warn{border-color:#DC2626;box-shadow:0 0 0 2px rgba(220,38,38,.12);background:#FFF6F6}

/* ===== 吸底操作栏 ===== */
.sticky-actions{position:sticky;bottom:0;z-index:50;background:linear-gradient(0deg,rgba(240,253,250,.96) 75%,rgba(240,253,250,0) 100%);backdrop-filter:blur(12px) saturate(140%);-webkit-backdrop-filter:blur(12px) saturate(140%);padding:14px 0 18px;margin:-12px 0 0}
.sticky-actions .btn{margin-top:0}

/* ===== 表面处理标签 ===== */
.surface-grid{display:flex;flex-wrap:wrap;gap:8px}
.surface-grid label{display:inline-flex;align-items:center;gap:4px;padding:8px 15px;border:1.5px solid var(--border-2);border-radius:20px;font-size:0.82rem;cursor:pointer;background:rgba(255,255,255,.6);color:var(--muted);transition:all .2s cubic-bezier(.34,1.56,.64,1);user-select:none}
.surface-grid input{display:none}
.surface-grid label:hover{border-color:rgba(13,148,136,.45);transform:translateY(-1px);box-shadow:0 3px 10px rgba(13,148,136,.12)}
.surface-grid label:has(input:checked){background:linear-gradient(135deg,rgba(13,148,136,.12),rgba(20,184,166,.12));border-color:var(--brand);color:var(--brand);font-weight:600;box-shadow:0 3px 12px rgba(13,148,136,.18)}

/* ===== 工序/特殊设置 开关 ===== */
.toggle-card{padding:16px 18px}
.toggle-head{font-size:0.92rem;font-weight:700;color:var(--brand-deep);margin-bottom:12px;display:flex;align-items:center;gap:6px;letter-spacing:.3px}
.toggle-head::before{content:'';display:inline-block;width:3px;height:14px;background:linear-gradient(180deg,var(--brand),var(--brand-2));border-radius:2px;flex:0 0 auto}
/* 工序开关：药丸芯片 */
.switch-grid{display:flex;flex-wrap:wrap;gap:8px}
.switch-chip{display:inline-flex;align-items:center;justify-content:center;gap:5px;padding:9px 17px;border:1.5px solid var(--border-2);border-radius:20px;font-size:0.82rem;cursor:pointer;background:rgba(255,255,255,.6);color:var(--muted);transition:all .2s cubic-bezier(.34,1.56,.64,1);user-select:none;min-width:62px}
.switch-chip input{display:none}
.switch-chip:hover{border-color:rgba(13,148,136,.45);transform:translateY(-1px)}
.switch-chip:has(input:checked){background:linear-gradient(135deg,#0D9488,#14B8A6);border-color:#0D9488;color:#fff;font-weight:600;box-shadow:0 4px 12px rgba(13,148,136,.32)}
.switch-chip:active{transform:scale(.97)}
/* 特殊设置：滑动开关 */
.toggle-list{display:flex;flex-wrap:wrap;gap:10px 22px;align-items:center}
.toggle-row{display:inline-flex;align-items:center;gap:8px;cursor:pointer;user-select:none;font-size:0.85rem;color:var(--ink);padding:6px 10px;border-radius:8px;transition:background .15s}
.toggle-row:hover{background:rgba(13,148,136,.05)}
.toggle-text{line-height:1;white-space:nowrap}
.toggle{position:relative;display:inline-block;width:42px;height:24px;flex:0 0 auto}
.toggle input{position:absolute;opacity:0;width:100%;height:100%;margin:0;cursor:pointer;z-index:1}
.toggle-track{position:absolute;inset:0;background:#CBD5E1;border-radius:24px;transition:background .25s cubic-bezier(.34,1.56,.64,1);pointer-events:none}
.toggle-track::after{content:'';position:absolute;width:18px;height:18px;left:3px;top:3px;background:#fff;border-radius:50%;transition:transform .25s cubic-bezier(.34,1.56,.64,1);box-shadow:0 2px 4px rgba(0,0,0,.2)}
.toggle input:checked + .toggle-track{background:linear-gradient(135deg,#0D9488,#14B8A6)}
.toggle input:checked + .toggle-track::after{transform:translateX(18px);box-shadow:0 2px 6px rgba(0,0,0,.25)}
.toggle-row.t-green .toggle input:checked + .toggle-track{background:linear-gradient(135deg,#0D9488,#14B8A6)}
.toggle-row.t-purple .toggle input:checked + .toggle-track{background:linear-gradient(135deg,#8E44AD,#A855F7)}
.toggle-row.t-red .toggle input:checked + .toggle-track{background:linear-gradient(135deg,#DC2626,#EF4444)}
.toggle-row.t-orange .toggle input:checked + .toggle-track{background:linear-gradient(135deg,#EA580C,#F97316)}
/* 表格内复选框（全选/历史行）：青绿圆角勾选框 */
.cb-check{appearance:none;-webkit-appearance:none;width:18px;height:18px;border:2px solid var(--border-2);border-radius:5px;background:rgba(255,255,255,.7);cursor:pointer;position:relative;transition:background .18s,border-color .18s,transform .12s;vertical-align:middle;flex:0 0 auto}
.cb-check:hover{border-color:var(--brand);transform:scale(1.08)}
.cb-check:checked{background:linear-gradient(135deg,#0D9488,#14B8A6);border-color:#0D9488}
.cb-check:checked::after{content:'';position:absolute;left:5px;top:1px;width:5px;height:10px;border:solid #fff;border-width:0 2px 2px 0;transform:rotate(45deg)}

/* ===== 按钮体系 ===== */
.btn{display:block;width:100%;padding:15px;border:none;border-radius:var(--radius);background:linear-gradient(135deg,#0D9488 0%,#14B8A6 50%,#0D9488 100%);background-size:200% 100%;color:#fff;font-size:1.1rem;font-weight:700;cursor:pointer;margin-top:8px;transition:transform .12s cubic-bezier(.34,1.56,.64,1),box-shadow .2s,background-position .4s;font-family:inherit;letter-spacing:.5px;box-shadow:0 6px 20px rgba(13,148,136,.32),0 2px 6px rgba(0,0,0,.06);position:relative;overflow:hidden}
.btn::before{content:'';position:absolute;inset:0;background:linear-gradient(120deg,transparent 30%,rgba(255,255,255,.25) 50%,transparent 70%);transform:translateX(-100%);transition:transform .6s}
.btn:hover{background-position:100% 0;box-shadow:0 10px 28px rgba(13,148,136,.42),0 4px 10px rgba(0,0,0,.08)}
.btn:hover::before{transform:translateX(100%)}
.btn:active{transform:scale(.96)}
.btn-copy{flex:1.4;padding:14px;border:none;border-radius:var(--radius);background:linear-gradient(135deg,#0D9488,#0F766E);color:#fff;font-size:1rem;font-weight:600;cursor:pointer;transition:transform .12s cubic-bezier(.34,1.56,.64,1),box-shadow .2s;font-family:inherit;box-shadow:0 4px 14px rgba(13,148,136,.3)}
.btn-copy:hover{box-shadow:0 8px 22px rgba(13,148,136,.42);transform:translateY(-1px)}
.btn-copy:active{transform:scale(.96)}
.btn-secondary{flex:1;padding:12px;border:1.5px solid #99F6E4;background:rgba(255,255,255,.7);color:var(--brand);border-radius:var(--radius);font-size:0.85rem;font-weight:600;cursor:pointer;transition:background .18s,border-color .18s,transform .12s;font-family:inherit;backdrop-filter:blur(6px)}
.btn-secondary:hover{background:#fff;border-color:var(--brand);transform:translateY(-1px);box-shadow:0 4px 12px rgba(13,148,136,.15)}
.btn-secondary:active{transform:scale(.97)}
.btn-secondary.blue{border-color:#99F6E4;color:var(--brand)}
.btn-secondary.blue:hover{background:#F0FDFA}
.btn-secondary.gray{border-color:#D8E8E6;color:#7A9C99}
.btn-secondary.gray:hover{background:#F5FAF9}

/* ===== 页签切换 ===== */
.mode-tabs{display:flex;gap:6px;margin-bottom:18px;padding:6px;border-radius:var(--radius);background:rgba(255,255,255,.65);backdrop-filter:blur(12px) saturate(140%);-webkit-backdrop-filter:blur(12px) saturate(140%);box-shadow:var(--shadow-md),inset 0 1px 0 rgba(255,255,255,.6);border:1px solid rgba(224,242,239,.7)}
.mode-tab{flex:1;padding:11px 14px;text-align:center;font-size:0.92rem;font-weight:600;cursor:pointer;border:none;border-radius:8px;background:transparent;color:var(--muted);transition:all .25s cubic-bezier(.34,1.56,.64,1);text-decoration:none;display:block;font-family:inherit;position:relative}
.mode-tab:hover{color:var(--brand-deep);background:rgba(13,148,136,.06)}
.mode-tab.active{background:linear-gradient(135deg,#0D9488,#14B8A6);color:#fff;box-shadow:0 4px 14px rgba(13,148,136,.35),inset 0 1px 0 rgba(255,255,255,.2)}

/* ===== 步进器 ===== */
.stepper{display:flex;align-items:stretch;height:44px;border:1.5px solid var(--border-2);border-radius:var(--radius-sm);overflow:hidden;background:rgba(255,255,255,.7);backdrop-filter:blur(6px)}
.stepper button{flex:0 0 auto;padding:0 14px;border:none;background:transparent;cursor:pointer;font-size:1.35rem;line-height:1;color:var(--muted);display:flex;align-items:center;justify-content:center;transition:background .15s,transform .12s,color .15s;font-family:inherit;user-select:none}
.stepper button:hover{background:linear-gradient(135deg,#0D9488,#14B8A6);color:#fff}
.stepper button:active{transform:scale(.88)}
.stepper input{flex:1;min-width:0;text-align:center;border:none;font-size:0.9rem;font-family:inherit;color:var(--ink);background:transparent}
.stepper input:focus{outline:none;box-shadow:inset 0 0 0 2px rgba(13,148,136,.18)}

/* ===== 结果区 ===== */
.result-card{padding:0;overflow:hidden;border:1px solid rgba(153,246,228,.7);border-radius:var(--radius-lg);box-shadow:var(--shadow-lg);animation:cardIn .45s cubic-bezier(.22,.61,.36,1)}
#actionBtns{animation:cardIn .35s ease-out}
.result-header{background:linear-gradient(135deg,#0D9488 0%,#14B8A6 50%,#0F766E 100%);background-size:200% 100%;color:#fff;padding:28px 20px 24px;text-align:center;position:relative;overflow:hidden}
.result-header::before{content:'';position:absolute;inset:0;background:radial-gradient(circle at 30% 20%,rgba(255,255,255,.18),transparent 50%),radial-gradient(circle at 80% 80%,rgba(255,255,255,.1),transparent 45%);pointer-events:none}
.result-header::after{content:'';position:absolute;top:-50%;right:-20%;width:60%;height:200%;background:linear-gradient(45deg,transparent,rgba(255,255,255,.08),transparent);transform:rotate(15deg);pointer-events:none}
.result-header .rh-label{font-size:0.85rem;opacity:.9;letter-spacing:1.5px;font-weight:500;text-transform:uppercase;position:relative}
.result-header .rh-total{font-size:3rem;font-weight:800;margin:8px 0 4px;font-family:'Plus Jakarta Sans',monospace;letter-spacing:-1.5px;text-shadow:0 2px 12px rgba(0,0,0,.15);position:relative;background:linear-gradient(180deg,#fff,rgba(255,255,255,.92));-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent}
.result-header .rh-sub{font-size:0.82rem;opacity:.88;position:relative;font-weight:500}
.result-header .rh-tax{font-size:0.72rem;opacity:.7;margin-top:4px;position:relative}

/* ===== 成本链 ===== */
.cost-chain{display:flex;padding:16px 18px;background:linear-gradient(135deg,rgba(240,253,250,.9),rgba(230,247,245,.7));border-bottom:1px solid var(--border);gap:4px;align-items:center;backdrop-filter:blur(8px)}
.cost-chain .cc-item{flex:1;text-align:center;transition:transform .2s}
.cost-chain .cc-item:hover{transform:translateY(-2px)}
.cost-chain .cc-label{font-size:0.7rem;color:var(--muted-2);font-weight:500;letter-spacing:.3px}
.cost-chain .cc-val{font-size:1rem;font-weight:700;color:var(--ink);font-family:'Plus Jakarta Sans',monospace}
.cost-chain .cc-val.accent{font-size:1.1rem;font-weight:800;color:var(--accent);text-shadow:0 1px 3px rgba(234,88,12,.15)}
.cost-chain .cc-arrow{color:#B0C8C5;font-size:1.1rem}

/* ===== 成本明细表 ===== */
/* 结果卡备注行：有备注内容才显示（由 renderResultRemark 控制显隐），无内容不占位 */
.result-remark{margin:0 16px 14px;padding:9px 12px;border-left:3px solid #c0392b;background:rgba(192,57,43,.06);border-radius:0 8px 8px 0;color:#c0392b;font-size:0.8rem;line-height:1.6;white-space:pre-wrap;word-break:break-word}
body.dark .result-remark{border-left-color:#f87171;background:rgba(248,113,113,.1);color:#fca5a5}
.cost-table{width:100%;border-collapse:collapse;font-size:0.8rem}
.cost-table th{padding:8px 10px;text-align:left;border-bottom:2px solid var(--border);background:linear-gradient(180deg,rgba(240,253,250,.9),rgba(230,247,245,.7));color:var(--brand-deep);font-weight:700;letter-spacing:.3px}
.cost-table th.num{text-align:right}
.cost-table td{padding:6px 10px;border-bottom:1px solid var(--border-soft)}
.cost-table tr:hover td{background:rgba(240,253,250,.6)}
.cost-table td.num{text-align:right;font-family:'Plus Jakarta Sans',monospace}
.cost-table td.muted{color:#7A9C99;font-size:0.75rem}
.cost-table .cat-header td{padding:5px 10px;font-size:0.72rem;font-weight:700;border-bottom:1px solid var(--border);letter-spacing:.5px}
.cost-table .cat-header.cat-material{color:#0D9488;background:linear-gradient(90deg,rgba(230,247,245,.9),rgba(240,253,250,.5))}
.cost-table .cat-header.cat-print{color:#EA580C;background:linear-gradient(90deg,rgba(255,245,239,.9),rgba(255,247,237,.5))}
.cost-table .cat-header.cat-process{color:#8E44AD;background:linear-gradient(90deg,rgba(248,240,255,.9),rgba(252,245,255,.5))}
.cost-table .cat-header.cat-other{color:#0D9488;background:linear-gradient(90deg,rgba(230,247,245,.9),rgba(240,253,250,.5))}
.cost-table .cat-header.cat-accessory{color:#4F46E5;background:linear-gradient(90deg,rgba(238,242,255,.9),rgba(243,245,255,.5))}
.cost-table .cat-header.cat-outsource{color:#DC2626;background:linear-gradient(90deg,rgba(254,242,242,.9),rgba(254,246,246,.5))}
.cost-table .total-row{background:linear-gradient(135deg,rgba(240,253,250,.95),rgba(230,247,245,.85))}
.cost-table .total-row td{padding:10px;font-weight:800}
.cost-table .total-row .total-val{color:var(--accent);font-size:1.05rem;font-family:'Plus Jakarta Sans',monospace;text-shadow:0 1px 3px rgba(234,88,12,.15)}

/* ===== 公式区 ===== */
.formula-toggle{border-top:1px solid #E0F2EF;padding:10px 16px;text-align:center;cursor:pointer;user-select:none}
.formula-toggle span{font-size:0.78rem;color:#0D9488;font-weight:500}
/* 公式详情：默认收起，展开用 max-height+opacity 平滑过渡 */
.formula-detail{max-height:0;opacity:0;padding:0 16px;overflow:hidden;background:#FBFEFD;font-size:0.75rem;color:#5B8A87;line-height:1.5;border-top:1px solid transparent;transition:max-height .28s ease,opacity .28s ease,padding .28s ease}
.formula-detail.open{max-height:4000px;opacity:1;padding:12px 16px;border-top-color:#E0F2EF}
/* 公式区：段标题行（容器）+ 内部 inline 排版 */
.formula-detail .fhead{display:block;margin-top:32px;padding-bottom:4px;border-bottom:1px dashed #BFDBFE}
.formula-detail .fhead:first-child{margin-top:0}
.formula-detail .fsec{display:inline;color:#2563EB;font-weight:700;font-size:0.84rem}
.formula-detail .fsub{color:#64748B;font-weight:400;font-size:0.75rem;margin-left:10px}
/* 两栏参数行：统一包装 .frow，标签右对齐+算式 mono，段间距由 .fhead 控制 */
.formula-detail .frow{margin-top:4px}
.formula-detail .flabel{display:inline-block;width:72px;color:#0F766E;font-weight:600;text-align:right;margin-right:10px;vertical-align:top}
.formula-detail .fval{display:inline-block;color:#334155;font-family:'Plus Jakarta Sans',monospace;font-weight:500;letter-spacing:.2px}
/* 两片分印二级段：缩进层级 + 浅蓝副色，与主段区分 */
.formula-detail .frow.lvl2{margin-left:16px}
.formula-detail .flabel.lvl2{color:#2563EB}
.formula-detail .fval.lvl2{color:#1E3A8A}
/* 成本汇总：统一两栏，不要 ASCII 线 */
.formula-detail .fsum{display:block;margin-top:4px}
.formula-detail .fsum .flabel{color:#475569;font-weight:600}
.formula-detail .fsum .fval{color:#0F172A;font-weight:600}
.formula-detail .fsum.total .flabel{color:#EA580C;font-weight:700}
.formula-detail .fsum.total .fval{color:#EA580C;font-weight:700}
/* 两片分印分隔条 */
.formula-detail .fpiece2{display:block;margin-top:8px;background:#EFF6FF;color:#1D4ED8;padding:3px 10px;border-radius:4px;font-weight:700;font-size:0.76rem;width:fit-content}

/* ===== 结果占位卡 ===== */
.result-placeholder{background:linear-gradient(135deg,rgba(240,253,250,.8),rgba(232,245,243,.7));border:2px dashed rgba(153,246,228,.7);border-radius:var(--radius);padding:52px 20px;text-align:center;color:#B0C8C5;backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);position:relative;overflow:hidden}
.result-placeholder::before{content:'';position:absolute;top:-30%;left:-10%;width:50%;height:80%;background:radial-gradient(circle,rgba(13,148,136,.08),transparent 60%);pointer-events:none}
.result-placeholder .ph-icon{font-size:2.8rem;margin-bottom:12px;display:inline-block;animation:phBob 2.8s ease-in-out infinite}
.result-placeholder .ph-title{font-size:1rem;font-weight:700;color:var(--muted);margin-bottom:6px;letter-spacing:.3px}
.result-placeholder .ph-sub{font-size:0.8rem;color:#99B5B2}
@keyframes phBob{0%,100%{transform:translateY(0)}50%{transform:translateY(-6px)}}

/* ===== 统计栏 ===== */
.stats-bar{display:flex;gap:0;margin-bottom:14px;border-radius:var(--radius);overflow:hidden;box-shadow:var(--shadow-md);border:1px solid rgba(224,242,239,.7)}
.stat-item{flex:1;padding:12px 8px;text-align:center;background:linear-gradient(180deg,rgba(255,255,255,.85),rgba(240,253,250,.7));border-right:1px solid var(--border);transition:background .2s;position:relative;overflow:hidden}
.stat-item:hover{background:linear-gradient(180deg,#fff,rgba(240,253,250,.9))}
.stat-item:last-child{border-right:none}
.stat-item .stat-num{font-size:1.3rem;font-weight:800;color:var(--brand);font-family:'Plus Jakarta Sans',monospace;letter-spacing:-.5px}
.stat-item .stat-label{font-size:0.7rem;color:var(--muted-2);margin-top:2px;font-weight:500;letter-spacing:.3px}
.stat-item.accent .stat-num{color:var(--accent)}
.stat-item.accent::after{content:'';position:absolute;top:0;left:0;right:0;height:2px;background:linear-gradient(90deg,transparent,var(--accent),transparent)}
.stat-item.accent .stat-num{color:#EA580C}

/* ===== 历史记录表 ===== */
.history-table{width:100%;border-collapse:collapse;font-size:0.8rem}
.history-table th{padding:10px;border-bottom:2px solid var(--border);text-align:left;background:linear-gradient(180deg,rgba(240,253,250,.9),rgba(230,247,245,.7));white-space:nowrap;color:var(--brand-deep);font-weight:700;letter-spacing:.3px}
.history-table td{padding:8px 10px;border-bottom:1px solid var(--border-soft)}
.history-table tbody tr{transition:background .18s}
.history-table tbody tr:hover{background:rgba(240,253,250,.7)}
.history-table .col-cb{width:30px;text-align:center}
.history-table .col-name{cursor:pointer}
.history-table .col-time{white-space:nowrap;font-size:0.75rem;color:var(--muted-2)}
.history-table .col-num{text-align:right;white-space:nowrap;font-family:'Plus Jakarta Sans',monospace}
.history-table .col-action{text-align:center;white-space:nowrap}
.history-table .action-btn{background:linear-gradient(135deg,#0D9488,#14B8A6);color:#fff;border:none;padding:4px 9px;border-radius:6px;cursor:pointer;font-size:0.72rem;margin:0 1px;transition:all .15s;font-family:inherit;box-shadow:0 2px 6px rgba(13,148,136,.2)}
.history-table .action-btn:hover{background:linear-gradient(135deg,#0F766E,#0D9488);transform:translateY(-1px);box-shadow:0 4px 10px rgba(13,148,136,.3)}
.history-table .action-btn.del{background:linear-gradient(135deg,#EA580C,#F97316);box-shadow:0 2px 6px rgba(234,88,12,.2)}
.history-table .action-btn.del:hover{background:linear-gradient(135deg,#D4520A,#EA580C);box-shadow:0 4px 10px rgba(234,88,12,.3)}
.history-table .action-btn.exp{background:linear-gradient(135deg,#0D9488,#14B8A6)}

/* ===== 客户标签 ===== */
.cust-tag{display:inline-block;padding:1px 6px;border-radius:4px;font-size:0.72rem;font-weight:500}
.cust-tag.c1{background:#E6F7F5;color:#0D9488}
.cust-tag.c2{background:#E0F2FE;color:#0EA5E9}
.cust-tag.c3{background:#FFF5EF;color:#EA580C}
.cust-tag.c4{background:#F8F0FF;color:#8E44AD}
.cust-tag.c5{background:#FEF2F2;color:#DC2626}
.cust-tag.c0{background:#F0F2F5;color:#999}
.no-result{text-align:center;color:#B0C8C5;padding:20px;font-size:0.85rem}

/* ===== 页脚 ===== */
.footer{text-align:center;color:#B0C8C5;font-size:0.7rem;margin-top:20px;font-weight:500}
.foot-update{text-align:center;color:#B0C8C5;font-size:0.75rem;padding:14px 0 22px;margin-top:10px;border-top:1px solid #E0F2EF}

/* ===== 辅助标签 ===== */
.auto-tag{font-size:0.65rem;margin-left:4px;font-weight:600;padding:1px 7px;border-radius:10px;letter-spacing:.3px;white-space:nowrap}
.auto-tag[data-mode="auto"]{background:#E6F7F5;color:#0D9488;border:1px solid #99F6E4}
.auto-tag[data-mode="manual"]{background:#FFF5EF;color:#EA580C;border:1px solid #FED7AA}
/* 填 0 = 明确无损耗：实心橙底白字，和「自动」「手填」一眼分得开 */
.auto-tag[data-mode="zero"]{background:#EA580C;color:#fff;border:1px solid #C2410C}
/* 印刷关闭时面纸损耗必填：橙色描边提示（与 markInvalid 的红色错误态区分，此处为常态提示） */
.force-required{outline:1px solid #EA580C!important;border-radius:6px}
.force-required::placeholder{color:#EA580C;opacity:.8}
/* 外加工印刷开启时：原「面纸损耗」框失效置灰（损耗改由外加工框填写） */
#paperLoss:disabled{background:#F1F5F9;color:#94A3B8;cursor:not-allowed;border-style:dashed;border-color:#CBD5E1}
body.dark #paperLoss:disabled{background:#1E293B;color:#64748B;border-color:#334155}
/* 字重固定 400：放在 h2 / .toggle-head / .mq-tool-label 里时不继承标题的 500~600，全页 ? 粗细一致 */
.help-tip{position:relative;cursor:help;color:#B0C8C5;font-size:0.8rem;font-weight:400;margin-left:4px;display:inline-block;line-height:1;vertical-align:middle}
/* 字段标题里的 ? 与文字中线对齐（0.78rem 小字下 middle 仍略沉 1px） */
.field label .help-tip{vertical-align:middle;top:-1px}
/* ? 气泡：挂 body 的独立浮层（tooltip.js 按视口边界定位），不会撑出页面 / 横向滚动条 */
.help-tip-bubble{
  position:fixed;left:0;top:0;display:none;
  background:#134E4A;color:#fff;padding:8px 12px;border-radius:6px;
  font-size:0.75rem;line-height:1.6;white-space:pre-line;overflow-wrap:anywhere;
  width:max-content;min-width:min(220px, calc(100vw - 16px));
  max-width:320px;max-width:min(320px, calc(100vw - 16px));
  z-index:99999;box-shadow:0 4px 12px rgba(0,0,0,.2);pointer-events:none;
}

/* ===== 统一按钮体系（设置弹窗用） ===== */
.btn-sm{display:inline-flex;align-items:center;justify-content:center;gap:4px;padding:10px 18px;font-size:0.85rem;font-weight:700;border-radius:var(--radius-sm);border:none;cursor:pointer;transition:all .18s cubic-bezier(.34,1.56,.64,1);font-family:inherit;letter-spacing:.3px}
.btn-sm:hover{transform:translateY(-1px);filter:brightness(1.05)}
.btn-sm:active{transform:scale(.96)}
.btn-sm.green{background:linear-gradient(135deg,#0D9488,#14B8A6);color:#fff;box-shadow:0 3px 10px rgba(13,148,136,.25)}
.btn-sm.blue{background:linear-gradient(135deg,#0D9488,#14B8A6);color:#fff;box-shadow:0 3px 10px rgba(13,148,136,.25)}
.btn-sm.orange{background:linear-gradient(135deg,#EA580C,#F97316);color:#fff;box-shadow:0 3px 10px rgba(234,88,12,.25)}
.btn-sm.red{background:linear-gradient(135deg,#DC2626,#EF4444);color:#fff;box-shadow:0 3px 10px rgba(220,38,38,.25)}
.btn-sm.gray{background:rgba(224,242,239,.8);color:var(--muted);backdrop-filter:blur(6px);border:1px solid var(--border-2)}
.btn-sm.gray:hover{background:#fff;border-color:var(--brand);color:var(--brand-deep)}

/* ===== 弹窗通用 ===== */
.overlay{display:none;position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(15,23,42,.55);z-index:100;justify-content:center;align-items:center;backdrop-filter:blur(8px) saturate(140%);-webkit-backdrop-filter:blur(8px) saturate(140%)}
.overlay.show{display:flex}
.panel{background:rgba(255,255,255,.95);backdrop-filter:blur(20px) saturate(160%);-webkit-backdrop-filter:blur(20px) saturate(160%);border-radius:var(--radius-lg);padding:0;max-width:680px;width:94%;max-height:90vh;overflow-y:auto;box-shadow:0 24px 64px rgba(0,0,0,.28),0 8px 24px rgba(13,148,136,.12);animation:panelPop .25s cubic-bezier(.34,1.56,.64,1);border:1px solid rgba(255,255,255,.6)}
@keyframes panelPop{from{opacity:0;transform:translateY(16px) scale(.96)}to{opacity:1;transform:none}}
@keyframes cardIn{from{opacity:0;transform:translateY(14px)}to{opacity:1;transform:none}}
.panel-head{display:flex;align-items:center;justify-content:space-between;padding:18px 22px;border-bottom:1px solid var(--border);position:sticky;top:0;background:rgba(255,255,255,.92);backdrop-filter:blur(12px);z-index:2;border-radius:var(--radius-lg) var(--radius-lg) 0 0}
.panel-head h3{font-size:1.05rem;margin:0;color:var(--ink);font-weight:800;letter-spacing:.5px}
.panel-head .panel-close{flex:0 0 auto;width:30px;height:30px;display:flex;align-items:center;justify-content:center;font-size:1.1rem;line-height:1;color:#B0C8C5;cursor:pointer;border-radius:8px;user-select:none;transition:all .15s}
.panel-head .panel-close:hover{background:rgba(240,253,250,.9);color:var(--ink);transform:rotate(90deg)}
.panel-body{padding:20px 22px 22px}
.panel-foot{display:flex;gap:10px;justify-content:center;margin-top:18px;padding-top:16px;border-top:1px solid var(--border)}
.panel-foot .btn-sm{flex:0 0 auto;min-width:110px}

/* ===== 后台设置表单 ===== */
.set-grid{display:grid;grid-template-columns:1fr;gap:18px}
.set-card{position:relative;background:transparent;border:none;border-left:4px solid #0D9488;border-radius:0;padding:0 0 0 14px;display:flex;flex-direction:column;gap:8px;overflow:visible}
.set-card.c-green{border-left-color:#0D9488}
.set-card.c-orange{border-left-color:#EA580C}
.set-card.c-purple{border-left-color:#8E44AD}
.set-card.c-blue{border-left-color:#0D9488}
.set-card.c-red{border-left-color:#DC2626}
.set-card.c-amber{border-left-color:#F59E0B}
.set-card h4{font-size:0.92rem;margin:0;color:#134E4A;font-weight:700;line-height:1.3}
.set-inner-grid{display:grid;grid-template-columns:1fr;gap:10px}
.set-inner-grid>div{display:flex;flex-direction:column;gap:0}
.set-card h5{font-size:0.8rem;margin:6px 0 2px;color:#5B8A87;font-weight:600;line-height:1.3;padding-left:2px}
.sub-card{background:transparent;border:none;padding:0;display:flex;flex-direction:column;gap:0}
.press-group{display:flex;flex-direction:column;gap:0;border-top:1px dashed #CCEBE7}
.press-size{font-size:0.8rem;color:#134E4A;font-weight:600;line-height:1.3;padding:8px 0 4px}
.set-card .srow{display:flex;align-items:center;gap:8px;margin:0;padding:8px 0;border-bottom:1px solid #E0F2EF}
.set-card .srow label{font-size:0.82rem;color:#134E4A;width:150px;min-width:150px;max-width:150px;font-weight:500;white-space:normal;line-height:1.3}
.set-input{width:90px;padding:7px 9px;border:1.5px solid #CCEBE7;border-radius:7px;font-size:0.82rem;text-align:right;background:#FBFEFD;transition:border-color .15s,box-shadow .15s;color:#134E4A;font-family:inherit}
.set-input:focus{outline:none;border-color:#0D9488;box-shadow:0 0 0 3px rgba(13,148,136,.12);background:#fff}
.set-card .srow input{width:90px;padding:7px 9px;border:1.5px solid #CCEBE7;border-radius:7px;font-size:0.82rem;text-align:right;background:#FBFEFD;transition:border-color .15s,box-shadow .15s;color:#134E4A;font-family:inherit}
.set-card .srow input:focus{outline:none;border-color:#0D9488;box-shadow:0 0 0 3px rgba(13,148,136,.12);background:#fff}
.set-card .srow .unit{font-size:0.78rem;color:#7A9C99;min-width:38px}
.set-card .srow span{font-size:0.78rem;color:#7A9C99;margin:0 2px}
.set-card.wide{grid-column:1/-1;background:#fff;border:1px solid #E0F2EF;border-radius:12px;padding:16px 18px 16px 18px;border-left:4px solid #0D9488;box-shadow:0 2px 10px rgba(13,148,136,.06)}
.set-card.wide h4{font-size:0.92rem;color:#134E4A;font-weight:700;margin-bottom:10px}
.set-card.wide .srow{display:flex;align-items:center;gap:8px;padding:6px 0;border-bottom:none}
.set-card.wide .srow label{width:auto;min-width:0;max-width:none}
/* 工艺参数卡：标签固定宽度 —— wide 卡默认 auto，标签字数不同会让输入框左边缘参差不齐 */
#setCraftSize .srow label,
#setCraftLoss .srow label{width:104px;min-width:104px;max-width:104px}
.set-card.wide .srow[style*="column"]{align-items:stretch;flex-direction:column}
.set-card.wide .srow[style*="column"] label{margin-bottom:4px}
.set-card.danger{border-left-color:#DC2626;background:#FFF8F8}
.set-card.danger .hint{font-size:0.78rem;color:#B06A6A;margin-bottom:10px;line-height:1.6}
.set-actions{display:flex;gap:8px;flex-wrap:wrap}

/* ===== 密码弹窗 ===== */
.pwd-panel{background:rgba(255,255,255,.95);backdrop-filter:blur(20px) saturate(160%);-webkit-backdrop-filter:blur(20px) saturate(160%);border-radius:var(--radius-lg);padding:0;max-width:340px;width:90%;box-shadow:0 24px 64px rgba(0,0,0,.28),0 8px 24px rgba(13,148,136,.12);overflow:hidden;animation:panelPop .25s cubic-bezier(.34,1.56,.64,1);border:1px solid rgba(255,255,255,.6)}
.pwd-body{padding:24px 24px 22px;text-align:center}
.pwd-body h3{font-size:1.1rem;margin:0 0 18px;color:#134E4A;font-weight:700}
.pwd-input{width:100%;padding:11px 12px;border:1.5px solid #CCEBE7;border-radius:9px;font-size:16px;text-align:center;background:#FBFEFD;transition:border-color .15s,box-shadow .15s;box-sizing:border-box;font-family:inherit;color:#134E4A}
.pwd-input:focus{outline:none;border-color:#0D9488;box-shadow:0 0 0 3px rgba(13,148,136,.12);background:#fff}
.pwd-err{font-size:0.75rem;color:#DC2626;margin-top:10px;display:none}
.pwd-actions{display:flex;gap:10px;margin-top:16px}
.pwd-actions .btn-sm{flex:1}

/* ===== 保存弹窗 ===== */
.modal-mask{position:fixed;inset:0;background:rgba(15,23,42,.55);z-index:10000;display:flex;align-items:center;justify-content:center;backdrop-filter:blur(8px) saturate(140%);-webkit-backdrop-filter:blur(8px) saturate(140%)}
.modal-card{position:relative;width:360px;max-width:92vw;background:rgba(255,255,255,.96);backdrop-filter:blur(20px) saturate(160%);-webkit-backdrop-filter:blur(20px) saturate(160%);border-radius:var(--radius-lg);box-shadow:0 24px 64px rgba(0,0,0,.28),0 8px 24px rgba(13,148,136,.12);padding:20px 20px 16px;box-sizing:border-box;animation:panelPop .25s cubic-bezier(.34,1.56,.64,1);overflow:hidden;border:1px solid rgba(255,255,255,.6)}
.modal-close{position:absolute;top:10px;right:12px;width:24px;height:24px;display:flex;align-items:center;justify-content:center;font-size:1.05rem;line-height:1;color:#B0C8C5;cursor:pointer;border-radius:5px;user-select:none}
.modal-close:hover{background:#F0FDFA;color:#134E4A}
.modal-title{font-size:1rem;font-weight:700;color:#134E4A;margin-bottom:4px}
.modal-sub{font-size:0.72rem;color:#7A9C99;margin-bottom:12px;line-height:1.4}
.modal-form{display:flex;flex-direction:column;gap:9px}
.modal-row{display:flex;align-items:center;gap:8px}
.modal-row label{flex:0 0 64px;font-size:0.8rem;color:#5B8A87;text-align:right}
.modal-row input,.modal-row textarea{flex:1;min-width:0;box-sizing:border-box;padding:7px 9px;border:1.5px solid #CCEBE7;border-radius:6px;font-size:0.85rem;font-family:inherit;line-height:1.4;resize:vertical;color:#134E4A;background:#FBFEFD}
.modal-row input:focus,.modal-row textarea:focus{outline:none;border-color:#0D9488}
.spec-group{display:flex;align-items:center;gap:6px;flex:1;min-width:0}
.spec-group input{flex:1;min-width:0;box-sizing:border-box;padding:7px 9px;border:1.5px solid #CCEBE7;border-radius:6px;font-size:0.85rem;font-family:inherit;line-height:1.4;color:#134E4A;background:#FBFEFD}
.spec-group input:focus{outline:none;border-color:#0D9488}
.spec-x{flex:0 0 auto;color:#B0C8C5;font-size:0.85rem}
.paper-group{display:flex;align-items:center;gap:6px;flex:1;min-width:0}
.gram-wrap{flex:1;min-width:0;display:flex;align-items:center;gap:3px;box-sizing:border-box;padding:7px 9px;border:1.5px solid #CCEBE7;border-radius:6px;font-size:0.85rem;font-family:inherit;line-height:1.4;background:#FBFEFD}
.gram-wrap input{flex:1;min-width:0;border:none;outline:none;padding:0;font-size:0.85rem;font-family:inherit;background:transparent;color:#134E4A}
.gram-wrap input:focus{outline:none}
.gram-unit{flex:0 0 auto;color:#7A9C99;font-size:0.85rem}
.paper-group select{flex:1;min-width:0;box-sizing:border-box;padding:7px 9px;border:1.5px solid #CCEBE7;border-radius:6px;font-size:0.85rem;font-family:inherit;line-height:1.4;background:#FBFEFD;color:#134E4A}
.paper-group select:focus{outline:none;border-color:#0D9488}
.flute-group{display:flex;align-items:center;gap:6px;flex:1;min-width:0}
.flute-group input[type=text]{flex:1;min-width:0;box-sizing:border-box;padding:7px 9px;border:1.5px solid #CCEBE7;border-radius:6px;font-size:0.85rem;font-family:inherit;line-height:1.4;color:#134E4A;background:#FBFEFD}
.flute-group input[type=text]:focus{outline:none;border-color:#0D9488}
.flute-group select{flex:1;min-width:0;box-sizing:border-box;padding:7px 9px;border:1.5px solid #CCEBE7;border-radius:6px;font-size:0.85rem;font-family:inherit;line-height:1.4;background:#FBFEFD;color:#134E4A}
.flute-group select:focus{outline:none;border-color:#0D9488}
.cross-label{flex:0 0 auto;display:flex;align-items:center;gap:3px;font-size:0.8rem;color:#5B8A87;white-space:nowrap;cursor:pointer}
.cross-label input[type=checkbox]{width:15px;height:15px;cursor:pointer}
.modal-actions{display:flex;gap:10px;margin-top:16px}
.modal-actions button{flex:1;padding:11px 0;border-radius:8px;font-size:0.88rem;font-weight:600;cursor:pointer;border:none;transition:background .15s,transform .1s;font-family:inherit}
.modal-actions button:active{transform:scale(.97)}
.btn-cancel{background:#E0F2EF;color:#5B8A87}
.btn-cancel:hover{background:#CCEBE7}
.btn-confirm{background:#0D9488;color:#fff}
.btn-confirm:hover{background:#0F766E}
.btn-primary{background:#0D9488;color:#fff}
.btn-primary:hover{background:#0F766E}
.modal-input-err,.modal-input-err:focus{border:2px solid #DC2626 !important;background:#FFF6F6 !important;outline:none}
.gram-wrap.modal-input-err{border:2px solid #DC2626 !important;background:#FFF6F6 !important}
.gram-wrap.modal-input-err input{border-color:#DC2626 !important}

/* ===== 全局提示条 ===== */
.gtip{background:#134E4A;color:#fff;padding:10px 14px;border-radius:8px;font-size:0.7rem;max-width:320px;line-height:1.7;box-shadow:0 4px 20px rgba(0,0,0,.4);pointer-events:auto;text-align:left;z-index:99999}
.gtip hr{border-color:#3D7A76;margin:4px 0}
.tip-edit{margin-top:8px;text-align:right}
.tip-edit .action-btn{background:#0D9488;color:#fff;border:none;border-radius:5px;padding:5px 10px;font-size:0.7rem;cursor:pointer}
.tip-edit .action-btn:hover{background:#0F766E}

/* ===== 移动端 ===== */
@media (max-width: 640px) {
  html{scroll-behavior:smooth;scroll-padding-top:20px}
  body{-webkit-overflow-scrolling:touch}
  .container{max-width:100%;padding:8px}
  .card{padding:10px;scroll-margin-top:20px}
  input[type=password],.field input,.field select,.panel input,.panel select{font-size:16px!important;padding:10px 8px}
  .mode-tab{font-size:0.85rem;padding:10px}
  h2{font-size:0.95rem}
  .btn{padding:12px;font-size:1rem}
  .set-card .srow input{width:60px}
  .overlay .panel{width:95%;max-height:90vh;overflow-y:auto}
  #actionBtns{flex-wrap:wrap}
  #actionBtns .btn{flex:1 1 45%!important;min-width:45%;font-size:0.85rem!important;padding:10px 8px!important}
  #multiQtyTable{overflow-x:auto;-webkit-overflow-scrolling:touch}
  .qb-textarea{font-size:0.8rem!important;min-height:200px}
  .cost-table td .desc{display:block;font-size:0.7rem;margin-top:2px}
}

/* ===== 多数量对比表（统一 Teal 主题） ===== */
#mqToolbar .field label{font-size:0.8rem;color:var(--muted);margin-bottom:4px;display:block}
#mqCompareTable{width:100%;border-collapse:collapse;font-size:0.85rem;color:var(--ink);border:1px solid var(--border);border-radius:var(--radius);overflow:hidden;margin-top:2px;box-shadow:var(--shadow-sm)}
#mqCompareTable thead th{background:linear-gradient(135deg,#0D9488,#14B8A6);color:#fff;padding:10px;border:1px solid #0F766E;text-align:right;font-weight:700;position:sticky;top:0;z-index:2;letter-spacing:.3px}
#mqCompareTable thead th:first-child{text-align:left}
#mqCompareTable tbody tr{background:rgba(255,255,255,.75);border-bottom:1px solid var(--border-soft);transition:background .18s,transform .18s}
#mqCompareTable tbody tr:nth-child(even){background:rgba(240,253,250,.6)}
#mqCompareTable tbody tr:hover{background:rgba(230,247,245,.85);transform:translateY(-1px)}
#mqCompareTable tbody tr.mq-sel{background:linear-gradient(135deg,rgba(204,251,241,.9),rgba(204,251,241,.7));box-shadow:inset 4px 0 0 var(--brand);font-weight:700}
#mqCompareTable tbody td{padding:9px 10px;border:1px solid var(--border-soft);text-align:right;font-family:monospace;white-space:nowrap}
#mqCompareTable tbody td:first-child{text-align:left;font-family:inherit;font-weight:700}
/* 报价/个：徽章在前、单价靠右（不影响列右对齐） */
#mqCompareTable tbody td.mq-sp{display:flex;justify-content:flex-end;align-items:center;gap:6px}
#mqCompareTable tbody td.mq-sp .mq-sp-num{margin-left:auto}
/* 行依次淡入上滑 */
#mqCompareTable tbody tr.mq-row{animation:mqRowIn .42s cubic-bezier(.22,.61,.36,1) both}
@keyframes mqRowIn{from{opacity:0;transform:translateY(7px)}to{opacity:1;transform:none}}
/* 毛利列：醒目橙，强调这一单能挣多少 */
#mqCompareTable tbody td.mq-profit{color:#EA580C;font-weight:700;font-family:'Plus Jakarta Sans',monospace}
/* 最划算徽章（纯 💚 圆点） */
.best-badge{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;border-radius:999px;background:linear-gradient(135deg,#0D9488,#14B8A6);color:#fff;font-size:0.7rem;flex:0 0 auto;vertical-align:middle;box-shadow:0 2px 6px rgba(13,148,136,.35)}
/* 提示药丸（替代原来的行内小字） */
.mq-hint{font-size:0.78rem;color:var(--brand);background:rgba(240,253,250,.85);border:1px solid var(--border-2);padding:6px 12px;border-radius:999px;margin-bottom:8px;display:inline-block;backdrop-filter:blur(6px)}

/* 暗色模式：多数量表 */
body.dark #mqCompareTable{color:#CBD5E1;border-color:#334155}
body.dark #mqCompareTable thead th{background:#0F766E;border-color:#134E4A}
body.dark #mqCompareTable tbody tr{background:#1E293B;border-bottom-color:#334155}
body.dark #mqCompareTable tbody tr:nth-child(even){background:#172033}
body.dark #mqCompareTable tbody tr.mq-sel{background:#134E4A;box-shadow:inset 4px 0 0 #5EEAD4}
body.dark #mqCompareTable tbody td{border-color:#334155;color:#CBD5E1}
body.dark .best-badge{background:#14B8A6}
body.dark .mq-hint{background:#172033;border-color:#134E4A;color:#5EEAD4}

/* ===== 暗色模式 ===== */
body.dark{
  background:
    radial-gradient(1200px 600px at 10% -10%,rgba(20,184,166,.16),transparent 60%),
    radial-gradient(900px 500px at 100% 0%,rgba(234,88,12,.10),transparent 55%),
    radial-gradient(700px 700px at 50% 110%,rgba(13,148,136,.10),transparent 60%),
    linear-gradient(180deg,#0F172A 0%,#1A2333 100%);
  background-attachment:fixed;color:#CBD5E1}
body.dark::before{opacity:.6;filter:invert(1) hue-rotate(180deg)}
body.dark .card{background:rgba(30,41,59,.72);backdrop-filter:blur(12px) saturate(140%);-webkit-backdrop-filter:blur(12px) saturate(140%);border-color:rgba(51,65,85,.6);box-shadow:0 4px 16px rgba(0,0,0,.3),0 1px 4px rgba(0,0,0,.2)}
body.dark .card:hover{box-shadow:0 8px 24px rgba(0,0,0,.4),0 2px 8px rgba(0,0,0,.25)}
body.dark .card h2{color:#5EEAD4;border-bottom-color:#134E4A}
body.dark .field label{color:#94A3B8}
body.dark .field input,.dark .field select{background:rgba(15,23,42,.7);border-color:#334155;color:#E2E8F0}
body.dark .field input:hover,.dark .field select:hover{border-color:rgba(20,184,166,.45);background:rgba(15,23,42,.9)}
body.dark .field input:focus,.dark .field select:focus{border-color:#14B8A6;box-shadow:0 0 0 4px rgba(20,184,166,.18),0 2px 8px rgba(20,184,166,.12);background:#0F172A}
body.dark .field input[readonly]{background:linear-gradient(135deg,rgba(26,35,51,.85),rgba(15,23,42,.85));color:#5EEAD4}
body.dark .btn{background:linear-gradient(135deg,#0F766E,#0D9488,#14B8A6);box-shadow:0 6px 20px rgba(13,148,136,.32)}
body.dark .btn:hover{box-shadow:0 10px 28px rgba(13,148,136,.42)}
body.dark .btn-secondary{background:rgba(30,41,59,.7);border-color:#334155;color:#5EEAD4;backdrop-filter:blur(8px)}
body.dark .btn-secondary:hover{background:#0F172A;border-color:#14B8A6;box-shadow:0 4px 12px rgba(20,184,166,.15)}
body.dark .btn-secondary.gray{border-color:#334155;color:#94A3B8}
body.dark .mode-tabs{background:rgba(30,41,59,.65);border-color:rgba(51,65,85,.5)}
body.dark .mode-tab{background:transparent;color:#94A3B8}
body.dark .mode-tab:hover{color:#5EEAD4;background:rgba(20,184,166,.08)}
body.dark .mode-tab.active{background:linear-gradient(135deg,#0F766E,#0D9488,#14B8A6);color:#fff}
body.dark .stepper{background:rgba(15,23,42,.7);border-color:#334155}
body.dark .stepper button{background:transparent;border-color:#334155;color:#5EEAD4}
body.dark .stepper button:hover{background:linear-gradient(135deg,#14B8A6,#0D9488);color:#0F172A;box-shadow:0 2px 6px rgba(20,184,166,.3)}
body.dark .stepper input{background:transparent;border-color:#334155;color:#E2E8F0}
body.dark .unit-select.unit-green{background:rgba(19,78,74,.85);border-color:#14B8A6;color:#5EEAD4}
body.dark .unit-select.unit-orange{background:rgba(61,26,10,.85);border-color:#F97316;color:#FDBA74}
body.dark .toolbar-input{background:rgba(15,23,42,.7);border-color:#334155;color:#E2E8F0}
body.dark .toolbar-input:focus{border-color:#14B8A6;box-shadow:0 0 0 3px rgba(20,184,166,.15)}
body.dark .field select,.dark .toolbar-input,.dark .unit-select,.dark .set-input,.dark .panel select{background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%235EEAD4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");background-repeat:no-repeat;background-position:right 10px center}
body.dark .field input:focus,.dark .field select:focus{border-color:#14B8A6;box-shadow:0 0 0 4px rgba(20,184,166,.18)}
body.dark .surface-grid label{background:rgba(30,41,59,.7);border-color:#334155;color:#94A3B8}
body.dark .surface-grid label:hover{border-color:rgba(20,184,166,.45);box-shadow:0 3px 10px rgba(0,0,0,.25)}
body.dark .surface-grid label:has(input:checked){background:linear-gradient(135deg,rgba(19,78,74,.85),rgba(15,118,110,.85));border-color:#14B8A6;color:#5EEAD4;box-shadow:0 3px 12px rgba(20,184,166,.25)}
body.dark .result-card{border-color:rgba(19,78,74,.6);box-shadow:0 12px 32px rgba(0,0,0,.4)}
body.dark .result-header{background:linear-gradient(135deg,#0F766E 0%,#0D9488 50%,#14B8A6 100%)}
body.dark .cost-chain{background:linear-gradient(135deg,rgba(30,41,59,.85),rgba(15,23,42,.7));border-bottom-color:#334155;backdrop-filter:blur(8px)}
body.dark .cost-chain .cc-val{color:#E2E8F0}
body.dark .cost-chain .cc-val.accent{color:#F97316}
body.dark .cost-table th{background:linear-gradient(180deg,rgba(19,78,74,.85),rgba(15,118,110,.7));border-bottom-color:#0F766E;color:#5EEAD4}
body.dark .cost-table td{border-bottom-color:#334155}
body.dark .cost-table tr:hover td{background:rgba(30,41,59,.6)}
body.dark .cost-table .cat-header.cat-material{background:linear-gradient(90deg,rgba(19,78,74,.85),rgba(19,78,74,.5));color:#5EEAD4}
body.dark .cost-table .cat-header.cat-print{background:linear-gradient(90deg,rgba(61,26,10,.85),rgba(61,26,10,.5));color:#F97316}
body.dark .cost-table .cat-header.cat-process{background:linear-gradient(90deg,rgba(30,16,53,.85),rgba(30,16,53,.5));color:#A78BFA}
body.dark .cost-table .cat-header.cat-other{background:linear-gradient(90deg,rgba(19,78,74,.85),rgba(19,78,74,.5));color:#5EEAD4}
body.dark .cost-table .cat-header.cat-accessory{background:linear-gradient(90deg,rgba(30,27,75,.85),rgba(30,27,75,.5));color:#A5B4FC}
body.dark .cost-table .cat-header.cat-outsource{background:linear-gradient(90deg,rgba(45,17,17,.85),rgba(45,17,17,.5));color:#FCA5A5}
body.dark .cost-table .total-row{background:linear-gradient(135deg,rgba(30,41,59,.95),rgba(23,32,45,.85))}
body.dark .cost-table .total-row .total-val{color:#F97316}
body.dark .formula-toggle{border-top-color:#334155}
body.dark .formula-toggle span{color:#5EEAD4}
body.dark .formula-detail{background:rgba(30,41,59,.85);color:#94A3B8}
body.dark .formula-detail.open{border-top-color:#334155}
body.dark .result-placeholder{background:linear-gradient(135deg,rgba(30,41,59,.85),rgba(15,23,42,.85));border-color:rgba(51,65,85,.6);color:#475569;backdrop-filter:blur(10px)}
body.dark .result-placeholder .ph-title{color:#94A3B8}
body.dark .stats-bar{box-shadow:0 2px 8px rgba(0,0,0,.35);border-color:rgba(51,65,85,.5)}
body.dark .stat-item{background:linear-gradient(180deg,rgba(30,41,59,.85),rgba(15,23,42,.7));border-right-color:#334155}
body.dark .stat-item:hover{background:linear-gradient(180deg,rgba(30,41,59,.95),rgba(15,23,42,.85))}
body.dark .stat-item .stat-num{color:#5EEAD4}
body.dark .stat-item .stat-label{color:#94A3B8}
body.dark .stat-item.accent .stat-num{color:#F97316}
body.dark .history-table th{background:#134E4A;border-bottom-color:#0F766E;color:#5EEAD4}
body.dark .history-table td{border-bottom-color:#334155}
body.dark .history-table th{background:linear-gradient(180deg,rgba(19,78,74,.85),rgba(15,118,110,.7));border-bottom-color:#0F766E;color:#5EEAD4}
body.dark .history-table td{border-bottom-color:#334155}
body.dark .history-table tr:hover{background:rgba(30,41,59,.6)}
body.dark .history-table .action-btn{background:linear-gradient(135deg,#0F766E,#0D9488);box-shadow:0 2px 6px rgba(0,0,0,.3)}
body.dark .history-table .action-btn.del{background:linear-gradient(135deg,#B91C1C,#EF4444);box-shadow:0 2px 6px rgba(0,0,0,.3)}
body.dark .footer{color:#475569}
body.dark .foot-update{color:#475569;border-top-color:#334155}
body.dark .sticky-actions{background:linear-gradient(0deg,rgba(15,23,42,.96) 75%,rgba(15,23,42,0) 100%);backdrop-filter:blur(12px) saturate(140%);-webkit-backdrop-filter:blur(12px) saturate(140%)}
body.dark .no-result{color:#475569}
body.dark .auto-tag[data-mode="auto"]{background:rgba(19,78,74,.85);color:#5EEAD4;border-color:#0F766E}
body.dark .toggle-head{color:#5EEAD4}
body.dark .switch-chip{background:rgba(30,41,59,.7);border-color:#334155;color:#94A3B8}
body.dark .switch-chip:hover{border-color:rgba(20,184,166,.45)}
body.dark .switch-chip:has(input:checked){background:linear-gradient(135deg,#0D9488,#14B8A6);border-color:#0D9488;color:#fff;box-shadow:0 4px 12px rgba(20,184,166,.32)}
body.dark .toggle-row{color:#E2E8F0}
body.dark .toggle-row:hover{background:rgba(20,184,166,.08)}
body.dark .toggle-track{background:#334155}
body.dark .toggle-row.t-green .toggle input:checked + .toggle-track{background:linear-gradient(135deg,#0D9488,#14B8A6)}
body.dark .toggle-row.t-purple .toggle input:checked + .toggle-track{background:linear-gradient(135deg,#8E44AD,#A855F7)}
body.dark .toggle-row.t-red .toggle input:checked + .toggle-track{background:linear-gradient(135deg,#DC2626,#EF4444)}
body.dark .toggle-row.t-orange .toggle input:checked + .toggle-track{background:linear-gradient(135deg,#EA580C,#F97316)}
body.dark .cb-check{background:rgba(15,23,42,.7);border-color:#334155}
body.dark .cb-check:hover{border-color:#14B8A6;transform:scale(1.08)}
body.dark .cb-check:checked{background:linear-gradient(135deg,#0D9488,#14B8A6);border-color:#0D9488}
body.dark .auto-tag[data-mode="manual"]{background:rgba(61,26,10,.85);color:#F97316;border-color:#7C2D12}
body.dark .force-required{outline-color:#F97316!important}
body.dark .help-tip{color:#475569}
body.dark .btn-sm.green,body.dark .btn-sm.blue{background:linear-gradient(135deg,#0F766E,#0D9488);box-shadow:0 3px 10px rgba(20,184,166,.25)}
body.dark .btn-sm.orange{background:linear-gradient(135deg,#EA580C,#F97316);box-shadow:0 3px 10px rgba(234,88,12,.25)}
body.dark .btn-sm.red{background:linear-gradient(135deg,#B91C1C,#DC2626);box-shadow:0 3px 10px rgba(220,38,38,.25)}
body.dark .btn-sm.gray{background:rgba(51,65,85,.7);color:#94A3B8;backdrop-filter:blur(6px);border:1px solid #334155}
body.dark .btn-sm.gray:hover{background:rgba(30,41,59,.9);border-color:#14B8A6;color:#5EEAD4}
/* 暗色弹窗 */
body.dark .overlay{background:rgba(0,0,0,.7);backdrop-filter:blur(8px) saturate(140%);-webkit-backdrop-filter:blur(8px) saturate(140%)}
body.dark .panel{background:rgba(30,41,59,.92);backdrop-filter:blur(20px) saturate(160%);-webkit-backdrop-filter:blur(20px) saturate(160%);box-shadow:0 24px 64px rgba(0,0,0,.5),0 8px 24px rgba(0,0,0,.3);border:1px solid rgba(51,65,85,.5)}
body.dark .panel-head{background:rgba(30,41,59,.92);backdrop-filter:blur(12px);border-bottom-color:#334155}
body.dark .panel-head h3{color:#E2E8F0}
body.dark .panel-head .panel-close{color:#475569}
body.dark .panel-head .panel-close:hover{background:rgba(15,23,42,.7);color:#E2E8F0}
body.dark .panel-body{background:transparent}
body.dark .set-card h4{color:#E2E8F0}
body.dark .set-card h5{color:#94A3B8}
body.dark .set-card .srow{border-bottom-color:#334155}
body.dark .set-card .srow label{color:#94A3B8}
body.dark .set-card .srow input,.dark .set-input{background:rgba(15,23,42,.7);border-color:#334155;color:#E2E8F0}
body.dark .set-card .srow input:focus,.dark .set-input:focus{border-color:#14B8A6;box-shadow:0 0 0 3px rgba(20,184,166,.15)}
body.dark .set-card.wide{background:rgba(30,41,59,.7);border-color:#334155}
body.dark .set-card.danger{background:rgba(45,17,17,.7)}
body.dark .press-group{border-top-color:#334155}
body.dark .press-size{color:#E2E8F0}
body.dark .set-card .srow .unit{color:#475569}
body.dark .set-card .srow span{color:#475569}
body.dark .pwd-panel{background:rgba(30,41,59,.92);backdrop-filter:blur(20px) saturate(160%);-webkit-backdrop-filter:blur(20px) saturate(160%);border:1px solid rgba(51,65,85,.5)}
body.dark .pwd-body{background:transparent}
body.dark .pwd-body h3{color:#E2E8F0}
body.dark .pwd-input{background:rgba(15,23,42,.7);border-color:#334155;color:#E2E8F0}
body.dark .pwd-input:focus{border-color:#14B8A6;box-shadow:0 0 0 4px rgba(20,184,166,.15)}

/* ===== 移动端适配（≤768px）：修复记录卡片横向溢出 + 输入框挤压/标题换行 ===== */
@media (max-width:640px){
  .hist-filter-bar{flex-wrap:wrap}
  .hist-filter-bar #searchInput{flex:1 0 100%}
  .hist-filter-bar #sortBy{flex:1 1 0;min-width:0}
  .hist-action-bar{flex-wrap:wrap}
  .hist-action-bar .btn-sm{flex:1 1 0;min-width:0;justify-content:center}
  .hist-action-bar #selectedCount{flex:1 0 100%;margin-left:0;text-align:right}
  /* 历史表格：允许横向滚动而非撑开容器 */
  .history-table{width:100%;min-width:unset}

  /* —— 手机端参数卡片：每行最多 2 个 field，杜绝输入框被压成 60px —— */
  .row{display:flex;flex-wrap:wrap;gap:10px}
  /* !important 覆盖 HTML 内联 flex（如其他成本 flex:1.5），移动端统一两列等宽 */
  .field{flex:1 1 calc(50% - 5px) !important;min-width:0 !important;max-width:100% !important}
  /* 标题允许换行，但给固定最小高度（单行高），保证同一行各 field 的输入框顶部对齐、不参差不齐 */
  .field label{white-space:normal;min-height:1.05rem;line-height:1.05rem;display:flex;align-items:baseline;flex-wrap:wrap}
  .auto-tag,.help-tip{flex:0 0 auto;white-space:nowrap;align-self:baseline}
  /* 带下拉的 field（色数/X2/印刷机型等）也保持两列等宽 */
  .field select{width:100%}
  /* 内部是 input+select 复合横排的 field（运输区域/其他成本/优惠）：整行排，避免二次切分把输入框压成 60px */
  .field:has(> div[style*="display:flex"]){flex:1 0 100% !important}
  /* 复合横排字段内部：input/select 改竖排堆叠（先 input 占满，下一行 select 全宽） */
  .field > div[style*="display:flex"]{flex-wrap:wrap;gap:6px}
  .field > div[style*="display:flex"] > input,
  .field > div[style*="display:flex"] > select{flex:1 0 100% !important;min-width:0 !important}
}
body.dark .modal-card{background:rgba(30,41,59,.92);backdrop-filter:blur(20px) saturate(160%);-webkit-backdrop-filter:blur(20px) saturate(160%);border:1px solid rgba(51,65,85,.5)}
body.dark .modal-title{color:#E2E8F0}
body.dark .modal-sub{color:#94A3B8}
body.dark .modal-row label{color:#94A3B8}
body.dark .modal-row input,.dark .modal-row textarea{background:rgba(15,23,42,.7);border-color:#334155;color:#E2E8F0}
body.dark .modal-row input:focus,.dark .modal-row textarea:focus{border-color:#14B8A6;box-shadow:0 0 0 3px rgba(20,184,166,.15)}
body.dark .spec-group input{background:rgba(15,23,42,.7);border-color:#334155;color:#E2E8F0}
body.dark .gram-wrap{background:rgba(15,23,42,.7);border-color:#334155}
body.dark .gram-wrap input{color:#E2E8F0}
body.dark .paper-group select,.dark .flute-group select,.dark .flute-group input[type=text]{background:rgba(15,23,42,.7);border-color:#334155;color:#E2E8F0}
body.dark .btn-cancel{background:rgba(51,65,85,.7);color:#94A3B8;border:1px solid #334155}
body.dark .btn-confirm{background:linear-gradient(135deg,#0F766E,#0D9488);box-shadow:0 3px 10px rgba(20,184,166,.25)}
body.dark .btn-primary{background:linear-gradient(135deg,#0F766E,#0D9488);box-shadow:0 3px 10px rgba(20,184,166,.25)}
body.dark .cross-label{color:#94A3B8}
body.dark .paper-group select,.dark .flute-group select,.dark .flute-group input[type=text]{background:rgba(15,23,42,.7);border-color:#334155;color:#E2E8F0}
body.dark .btn-cancel{background:rgba(51,65,85,.7);color:#94A3B8;border:1px solid #334155}
body.dark .btn-confirm{background:linear-gradient(135deg,#0F766E,#0D9488);box-shadow:0 3px 10px rgba(20,184,166,.25)}
body.dark .btn-primary{background:linear-gradient(135deg,#0F766E,#0D9488);box-shadow:0 3px 10px rgba(20,184,166,.25)}
body.dark .cust-tag.c1{background:rgba(19,78,74,.85);color:#5EEAD4}
body.dark .cust-tag.c2{background:rgba(30,58,95,.85);color:#7DD3FC}
body.dark .cust-tag.c3{background:rgba(61,26,10,.85);color:#F97316}
body.dark .cust-tag.c4{background:rgba(30,16,53,.85);color:#A78BFA}
body.dark .cust-tag.c5{background:rgba(45,17,17,.85);color:#FCA5A5}
body.dark .cust-tag.c0{background:rgba(30,41,59,.7);color:#475569}
body.dark .gtip{background:rgba(15,23,42,.95);backdrop-filter:blur(12px);box-shadow:0 4px 20px rgba(0,0,0,.5)}

/* ===== CanIRun 工具主题（已合并到源文件） ===== */
/* Quote Tool — CanIRun-inspired quiet utility theme
   Presentation only: no field order, markup behavior, or calculation logic changes. */

:root {
  --brand: #16a34a;
  --brand-2: #22c55e;
  --brand-deep: #15803d;
  --brand-ink: #14532d;
  --accent: #c2410c;
  --accent-2: #ea580c;
  --bg-1: #ffffff;
  --bg-2: #f7f7f8;
  --bg-3: #fafafa;
  --border: #e4e4e7;
  --border-2: #d4d4d8;
  --border-soft: #eeeeef;
  --ink: #18181b;
  --ink-2: #09090b;
  --muted: #52525b;
  --muted-2: #71717a;
  --muted-3: #a1a1aa;
  --card-bg: #ffffff;
  --card-bg-solid: #ffffff;
  --shadow-sm: none;
  --shadow-md: none;
  --shadow-lg: none;
  --shadow-glow: none;
  --shadow-accent: none;
  --radius-sm: 6px;
  --radius: 7px;
  --radius-lg: 8px;
  --radius-xl: 10px;
  --ui-font: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Segoe UI Variable", system-ui, sans-serif;
  --utility-mono: var(--ui-font);
  --text-meta: 11px;
  --text-small: 12px;
  --text-control: 13px;
  --text-body: 15px;
}

html { background: #fff; }

/* Corrugated-box page: kraft amber accent, while retaining the same neutral theme. */
body.carton-page {
  --brand: #b45309;
  --brand-2: #d97706;
  --brand-deep: #92400e;
  --brand-ink: #78350f;
}
body.carton-page .field input.input-ok {
  border-color: #fcd34d !important;
  background: #fffbeb !important;
}
body.carton-page .surface-grid label:has(input:checked),
body.carton-page .switch-chip:has(input:checked) {
  border-color: #fcd34d;
  background: #fffbeb;
  color: var(--brand-deep);
}
body.carton-page .btn-sm.green,
body.carton-page .btn-sm.blue,
body.carton-page .qb-btn.qb-copy {
  border-color: #fcd34d;
  background: #fffbeb;
  color: var(--brand-deep);
}
body.carton-page .fab-btn:hover,
body.carton-page .fab-btn.fab-reset:hover {
  border-color: var(--brand);
  background: #fffbeb;
  color: var(--brand-deep);
}

body {
  min-height: 100vh;
  padding: 18px 18px 38px;
  color: var(--ink);
  background: #fff;
  background-image: none;
  font-family: var(--ui-font);
  font-size: 15px;
  line-height: 1.55;
}

body::before { display: none; }
body, body * { transition-duration: .12s; }
.container { max-width: 840px; }

/* Minimal segmented navigation */
.mode-tabs {
  gap: 0;
  margin: 0 0 18px;
  padding: 0;
  border: 1px solid var(--border-2);
  border-radius: 7px;
  background: #f4f4f5;
  box-shadow: none;
  backdrop-filter: none;
}

.mode-tab {
  padding: 10px 14px;
  border-radius: 5px;
  color: var(--muted);
  font-family: var(--utility-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
}

.mode-tab:hover { color: var(--ink); background: #ededee; }
.mode-tab.active {
  margin: 3px;
  color: var(--brand-deep);
  background: #fff;
  border: 1px solid var(--border-2);
  box-shadow: none;
}

/* Flat sections: information first, decoration second */
.card {
  margin-bottom: 10px;
  padding: 17px 16px;
  overflow: visible;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: none;
  backdrop-filter: none;
  animation: none;
}

.card:hover {
  transform: none;
  border-color: var(--border-2);
  box-shadow: none;
}

.card h2 {
  min-height: 24px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0;
}

.card h2 > span:first-child,
.toggle-head {
  font-family: var(--utility-mono), "Microsoft YaHei";
}
/* 卡片标题里的内联色统一压成灰（标题副文本不抢眼）；#pressLimit 例外：正常灰、超限红由 JS 控制 */
.card h2 [style*="color"]:not(#pressLimit) { color: var(--muted-2) !important; }

.card h2::before {
  width: 5px;
  height: 5px;
  margin-right: 3px;
  border-radius: 1px;
  background: var(--brand);
}

.row { gap: 10px; }
.field { min-width: 112px; }
.field label {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .01em;
}

.req::after, .req-x2::after { color: #dc2626; }
.auto-tag {
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: #f4f4f5;
  color: var(--muted-2);
  font-family: var(--utility-mono);
  font-size: 9px;
}

/* Dense tool controls */
.field input,
.field select,
.toolbar-input,
.set-input,
.panel input,
.panel select,
.modal input,
.modal select,
.modal textarea {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--border-2);
  border-radius: 6px;
  background-color: #f4f4f5;
  color: var(--ink);
  box-shadow: none;
  font-family: var(--utility-mono);
  font-size: 12px;
}

.field input { text-align: center; font-variant-numeric: tabular-nums; }
.field select { text-align: center; text-align-last: center; }
.stepper input { text-align: center; }
.field input[type="text"] { text-align: center; }
.field input[readonly] { text-align: center; }

.field select.unit-select,
.unit-select.unit-green,
.unit-select.unit-orange {
  width: auto;
  min-width: 82px;
  min-height: 38px;
  padding: 8px 26px 8px 10px !important;
  border: 1px solid var(--border-2);
  border-radius: 6px;
  background-color: #f4f4f5;
  color: var(--muted);
  font-family: var(--utility-mono);
  font-size: var(--text-control);
  font-weight: 400;
  line-height: 1.2;
  text-align: center;
  text-align-last: center;
  box-shadow: none;
}
.field select.unit-select:hover,
.unit-select.unit-green:hover,
.unit-select.unit-orange:hover { border-color: #a1a1aa; background-color: #f4f4f5; color: var(--ink); }
.field select.unit-select:focus,
.unit-select.unit-green:focus,
.unit-select.unit-orange:focus { border-color: var(--brand); background-color: #fff; color: var(--ink); box-shadow: 0 0 0 2px rgba(22,163,74,.12); }

.field select,
.toolbar-input,
.unit-select,
.set-input,
.panel select,
.modal select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='m1 1 4 4 4-4' fill='none' stroke='%2352525b' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.field input:hover, .field select:hover, .toolbar-input:hover {
  border-color: #a1a1aa;
  background-color: #f4f4f5;
}

.field input:focus,
.field select:focus,
.toolbar-input:focus,
.set-input:focus,
.panel input:focus,
.panel select:focus,
.modal input:focus,
.modal select:focus,
.modal textarea:focus {
  outline: none;
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, .12);
}

.field input[readonly], .field input:disabled, .field select:disabled {
  border-style: solid;
  border-color: #e4e4e7 !important;
  background: #fafafa !important;
  color: #a1a1aa !important;
  opacity: 1;
}

.field input.input-ok { border-color: #86efac !important; background: #f0fdf4 !important; color: var(--ink) !important; box-shadow: none !important; }
.field input.input-warn { border-color: var(--border-2); background: #f4f4f5; box-shadow: none; }
.field input.hl-emph:not(.input-ok) { border-color: var(--border-2); background: #f4f4f5; box-shadow: none; }

.stepper {
  height: 38px;
  border: 1px solid var(--border-2);
  border-radius: 6px;
  background: #f4f4f5;
  backdrop-filter: none;
}

.stepper button {
  padding: 0 12px;
  color: var(--muted);
  font-family: var(--utility-mono);
  font-size: 16px;
}

.stepper button:hover { color: var(--brand-deep); background: #e8f7ed; }
.stepper input { font-family: var(--utility-mono); font-size: 12px; }

/* Chips and switches */
.surface-grid, .switch-grid { gap: 6px; }
.surface-grid label, .switch-chip {
  min-width: 0;
  padding: 7px 11px;
  border: 1px solid var(--border-2);
  border-radius: 5px;
  background: #fafafa;
  color: var(--muted);
  font-family: var(--utility-mono);
  font-size: 11px;
  box-shadow: none;
}

.surface-grid label:hover, .switch-chip:hover {
  transform: none;
  border-color: #a1a1aa;
  box-shadow: none;
}

.surface-grid label:has(input:checked), .switch-chip:has(input:checked) {
  border-color: #86efac;
  background: #f0fdf4;
  color: var(--brand-deep);
  box-shadow: none;
}

.toggle-card { padding: 14px 16px; }
.toggle-head {
  margin-bottom: 10px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
}
.toggle-head::before { width: 5px; height: 5px; border-radius: 1px; background: var(--brand); }
.toggle-row { padding: 4px 6px; color: var(--muted); font-size: 12px; }
.toggle-row:hover { background: #f4f4f5; }
.toggle { width: 34px; height: 19px; }
.toggle-track { border: 1px solid #d4d4d8; border-radius: 10px; background: #e4e4e7; }
.toggle-track::after { width: 13px; height: 13px; top: 2px; left: 2px; box-shadow: none; }
.toggle input:checked + .toggle-track,
.toggle-row.t-green .toggle input:checked + .toggle-track,
.toggle-row.t-purple .toggle input:checked + .toggle-track,
.toggle-row.t-red .toggle input:checked + .toggle-track,
.toggle-row.t-orange .toggle input:checked + .toggle-track { border-color: var(--brand); background: var(--brand); }
.toggle input:checked + .toggle-track::after { transform: translateX(15px); box-shadow: none; }

/* Calm actions with one clear primary color */
.sticky-actions {
  padding: 10px 0 12px;
  background: rgba(255, 255, 255, .94);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.btn, .btn-copy, .btn-primary, .btn-confirm {
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid var(--brand-deep);
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  box-shadow: none;
  font-family: var(--utility-mono);
  font-weight: 600;
}

.btn { padding: 12px; font-size: 13px; letter-spacing: 0; }
.btn::before { display: none; }
.btn:hover, .btn-copy:hover, .btn-primary:hover, .btn-confirm:hover {
  transform: none;
  background: var(--brand-deep);
  box-shadow: none;
}

.sticky-actions .row:first-child .btn:last-child {
  border-color: var(--border-2) !important;
  background: #f4f4f5 !important;
  color: var(--muted) !important;
}

.sticky-actions .row:first-child .btn:last-child:hover { background: #e4e4e7 !important; color: var(--ink) !important; }
.btn-secondary, .btn-cancel {
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--border-2) !important;
  border-radius: 6px;
  background: #fafafa !important;
  color: var(--muted) !important;
  box-shadow: none;
  font-family: var(--utility-mono);
}
.btn-secondary:hover, .btn-cancel:hover { transform: none; border-color: #a1a1aa !important; background: #f4f4f5 !important; }

/* Results and data tables */
.result-placeholder {
  min-height: 0;
  padding: 17px 18px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  background: #fff;
  color: var(--muted-2);
  text-align: left;
  backdrop-filter: none;
}
.result-placeholder::before { display: none; }
.result-placeholder .ph-icon { display: none; }
.result-placeholder .ph-title { display: inline; color: var(--ink); font-family: var(--utility-mono); font-size: 12px; font-weight: 600; }
.result-placeholder .ph-title::before { content: "READY  "; color: var(--brand); font-size: 10px; }
.result-placeholder .ph-sub { display: inline; margin-left: 10px; color: var(--muted-3); font-family: var(--utility-mono); font-size: 10px; }
/* 缺尺寸待补状态：前缀从 READY 换成 MISSING，左边条转琥珀色——能看见，但不弹窗、不标红输入框 */
.result-placeholder.ph-missing { border-left-color: #F59E0B; }
.result-placeholder.ph-missing .ph-title::before { content: "MISSING  "; color: #B45309; }
.result-card { border-color: var(--border-2); box-shadow: none; }
.result-header {
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  text-align: center;
}
.result-header::before, .result-header::after { display: none; }
.result-header .rh-label { color: var(--muted-2); font-family: var(--utility-mono); font-size: 9px; letter-spacing: .08em; }
.result-header .rh-total {
  margin: 4px 0 2px;
  color: var(--brand-deep);
  background: none;
  font-family: var(--utility-mono);
  font-size: 30px;
  letter-spacing: -1px;
  text-shadow: none;
  -webkit-text-fill-color: currentColor;
}
.result-header .rh-sub, .result-header .rh-tax { color: var(--muted-2); opacity: 1; font-family: var(--utility-mono); font-size: 10px; }
.cost-chain { padding: 11px 12px; border-bottom: 1px solid var(--border); background: #fafafa; backdrop-filter: none; }
.cost-chain .cc-item:hover { transform: none; }
.cost-chain .cc-label { color: var(--muted-3); font-family: var(--utility-mono); font-size: 9px; }
.cost-chain .cc-val { color: var(--ink); font-size: 12px; font-weight: 600; }
.cost-chain .cc-val.accent { color: var(--brand-deep); font-size: 12px; text-shadow: none; }
.cost-chain .cc-arrow { color: var(--border-2); font-size: 12px; }
.cost-chain .cc-val, .cost-table td.num, .stat-item .stat-num { font-family: var(--utility-mono); }
.cost-table { font-size: 11px; }
.cost-table th { padding: 8px 10px; border-bottom: 1px solid var(--border-2); background: #f4f4f5; color: var(--muted-2); font-family: var(--utility-mono); font-size: 9px; font-weight: 500; }
.cost-table td { padding: 7px 10px; border-bottom-color: var(--border); }
.cost-table tr:hover td { background: #fafafa; }
.cost-table .cat-header td,
.cost-table .cat-header.cat-material td,
.cost-table .cat-header.cat-print td,
.cost-table .cat-header.cat-process td,
.cost-table .cat-header.cat-other td,
.cost-table .cat-header.cat-accessory td,
.cost-table .cat-header.cat-outsource td {
  padding: 6px 10px;
  background: #fafafa;
  color: var(--muted-2);
  font-family: var(--utility-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .04em;
}
.cost-table .total-row { background: #f0fdf4; }
.cost-table .total-row td { padding: 9px 10px; }
.cost-table .total-row .total-val { color: var(--brand-deep); font-family: var(--utility-mono); font-size: 12px; text-shadow: none; }
.formula-toggle { padding: 9px 12px; border-top-color: var(--border); text-align: left; }
.formula-toggle span { color: var(--muted-2); font-family: var(--utility-mono); font-size: 9px; }
.formula-detail { background: #fafafa; color: var(--muted); font-family: var(--utility-mono); font-size: 10px; }
.formula-detail.open { padding: 12px; border-top-color: var(--border); }
.formula-detail .fhead { margin-top: 18px; border-bottom-color: var(--border); }
.formula-detail .fsec, .formula-detail .flabel, .formula-detail .flabel.lvl2 { color: var(--brand-deep); }
.formula-detail .fsub, .formula-detail .fval, .formula-detail .fval.lvl2,
.formula-detail .fsum .flabel, .formula-detail .fsum .fval { color: var(--muted); font-family: var(--utility-mono); }
.formula-detail .fsum.total .flabel, .formula-detail .fsum.total .fval { color: var(--brand-deep); }
.formula-detail .fpiece2 { border: 1px solid var(--border); border-radius: 3px; background: #fff; color: var(--muted); }
.stats-bar { border-color: var(--border); box-shadow: none; }
.stat-item { background: #fafafa; }
.stat-item:hover { background: #f4f4f5; }
.stat-item .stat-num, .stat-item.accent .stat-num { color: var(--ink); }

/* History behaves like a compact data browser, not a dashboard card. */
#historyCard { padding-bottom: 10px; }
#historyCard .stats-bar {
  gap: 20px;
  align-items: center;
  margin-bottom: 12px;
  padding: 10px 12px;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: #fafafa;
}
#historyCard .stat-item {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
}
#historyCard .stat-item:hover { background: transparent; }
#historyCard .stat-item .stat-num { font-size: 13px; font-weight: 650; }
#historyCard .stat-item .stat-label { margin: 0; color: var(--muted-3); font-family: var(--utility-mono); font-size: 9px; }
#historyCard .stat-item.accent .stat-num { color: var(--brand-deep); }

#historyCard .hist-filter-bar { gap: 6px !important; margin-bottom: 7px !important; }
#historyCard .toolbar-input {
  min-height: 34px;
  padding-top: 6px;
  padding-bottom: 6px;
  background-color: #fafafa;
  font-size: 11px;
  text-align: center;
  text-align-last: center;
}
/* 报价记录：规格三框（长 × 宽 × 高）。三个框等宽等高等字号，与旁边筛选控件同一基线 */
#historyCard .hist-spec-search {
  display: flex; align-items: center; gap: 4px; flex: 0 0 auto;
}
#historyCard .hist-spec-search .spec-input {
  width: 62px; flex: 0 0 62px; box-sizing: border-box;
  min-height: 34px; padding: 6px 2px;
  border: 1.5px solid #CCEBE7; border-radius: 8px;
  background-color: #fafafa; color: #134E4A;
  font-family: inherit; font-size: 11px; text-align: center;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
#historyCard .hist-spec-search .spec-input::placeholder { color: #99B5B2; }
#historyCard .hist-spec-search .spec-input:focus {
  outline: none; border-color: #0D9488; background: #fff;
  box-shadow: 0 0 0 3px rgba(13,148,136,.12);
}
#historyCard .hist-spec-search .spec-mul {
  color: #99B5B2; font-size: 11px; line-height: 1; user-select: none;
}
body.dark #historyCard .hist-spec-search .spec-input {
  background-color: #18181b; border-color: #3f3f46; color: #e4e4e7;
}
body.dark #historyCard .hist-spec-search .spec-input::placeholder { color: #71717a; }
body.dark #historyCard .hist-spec-search .spec-input:focus {
  border-color: #14B8A6; box-shadow: 0 0 0 3px rgba(20,184,166,.15);
}
body.dark #historyCard .hist-spec-search .spec-mul { color: #71717a; }

/* 文字搜索框不是下拉，去掉 .toolbar-input 的通用下拉箭头（并收回右侧为箭头预留的 28px） */
#historyCard #searchInput.toolbar-input { background-image: none; padding-right: 14px; }

/* ===== 报价记录：客户筛选（可打字下拉 + 最近客户标签） =====
   尺寸跟同排 .toolbar-input 走：min-height 34 / padding 6 / font 11，不硬编码 height */
#historyCard .client-picker { position: relative; flex: 0 0 auto; display: flex; min-width: 0; }
#historyCard .client-picker-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  min-height: 34px; padding: 6px 10px 6px 12px; box-sizing: border-box;
  max-width: 180px;
  border: 1.5px solid #CCEBE7; border-radius: 8px;
  background-color: #fafafa; color: #134E4A;
  font-family: inherit; font-size: 11px; cursor: pointer;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
#historyCard .client-picker-btn:hover { background-color: #fff; }
#historyCard .client-picker-btn:focus { outline: none; border-color: #0D9488; box-shadow: 0 0 0 3px rgba(13,148,136,.12); }
#historyCard .client-picker-btn.active { border-color: #0D9488; background-color: #E6F7F5; font-weight: 600; }
#clientPickerLabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }
#historyCard .cp-arrow {
  width: 0; height: 0; flex: 0 0 auto;
  border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid #0D9488;
  transition: transform .15s;
}
#historyCard .client-picker-btn[aria-expanded="true"] .cp-arrow { transform: rotate(180deg); }
#historyCard .client-picker-pop {
  position: absolute; z-index: 60; top: calc(100% + 5px); left: 0;
  width: 240px; box-sizing: border-box; padding: 8px;
  background: #fff; border: 1.5px solid #CCEBE7; border-radius: 10px;
  box-shadow: 0 10px 28px rgba(13,148,136,.16);
}
#historyCard .client-picker-pop[hidden] { display: none; }
#historyCard .cp-search {
  width: 100%; min-height: 32px; padding: 6px 10px; box-sizing: border-box;
  border: 1.5px solid #CCEBE7; border-radius: 8px;
  background-color: #FBFEFD; color: #134E4A;
  font-family: inherit; font-size: 12px;
}
#historyCard .cp-search:focus { outline: none; border-color: #0D9488; box-shadow: 0 0 0 3px rgba(13,148,136,.12); }
#historyCard .cp-list { margin-top: 6px; max-height: 260px; overflow-y: auto; }
#historyCard .cp-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 7px 8px; border-radius: 6px;
  font-size: 12px; color: #134E4A; cursor: pointer;
}
#historyCard .cp-item.hl, #historyCard .cp-item:hover { background: #E6F7F5; }
#historyCard .cp-item.sel { font-weight: 650; }
#historyCard .cp-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#historyCard .cp-meta { flex: 0 0 auto; color: #8AA8A5; font-size: 10px; }
#historyCard .cp-empty { padding: 10px 8px; color: #8AA8A5; font-size: 11px; text-align: center; }

#historyCard .client-chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 0 0 8px; }
#historyCard .client-chips[hidden] { display: none; }
#historyCard .chip-label { color: #8AA8A5; font-size: 10px; }
#historyCard .client-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px; border: 1px solid #CCEBE7; border-radius: 999px;
  background: #fff; color: #134E4A;
  font-family: inherit; font-size: 11px; cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
#historyCard .client-chip:hover { border-color: #0D9488; }
#historyCard .client-chip.on { background: #0D9488; border-color: #0D9488; color: #fff; }
#historyCard .chip-count { font-size: 9px; opacity: .65; }

body.dark #historyCard .client-picker-btn { background-color: #18181b; border-color: #3f3f46; color: #e4e4e7; }
body.dark #historyCard .client-picker-btn:hover { background-color: #1f1f23; }
body.dark #historyCard .client-picker-btn.active { background-color: rgba(20,184,166,.16); border-color: #14B8A6; }
body.dark #historyCard .cp-arrow { border-top-color: #5EEAD4; }
body.dark #historyCard .client-picker-pop { background: #18181b; border-color: #3f3f46; box-shadow: 0 10px 28px rgba(0,0,0,.5); }
body.dark #historyCard .cp-search { background-color: #111113; border-color: #3f3f46; color: #e4e4e7; }
body.dark #historyCard .cp-item { color: #e4e4e7; }
body.dark #historyCard .cp-item.hl, body.dark #historyCard .cp-item:hover { background: rgba(20,184,166,.14); }
body.dark #historyCard .cp-meta, body.dark #historyCard .cp-empty, body.dark #historyCard .chip-label { color: #71717a; }
body.dark #historyCard .client-chip { background: #18181b; border-color: #3f3f46; color: #e4e4e7; }
body.dark #historyCard .client-chip.on { background: #0D9488; border-color: #0D9488; color: #fff; }

@media (max-width: 620px) {
  #historyCard .client-picker { flex: 1 1 0; min-width: 0; }
  #historyCard .client-picker-btn { max-width: none; width: 100%; }
  #historyCard .client-picker-pop { width: 100%; min-width: 190px; }
}
#historyCard .hist-action-bar { margin-bottom: 8px !important; }
#historyCard .btn-sm {
  min-height: 32px;
  padding: 6px 11px;
  border: 1px solid var(--border-2);
  border-radius: 5px;
  background: #fff;
  color: var(--muted);
  box-shadow: none;
  font-family: var(--utility-mono);
  font-size: 10px;
  font-weight: 500;
}
#historyCard .btn-sm:hover { transform: none; border-color: #a1a1aa; background: #f4f4f5; filter: none; }
#historyCard .btn-sm.red:hover { border-color: #fca5a5; background: #fef2f2; color: #b91c1c; }
#historyCard #selectedCount { color: var(--muted-2) !important; font-family: var(--utility-mono); font-size: 10px !important; font-weight: 500 !important; }

.history-table {
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
  overflow: hidden;
}
.history-table th {
  padding: 8px 9px;
  border-bottom: 1px solid var(--border-2);
  background: #f4f4f5;
  color: var(--muted-2);
  font-family: var(--utility-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0;
}
.history-table td { padding: 8px 9px; border-bottom: 1px solid var(--border); }
.history-table tbody tr:hover { background: #fafafa; }
.history-table .col-num { font-family: var(--utility-mono); font-variant-numeric: tabular-nums; }
.history-table .action-btn,
.history-table .action-btn.del,
.history-table .action-btn.exp {
  padding: 4px 7px;
  border: 1px solid var(--border-2);
  border-radius: 4px;
  background: #fff;
  color: var(--muted);
  box-shadow: none;
  font-family: var(--utility-mono);
  font-size: 9px;
}
.history-table .action-btn:hover,
.history-table .action-btn.del:hover,
.history-table .action-btn.exp:hover { transform: none; border-color: var(--brand); background: #f0fdf4; color: var(--brand-deep); box-shadow: none; }
.no-result { padding: 20px !important; color: var(--muted-3); font-family: var(--utility-mono); font-size: 10px; }
.footer { margin-top: 12px; color: var(--muted-3); font-family: var(--utility-mono); font-size: 9px; }

/* Unified button hierarchy across settings, dialogs and generated panels. */
.btn-sm, .qb-btn, .action-btn, .tip-edit .action-btn {
  min-height: 32px;
  padding: 6px 11px;
  border: 1px solid var(--border-2);
  border-radius: 5px;
  background: #fff;
  color: var(--muted);
  box-shadow: none;
  font-family: var(--utility-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0;
}
.btn-sm:hover, .qb-btn:hover, .action-btn:hover, .tip-edit .action-btn:hover {
  transform: none;
  border-color: #a1a1aa;
  background: #f4f4f5;
  color: var(--ink);
  box-shadow: none;
  filter: none;
}
.btn-sm.green, .btn-sm.blue, .qb-btn.qb-copy {
  border-color: #86efac;
  background: #f0fdf4;
  color: var(--brand-deep);
  box-shadow: none;
}
.btn-sm.orange, .qb-btn.qb-tpl {
  border-color: #fde68a;
  background: #fffbeb;
  color: #92400e;
  box-shadow: none;
}
.btn-sm.red, .action-btn.del {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b91c1c;
  box-shadow: none;
}
.btn-sm.gray, .qb-btn.qb-close { background: #fff; color: var(--muted); }
.set-actions .btn-sm, .panel-foot .btn-sm { min-width: 92px; }
.transport-del { min-height: 28px !important; padding: 4px 8px !important; }

/* Settings/password/quote-preview overlays use the same flat utility surfaces. */
.overlay { background: rgba(24, 24, 27, .38); backdrop-filter: blur(2px); }
.panel, .pwd-panel, .quote-box {
  border: 1px solid var(--border-2);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .16);
  backdrop-filter: none;
  animation: none;
}
.panel-head {
  min-height: 48px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #fff;
  backdrop-filter: none;
}
.panel-head h3, .pwd-body h3, .quote-box h3 {
  color: var(--ink);
  font-family: var(--utility-mono), "Microsoft YaHei";
  font-size: 13px;
}
.panel-head .panel-close { color: var(--muted-3); }
.panel-head .panel-close:hover { background: #f4f4f5; color: var(--ink); }
.panel-body, .pwd-body { background: #fff; }
.panel-foot {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: #fafafa;
}
.set-card, .set-card.wide, .set-card.danger {
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-2);
  border-radius: 6px;
  background: #fff;
  box-shadow: none;
}
.set-card.c-green, .set-card.c-blue, .set-card.wide { border-left-color: var(--brand); }
.set-card.c-orange, .set-card.c-purple, .set-card.c-amber { border-left-color: var(--border-2); }
.set-card.c-red, .set-card.danger { border-left-color: #ef4444; background: #fff; }
.set-card h4, .set-card.wide h4 { color: var(--ink); font-family: var(--utility-mono), "Microsoft YaHei"; font-size: 11px; }
.set-card h5, .press-size { color: var(--muted); font-size: 10px; }
.set-card .srow { border-bottom-color: var(--border); }
.set-card .srow label { color: var(--muted); font-size: 10px; }
.set-card .srow input, .set-input, .pwd-input, .qb-textarea {
  border: 1px solid var(--border-2);
  border-radius: 5px;
  background: #f4f4f5;
  color: var(--ink);
  box-shadow: none;
  font-family: var(--utility-mono);
  text-align: center;
}
.set-card .srow input:focus, .set-input:focus, .pwd-input:focus, .qb-textarea:focus {
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, .12);
}
/* 报价文本是可复制的多行正文，始终从左侧开始阅读和编辑。 */
#quoteOverlay .qb-textarea { text-align: left !important; }
.press-group { border-top-color: var(--border); }
.qb-actions { gap: 7px; }
.qb-btn { flex: 1; }
.gtip { border: 1px solid #3f3f46; border-radius: 5px; background: #27272a; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); font-family: var(--utility-mono); }

/* Multi-quantity comparison follows the same neutral data-table language. */
#multiQtyTable { padding: 12px 0 0 !important; }
.mq-hint {
  margin: 0 0 8px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fafafa;
  color: var(--muted-2);
  font-family: var(--utility-mono);
  font-size: 9px;
  backdrop-filter: none;
}
#mqCompareTable {
  border-collapse: separate;
  border-spacing: 0;
  border-color: var(--border);
  border-radius: 6px;
  color: var(--ink);
  font-size: 10px;
  box-shadow: none;
}
#mqCompareTable thead th {
  padding: 8px 9px;
  border: 0;
  border-bottom: 1px solid var(--border-2);
  background: #f4f4f5;
  color: var(--muted-2);
  font-family: var(--utility-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0;
}
#mqCompareTable tbody tr,
#mqCompareTable tbody tr:nth-child(even) { background: #fff; animation: none; }
#mqCompareTable tbody tr:hover { transform: none; background: #fafafa; }
#mqCompareTable tbody tr.mq-sel { background: #f0fdf4; box-shadow: inset 3px 0 0 var(--brand); font-weight: 600; }
#mqCompareTable tbody td { padding: 8px 9px; border: 0; border-bottom: 1px solid var(--border); font-family: var(--utility-mono); }
#mqCompareTable tbody td:first-child { font-family: var(--utility-mono); }
/* 阶梯表：逐档毛利率（− 值 + 三件套共用一个外框，三个控件等高、按钮等宽，不破坏表格节奏） */
#mqCompareTable tbody td.mq-margin { padding: 4px 6px; text-align: right; }
#mqCompareTable .mq-step {
  display: inline-flex; align-items: stretch; vertical-align: middle;
  border: 1px solid var(--border-2); border-radius: 4px;
  background: #fff; overflow: hidden;
}
#mqCompareTable .mq-step-btn {
  flex: 0 0 auto; width: 22px; padding: 0; border: 0;
  background: transparent; color: var(--muted-2);
  font-family: var(--utility-mono); font-size: 13px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; user-select: none;
  transition: background-color .12s, color .12s;
}
#mqCompareTable .mq-step-btn:first-child { border-right: 1px solid var(--border); }
#mqCompareTable .mq-step-btn:last-child { border-left: 1px solid var(--border); }
#mqCompareTable .mq-step-btn:hover { background-color: #e8f7ed; color: var(--brand-deep); }
#mqCompareTable .mq-step-btn:active { background-color: #d5f0dd; }
#mqCompareTable .mq-step-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
#mqCompareTable .mq-step .mq-margin-input {
  width: 34px; box-sizing: border-box; padding: 4px 0;
  border: 0; border-radius: 0; background: transparent; color: var(--ink);
  font-family: var(--utility-mono); font-size: 10px; text-align: center;
}
#mqCompareTable .mq-margin-input::-webkit-outer-spin-button,
#mqCompareTable .mq-margin-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#mqCompareTable .mq-margin-input { -moz-appearance: textfield; appearance: textfield; }
#mqCompareTable .mq-step:focus-within { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(13,148,136,.16); }
#mqCompareTable .mq-margin-input:focus { outline: none; }
body.dark #mqCompareTable .mq-step { background-color: #0F172A; border-color: #334155; }
body.dark #mqCompareTable .mq-step-btn { color: #94A3B8; }
body.dark #mqCompareTable .mq-step-btn:first-child,
body.dark #mqCompareTable .mq-step-btn:last-child { border-color: #334155; }
body.dark #mqCompareTable .mq-step-btn:hover { background-color: rgba(20,184,166,.16); color: #5EEAD4; }
body.dark #mqCompareTable .mq-step-btn:active { background-color: rgba(20,184,166,.26); }
body.dark #mqCompareTable .mq-step .mq-margin-input { color: #E2E8F0; }
body.dark #mqCompareTable .mq-step:focus-within { border-color: #5EEAD4; box-shadow: 0 0 0 2px rgba(94,234,212,.16); }
/* 「最划算」的 ✓ 紧贴报价数字，不能甩到单元格最左边贴着毛利率框（容易被误读成勾选毛利） */
#mqCompareTable tbody td.mq-sp { justify-content: flex-end; }
#mqCompareTable tbody td.mq-sp .mq-sp-num { margin-left: 0; }
/* 表格多了一列，窄屏允许横向滑动，不压字 */
#multiQtyTable { overflow-x: auto; }
.best-badge { width: 14px; height: 14px; border-radius: 3px; background: var(--brand); box-shadow: none; font-size: 8px; }
#mqDetailPanel { margin-top: 8px; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }

/* Save dialog: flat utility panel, matching the page instead of a glass card. */
.modal-mask { padding: 18px; background: rgba(24, 24, 27, .38); backdrop-filter: blur(2px); }
.modal-card {
  width: 410px;
  max-width: 100%;
  max-height: calc(100vh - 36px);
  padding: 18px;
  overflow-y: auto;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .16);
  backdrop-filter: none;
  animation: none;
}
.modal-close { top: 9px; right: 9px; border: 1px solid transparent; color: var(--muted-3); font-family: var(--utility-mono); font-size: 13px; }
.modal-close:hover { border-color: var(--border); background: #f4f4f5; color: var(--ink); }
.modal-title { margin: 0 30px 3px 0; color: var(--ink); font-family: var(--utility-mono); font-size: 13px; font-weight: 650; }
.modal-sub { margin-bottom: 14px; color: var(--muted-3); font-size: 10px; }
.modal-form { gap: 8px; }
.modal-row { gap: 8px; }
.modal-row label { flex-basis: 68px; color: var(--muted); font-size: 10px; font-weight: 500; }
.modal-row input, .modal-row textarea,
.spec-group input, .gram-wrap, .paper-group select,
.flute-group input[type="text"], .flute-group select {
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--border-2);
  border-radius: 5px;
  background: #f4f4f5;
  color: var(--ink);
  box-shadow: none;
  font-family: var(--utility-mono);
  font-size: 10px;
  text-align: center;
}
.gram-wrap { padding: 0 8px; }
.gram-wrap input { min-height: 30px; color: var(--ink); font-family: var(--utility-mono); font-size: 10px; text-align: center; }
.modal-row input:focus, .modal-row textarea:focus,
.spec-group input:focus, .paper-group select:focus,
.flute-group input[type="text"]:focus, .flute-group select:focus {
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, .12);
}
.cross-label { color: var(--muted); font-family: var(--utility-mono); font-size: 9px; }
.modal-actions { gap: 7px; margin-top: 14px; }
.modal-actions button { min-height: 34px; padding: 7px 9px; border-radius: 5px; font-family: var(--utility-mono); font-size: 10px; font-weight: 600; }
#saveModal #btnModalConfirm {
  border: 1px solid var(--border-2);
  background: #fff;
  color: var(--muted);
}
#saveModal #btnModalConfirm:hover { border-color: #a1a1aa; background: #f4f4f5; color: var(--ink); }
.modal-input-err, .modal-input-err:focus,
.gram-wrap.modal-input-err { border-width: 1px !important; border-color: #ef4444 !important; background: #fef2f2 !important; box-shadow: 0 0 0 2px rgba(239, 68, 68, .1) !important; }

/* Utility buttons stay visible without floating orange blobs */
.fab-group { right: 12px; bottom: 16px; gap: 6px; }
.fab-btn, .fab-btn.fab-reset {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-2);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  box-shadow: none;
  animation: none;
  font-size: 13px;
}
.fab-btn:hover, .fab-btn.fab-reset:hover { transform: none; border-color: var(--brand); background: #f0fdf4; color: var(--brand-deep); box-shadow: none; }

/* Dialogs and secondary surfaces */
.modal-content, .panel, .sub-card, .press-group {
  border-color: var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: none;
}
.formula-detail, .formula-detail.open { background: #fafafa; }
.formula-toggle span { color: var(--brand-deep); }
.hist-table th { background: #f4f4f5; color: var(--muted); font-family: var(--utility-mono); }

/* Final typography scale: no UI text below 10px. */
.mode-tab, .field input, .field select, .stepper input { font-size: var(--text-control); }
.card h2, .toggle-head { font-size: var(--text-body); }
.field label, .surface-grid label, .switch-chip, .toggle-row { font-size: var(--text-small); }
.auto-tag { font-size: var(--text-meta); }
.btn, .btn-copy { font-size: var(--text-control); }
.btn-secondary, .btn-primary, .btn-confirm, .btn-cancel { font-size: var(--text-small); }
.btn-sm, .qb-btn, .action-btn, .tip-edit .action-btn { font-size: var(--text-meta); }
.result-header .rh-label,
.result-header .rh-sub,
.result-header .rh-tax,
.cost-chain .cc-label,
.cost-table th,
.cost-table .cat-header td,
.formula-toggle span,
#historyCard .stat-item .stat-label,
.history-table th,
.history-table .action-btn,
.no-result,
.footer,
.mq-hint,
#mqCompareTable thead th,
.modal-sub,
.modal-row label,
.cross-label { font-size: var(--text-meta); }
.cost-table .cat-header td { font-size: var(--text-meta) !important; }
.cost-table, .history-table, #mqCompareTable { font-size: var(--text-small); }
.formula-detail, .modal-row input, .modal-row textarea,
.spec-group input, .paper-group select, .flute-group input[type="text"],
.flute-group select, .gram-wrap input { font-size: var(--text-small); }
.modal-title, .panel-head h3, .pwd-body h3, .quote-box h3 { font-size: 13px; }
.modal-actions button { font-size: var(--text-small); }
.best-badge { width: 16px; height: 16px; font-size: var(--text-meta); }

/* Neutral dark mode — same hierarchy, without reviving the previous gradients. */
body.dark {
  --bg-1: #09090b;
  --bg-2: #111113;
  --bg-3: #18181b;
  --border: #27272a;
  --border-2: #3f3f46;
  --border-soft: #202023;
  --ink: #f4f4f5;
  --ink-2: #fafafa;
  --muted: #a1a1aa;
  --muted-2: #a1a1aa;
  --muted-3: #71717a;
  --card-bg: #111113;
  --card-bg-solid: #111113;
  color: var(--ink);
  background: #09090b;
  background-image: none;
}
body.dark::before { display: none; }
body.dark .card,
body.dark .mode-tabs,
body.dark .panel,
body.dark .pwd-panel,
body.dark .quote-box,
body.dark .modal-card,
body.dark .panel-head,
body.dark .panel-body,
body.dark .pwd-body,
body.dark .set-card,
body.dark .set-card.wide,
body.dark .set-card.danger,
body.dark .modal-content,
body.dark .sub-card,
body.dark .press-group {
  border-color: var(--border);
  background: #111113;
  color: var(--ink);
  box-shadow: none;
  backdrop-filter: none;
}
body.dark .card:hover { border-color: var(--border-2); box-shadow: none; }
body.dark .card h2,
body.dark .toggle-head,
body.dark .panel-head h3,
body.dark .pwd-body h3,
body.dark .modal-title,
body.dark .set-card h4,
body.dark .set-card.wide h4 { color: var(--ink); border-color: var(--border); }
body.dark .mode-tab { color: var(--muted); background: transparent; }
body.dark .mode-tab:hover { color: var(--ink); background: #18181b; }
body.dark .mode-tab.active { border-color: var(--border-2); background: #18181b; color: #4ade80; }
body.dark .field label,
body.dark .modal-row label,
body.dark .set-card .srow label { color: var(--muted); }
body.dark .field input,
body.dark .field select,
body.dark .toolbar-input,
body.dark .set-input,
body.dark .set-card .srow input,
body.dark .pwd-input,
body.dark .qb-textarea,
body.dark .modal-row input,
body.dark .modal-row textarea,
body.dark .spec-group input,
body.dark .gram-wrap,
body.dark .paper-group select,
body.dark .flute-group input[type="text"],
body.dark .flute-group select {
  border-color: var(--border-2);
  background-color: #18181b;
  color: var(--ink);
  box-shadow: none;
}
body.dark .field input:focus,
body.dark .field select:focus,
body.dark .toolbar-input:focus,
body.dark .modal-row input:focus,
body.dark .modal-row textarea:focus { border-color: #22c55e; background: #18181b; box-shadow: 0 0 0 2px rgba(34,197,94,.14); }
body.dark .field input[readonly], body.dark .field input:disabled { border-color: var(--border) !important; background: #111113 !important; color: #71717a !important; }
body.dark .stepper { border-color: var(--border-2); background: #18181b; }
body.dark .stepper button, body.dark .stepper input { color: var(--ink); background: transparent; }
body.dark .surface-grid label, body.dark .switch-chip,
body.dark .btn-secondary, body.dark .btn-cancel,
body.dark .btn-sm, body.dark .qb-btn, body.dark .action-btn,
body.dark .fab-btn, body.dark .fab-btn.fab-reset {
  border-color: var(--border-2) !important;
  background: #18181b !important;
  color: var(--muted) !important;
  box-shadow: none;
}
body.dark .btn.btn-sm,
body.dark .btn-sm.green,
body.dark .btn-sm.blue,
body.dark .btn-sm.orange,
body.dark .btn-sm.red,
body.dark .btn-sm.gray {
  box-shadow: none !important;
}
body.dark .btn-sm.green, body.dark .btn-sm.blue { border-color: #166534 !important; background: #052e16 !important; color: #4ade80 !important; }
body.dark .btn-sm.orange { border-color: #78350f !important; background: #2b1607 !important; color: #fbbf24 !important; }
body.dark .btn-sm.red { border-color: #7f1d1d !important; background: #2a0d0d !important; color: #f87171 !important; }
body.dark .btn,
body.dark .btn-copy,
body.dark .btn-primary,
body.dark .btn-confirm {
  border-color: #15803d;
  background: #16a34a;
  color: #fff;
  box-shadow: none;
}
body.dark .btn:hover,
body.dark .btn-copy:hover,
body.dark .btn-primary:hover,
body.dark .btn-confirm:hover { background: #15803d; box-shadow: none; }
body.dark .sticky-actions .row:first-child .btn:last-child {
  border-color: var(--border-2) !important;
  background: #18181b !important;
  color: var(--muted) !important;
  box-shadow: none !important;
}
body.dark #saveModal #btnModalConfirm { border-color: var(--border-2); background: #18181b; color: var(--muted); }
body.dark .field input.input-ok { border-color: #166534 !important; background: #052e16 !important; color: #dcfce7 !important; }
body.dark.carton-page .btn,
body.dark.carton-page .btn-copy,
body.dark.carton-page .btn-primary,
body.dark.carton-page .btn-confirm {
  border-color: #92400e;
  background: #b45309;
}
body.dark.carton-page .btn:hover,
body.dark.carton-page .btn-copy:hover,
body.dark.carton-page .btn-primary:hover,
body.dark.carton-page .btn-confirm:hover { background: #92400e; }
body.dark.carton-page .field input.input-ok { border-color: #a16207 !important; background: #2b1607 !important; color: #fef3c7 !important; }
body.dark.carton-page .btn-sm.green,
body.dark.carton-page .btn-sm.blue { border-color: #78350f !important; background: #2b1607 !important; color: #fbbf24 !important; }
body.dark .surface-grid label:has(input:checked), body.dark .switch-chip:has(input:checked) { border-color: #22c55e; background: #052e16; color: #4ade80; }
body.dark .sticky-actions { border-top-color: var(--border); background: rgba(9,9,11,.94); backdrop-filter: blur(8px); }
body.dark .result-header, body.dark .cost-table td, body.dark #mqCompareTable tbody tr,
body.dark #mqCompareTable tbody tr:nth-child(even), body.dark .history-table td { background: #111113; color: var(--ink); }
body.dark .cost-chain, body.dark .cost-table th, body.dark .cost-table .cat-header td,
body.dark #mqCompareTable thead th, body.dark .history-table th,
body.dark #historyCard .stats-bar, body.dark .formula-detail,
body.dark .mq-hint, body.dark .panel-foot { border-color: var(--border); background: #18181b; color: var(--muted); }
body.dark .cost-table .total-row, body.dark #mqCompareTable tbody tr.mq-sel { background: #052e16; }
body.dark .result-placeholder { border-color: var(--border); border-left-color: #22c55e; background: #111113; }
body.dark .result-placeholder.ph-missing { border-left-color: #F59E0B; }
body.dark .result-placeholder.ph-missing .ph-title::before { color: #FBBF24; }
body.dark .modal-mask, body.dark .overlay { background: rgba(0,0,0,.64); backdrop-filter: blur(2px); }
body.dark .footer { color: var(--muted-3); }

/* 2026-11-19 方案A门槛修正：735→759。735 只保证字段单行排得下，但 736~759 这段
   「自动」徽章会掉到标签第二行（exe/WebView2 字体渲染比浏览器偏宽，浏览器探不出来），
   标签区参差不齐。门槛改按「徽章稳稳同行」的最宽需求 760 留 1px 余量：
   <760 齐步换两列紧凑版，≥760（含 ↔ 竖屏挡位）才是宽版。 */
@media (max-width: 759px) {
  .field { min-width: calc(50% - 6px); }
}

@media (max-width: 680px) {
  body { padding: 10px 9px 28px; }
  .card { padding: 14px 12px; }
  .container { max-width: 100%; }
  .mode-tab { padding: 9px 8px; font-size: 11px; }
}

/* 2026-11-06 撤除：远程桌面 / 部分浏览器与系统「优化动画」工具会把 prefers-reduced-motion
   误报成 reduce，一旦生效会把整页动画与过渡（卡片淡入、阶梯行淡入、按钮悬停、toast 滑出）
   全部静默关掉，用户体感就是「所有动画都消失了」。本项目是内部单用户工具，动画均为装饰性，
   故恒定保留。日后若要做无障碍开关，请做成用户可选项，不要用媒体查询硬关。
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
*/

/* ===== Typography & dark palette refinement ===== */
/* Keep Chinese text soft and readable; use tabular figures instead of a monospace face. */
button, input, select, textarea { font-family: var(--ui-font); }
.cost-table td.num, .stat-item .stat-num, .history-table .col-num,
.result-header .rh-total, .cost-chain .cc-val { font-variant-numeric: tabular-nums; }
.card h2, .toggle-head { font-size: 15px; font-weight: 600; }
.field label, .surface-grid label, .switch-chip, .toggle-row { font-size: 12px; font-weight: 400; }
.field input, .field select, .stepper input, .mode-tab, .btn, .btn-copy { font-size: 13px; }
.result-header .rh-label, .cost-chain .cc-label, .cost-table th,
.formula-toggle span, #historyCard .stat-item .stat-label,
.history-table th, #mqCompareTable thead th { font-size: 11px; }
.result-header .rh-sub, .result-header .rh-tax, .formula-detail,
.modal-sub, .modal-row label, .set-card .srow label { font-size: 12px; }
.cost-table, .history-table, #mqCompareTable { font-size: 12px; line-height: 1.5; }
.modal-title, .panel-head h3, .pwd-body h3, .quote-box h3 { font-size: 15px; font-weight: 600; }
.modal-row input, .modal-row textarea, .spec-group input, .paper-group select,
.flute-group input[type="text"], .flute-group select, .gram-wrap input,
.modal-actions button { font-size: 12px; }
.result-placeholder .ph-title::before, .result-placeholder .ph-sub,
.cost-table .cat-header td, .formula-detail .fhead,
#historyCard .toolbar-input, #historyCard .toolbar-btn,
#historyCard #selectedCount, .history-table .action-btn,
.no-result, .footer, .set-card h5, .press-size,
.cross-label, .best-badge { font-size: 11px !important; }
.set-card .srow label, .set-card .srow input, .set-input,
.pwd-input, .qb-textarea, .mq-hint, .panel-foot { font-size: 12px; }

body.dark {
  --bg-1: #000000;
  --bg-2: #111111;
  --bg-3: #181818;
  --border: #222222;
  --border-2: #303034;
  --border-soft: #1a1a1a;
  --ink: #ededef;
  --ink-2: #f5f5f6;
  --muted: #8a8a97;
  --muted-2: #707079;
  --muted-3: #56565f;
  --card-bg: #111111;
  --card-bg-solid: #111111;
  background: var(--bg-1);
}
body.dark .card, body.dark .mode-tabs, body.dark .panel,
body.dark .pwd-panel, body.dark .quote-box, body.dark .modal-card,
body.dark .panel-head, body.dark .panel-body, body.dark .pwd-body,
body.dark .set-card, body.dark .set-card.wide, body.dark .set-card.danger,
body.dark .modal-content, body.dark .sub-card, body.dark .press-group,
body.dark .result-header, body.dark .cost-table td,
body.dark #mqCompareTable tbody tr, body.dark .history-table td {
  border-color: var(--border);
  background: var(--bg-2);
}
body.dark .field input, body.dark .field select, body.dark .toolbar-input,
body.dark .set-input, body.dark .set-card .srow input, body.dark .pwd-input,
body.dark .qb-textarea, body.dark .modal-row input, body.dark .modal-row textarea,
body.dark .spec-group input, body.dark .gram-wrap, body.dark .paper-group select,
body.dark .flute-group input[type="text"], body.dark .flute-group select,
body.dark .stepper { border-color: var(--border-2); background: var(--bg-3); color: var(--ink); }
body.dark .field input[readonly], body.dark .field input:disabled {
  border-color: var(--border) !important; background: var(--bg-2) !important; color: var(--muted-3) !important;
}
body.dark .field input.input-ok,
body.dark.carton-page .field input.input-ok {
  border-color: var(--brand) !important; background: var(--bg-3) !important; color: var(--ink) !important;
}
body.dark .surface-grid label, body.dark .switch-chip,
body.dark .btn-secondary, body.dark .btn-cancel, body.dark .btn-sm,
body.dark .qb-btn, body.dark .action-btn, body.dark .fab-btn,
body.dark .fab-btn.fab-reset, body.dark .btn-sm.green,
body.dark .btn-sm.blue, body.dark .btn-sm.orange,
body.dark.carton-page .btn-sm.green, body.dark.carton-page .btn-sm.blue {
  border-color: var(--border-2) !important; background: var(--bg-3) !important; color: var(--muted) !important;
}
body.dark .surface-grid label:has(input:checked) {
  border-color: var(--brand) !important; background: var(--bg-3) !important; color: var(--ink) !important;
}
/* 工序开关在暗色模式下必须一眼分清开/关，避免被上方通用按钮规则覆盖。 */
body.dark .switch-chip {
  border-color: #3f3f46 !important;
  background: #18181b !important;
  color: #a1a1aa !important;
  box-shadow: none !important;
}
body.dark .switch-chip > span::before {
  content: '○';
  display: inline-block;
  width: 14px;
  margin-right: 4px;
  color: #71717a;
  text-align: center;
}
body.dark .switch-chip:has(input:checked) {
  border-color: #22c55e !important;
  background: #052e16 !important;
  color: #dcfce7 !important;
  box-shadow: inset 0 0 0 1px rgba(34,197,94,.16) !important;
}
body.dark .switch-chip:has(input:checked) > span::before {
  content: '✓';
  color: #4ade80;
  font-weight: 700;
}
body.dark .switch-chip:hover {
  border-color: #71717a !important;
  color: #e4e4e7 !important;
}
body.dark .switch-chip:has(input:checked):hover {
  border-color: #4ade80 !important;
  color: #f0fdf4 !important;
}

/* 报价资料是独立的可选浮层，不占用表单高度，也不与保存动作绑定。 */
.quote-meta-menu { position: relative; flex: 0 0 88px; min-width: 88px; }
.quote-meta-menu > summary { display: flex; width: 100%; min-height: 40px; align-items: center; justify-content: center; gap: 6px; padding: 9px 10px; border: 1px solid var(--border-2); border-radius: 6px; background: #fafafa; color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 500; list-style: none; }
.quote-meta-menu > summary::-webkit-details-marker { display: none; }
.quote-meta-menu > summary i { width: 6px; height: 6px; border-radius: 50%; background: var(--border-2); }
.quote-meta-menu > summary i.has-data { background: var(--brand); box-shadow: 0 0 0 2px rgba(22,163,74,.12); }
.quote-meta-menu[open] > summary, .quote-meta-menu > summary:hover { border-color: var(--brand); background: #f0fdf4; color: var(--brand-deep); }
.quote-meta-popover { position: absolute; z-index: 160; right: 0; bottom: calc(100% + 8px); width: min(540px, calc(100vw - 112px)); max-height: min(70vh, 620px); overflow: auto; border: 1px solid var(--border-2); border-radius: 8px; background: #fff; box-shadow: 0 14px 38px rgba(0,0,0,.16); }
.quote-meta-popover-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.quote-meta-popover-head b { color: var(--ink); font-size: 13px; font-weight: 600; }
.quote-meta-popover-head span { color: var(--muted-3); font-size: 10px; }
.quote-meta-form { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px 14px; padding: 12px 14px 14px; }
.quote-meta-form > label { display: grid; min-width: 0; gap: 5px; color: var(--muted); font-size: 11px; }
.quote-meta-form > label > input, .quote-meta-form > label > textarea { width: 100%; min-width: 0; min-height: 36px; padding: 7px 9px; border: 1px solid var(--border-2); border-radius: 6px; outline: 0; background: #f4f4f5; color: var(--ink); font-family: var(--ui-font); font-size: 12px; }
.quote-meta-form > label > textarea { resize: vertical; }
.quote-meta-form input:focus, .quote-meta-form select:focus, .quote-meta-form textarea:focus, .quote-meta-form .gram-wrap:focus-within { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 2px rgba(22,163,74,.12); }
.quote-meta-wide { grid-column: 1 / -1; }
.quote-meta-form .spec-group i, .quote-meta-form .gram-wrap i { color: var(--muted-3); font-style: normal; font-size: 10px; }
.quote-meta-form .spec-group input, .quote-meta-form .paper-group select, .quote-meta-form .flute-group input[type="text"], .quote-meta-form .flute-group select, .quote-meta-form .gram-wrap { min-height: 36px; border-width: 1px; border-color: var(--border-2); background: #f4f4f5; color: var(--ink); font-family: var(--ui-font); font-size: 12px; }
.quote-meta-form .quote-meta-check { display: inline-flex; min-height: 36px; align-items: center; gap: 5px; padding: 0 7px; border: 1px solid var(--border-2); border-radius: 6px; color: var(--muted); white-space: nowrap; }
/* 克重只读镜像：值来自报价面纸板块，弱化显示且不可输入 */
.quote-meta-form .gram-wrap input[readonly] { color: var(--muted-3); cursor: default; user-select: text; }
.quote-meta-form .gram-wrap:focus-within:has(input[readonly]) { border-color: var(--border-2); box-shadow: none; }
/* 客户名称候选：覆盖在下方内容之上（脱离文档流），不撑高同行控件、不推动其它字段 */
.quote-meta-form > label { position: relative; }
.quote-meta-form > label > .client-suggest { display: none; position: absolute; left: 0; right: 0; top: 100%; z-index: 6; max-height: 168px; overflow: auto; margin-top: 4px; padding: 3px; border: 1px solid var(--border-2); border-radius: 6px; background: var(--bg-1); box-shadow: 0 6px 16px rgba(0,0,0,.08); }
.quote-meta-form > label > .client-suggest.on { display: block; }
.client-suggest-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; border-radius: 4px; color: var(--ink); font-size: 12px; line-height: 1.4; cursor: pointer; }
.client-suggest-item:hover, .client-suggest-item.hl { background: var(--bg-3); color: var(--brand-deep); }
.client-suggest-item .cs-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-suggest-item .cs-meta { flex: 0 0 auto; color: var(--muted-3); font-size: 10px; }
.client-suggest-empty { padding: 7px 8px; color: var(--muted-3); font-size: 11px; line-height: 1.4; }
body.dark .quote-meta-form > label > .client-suggest { background: #1E293B; border-color: #334155; box-shadow: 0 10px 24px rgba(0,0,0,.5); }
body.dark .client-suggest-item { color: #E2E8F0; }
body.dark .client-suggest-item:hover, body.dark .client-suggest-item.hl { background: rgba(20,184,166,.16); color: #5EEAD4; }
.quote-meta-form .quote-meta-check input { width: 14px; height: 14px; margin: 0; accent-color: var(--brand); }
body.dark .quote-meta-menu > summary { border-color: var(--border-2); background: var(--bg-3); color: var(--muted); }
body.dark .quote-meta-menu[open] > summary, body.dark .quote-meta-menu > summary:hover { border-color: var(--brand); background: #10261a; color: var(--brand-2); }
body.dark .quote-meta-menu > summary i.has-data { background: var(--brand-2); }
body.dark .quote-meta-popover { border-color: var(--border-2); background: var(--bg-2); box-shadow: 0 16px 42px rgba(0,0,0,.5); }
body.dark .quote-meta-popover-head { border-color: var(--border); }
body.dark .quote-meta-form > label > input, body.dark .quote-meta-form > label > textarea,
body.dark .quote-meta-form .spec-group input, body.dark .quote-meta-form .paper-group select,
body.dark .quote-meta-form .flute-group input[type="text"], body.dark .quote-meta-form .flute-group select,
body.dark .quote-meta-form .gram-wrap, body.dark .quote-meta-form .quote-meta-check { border-color: var(--border-2); background: var(--bg-3); color: var(--ink); }
@media (max-width: 620px) {
  .quote-meta-form { grid-template-columns: 1fr; }
  .quote-meta-wide { grid-column: 1; }
  .quote-meta-popover { position: fixed; right: 10px; bottom: 74px; left: 10px; width: auto; max-height: 72vh; }
}

body.dark .cost-chain, body.dark .cost-table th,
body.dark .cost-table .cat-header td, body.dark #mqCompareTable thead th,
body.dark .history-table th, body.dark #historyCard .stats-bar,
body.dark .formula-detail, body.dark .mq-hint, body.dark .panel-foot {
  border-color: var(--border); background: var(--bg-3); color: var(--muted);
}
body.dark .cost-table .total-row, body.dark #mqCompareTable tbody tr.mq-sel {
  background: var(--bg-3); box-shadow: inset 3px 0 0 var(--brand);
}
body.dark .result-placeholder { border-color: var(--border); border-left-color: var(--brand); background: var(--bg-2); }
body.dark .sticky-actions { border-top-color: var(--border); background: rgba(0,0,0,.94); }
body.dark input, body.dark select, body.dark textarea { color-scheme: dark; }
body.dark .modal-close:hover { border-color: var(--border); background: var(--bg-3); color: var(--ink); }
body.dark .modal-input-err, body.dark .modal-input-err:focus,
body.dark .gram-wrap.modal-input-err {
  border-color: #7f1d1d !important;
  background: #1c1010 !important;
  color: #fecaca !important;
  box-shadow: 0 0 0 2px rgba(239,68,68,.10) !important;
}
body.dark ::-webkit-scrollbar { width: 10px; height: 10px; }
body.dark ::-webkit-scrollbar-track { background: #000; }
body.dark ::-webkit-scrollbar-thumb { border: 2px solid #000; border-radius: 10px; background: #303034; }
body.dark ::-webkit-scrollbar-thumb:hover { background: #3f3f46; }

/* ===== Complete component color audit ===== */
body.dark .toggle input:checked + .toggle-track,
body.dark .toggle-row.t-green .toggle input:checked + .toggle-track,
body.dark .toggle-row.t-purple .toggle input:checked + .toggle-track,
body.dark .toggle-row.t-red .toggle input:checked + .toggle-track,
body.dark .toggle-row.t-orange .toggle input:checked + .toggle-track {
  border-color: var(--brand) !important;
  background: var(--brand) !important;
  box-shadow: none !important;
}
body.dark .unit-select, body.dark .unit-select.unit-green,
body.dark .unit-select.unit-orange, body.dark .field select.unit-select {
  border-color: var(--border-2) !important;
  background-color: var(--bg-3) !important;
  color: var(--ink) !important;
  box-shadow: none !important;
}
#historyCard .stat-item::before,
#historyCard .stat-item::after { display: none !important; }
body.dark #historyCard .stat-item .stat-num { color: var(--ink) !important; }
body.dark #historyCard .stat-item.accent .stat-num { color: var(--brand-2) !important; }
body.dark .cust-tag, body.dark .cust-tag.c0, body.dark .cust-tag.c1,
body.dark .cust-tag.c2, body.dark .cust-tag.c3,
body.dark .cust-tag.c4, body.dark .cust-tag.c5 {
  border: 1px solid var(--border-2) !important;
  background: var(--bg-3) !important;
  color: var(--muted) !important;
}
body.dark .cb-check { border-color: var(--border-2) !important; background: var(--bg-3) !important; accent-color: var(--brand); }
body.dark .cb-check:checked { border-color: var(--brand) !important; background: var(--brand) !important; }
body.dark .history-table .action-btn,
body.dark .history-table .action-btn.exp {
  border-color: var(--border-2) !important;
  background: var(--bg-3) !important;
  color: var(--muted) !important;
}
body.dark .history-table .action-btn:hover,
body.dark .history-table .action-btn.exp:hover {
  border-color: var(--brand) !important;
  background: var(--bg-3) !important;
  color: var(--brand-2) !important;
}
body.dark .history-table .action-btn.del {
  border-color: #5f2525 !important;
  background: var(--bg-3) !important;
  color: #f87171 !important;
}
body.dark .foot-update, body.dark .footer { border-color: var(--border); color: var(--muted-3); }

/* ===== Sidebar workspace + quote history redesign ===== */
@media (min-width: 681px) {
  body { padding-left: 146px; }
  .mode-tabs {
    position: fixed; z-index: 120; inset: 0 auto 0 0;
    width: 128px; margin: 0; padding: 16px 10px;
    display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 5px;
    border: 0; border-right: 1px solid var(--border); border-radius: 0; background: #fafafa;
  }
  .mode-tab { flex: 0 0 auto; width: 100%; min-height: 38px; padding: 0 8px; display: flex; align-items: center; gap: 8px; border: 0; text-align: left; }
  .mode-tab.active { margin: 0; border: 0; background: #eaf7ef; color: var(--brand-deep); box-shadow: inset 3px 0 0 var(--brand); }
}
.side-brand { display: flex; align-items: center; gap: 8px; margin: 0 2px 13px; padding: 0 2px 14px; border-bottom: 1px solid var(--border); }
.side-brand b { display: grid; width: 28px; height: 28px; place-items: center; border-radius: 8px; background: var(--ink); color: #fff; font-size: 12px; }
.side-brand span { color: var(--ink); font-size: 12px; font-weight: 600; }
.nav-icon { display: grid; flex: 0 0 auto; width: 23px; height: 23px; place-items: center; border-radius: 6px; background: #ededee; color: var(--muted); font-size: 9px; font-weight: 600; }
.mode-tab.active .nav-icon { background: var(--brand); color: #fff; }
body.quote-mode #historyCard { display: none; }
body.records-mode #quoteWorkspace, body.records-mode .fab-group { display: none; }
body.records-mode #historyCard { display: block; min-height: calc(100vh - 56px); }
.history-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.history-heading h2 { min-height: 0; margin: 2px 0 0; padding: 0; border: 0; font-size: 18px; }
.history-heading > div > span { color: var(--muted-3); font-size: 10px; }
.history-heading > button { min-height: 34px; padding: 0 13px; border: 1px solid var(--brand); border-radius: 6px; background: var(--brand); color: #fff; cursor: pointer; font-size: 11px; }
.editing-banner { position: sticky; z-index: 80; top: 8px; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; padding: 10px 12px; border: 1px solid #86efac; border-radius: 7px; background: #f0fdf4; box-shadow: 0 4px 14px rgba(0,0,0,.06); }
.editing-banner > div:first-child { display: grid; gap: 2px; }.editing-banner span { color: var(--muted); font-size: 10px; }.editing-banner strong { font-size: 12px; }
.editing-banner > div:last-child { display: flex; gap: 6px; }.editing-banner button { min-height: 30px; padding: 0 9px; border: 1px solid var(--border-2); border-radius: 5px; background: #fff; color: var(--muted); cursor: pointer; font-size: 10px; }.editing-banner button:first-child { border-color: var(--brand); background: var(--brand); color: #fff; }
.history-table .col-name strong, .history-table .col-name small { display: block; }.history-table .col-name strong { color: var(--ink); font-size: 12px; font-weight: 600; }.history-table .col-name small { margin-top: 2px; color: var(--muted-3); font-size: 10px; }
.history-table th.col-num, .history-table td.col-num { text-align: left; }
.history-table .history-row { cursor: pointer; }.history-table .history-row.no-client { }.history-table .history-row.selected { background: #f0fdf4; outline: 2px solid var(--brand); outline-offset: -2px; }.history-table .quote-unit { color: var(--brand-deep); font-weight: 600; }
/* 色条：用 td:first-child::before 画圆角竖条（圆润），兼容 border-collapse */
.history-table .history-row td:first-child { position: relative; }
.history-table .history-row td:first-child::before {
  content: '';
  position: absolute;
  left: 0; top: 7px; bottom: 7px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--dot, hsl(var(--h, 170), var(--s, 60%), var(--l, 50%)));
}
.history-table .history-row.no-client td:first-child::before { background: #94A3B8; }
.history-table .detail-row > td { padding: 4px 8px 12px; background: #f0fdf4; border-bottom: 1px solid var(--border-soft); }
.history-table .detail-row .history-detail { margin-top: 0; }
/* ===== T-03 报价记录增强 ===== */
.client-color-list { max-height:240px; overflow-y:auto; border:1px solid var(--border); border-radius:8px; padding:6px; margin-top:6px; }
.cc-row { display:flex; align-items:center; gap:6px; flex-wrap:wrap; padding:6px 4px; border-bottom:1px dashed var(--border); }
.cc-row:last-child { border-bottom:none; }
.cc-name { min-width:96px; max-width:160px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-weight:600; font-size:0.86rem; margin-right:4px; }
.cc-swatch { width:22px; height:22px; border-radius:6px; border:2px solid transparent; cursor:pointer; padding:0; font-size:0.6rem; color:#fff; line-height:1; flex:0 0 auto; }
.cc-swatch.auto { background:#94A3B8; color:#0f172a; font-weight:700; min-width:34px; }
.cc-swatch.selected { border-color:#0f172a; box-shadow:0 0 0 2px #fff,0 0 0 4px #14B8A6; }
body.dark .cc-swatch.selected { border-color:#fff; box-shadow:0 0 0 2px #0f172a,0 0 0 4px #5EEAD4; }
.history-table .col-handle { width:28px; text-align:center; color:var(--muted-3); cursor:grab; user-select:none; font-size:13px; line-height:1; }
.history-table .col-handle:active { cursor:grabbing; }
.history-table .history-row.drag-over > td { box-shadow: inset 0 2px 0 var(--brand); background:#ecfeff; }
.history-table .history-row.drag-src { opacity:.4; }
.resume-banner { border-color:#fca5a5; background:#fef2f2; }
.resume-banner strong { color:#b91c1c; }
.resume-banner button:first-child { border-color:#dc2626; background:#dc2626; }
body.dark .resume-banner { border-color:#7f1d1d; background:#1a0c0c; }
body.dark .history-table .detail-row > td { background: var(--bg-3); }
.history-detail { margin-top: 10px; padding: 15px; border: 1px solid var(--border-2); border-radius: 7px; background: #fafafa; }
.detail-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 11px; border-bottom: 1px solid var(--border); }.detail-head span { color: var(--muted-3); font-size: 10px; }.detail-head h3 { margin: 2px 0 0; font-size: 14px; }.detail-head > button { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 10px; }
.detail-summary { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 1px; margin-top: 12px; overflow: hidden; border: 1px solid var(--border); border-radius: 6px; background: var(--border); }.detail-summary div { display: grid; gap: 4px; padding: 9px; background: #fff; text-align: center; }.detail-summary span { color: var(--muted-3); font-size: 9px; }.detail-summary b { font-size: 12px; font-variant-numeric: tabular-nums; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 7px 16px; margin-top: 11px; color: var(--muted); font-size: 10px; }.detail-remark { margin: 10px 0 0; padding: 9px 10px; border-left: 2px solid var(--brand); background: #fff; color: var(--muted); font-size: 11px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 13px; }.detail-actions button { min-height: 32px; padding: 0 11px; border: 1px solid var(--border-2); border-radius: 5px; background: #fff; color: var(--muted); cursor: pointer; font-size: 10px; }.detail-actions .primary { border-color: var(--brand); background: var(--brand); color: #fff; }.detail-actions .danger { margin-left: auto; border-color: #dc2626 !important; background: #dc2626 !important; color: #fff !important; }
.detail-actions .danger:hover { border-color: #b91c1c !important; background: #b91c1c !important; color: #fff !important; }
.modal-more { margin: 10px 0; padding: 0 10px 9px; border: 1px solid var(--border); border-radius: 6px; background: #fafafa; }.modal-more summary { padding: 9px 0; color: var(--muted); cursor: pointer; font-size: 11px; }.modal-more .modal-row:first-of-type { margin-top: 2px; }
body.dark .mode-tabs, body.dark .history-detail, body.dark .modal-more { border-color: var(--border); background: var(--bg-2); }
body.dark .side-brand { border-color: var(--border); } body.dark .side-brand b { background: var(--ink); color: #111; } body.dark .side-brand span { color: var(--ink); }
body.dark .nav-icon { background: var(--bg-3); color: var(--muted); } body.dark .mode-tab.active { background: var(--bg-3); color: var(--brand-2); box-shadow: inset 3px 0 0 var(--brand); } body.dark .mode-tab.active .nav-icon { background: var(--brand); color: #fff; }
body.dark .editing-banner { border-color: #14532d; background: #0d1a12; } body.dark .editing-banner button, body.dark .detail-summary div, body.dark .detail-remark, body.dark .detail-actions button { border-color: var(--border-2); background: var(--bg-3); color: var(--muted); }
body.dark .editing-banner button:first-child, body.dark .detail-actions .primary { border-color: var(--brand); background: var(--brand); color: #fff; }
body.dark .detail-actions .danger { border-color: #ef4444 !important; background: #7f1d1d !important; color: #fee2e2 !important; }
body.dark .detail-actions .danger:hover { border-color: #f87171 !important; background: #991b1b !important; color: #fff !important; }
 body.dark .history-table .history-row.selected { background: var(--bg-3); } body.dark .history-table .history-row td:first-child::before { background: var(--dot, hsl(var(--h, 170), var(--s, 60%), calc(var(--l, 50%) + 7%))); } body.dark .history-table .history-row.no-client td:first-child::before { background: #475569; } body.dark .detail-summary { border-color: var(--border); background: var(--border); }
@media (max-width: 680px) {
  .side-brand { display: none; }
  .mode-tabs { display: flex; flex-direction: row; }
  .mode-tab { flex: 1; justify-content: center; text-align: center; }
  .nav-icon { display: none; }
  .detail-summary { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 680px) {
  .history-table th:nth-child(3), .history-table td:nth-child(3), .history-table th:nth-child(4), .history-table td:nth-child(4) { display: none; }
  .editing-banner { position: static; align-items: stretch; flex-direction: column; }
  .editing-banner > div:last-child { display: grid; grid-template-columns: 1fr 1fr 1fr; }
}
body.dark .auto-tag, body.dark .auto-tag[data-mode="auto"],
body.dark .auto-tag[data-mode="manual"] {
  border-color: var(--border-2) !important;
  background: var(--bg-3) !important;
  color: var(--muted) !important;
}
/* 「无损耗」在暗色下也保持醒目，不被上面的中性灰覆盖 */
body.dark .auto-tag[data-mode="zero"] {
  border-color: #C2410C !important;
  background: #9A3412 !important;
  color: #FFEDD5 !important;
}
body.dark .cost-table .cat-header.cat-material,
body.dark .cost-table .cat-header.cat-print,
body.dark .cost-table .cat-header.cat-process,
body.dark .cost-table .cat-header.cat-other,
body.dark .cost-table .cat-header.cat-accessory,
body.dark .cost-table .cat-header.cat-outsource {
  border-color: var(--border) !important;
  background: var(--bg-3) !important;
  color: var(--muted) !important;
}
body.dark .cost-chain .cc-val.accent,
body.dark .cost-table .total-row .total-val,
body.dark .formula-detail .fsum.total .flabel,
body.dark .formula-detail .fsum.total .fval { color: var(--brand-2) !important; }

/* Two-piece setup follows the same neutral card in both themes. */
.two-piece-card {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-3);
  color: var(--ink);
}
.two-piece-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}
.two-piece-card > div:nth-child(2),
.two-piece-card > div:nth-child(2) label { color: var(--muted); }
.two-piece-card input[type="radio"] { accent-color: var(--brand); }
.two-piece-card .toggle-row { color: var(--muted); }
.two-piece-card .toggle-row:has(input:disabled) { opacity: .55; }
body.dark .two-piece-card {
  border-color: var(--border);
  background: var(--bg-2);
  color: var(--ink);
}
body.dark .two-piece-head { color: var(--ink); }
body.dark .two-piece-card > div:nth-child(2),
body.dark .two-piece-card > div:nth-child(2) label,
body.dark .two-piece-card .toggle-row { color: var(--muted); }

/* ===== Final navigation: separate desktop rail and mobile tabs ===== */
.desktop-nav { display: none; }
.mobile-nav { display: none; }
@media (min-width: 421px) {
  body { padding-left: 76px; }
  .desktop-nav {
    position: fixed;
    z-index: 120;
    inset: 0 auto 0 0;
    display: flex;
    width: 58px;
    padding: 16px 9px;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    border-right: 1px solid var(--border);
    background: #fafafa;
  }
  .desktop-brand {
    display: grid;
    width: 32px;
    height: 32px;
    margin-bottom: 8px;
    place-items: center;
    border-radius: 9px;
    background: #18181b;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
  }
  .desktop-nav-btn {
    display: grid;
    width: 36px;
    height: 36px;
    padding: 0;
    flex: 0 0 36px;
    place-items: center;
    border: 1px solid transparent;
    border-radius: 9px;
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
  }
  .desktop-nav-btn.nav-color { border-color: #bbf7d0; background: #dcfce7; color: #15803d; }
  .desktop-nav-btn.nav-carton { border-color: #fed7aa; background: #ffedd5; color: #c2410c; }
  .desktop-nav-btn.nav-record { border-color: #bfdbfe; background: #dbeafe; color: #1d4ed8; }
  .desktop-nav-btn.nav-client { border-color: #e9d5ff; background: #f3e8ff; color: #7e22ce; }
  .desktop-nav-btn.nav-color:hover, .desktop-nav-btn.nav-color.active { background: #16a34a; color: #fff; }
  .desktop-nav-btn.nav-carton:hover, .desktop-nav-btn.nav-carton.active { background: #f97316; color: #fff; }
  .desktop-nav-btn.nav-record:hover, .desktop-nav-btn.nav-record.active { background: #3b82f6; color: #fff; }
  .desktop-nav-btn.nav-client:hover, .desktop-nav-btn.nav-client.active { background: #9333ea; color: #fff; }
}
@media (max-width: 420px) {
  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    margin-bottom: 12px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f4f4f5;
  }
  .mobile-nav a { padding: 8px 4px; border-radius: 6px; color: var(--muted); text-align: center; text-decoration: none; font-size: 11px; }
  .mobile-nav a.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
}
body.dark .desktop-nav { border-color: var(--border); background: var(--bg-2); }
body.dark .desktop-brand { background: var(--ink); color: #111; }
body.dark .desktop-nav-btn.nav-color { border-color: #14532d; background: #123522; color: #86efac; }
body.dark .desktop-nav-btn.nav-carton { border-color: #7c2d12; background: #3b2617; color: #fdba74; }
body.dark .desktop-nav-btn.nav-record { border-color: #1e3a8a; background: #172b4d; color: #93c5fd; }
body.dark .desktop-nav-btn.nav-client { border-color: #581c87; background: #2E1A47; color: #d8b4fe; }
body.dark .desktop-nav-btn.nav-color:hover, body.dark .desktop-nav-btn.nav-color.active { background: #16a34a; color: #fff; }
body.dark .desktop-nav-btn.nav-carton:hover, body.dark .desktop-nav-btn.nav-carton.active { background: #ea580c; color: #fff; }
body.dark .desktop-nav-btn.nav-record:hover, body.dark .desktop-nav-btn.nav-record.active { background: #2563eb; color: #fff; }
body.dark .desktop-nav-btn.nav-client:hover, body.dark .desktop-nav-btn.nav-client.active { background: #9333ea; color: #fff; }
body.dark .mobile-nav { border-color: var(--border); background: var(--bg-2); }
body.dark .mobile-nav a.active { background: var(--bg-3); color: var(--ink); }

@media (min-width: 421px) {
  .desktop-nav-tools { display: flex; margin-top: auto; flex-direction: column; gap: 6px; }
  .desktop-nav-tools button {
    display: grid;
    width: 34px;
    height: 34px;
    padding: 0;
    place-items: center;
    border: 1px solid var(--border-2);
    border-radius: 9px;
    background: #fff;
    color: var(--muted);
    box-shadow: none;
    cursor: pointer;
    font-family: var(--ui-font);
    font-size: 12px;
    line-height: 1;
  }
  .desktop-nav-tools button:hover { border-color: #a1a1aa; background: #f4f4f5; color: var(--ink); }
  .desktop-nav-tools .nav-tool-settings::before { content: "⚙"; font-family: "Segoe UI Symbol", "Microsoft YaHei UI", sans-serif; font-size: 16px; line-height: 1; }
  .fab-group { display: none !important; }
  .mobile-footer-action { display: none !important; }
}
body.dark .desktop-nav-tools button { border-color: var(--border-2); background: var(--bg-3); color: var(--muted); }
body.dark .desktop-nav-tools button:hover { border-color: #52525b; background: #27272a; color: var(--ink); }

.output-menu { position: relative; flex: 1; min-width: 108px; }
.output-menu summary { display: grid; min-height: 40px; padding: 9px 14px; place-items: center; border: 1px solid var(--border-2); border-radius: 6px; background: #fafafa; color: var(--muted); cursor: pointer; font-size: 13px; font-weight: 500; list-style: none; }
.output-menu summary::-webkit-details-marker { display: none; }
.output-menu summary::after { content: "⌄"; margin-left: 7px; color: var(--muted-3); }
.output-menu[open] summary { border-color: var(--brand); color: var(--ink); }
.output-menu-list { position: absolute; z-index: 140; right: 0; bottom: calc(100% + 6px); display: grid; width: 132px; padding: 5px; border: 1px solid var(--border-2); border-radius: 7px; background: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.output-menu-list button { min-height: 34px; padding: 7px 10px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); cursor: pointer; text-align: left; font-size: 12px; }
.output-menu-list button:hover { background: #f4f4f5; color: var(--ink); }
body.dark .output-menu summary, body.dark .output-menu-list { border-color: var(--border-2); background: var(--bg-3); color: var(--muted); }
body.dark .output-menu-list button { color: var(--muted); }
body.dark .output-menu-list button:hover { background: #27272a; color: var(--ink); }

.record-output { position: relative; }
.record-output summary { display: grid; min-height: 32px; padding: 0 11px; place-items: center; border: 1px solid var(--border-2); border-radius: 5px; background: #fff; color: var(--muted); cursor: pointer; font-size: 10px; list-style: none; }
.record-output summary::-webkit-details-marker { display: none; }
.record-output > div { position: absolute; z-index: 20; bottom: calc(100% + 5px); left: 0; display: grid; width: 105px; padding: 4px; border: 1px solid var(--border-2); border-radius: 6px; background: #fff; box-shadow: 0 7px 20px rgba(0,0,0,.12); }
.detail-actions .record-output > div > button { min-height: 30px; border: 0; background: transparent; text-align: left; }
.detail-actions .record-output > div > button:hover { background: #f4f4f5; }
body.dark .record-output summary, body.dark .record-output > div { border-color: var(--border-2); background: var(--bg-3); color: var(--muted); }
body.dark .detail-actions .record-output > div > button:hover { background: #27272a; }

/* 阶梯：鼠标悬停弹出下拉子菜单（hover + focus-within 兜底），弹层按 UI 标准（8px 圆角 / 1px 边框 / 0 12px 36px 阴影 / 双主题） */
.record-tier { position: relative; }
/* 桥接伪元素：覆盖触发按钮与向上弹出菜单之间的 5px 空隙，鼠标从按钮滑到菜单时不丢失 :hover */
.record-tier::before { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 5px; }
.record-tier-trigger { min-height: 32px; padding: 0 11px; border: 1px solid var(--border-2); border-radius: 5px; background: #fff; color: var(--muted); cursor: pointer; font-size: 10px; }
.record-tier-trigger:hover { border-color: var(--brand); color: var(--brand); }
.record-tier-menu { position: absolute; z-index: 20; bottom: calc(100% + 5px); left: 0; display: grid; width: 105px; padding: 4px; border: 1px solid var(--border-2); border-radius: 8px; background: #fff; box-shadow: 0 12px 36px rgba(0,0,0,.30); opacity: 0; visibility: hidden; transform: translateY(4px); transition: opacity .14s ease, transform .14s ease, visibility .14s; }
.record-tier-menu > button { min-height: 30px; border: 0; background: transparent; text-align: left; border-radius: 5px; color: var(--muted); cursor: pointer; font-size: 10px; padding: 0 8px; }
.record-tier-menu > button:hover { background: #f4f4f5; color: var(--brand); }
.record-tier:hover .record-tier-menu,
.record-tier:focus-within .record-tier-menu { opacity: 1; visibility: visible; transform: translateY(0); }
body.dark .record-tier-trigger { border-color: var(--border-2); background: var(--bg-3); color: var(--muted); }
body.dark .record-tier-trigger:hover { border-color: var(--brand); color: var(--brand); }
body.dark .record-tier-menu { border-color: var(--border-2); background: var(--bg-3); box-shadow: 0 12px 36px rgba(0,0,0,.55); }
body.dark .record-tier-menu > button { color: var(--muted); }
body.dark .record-tier-menu > button:hover { background: #27272a; color: var(--brand); }

/* Compact quote actions: calculation remains the only strong primary action. */
.quote-actions { display: grid !important; grid-template-columns: repeat(3, minmax(0, 1fr)) 88px; align-items: stretch; }
.quote-actions[style*="display:none"] { display: none !important; }
.quote-action,
.quote-actions .output-menu summary {
  display: flex;
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-2);
  border-radius: 6px;
  background: #fafafa;
  color: var(--muted);
  box-shadow: none;
  cursor: pointer;
  font-family: var(--ui-font);
  font-size: 12px;
  font-weight: 500;
}
.quote-action:hover, .quote-actions .output-menu summary:hover { border-color: #a1a1aa; background: #f4f4f5; color: var(--ink); }
.quote-action.quote-action-save { border-color: #bbf7d0; background: #ecfdf3; color: #15803d; font-weight: 600; }
.quote-action.quote-action-save:hover { border-color: #86efac; background: #dcfce7; color: #166534; }
.quote-actions .output-menu { width: 100%; min-width: 0; }
.quote-actions .output-menu summary::after { margin-left: 6px; }
body.dark .quote-action,
body.dark .quote-actions .output-menu summary { border-color: #3f3f46; background: #18181b; color: #a1a1aa; }
body.dark .quote-action:hover,
body.dark .quote-actions .output-menu summary:hover { border-color: #52525b; background: #202023; color: #e4e4e7; }
body.dark .quote-action.quote-action-save { border-color: #166534; background: #10261a; color: #86efac; }
body.dark .quote-action.quote-action-save:hover { border-color: #15803d; background: #123522; color: #bbf7d0; }
@media (max-width: 420px) {
  .quote-actions { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .quote-meta-menu { width: 100%; }
}

/* Balanced record filters and readable native controls in dark mode. */
/* 四列：文字搜索（占大头）→ 规格三框 → 客户 → 排序。规格组按内容宽度走，不参与拉伸 */
/* 四列：搜索(2fr) | 规格三框(auto) | 客户(auto) | 排序(.8fr)
   客户列必须是 auto —— 客户框是自适应内容宽度的按钮，若给固定下限（如 minmax(130px,…)）
   按钮只有 82px 却被拉到 130px 以上，框右边会空出一条，像「框后多了一段留白」。 */
#historyCard .hist-filter-bar { display: grid !important; grid-template-columns: auto minmax(0, 2fr) auto minmax(110px, .8fr); gap: 8px !important; }
#historyCard .hist-filter-bar .toolbar-input { width: 100%; min-width: 0; }
body.dark #historyCard .hist-filter-bar .toolbar-input {
  border-color: #3f3f46 !important;
  background-color: #18181b !important;
  color: #e4e4e7 !important;
  -webkit-text-fill-color: #e4e4e7;
  opacity: 1;
}
body.dark #historyCard .hist-filter-bar .toolbar-input::placeholder { color: #71717a !important; -webkit-text-fill-color: #71717a; }
body.dark #historyCard input[type="month"] { color-scheme: dark; }
body.dark #historyCard .hist-filter-bar option { background: #18181b; color: #e4e4e7; }
@media (max-width: 620px) {
  #historyCard .hist-filter-bar { grid-template-columns: 1fr 1fr; }
  /* 窄屏顺序：客户筛选 + 排序并排 → 搜索整行 → 规格三框整行（客户筛选始终在首位） */
  #historyCard .client-picker { grid-column: 1; grid-row: 1; }
  #historyCard #sortBy { grid-column: 2; grid-row: 1; }
  #historyCard #searchInput { grid-column: 1 / -1; grid-row: 2; }
  /* 窄屏：规格三框独占一行，免得被压成看不清的小格子 */
  #historyCard .hist-spec-search { grid-column: 1 / -1; grid-row: 3; justify-content: flex-start; }
}

/* True in-place editing: keep the expanded card and replace only editable values. */
.inline-editing input, .inline-editing select, .inline-editing textarea { border: 1px solid var(--border-2); border-radius: 5px; outline: 0; background: #fff; color: var(--ink); font-family: var(--ui-font); font-size: 11px; }
.inline-editing input:focus, .inline-editing select:focus, .inline-editing textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 14%, transparent); }
.inline-title-editor { display: grid; grid-template-columns: minmax(90px, 1fr) auto minmax(90px, 1fr); align-items: center; gap: 6px; max-width: 390px; }
.inline-title-editor > span { color: var(--muted-3); font-size: 12px; }
.inline-title-editor input { width: 100%; min-width: 0; height: 30px; padding: 4px 7px; font-size: 13px; font-weight: 600; }
.inline-spec-editor { display: grid; grid-template-columns: minmax(34px,1fr) auto minmax(34px,1fr) auto minmax(34px,1fr); align-items: center; gap: 3px; }
.inline-spec-editor input { width: 100%; min-width: 0; height: 27px; padding: 3px; text-align: center; font-variant-numeric: tabular-nums; }
.inline-spec-editor > span { color: var(--muted-3); font-size: 10px; }
.inline-value-editor { width: 100%; min-width: 0; height: 30px; padding: 4px 7px; }
.inline-material-editor { display: grid; grid-template-columns: minmax(54px,.65fr) minmax(92px,1.35fr); gap: 5px; }
.inline-flute-editor { display: grid; grid-template-columns: minmax(54px,.65fr) minmax(72px,1fr) auto; align-items: center; gap: 5px; }
.inline-material-editor input, .inline-material-editor select, .inline-flute-editor > input, .inline-flute-editor select { width: 100%; min-width: 0; height: 30px; padding: 4px 6px; }
/* 记录内联编辑的克重只读镜像：值来自报价面纸板块 */
.inline-material-editor input[readonly] { color: var(--muted-3); background: transparent; cursor: default; }
.inline-flute-editor label { display: flex; align-items: center; gap: 4px; white-space: nowrap; color: var(--muted); font-size: 10px; }
.inline-flute-editor label input { width: 14px; height: 14px; margin: 0; accent-color: var(--brand); }
.inline-remark-editor { display: grid; grid-template-columns: 108px minmax(0,1fr); align-items: start; margin-top: 10px; color: var(--muted-3); font-size: 10px; }
.inline-remark-editor textarea { width: 100%; min-height: 54px; padding: 7px 8px; resize: vertical; }
.inline-editing .detail-actions { justify-content: flex-end; padding-top: 11px; border-top: 1px solid var(--border); }
body.dark .inline-editing input, body.dark .inline-editing select, body.dark .inline-editing textarea { border-color: var(--border-2); background: var(--bg-3); color: var(--ink); color-scheme: dark; }
body.dark .inline-editing .detail-actions { border-color: var(--border); }
@media (max-width: 620px) {
  .inline-title-editor { grid-template-columns: minmax(70px,1fr) auto minmax(70px,1fr); }
  .inline-remark-editor { grid-template-columns: 92px minmax(0,1fr); }
  .inline-material-editor, .inline-flute-editor { grid-template-columns: 1fr; }
}

/* Expanded record detail: grouped operational data rather than a short summary. */
.detail-section { margin-top: 12px; padding-top: 11px; border-top: 1px solid var(--border); }
.detail-section h4 { margin: 0 0 8px; color: var(--ink); font-size: 11px; font-weight: 600; }
.detail-section dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px 14px; margin: 0; }
.detail-item { display: grid; grid-template-columns: 108px minmax(0, 1fr); align-items: baseline; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.detail-item dt { color: var(--muted-3); font-size: 10px; }
.detail-item dd { min-width: 0; margin: 0; color: var(--ink); font-size: 11px; overflow-wrap: anywhere; }
.detail-item-wide { grid-column: 1 / -1; }
.detail-costs { display: grid; grid-template-columns: 82px minmax(0, 1fr); align-items: start; gap: 8px; margin-top: 9px; padding-top: 9px; border-top: 1px dashed var(--border); }
.detail-cost-label { padding-top: 7px; color: var(--muted-3); font-size: 10px; }
.detail-costs > div { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.detail-costs > div > span { display: flex; min-width: 0; padding: 7px 8px; justify-content: space-between; gap: 6px; border: 1px solid var(--border); border-radius: 5px; background: #fff; color: var(--muted); font-size: 10px; }
.detail-costs b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
body.dark .detail-section { border-color: var(--border); }
body.dark .detail-section h4, body.dark .detail-item dd, body.dark .detail-costs b { color: var(--ink); }
body.dark .detail-item, body.dark .detail-costs { border-color: #303034; }
body.dark .detail-costs > div > span { border-color: var(--border-2); background: var(--bg-3); color: var(--muted); }
@media (max-width: 620px) {
  .detail-section dl { grid-template-columns: 1fr; }
  .detail-item { grid-template-columns: 92px minmax(0, 1fr); }
  .detail-costs { grid-template-columns: 1fr; }
  .detail-costs > div { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ===== 刀版长/宽「互换」按钮（2026-11-05） =====
   结构与输入框同基线：flex 底部对齐 + min-height 38px（复用表单控件基线，不硬编码 height） */
.die-pair { display: flex; align-items: flex-end; gap: 8px; flex: 2; min-width: 248px; }
.die-pair > .field { flex: 1; min-width: 0; }
.die-swap {
  flex: 0 0 auto; width: 34px; min-height: 38px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-2); border-radius: 6px;
  background-color: var(--bg-3); color: var(--muted);
  font-family: inherit; font-size: 15px; line-height: 1; cursor: pointer;
  transition: border-color .16s, color .16s, background-color .16s, transform .1s;
}
.die-swap:hover { border-color: var(--brand); color: var(--brand); }
.die-swap:active { transform: scale(.94); }
.die-swap:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
body.dark .die-swap { background-color: var(--bg-3); color: var(--muted); border-color: var(--border-2); }
body.dark .die-swap:hover { border-color: var(--brand); color: var(--brand-2); }
@media (max-width: 620px) { .die-pair { flex: 1 1 100%; min-width: 0; } }

/* ===== 阶梯档位：小格子输入（替代逗号串） ===== */
/* 每行都是「从左往右排、排不下就换行」，不用两端顶开——避免按钮孤零零挂在右端。
   注意类名不能叫 .mq-row：表格行本身就是 <tr class="mq-row">，同名会把 tr 变成 flex 容器、打乱列对齐。 */
.mq-tool-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
}
.mq-tool-label { flex: 0 0 auto; font-size: .78rem; color: var(--muted-2); font-weight: 500; }
/* 格子容器本身不占块：让每个格子直接参与这一行的排列，「+ 加一档」「翻倍」才紧跟在最后一个格子后面 */
#mqQtyChips { display: contents; }
.mq-mini {
  border: 1px solid var(--border-2); border-radius: 6px;
  background-color: var(--bg-3); color: var(--muted);
  font-family: inherit; font-size: .82rem; padding: 6px 12px;
  line-height: 1.2;
  cursor: pointer; transition: border-color .16s, color .16s;
}
.mq-mini:hover { border-color: var(--brand); color: var(--brand); }
.mq-mini:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.mq-chip {
  display: inline-flex; align-items: center;
  border: 1px solid var(--border-2); border-radius: 8px;
  background-color: var(--bg-3); padding: 0 3px;
  transition: border-color .16s;
}
.mq-chip:focus-within { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(13,148,136,.14); }
.mq-chip input {
  /* 宽度由 mqChipWidth() 按数字位数内联设置（4 位约 42px、7 位约 65px），这里只作兜底 */
  width: 42px; border: 0; background: transparent; color: var(--ink);
  font-family: var(--utility-mono); font-size: .82rem; text-align: center;
  padding: 7px 0; outline: none;
}
.mq-chip input::-webkit-outer-spin-button,
.mq-chip input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.mq-chip input { -moz-appearance: textfield; appearance: textfield; }
.mq-chip-del {
  width: 20px; height: 20px; border: 0; border-radius: 5px;
  background: transparent; color: var(--muted-3);
  font-family: inherit; font-size: 13px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background-color .15s, color .15s;
}
.mq-chip-del:hover { background-color: rgba(234,88,12,.12); color: var(--accent); }
.mq-chip-del:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.mq-chip-add {
  border: 1px dashed var(--border-2); border-radius: 8px;
  background: transparent; color: var(--muted);
  font-family: inherit; font-size: .78rem; padding: 7px 12px;
  cursor: pointer; transition: border-color .16s, color .16s;
}
.mq-chip-add:hover { border-color: var(--brand); color: var(--brand); }

/* 末档毛利 + 自动分配预览（同样左对齐，跟上面一行保持同一节奏） */
.mq-plan {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border-2);
}
.mq-plan-end {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .78rem; color: var(--muted-2); font-weight: 500; white-space: nowrap;
}
.mq-plan-end input {
  width: 58px; box-sizing: border-box; padding: 6px;
  border: 1px solid var(--border-2); border-radius: 6px;
  background-color: var(--bg-3); color: var(--ink);
  font-family: var(--utility-mono); font-size: .82rem; text-align: right;
}
.mq-plan-end input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px rgba(13,148,136,.16); }
.mq-plan-end input::-webkit-outer-spin-button,
.mq-plan-end input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.mq-plan-end input { -moz-appearance: textfield; appearance: textfield; }
.mq-plan-hint { font-size: .78rem; color: var(--muted-2); font-family: var(--utility-mono); }
.mq-plan-hint b { color: var(--brand); font-weight: 600; }
.mq-plan.is-warn .mq-plan-hint { color: var(--accent); font-family: inherit; }

/* 暗色 */
body.dark .mq-tool-label,
body.dark .mq-plan-end,
body.dark .mq-plan-hint { color: #94A3B8; }
body.dark .mq-mini { background-color: #0F172A; border-color: #334155; color: #94A3B8; }
body.dark .mq-mini:hover { border-color: #5EEAD4; color: #5EEAD4; }
body.dark .mq-chip { background-color: #0F172A; border-color: #334155; }
body.dark .mq-chip:focus-within { border-color: #5EEAD4; box-shadow: 0 0 0 2px rgba(94,234,212,.16); }
body.dark .mq-chip input { color: #E2E8F0; }
body.dark .mq-chip-del { color: #64748B; }
body.dark .mq-chip-del:hover { background-color: rgba(234,88,12,.18); color: #FB923C; }
body.dark .mq-chip-add { border-color: #334155; color: #94A3B8; }
body.dark .mq-chip-add:hover { border-color: #5EEAD4; color: #5EEAD4; }
body.dark .mq-plan { border-top-color: #334155; }
body.dark .mq-plan-end input { background-color: #0F172A; border-color: #334155; color: #E2E8F0; }
body.dark .mq-plan-end input:focus { border-color: #5EEAD4; }
body.dark .mq-plan-hint b { color: #5EEAD4; }

/* ===== 阶梯明细里的「计算公式」=====
   复用单数量模式 .formula-detail 的行样式，只另外框一圈，让它在明细表下面自成一区 */
.mq-formula {
  margin-top: 10px;
  border: 1px solid var(--border-2); border-radius: 8px;
  background-color: var(--bg-3); overflow: hidden;
}
.mq-formula .mq-formula-toggle {
  border-top: 0; padding: 9px 12px;
  text-align: left;
  background-color: rgba(15,23,42,.055);
  border-bottom: 1px solid var(--border);
  transition: background-color .16s;
}
.mq-formula .mq-formula-toggle:hover { background-color: rgba(15,23,42,.09); }
.mq-formula .mq-formula-body {
  padding: 0 14px; border-top: 0;
}
.mq-formula .mq-formula-body.open {
  padding: 12px 14px; border-top: 0;
  max-height: none;              /* 公式很长，不能用单数量模式那个 4000px 上限截断 */
}
.mq-formula .fhead { margin-top: 18px; }
.mq-formula .fhead:first-child { margin-top: 0; }

body.dark .mq-formula { background-color: rgba(30,41,59,.55); border-color: #334155; }
body.dark .mq-formula .mq-formula-toggle { background-color: rgba(148,163,184,.12); border-bottom-color: #334155; }
body.dark .mq-formula .mq-formula-toggle:hover { background-color: rgba(148,163,184,.20); }
body.dark .mq-formula .mq-formula-body.open { border-top-color: transparent; }

