/* ============================================================================
   打印模板引擎样式（2026-10-15）—— 与 print_template.js 配套
   ============================================================================ */

.tpl-overlay{
  position:fixed;inset:0;z-index:9100;background:rgba(15,22,32,.55);
  display:flex;align-items:center;justify-content:center;padding:16px;
  animation:tplFade .16s ease;
}
@keyframes tplFade{from{opacity:0}to{opacity:1}}
.tpl-modal{
  width:100%;max-width:640px;max-height:90vh;display:flex;flex-direction:column;
  background:#fff;border-radius:14px;overflow:hidden;
  box-shadow:0 18px 48px rgba(0,0,0,.28);animation:tplPop .18s cubic-bezier(.2,.9,.3,1.2);
}
.tpl-overlay.tpl-wide .tpl-modal{max-width:940px;}
@keyframes tplPop{from{transform:translateY(14px) scale(.97);opacity:0}to{transform:none;opacity:1}}
.tpl-head{
  display:flex;align-items:center;justify-content:space-between;flex:none;
  padding:14px 16px;border-bottom:1px solid #e5e5e5;font-size:16px;font-weight:700;
}
.tpl-head button{
  width:30px;height:30px;border:none;border-radius:8px;background:none;
  font-size:22px;line-height:1;color:#888;cursor:pointer;
}
.tpl-head button:hover{background:#f2f3f5;color:#1a1a1a;}
.tpl-body{flex:1;overflow-y:auto;padding:16px;-webkit-overflow-scrolling:touch;}

/* ---- 管理页：左列表 + 右编辑 ---- */
.tpl-wrap{display:flex;gap:16px;align-items:flex-start;}
/* 🔴 2026-10-15 排版修复：左列从 210px 放宽到 232px。
   原来 210px 里塞「新建/复制/删除」三个 flex:1 按钮 + 2 个 5px gap，
   每个按钮只剩 ~64px，扣掉 .btn-sm 的左右 padding 14px×2=28px，
   内容区仅 36px —— 而「＋ 新建」四个字符在 14px 字号下实测需 45.9px，
   放不下就折成两行，把按钮撑到 3 行高，另两个按钮只有 1 行 → 三个按钮高度参差。
   （实测：内容宽 39.0px vs 需要 45.89px，溢出 6.89px）
   放宽左列 + 压缩按钮 padding 后，三按钮统一 33px 高、单行。 */
.tpl-left{flex:none;width:232px;display:flex;flex-direction:column;gap:6px;}
.tpl-left-head{font-size:12px;color:#888;font-weight:600;margin-bottom:2px;}
.tpl-item{
  padding:9px 11px;border-radius:10px;border:1.5px solid transparent;
  cursor:pointer;transition:all .14s ease;background:#f7f8fa;
}
.tpl-item:hover{background:#f0fbf5;}
.tpl-item.on{background:#f0fbf5;border-color:#07c160;}
.tpl-item b{display:block;font-size:13.5px;color:#1a1a1a;font-weight:600;line-height:1.4;}
/* 模板名超长时省略号截断（配合 JS 侧 title 兜底，鼠标悬停能看到全名） */
.tpl-item b,.tpl-item span{
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.tpl-item span{display:block;font-size:11px;color:#888;margin-top:2px;}
.tpl-bi,.tpl-def{
  font-style:normal;font-size:10px;padding:1px 5px;border-radius:8px;margin-left:5px;
  background:#e5e5e5;color:#666;font-weight:600;vertical-align:middle;
}
.tpl-def{background:#07c160;color:#fff;}

/* ---- 操作按钮行：等宽、等高、单行 ---- */
.tpl-left-ops{display:flex;gap:5px;margin-top:6px;}
/* 🔴 不写 flex-wrap:wrap —— 一旦允许换行，某个按钮文字放不下就会折到下一行，
   整行高度被撑高，视觉上就是「有的按钮大有的按钮小」。
   宁可让按钮均分宽度，也必须保持一行。 */
.tpl-left-ops .btn-sm{
  flex:1 1 0;min-width:0;          /* 0基准等分 + 允许收缩，文字再长也不换行 */
  white-space:nowrap;              /* 关键：文字不折行 */
  padding:0 4px;                   /* 压缩左右内边距，把宽度让给文字 */
  height:33px;line-height:33px;    /* 三按钮统一高度 */
  font-size:13px;text-align:center;
  display:inline-flex;align-items:center;justify-content:center;
  overflow:hidden;
}
.tpl-defsel{display:block;font-size:11.5px;color:#888;margin-top:12px;}
.tpl-left select{
  width:100%;margin-top:4px;padding:7px 9px;border:1.5px solid #e5e5e5;
  border-radius:8px;font-family:inherit;font-size:13px;background:#fff;
}
.tpl-savebar{margin-top:12px;}
/* 🔴 .btn-primary 全局是 padding:14px + font-size:17px，在 232px 宽的左列里
   「保存全部」四个 17px 汉字需 ~68px + 28px padding，虽放得下但行高被 padding 撑到 49px，
   跟上方 33px 的小按钮完全不在一个量级。统一压成与小按钮协调的尺寸。 */
.tpl-savebar .btn-primary{
  margin-top:0;height:36px;line-height:36px;padding:0 10px;
  font-size:14px;white-space:nowrap;
}

.tpl-right{flex:1;min-width:0;}
/* 编辑区容器：显式声明，不靠浏览器默认 div 行为 */
.tpl-ed{display:block;}
/* 模块名要能伸缩，否则长中文会把下方的 <i> 说明文字挤出容器 */
.tpl-mc span{flex:1 1 auto;min-width:0;}
.tpl-ed label{display:block;font-size:12.5px;color:#555;margin-bottom:4px;}
.tpl-ed input[type=text],.tpl-ed input[type=number],.tpl-ed input:not([type]){
  width:100%;padding:8px 10px;border:1.5px solid #e5e5e5;border-radius:8px;
  font-family:inherit;font-size:13.5px;background:#fff;color:#1a1a1a;
}
.tpl-ed input:focus{outline:none;border-color:#07c160;}
.tpl-mods{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:12px;}
.tpl-mg{border:1px solid #ececec;border-radius:10px;padding:10px 12px;background:#fcfcfd;}
.tpl-mgt{font-size:12px;font-weight:700;color:#06a050;margin-bottom:6px;}
.tpl-mc{display:flex;align-items:flex-start;gap:6px;padding:4px 0;cursor:pointer;margin:0;}
.tpl-mc input{width:15px;height:15px;min-width:15px;flex:none;margin:2px 0 0;accent-color:#07c160;}
.tpl-mc span{font-size:13px;color:#333;line-height:1.4;}
.tpl-mc i{display:block;font-style:normal;font-size:11px;color:#999;line-height:1.4;}

/* ---- 打单前选择 ---- */
.tpl-pick{display:flex;flex-direction:column;gap:8px;}
.tpl-pickitem{
  display:grid;grid-template-columns:auto 1fr;gap:4px 10px;align-items:center;
  padding:11px 13px;border:1.5px solid #e5e5e5;border-radius:11px;cursor:pointer;
  transition:all .14s ease;
}
.tpl-pickitem:hover{border-color:#b8e6cd;background:#f7fdfa;}
.tpl-pickitem input{grid-row:span 3;width:17px;height:17px;accent-color:#07c160;}
.tpl-pickitem b{font-size:14px;color:#1a1a1a;font-weight:600;}
.tpl-pickitem span{font-size:11.5px;color:#888;}
.tpl-pickd{font-style:normal;font-size:11.5px;color:#999;line-height:1.5;}
.tpl-pick-remember{
  display:flex;align-items:center;gap:7px;margin-top:14px;font-size:13px;
  color:#444;cursor:pointer;
}
.tpl-pick-remember input{width:16px;height:16px;min-width:16px;accent-color:#07c160;}

/* ---- 打单前选择弹窗底部按钮行 ---- */
/* 🔴 2026-10-15 排版修复：此处三个按钮原本完全没有 CSS 规则，
   .btn-sm 走全局小按钮样式、.btn-primary 走全局 padding:14px/17px 大按钮，
   实测高度 35.89 / 35.89 / 49.47 —— 「开始打单」比另两个高出一截，
   一行三个按钮底边对不齐。这里统一成同一个高度。 */
.fb-actions{
  display:flex;gap:8px;margin-top:16px;align-items:stretch;
}
.fb-actions > button{
  flex:1 1 0;min-width:0;
  white-space:nowrap;
  height:38px;line-height:38px;
  font-size:14px;
  display:inline-flex;align-items:center;justify-content:center;
  overflow:hidden;
  padding:0 8px;
}
/* 「开始打单」是主操作：同高但用底色区分，不靠尺寸堆层级 */
.fb-actions > .btn-primary{flex:0 0 auto;padding:0 20px;font-weight:600;}
.fb-actions > .btn-sm{
  flex:1 1 0;
  min-width:0;
  padding:0 8px;
}

/* ---- 自定义模块「添加行」 ---- */
/* 🔴 2026-10-15 排版修复：.tpl-extraidk 在 JS 里用了但 CSS 从没定义过，
   靠浏览器默认块级 div 堆叠，导致下拉框/输入框/两个按钮高度各自为政、
   「＋ 快速重复上一个」还会被挤到下一行。这里显式做一行 flex。 */
.tpl-extraidk{
  display:flex;align-items:center;gap:8px;flex-wrap:wrap;
  padding:9px 10px;background:#fafcfb;
  border:1px solid #e2ebe7;border-radius:9px;
}
.tpl-extraidk select,.tpl-extraidk input{
  height:32px;font-size:12.5px;padding:0 8px;
  border:1px solid #d8e2dd;border-radius:7px;background:#fff;
  font-family:inherit;color:#1a1a1a;
}
.tpl-extraidk select{width:150px;cursor:pointer;}
.tpl-extraidk input{width:170px;}
.tpl-extraidk select:focus,.tpl-extraidk input:focus{
  outline:none;border-color:#07c160;box-shadow:0 0 0 3px rgba(7,193,96,.13);
}
.tpl-extraidk .btn-sm{
  height:32px;line-height:32px;
  font-size:12.5px;white-space:nowrap;
  padding:0 10px;flex:none;
  display:inline-flex;align-items:center;justify-content:center;
}

@media (max-width:820px){
  .tpl-overlay{padding:0;align-items:flex-end;}
  .tpl-modal{max-width:none;border-radius:16px 16px 0 0;max-height:92vh;}
  .tpl-wrap{flex-direction:column;}
  .tpl-left{width:100%;}
  .tpl-mods{grid-template-columns:1fr;}
  /* 左列变全宽后三个按钮可以给足宽度，但依然保持一行等高 */
  .tpl-left-ops .btn-sm{font-size:13.5px;padding:0 6px;}
  /* 底部按钮在窄屏仍保持一行，只是「开始打单」少占一点宽度 */
  .fb-actions{gap:6px;}
  .fb-actions > button{font-size:13px;padding:0 4px;}
  .fb-actions > .btn-primary{flex:0 0 auto;padding:0 12px;}
  /* 自定义模块添加行：窄屏下拉框与输入框各占半行，按钮并排一行 */
  .tpl-extraidk select,.tpl-extraidk input{width:calc(50% - 4px)!important;}
  .tpl-extraidk .btn-sm{flex:1 1 calc(50% - 4px);padding:0 4px;}
}
/* ==========================================================================
   自定义模块（可重复添加）—— 2026-10-15 经理要求「模块可以重复添加」
   ========================================================================== */
.tpl-extra{display:flex;flex-direction:column;gap:7px;margin-bottom:9px;}
.tpl-x{
  display:flex;align-items:center;gap:7px;flex-wrap:wrap;
  padding:8px 9px;background:#fafcfb;
  border:1px solid #e2ebe7;border-radius:9px;
  transition:border-color .14s ease,background .14s ease;
}
.tpl-x:hover{border-color:#b8e6cd;background:#f5fbf8;}
.tpl-xsw{display:flex;align-items:center;margin:0;}
.tpl-xsw input{width:16px;height:16px;min-width:16px;accent-color:#07c160;cursor:pointer;}
.tpl-x select,.tpl-x input{
  height:30px;font-size:12.5px;padding:0 8px;
  border:1px solid #d8e2dd;border-radius:7px;background:#fff;
}
.tpl-x select{cursor:pointer;}
.tpl-x input[data-xl]{width:130px;}
.tpl-xdel{
  width:26px;height:26px;min-width:26px;flex:none;
  border:1px solid #f0d5d5;background:#fff;color:#c96;
  border-radius:7px;cursor:pointer;font-size:13px;line-height:1;
  transition:all .14s ease;
}
.tpl-xdel:hover{background:#fdf3f3;border-color:#e8b9b9;}
/* 纸张规格选择器 */
#e-paper{
  width:100%;max-width:420px;height:34px;
  font-size:13px;padding:0 10px;
  border:1px solid #d8e2dd;border-radius:8px;background:#fff;cursor:pointer;
}
#e-paper:focus{outline:none;border-color:#07c160;box-shadow:0 0 0 3px rgba(7,193,96,.13);}

@media (max-width:820px){
  .tpl-x{gap:6px;padding:8px;}
  .tpl-x input[data-xl],.tpl-x select{width:calc(50% - 4px)!important;}
  .tpl-x input[data-xt]{width:100%!important;}
}
