/* 门窗合同 · A4 合同纸（照纸质单排版）—— 屏幕 & 打印共用 */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }

body.paper-page {
  background: #e9ecf2; color: #000;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* ---------------- 纸张 ---------------- */
.sheet {
  width: 100%; max-width: 812px; margin: 0 auto; background: #fff;
  padding: 20px 22px 18px;
  font-family: "SimSun", "宋体", serif; font-size: 12.6px; line-height: 1.5; color: #000;
  box-shadow: 0 8px 30px rgba(20, 30, 60, .13); border-radius: 3px;
}

/* 抬头 */
.sh-head {
  position: relative; display: flex; justify-content: center; align-items: flex-end;
  border-bottom: 2px solid #000; padding-bottom: 4px; margin-bottom: 6px;
}
.sh-head h1 {
  margin: 0; font-family: "SimHei", "黑体", serif;
  font-size: 21px; font-weight: 700; letter-spacing: 9px; text-indent: 9px;
}
.sh-head .no {
  position: absolute; right: 0; bottom: 4px; display: flex; align-items: flex-end;
  font-family: Consolas, monospace; font-size: 12px; color: #b1201a;
}
.sh-head .no .u { width: 36mm; }

/* 字段行 */
.sh-row { display: flex; align-items: flex-end; margin-top: 1px; }
.sh-field { display: flex; align-items: flex-end; flex: 1; min-width: 0; padding-right: 9px; }
.sh-field:last-child { padding-right: 0; }
.sh-field > .lab { white-space: nowrap; }

.u {
  flex: 1; min-width: 0; display: block; width: 100%;
  border: 0; border-bottom: 1px solid #000; background: transparent;
  font: inherit; color: #000; padding: 0 4px; min-height: 1.45em;
  outline: none; white-space: nowrap; overflow: hidden;
}
input.u:focus { background: #fffde9; box-shadow: 0 1px 0 #2a5cff; }
input.u::placeholder { color: #c8cedb; font-size: 10.5px; }
input.u[type=date] { font-family: inherit; }
input.u[type=date]::-webkit-calendar-picker-indicator { opacity: .3; padding: 0; }
input.u.is-empty:not(:focus)::-webkit-datetime-edit { color: transparent; }
.tblhint { display: none; }

/* 表格横向提示（窄屏） */
@media screen and (max-width: 640px) {
  .tblhint {
    display: block; font-family: -apple-system, "Microsoft YaHei", sans-serif;
    font-size: 11px; color: #9aa3b2; margin: 3px 0 0 2px;
  }
}

/* 表格 + 右侧竖排存根条 */
.sh-tblwrap { display: flex; margin-top: 7px; align-items: stretch; }
.sh-tbl { flex: 1; min-width: 0; }
table.sh-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.sh-table th, .sh-table td { border: 1px solid #000; padding: 1px 3px; height: 22px; font-size: 11.8px; }
.sh-table th { font-family: "SimHei", "黑体", serif; font-weight: 400; text-align: center; height: 21px; }
.sh-table td.c { text-align: center; }
.sh-table td.r { text-align: right; }
.sh-table td { overflow: hidden; }
.sh-table input.u { border: 0; min-height: 19px; height: 19px; padding: 0; text-align: center; }
.sh-table td.r input.u { text-align: right; padding-right: 2px; }
.sh-table .amtcell { text-align: right; font-family: Consolas, monospace; padding-right: 3px; }
.stub {
  width: 23px; border: 1px solid #000; border-left: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: space-around;
  font-size: 9px; color: #333; padding: 6px 0; flex: none; line-height: 1.25;
}
.stub span { writing-mode: vertical-rl; letter-spacing: .5px; }

/* 金额框（大写格子） */
.amtrow {
  display: flex; align-items: stretch; border: 1px solid #000; border-top: 0; min-height: 36px;
}
.amtrow:first-of-type { border-top: 1px solid #000; }
.amtrow .lab {
  display: flex; align-items: center; padding: 0 6px; white-space: nowrap;
  font-size: 12px; border-right: 1px solid #000; width: 40mm; flex: none;
}
.amtrow .cells { position: relative; flex: 1; min-width: 0; padding: 3px 6px 12px; }
.amtrow .cnval {
  position: relative; z-index: 1; font-size: 12.6px; letter-spacing: 2px; line-height: 1.55;
  white-space: nowrap; overflow: hidden; text-indent: 2px;
}
.amtrow .units {
  position: absolute; left: 2px; right: 2px; bottom: 1px; display: flex;
  font-size: 8.5px; color: #a8afba;
}
.amtrow .units i { flex: 1; text-align: center; border-right: 1px solid #e2e2e2; font-style: normal; }
.amtrow .units i:last-child { border-right: 0; }
.amtrow .cur {
  display: flex; align-items: center; gap: 2px; padding: 0 6px; border-left: 1px solid #000;
  font-family: Consolas, monospace; font-size: 12.5px; white-space: nowrap;
}
.amtrow .cur b { font-weight: 400; min-width: 20mm; text-align: right; display: inline-block; }
input.cur-in {
  width: 22mm; border: 0; background: transparent; font: inherit;
  font-family: Consolas, monospace; text-align: right; outline: none; padding: 0 2px;
}
input.cur-in:focus { background: #fffde9; }

/* 条款 */
.sh-terms { margin-top: 6px; font-size: 10.8px; line-height: 1.55; }
.sh-terms p { margin: 0; padding-left: 1.4em; text-indent: -1.4em; }
.sh-terms input.blk {
  border: 0; border-bottom: 1px solid #000; background: transparent; font: inherit;
  text-align: center; outline: none; padding: 0 2px; height: 1.3em;
}
.sh-terms input.blk:focus { background: #fffde9; }
.w1 { width: 8mm; } .w2 { width: 13mm; } .w3 { width: 22mm; } .w4 { width: 40mm; }

.sh-tip { margin-top: 4px; font-size: 10.4px; }

/* 签名 */
.sh-signs { display: flex; gap: 8mm; margin-top: 4px; }
.sh-sign { flex: 1; min-width: 0; }
.sh-sign .sh { font-size: 12px; }
.sh-sign .box {
  height: 22mm; border-bottom: 1px solid #000; position: relative;
  display: flex; align-items: center; justify-content: center;
}
.sh-sign .box img { max-height: 21mm; max-width: 100%; object-fit: contain; }
.sh-sign .box .ph { color: #c8cedb; font-size: 11px; }
.sh-sign .box.tapable { cursor: pointer; }
.sh-sign .box.tapable:active { background: #f2f6ff; }
.sh-sign .sf { margin-top: 3px; font-size: 12px; display: flex; align-items: flex-end; }
.sh-sign .sf .u { width: 30mm; flex: none; }

.sh-foot { margin-top: 4px; font-size: 10.2px; color: #666; text-align: right; }
.sh-stamp {
  margin-top: 4px; font-size: 9.4px; color: #555; line-height: 1.5;
  border-top: 1px dashed #bbb; padding-top: 3px;
}

/* ---------------- 打印 ---------------- */
@page { size: A4; margin: 9mm; }
@media print {
  body.paper-page { background: #fff; }
  .noprint { display: none !important; }
  .sheet { max-width: none; width: auto; box-shadow: none; border-radius: 0; padding: 0; margin: 0; font-size: 12px; }
  .sh-table tr { page-break-inside: avoid; }
  input.u[type=date]::-webkit-calendar-picker-indicator { display: none !important; }
  input.u::placeholder { color: transparent !important; }
  input.u.is-empty::-webkit-datetime-edit { color: transparent !important; }
  .tblhint { display: none !important; }
}

/* ---------------- 手机 ---------------- */
@media screen and (max-width: 640px) {
  .sheet { padding: 14px 12px 12px; font-size: 12px; }
  .sh-head { flex-direction: column; align-items: center; padding-bottom: 6px; }
  .sh-head h1 { font-size: 18px; letter-spacing: 6px; text-indent: 6px; }
  .sh-head .no { position: static; margin-top: 4px; font-size: 11px; }
  .sh-head .no .u { width: 46mm; }
  .sh-row { flex-wrap: wrap; }
  .sh-field { flex: 1 1 100%; padding-right: 0; margin-top: 1px; }
  .sh-field.half { flex: 1 1 47%; }
  .sh-tblwrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .sh-tbl { min-width: 470px; }
  .sh-terms { font-size: 10.4px; }
  .sh-signs { gap: 10px; }
  .sh-sign .box { height: 20mm; }
  input.u { font-size: 12px; }
}

/* ---------------- 控件 ---------------- */
.btn {
  border: 0; border-radius: 11px; padding: 13px 20px; font-size: 15px; font-weight: 600;
  font-family: inherit; background: linear-gradient(135deg, #2a5cff, #1f47c9); color: #fff; cursor: pointer;
  box-shadow: 0 6px 16px rgba(42, 92, 255, .28); white-space: nowrap;
}
.btn:disabled { opacity: .5; box-shadow: none; }
.btn.g { background: #eef2fa; color: #2a3d63; box-shadow: none; }
.btn.green { background: linear-gradient(135deg, #1fa860, #158a4c); box-shadow: 0 6px 16px rgba(31, 168, 96, .3); }
.btn.sm { padding: 8px 12px; font-size: 13px; border-radius: 8px; }

.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: rgba(255, 255, 255, .98); border-top: 1px solid #e2e7f0;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 -4px 18px rgba(20, 30, 60, .06);
}
.bar .sp { flex: 1; min-width: 0; }
.bar .t1 { font-size: 11.5px; color: #8a93a6; }
.bar .t2 { font-size: 19px; font-weight: 800; color: #e0402a; font-family: Consolas, monospace; line-height: 1.2; }
.bar .t3 { font-size: 13.5px; color: #1a8a4d; font-weight: 600; }
.gap { height: calc(84px + env(safe-area-inset-bottom)); }

.mask { position: fixed; inset: 0; background: rgba(15, 20, 32, .5); z-index: 90; display: none; align-items: flex-end; }
.mask.show { display: flex; }
.sheetbox {
  width: 100%; background: #fff; border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(16px + env(safe-area-inset-bottom));
  font-family: -apple-system, "Microsoft YaHei", sans-serif;
}
.sheetbox h4 { margin: 0 0 4px; font-size: 17px; }
.sheetbox p { margin: 0 0 12px; font-size: 13px; color: #8a93a6; line-height: 1.5; }
.sheetbox input.link {
  width: 100%; border: 1px solid #dfe4ee; border-radius: 9px; padding: 11px 12px;
  font: 13px Consolas, monospace; background: #f5f7fb; color: #2a3d63;
}
.sheetbox .acts { display: flex; gap: 9px; margin-top: 12px; }
.sheetbox .acts .btn { flex: 1; padding: 13px 0; text-align: center; }

.padmodal { position: fixed; inset: 0; background: #fff; z-index: 120; display: none; flex-direction: column; }
.padmodal.show { display: flex; }
.padmodal .ph { padding: 14px 16px 6px; text-align: center; font-family: -apple-system, "Microsoft YaHei", sans-serif; }
.padmodal .ph b { font-size: 15px; }
.padmodal .ph span { display: block; font-size: 12px; color: #8a93a6; margin-top: 3px; }
.padmodal .pc { flex: 1; position: relative; padding: 0 10px; }
.padmodal .pc::after {
  content: "签名区"; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  color: #e6eaf2; font-size: 26px; letter-spacing: 8px; pointer-events: none;
}
.padmodal canvas { position: relative; display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.padmodal .pf {
  display: flex; gap: 10px; padding: 12px 14px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid #eef1f7;
}
.padmodal .pf .btn { flex: 1; padding: 13px 0; text-align: center; }

.toast {
  position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%);
  background: rgba(27, 31, 39, .94); color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 13.5px; z-index: 200; max-width: 82vw; text-align: center;
  font-family: -apple-system, "Microsoft YaHei", sans-serif;
}

.topnote {
  max-width: 812px; margin: 0 auto; padding: 10px 14px;
  font-size: 12.5px; color: #5b6478; display: flex; align-items: center; gap: 8px;
  font-family: -apple-system, "Microsoft YaHei", sans-serif;
}
.topnote b { color: #2a3d63; }
.topnote .sp { flex: 1; }
.topnote a { color: #2a5cff; text-decoration: none; font-weight: 600; white-space: nowrap; }

.okbanner {
  max-width: 812px; margin: 12px auto 0; background: #e9f8ef; border: 1px solid #bfe9d2;
  color: #15794a; border-radius: 12px; padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start;
  font-family: -apple-system, "Microsoft YaHei", sans-serif;
}
.okbanner .ic { width: 32px; height: 32px; border-radius: 50%; background: #1fa860; flex: none; position: relative; }
.okbanner .ic::after {
  content: ""; position: absolute; left: 11px; top: 7px; width: 8px; height: 15px;
  border: 3px solid #fff; border-top: 0; border-left: 0; transform: rotate(42deg);
}
.okbanner b { display: block; font-size: 15px; margin-bottom: 2px; }
.okbanner span { font-size: 12.5px; line-height: 1.5; }
