/*
 * 智能报表「打印版式」：单据套打（医院门诊收费票据）/ 发票。配合 js/pages/smartreport-tpl.js。
 * 版式条（.sr-tplbar）跟随深浅主题；票面（.sr-tplroot）固定浅色，所有尺寸用毫米，屏幕预览与打印 1:1。
 * 票面元素分两类：.tp-fix（底版：线条、固定文字、标签）与 .tp-dat（数据：明细与手填内容）。
 * 套打开启（.tp-ovl）时底版颜色走 --tp-op：屏幕上按「底版预览」浓度半透明，打印 / 导出时为 0（隐藏但位置不变）。
 */

/* ───────── 画布：版式条在票面上方，票面居中 ───────── */
.sr-desk.sr-tpl-desk { flex-direction: column; align-items: flex-start; gap: 14px; }
.sr-tpl-desk > .sr-tplbar, .sr-tpl-desk > .sr-tplroot { margin-left: auto; margin-right: auto; }

/* ───────── 版式条 ───────── */
.sr-tplbar {
  box-sizing: border-box; width: 100%; max-width: 210mm; padding: 0 2px 10px; display: flex; flex-direction: column; gap: 10px;
  border: 0; border-bottom: 1px solid var(--sr-line); border-radius: 0; background: transparent; color: var(--sr-t1); font-size: 12.5px; line-height: 1.5;
}
.tpb-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.tpb-lb { flex: none; font-size: 12px; color: var(--sr-t2); }
.tpb-hint { flex: 1 1 0; min-width: 0; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--sr-t3); cursor: help; }
.tpb-hint-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpb-hint-i { flex: none; color: var(--sr-t3); }
.tpb-seg { display: inline-flex; gap: 2px; padding: 2px; border: 0; border-radius: 9px; background: var(--sr-fill-2); }
.tpb-segb {
  display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 12px; border: 0; border-radius: 7px;
  background: none; color: var(--sr-t2); font: inherit; font-size: 12.5px; cursor: pointer; transition: background .15s, color .15s;
}
.tpb-segb:hover:not(:disabled):not(.on) { color: var(--sr-t1); }
.tpb-segb.on { background: var(--sr-card); color: var(--sr-t1); font-weight: 700; box-shadow: var(--sr-sh-1); }
.tpb-segb.on .ivu-icon { color: var(--sr-iris); }
.tpb-segb:disabled { opacity: .55; cursor: not-allowed; }
.tpb-segb:focus-visible, .tpb-btn:focus-visible, .tpb-sel:focus-visible, .tpb-in:focus-visible, .tpb-link:focus-visible { outline: 2px solid var(--sr-iris); outline-offset: 1px; }
.tpb-opts { padding-top: 9px; border-top: 1px dashed var(--sr-line); }
.tpb-f { display: inline-flex; align-items: center; gap: 7px; }
.tpb-sel, .tpb-in {
  height: 28px; box-sizing: border-box; border: 1px solid var(--sr-line-2); border-radius: 7px; background: var(--sr-card); color: var(--sr-t1);
  font: inherit; font-size: 12.5px; padding: 0 8px; max-width: 230px;
}
.tpb-in { width: 66px; text-align: right; }
.tpb-sel:disabled, .tpb-in:disabled { opacity: .55; }
.tpb-btn {
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 11px; border: 1px solid var(--sr-line-2); border-radius: 7px;
  background: var(--sr-card); color: var(--sr-t1); font: inherit; font-size: 12.5px; cursor: pointer;
}
.tpb-btn:hover:not(:disabled) { border-color: var(--sr-iris); color: var(--sr-iris); }
.tpb-btn.on { background: var(--sr-iris-soft); border-color: var(--sr-iris-line); color: var(--sr-iris-ink, var(--sr-iris)); }
.tpb-btn:disabled { opacity: .5; cursor: not-allowed; }
.tpb-chk { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--sr-t1); }
.tpb-chk input { width: 15px; height: 15px; accent-color: var(--sr-iris); }
.tpb-rng { width: 110px; accent-color: var(--sr-iris); }
.tpb-num, .tpb-u { font-size: 12px; color: var(--sr-t2); font-variant-numeric: tabular-nums; }
.tpb-xy { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--sr-t2); }
.tpb-link { border: 0; background: none; color: var(--sr-iris); font: inherit; font-size: 12px; cursor: pointer; padding: 0 2px; }
.tpb-map {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px 14px; padding: 10px 12px;
  border: 1px solid var(--sr-line); border-radius: 9px; background: var(--sr-fill);
}
.tpb-mc { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tpb-mc .tpb-sel { max-width: none; width: 100%; }
/* 单据「列设置」：显示列勾选一整行，大写金额列单独一格 */
.tpb-cols { grid-template-columns: 1fr minmax(210px, 260px); align-items: start; }
.tpb-colrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; min-width: 0; }
.tpb-colrow .tpb-chk span { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 760px) { .tpb-cols { grid-template-columns: 1fr; } }
.tpb-warn {
  margin: 0; padding: 7px 12px 7px 28px; border: 1px solid var(--sr-warn-line); border-radius: 8px;
  background: var(--sr-warn-soft); color: var(--sr-warn-t); font-size: 12px; list-style: disc;
}

/* ───────── 票面 ───────── */
.sr-tplroot {
  --tp-line: rgba(var(--tp-rgb), var(--tp-op));
  --tp-tint: rgba(var(--tp-rgb), calc(var(--tp-op) * .06));
  --tp-ink: #0f2147;
  display: flex; flex-direction: column; gap: 18px; flex-shrink: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}
.sr-tpl-page {
  position: relative; box-sizing: border-box; overflow: hidden; flex-shrink: 0; background: #fff; color: var(--tp-ink);
  box-shadow: var(--sr-paper-sh); break-after: page; page-break-after: always;
}
.tp-in { position: absolute; box-sizing: border-box; line-height: 1.2; }
.tp-in *, .tp-in *::before, .tp-in *::after { box-sizing: border-box; }
.tp-fix { color: var(--tp-line); }
.tp-dat { color: var(--tp-ink); }
.tp-lb { flex: none; white-space: nowrap; }
.tp-n { text-align: right; font-variant-numeric: tabular-nums; }
.tp-c { text-align: center; }

/* 就地填写 */
.tp-f { position: relative; display: inline-block; min-width: 12mm; min-height: 1.25em; vertical-align: middle; }
.tp-f-ed { cursor: text; border-radius: 1px; }
.tp-f-ed:hover, .tp-f-ed:focus-visible { outline: 1px dashed rgba(102, 88, 245, .7); background: rgba(102, 88, 245, .08); }
.tp-ph {
  position: absolute; left: .4mm; top: 50%; transform: translateY(-50%); font-style: normal; font-size: .85em; font-weight: 400;
  letter-spacing: 0; white-space: nowrap; color: #a7aec2; pointer-events: none;
}
.tp-f-inp {
  width: 100%; min-width: 22mm; height: 1.7em; padding: 0 1mm; box-sizing: border-box; font: inherit; color: #10142a;
  border: 1px solid #6658f5; border-radius: 2px; background: #fffdf2; letter-spacing: 0;
}
.tp-f-inp:focus { outline: 2px solid rgba(102, 88, 245, .35); }

/* 表格（明细） */
.tp-tab { width: 100%; border-collapse: collapse; table-layout: fixed; margin: 0; }
.tp-tab th, .tp-tab td {
  border: .25mm solid var(--tp-line); padding: 0 1mm; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  line-height: 1.1; font-weight: 400; vertical-align: middle; font-size: inherit;
}
.tp-tab th { text-align: center; font-weight: 600; background: var(--tp-tint); letter-spacing: .05em; }

/* 业务单据：抬头、信息格、明细表尾合计与签章 */
.tp-rec { display: flex; flex-direction: column; height: 100%; }
.tp-ttl { text-align: center; font-weight: 700; letter-spacing: .22em; white-space: nowrap; }
.tp-ttl .tp-f { min-width: 50mm; }
.tp-sub { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.tp-sub-l { text-align: left; white-space: nowrap; }
.tp-sub-c { text-align: center; font-size: 1.15em; font-weight: 700; letter-spacing: .3em; white-space: nowrap; }
.tp-sub-r { text-align: right; white-space: nowrap; }
.tp-info { display: grid; grid-template-columns: repeat(4, 1fr); border-top: .25mm solid var(--tp-line); border-left: .25mm solid var(--tp-line); }
.tp-ic { display: flex; align-items: center; gap: 1mm; min-width: 0; padding: 0 1.2mm; overflow: hidden; white-space: nowrap; }
.tp-info .tp-ic { border-right: .25mm solid var(--tp-line); border-bottom: .25mm solid var(--tp-line); }
.tp-ic .tp-f { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tp-ic-w3 { grid-column: span 3; }
.tp-rec tfoot td { border: .25mm solid var(--tp-line); }
.tp-rec .tp-tl { font-weight: 600; letter-spacing: .2em; text-indent: .2em; }
.tp-rec .tp-tsum { font-weight: 600; font-variant-numeric: tabular-nums; }
.tp-ft1 {
  display: flex; align-items: center; gap: 2.5mm; padding: 0 1.5mm; border: .25mm solid var(--tp-line); border-top: 0;
}
.tp-cn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; letter-spacing: .1em; }
.tp-sm { min-width: 28mm; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.tp-ft2 { display: flex; align-items: center; gap: 5mm; padding: 0 1mm; }
.tp-sg { flex: 1; min-width: 0; display: flex; align-items: center; gap: 1mm; }
.tp-sg .tp-f { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* 发票：棕红色线框（示意样式） */
.tp-inv { position: relative; display: flex; flex-direction: column; height: 100%; }
.tp-itop { display: grid; grid-template-columns: 26% 1fr 44%; align-items: center; column-gap: 2mm; }
.tp-itop-l { display: flex; align-items: flex-start; }
.tp-pre {
  display: inline-block; padding: .4mm 1.6mm; border: .3mm dashed #b3261e; border-radius: 1mm; color: #b3261e; font-size: .95em; font-weight: 700;
  letter-spacing: .05em; white-space: nowrap;
}
.tp-itop-c { justify-self: center; padding: 0 3mm .6mm; border-bottom: .6mm double var(--tp-line); font-size: 2em; font-weight: 700; letter-spacing: .35em; white-space: nowrap; text-indent: .35em; }
.tp-itop-r { display: grid; grid-template-columns: 1fr 1.25fr; grid-auto-rows: 1fr; row-gap: .5mm; }
.tp-itop-r .tp-ic { padding: 0 1mm; }
.tp-party { display: flex; border: .25mm solid var(--tp-line); }
.tp-inv > .tp-party { border-bottom: 0; }
.tp-pv {
  flex: none; width: 6.2mm; display: flex; align-items: center; justify-content: center; writing-mode: vertical-rl; letter-spacing: .6em;
  font-weight: 600; border-right: .25mm solid var(--tp-line); background: var(--tp-tint);
}
.tp-pb { flex: 1; min-width: 0; display: grid; }
.tp-pr { display: flex; align-items: center; gap: 1mm; min-width: 0; padding: 0 1.5mm; border-bottom: .25mm solid var(--tp-line); white-space: nowrap; overflow: hidden; }
.tp-pr:last-child { border-bottom: 0; }
.tp-pr .tp-f { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tp-itab tfoot td { border: .25mm solid var(--tp-line); }
.tp-itab .tp-tl { text-align: center; letter-spacing: .9em; text-indent: .9em; font-weight: 600; }
.tp-itab .tp-jsh { font-weight: 600; }
.tp-itab .tp-jsh .tp-cn { margin-left: 2mm; letter-spacing: .08em; }
.tp-itab .tp-jsh .tp-sm { margin-left: 1mm; font-size: 1.05em; }
.tp-bot { display: flex; }
.tp-bot .tp-party { flex: 0 0 62%; border-top: 0; }
.tp-rmk { flex: 1; min-width: 0; display: flex; border: .25mm solid var(--tp-line); border-top: 0; border-left: 0; }
.tp-rmk-b { flex: 1; min-width: 0; padding: 1mm 1.5mm; overflow: hidden; }
.tp-rmk-b .tp-f { display: block; width: 100%; white-space: normal; word-break: break-all; }
.tp-isg { padding-top: .5mm; }
.tp-pgno { position: absolute; right: 0; top: -3.8mm; font-size: .9em; }

/* ───────── 打印 / 导出：底版隐藏（套打）、去掉编辑痕迹 ───────── */
.sr-tplroot[data-tp-exp] { gap: 0; }
.sr-tplroot[data-tp-exp] .sr-tpl-page { box-shadow: none; }
.sr-tplroot[data-tp-exp].tp-ovl { --tp-op: 0 !important; }
.sr-tplroot[data-tp-exp] .tp-f { outline: none !important; background: none !important; }
@media print {
  .sr-tplroot.tp-ovl { --tp-op: 0 !important; }
  html.sr-page-on .sr-tplroot { display: block; margin: 0; gap: 0; }
  html.sr-page-on .sr-tpl-page { page: sr-tpl; box-shadow: none; margin: 0; }
  html.sr-page-on .sr-tpl-page:last-child { break-after: auto; page-break-after: auto; }
  .tp-f-ed, .tp-f-ed:hover { outline: none !important; background: none !important; }
  .tp-ph { display: none !important; }
  html.sr-page-on .sr-tplroot .tp-in { visibility: visible; }
}

@media (max-width: 720px) {
  .tpb-hint-t { display: none; }
  .tpb-hint { flex: none; }
  .sr-tplbar { padding: 0 0 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .tpb-segb { transition: none; }
}
