* { box-sizing: border-box; }
:root {
  --gold: #b28a4e;
  --gold-dark: #8f6b34;
  --ink: #2c2418;
  --muted: #85796a;
  --line: #e7ded0;
  --paper: #fffdf8;
  --bg: #f5f0e7;
}
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  color: var(--ink);
  background: radial-gradient(circle at 15% 0%, #fbf6ec 0, var(--bg) 46%, #efe8dc 100%);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.w-page { width: min(980px, 100%); margin: 0 auto; padding: 32px 20px 28px; }
.w-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.w-brand img { width: 56px; height: 56px; object-fit: cover; border-radius: 15px; background: #191510; box-shadow: 0 8px 22px rgba(74, 49, 14, .22); }
.w-brand h1 { margin: 0; font-family: "Songti SC", "STSong", serif; font-size: 27px; letter-spacing: 2px; }
.w-brand p { margin: 3px 0 0; color: var(--muted); font-size: 13px; letter-spacing: 2px; }
.w-card {
  background: rgba(255,253,248,.92);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(82,62,30,.08);
}
.w-login { max-width: 520px; padding: 26px 26px 22px; margin: 28px auto; }
.w-login h2 { margin: 0 0 8px; font-size: 21px; letter-spacing: .5px; }
.w-muted { color: var(--muted); font-size: 13px; margin: 0; }
.w-tabs {
  display: flex; gap: 4px; margin: 18px 0 20px; padding: 4px;
  border: 1px solid #ece1cf; border-radius: 12px; background: #f3ece0;
}
.w-tabs[hidden] { display: none; }
.w-tab {
  flex: 1 1 0; height: 38px; border: 1px solid transparent; border-radius: 9px;
  background: none; color: var(--muted); font-size: 14px; cursor: pointer; transition: .15s ease;
}
.w-tab:hover { color: var(--gold-dark); }
.w-tab.is-active {
  background: #fff; border-color: #eadfcb; color: var(--ink);
  font-weight: 600; box-shadow: 0 2px 8px rgba(120,92,50,.10);
}
.w-panel[hidden] { display: none; }
.w-panel form { display: flex; flex-direction: column; gap: 14px; margin: 0; }
.w-field { display: flex; flex-direction: column; gap: 7px; }
.w-panel-note { margin: 0 0 16px; line-height: 1.7; }
.w-field > span { color: var(--muted); font-size: 13px; }
.w-field input { width: 100%; flex: none; height: 46px; }
.w-code-row { display: flex; gap: 8px; }
.w-code-row input { flex: 1 1 auto; height: 46px; }
.w-code-row .w-btn { flex: 0 0 auto; height: 46px; }
.w-login input {
  min-width: 0; flex: 1; height: 46px; padding: 0 15px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; font-size: 15px; color: var(--ink); outline: none;
}
.w-login input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(178,138,78,.16); }
.w-login .w-field > input { flex: 0 0 auto; height: 46px; }
.w-login .w-code-row input { flex: 1 1 auto; width: auto; min-width: 0; height: 46px; }
.w-btn {
  height: 44px; padding: 0 20px; border-radius: 10px; border: 1px solid transparent;
  font-size: 14px; cursor: pointer; white-space: nowrap; transition: .15s ease;
}
.w-btn-primary { color: #fff; background: linear-gradient(135deg, var(--gold), var(--gold-dark)); border-color: var(--gold-dark); }
.w-btn-primary:hover { filter: brightness(1.05); }
.w-btn-primary:disabled { opacity: .55; cursor: wait; }
.w-btn-ghost { color: var(--ink); background: #fff; border-color: var(--line); }
.w-btn-ghost:hover { border-color: var(--gold); color: var(--gold-dark); }
.w-msg { min-height: 20px; margin: 8px 0 0; color: #b24a3a; font-size: 13px; }
.w-msg-ok { color: #2f7a4d; }
.w-tip { margin: 16px 0 0; color: #a29684; font-size: 12px; line-height: 1.7; }
.w-result { margin-top: 10px; }
.w-result-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 4px; }
.w-result-head h2 { margin: 2px 0 3px; font-size: 20px; }
.w-orders { display: grid; gap: 14px; }
.w-order {
  padding: 20px 22px; border: 1px solid var(--line); border-radius: 16px;
  background: var(--paper); box-shadow: 0 8px 24px rgba(90,68,32,.05);
}
.w-order-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.w-order-no { margin: 0 0 5px; font-weight: 700; font-size: 16px; letter-spacing: .4px; }
.w-order-meta { color: var(--muted); font-size: 12px; line-height: 1.8; }
.w-order-total { text-align: right; white-space: nowrap; }
.w-order-total b { display: block; font-size: 20px; color: var(--gold-dark); font-family: "Songti SC", serif; }
.w-order-total span { color: var(--muted); font-size: 12px; }
.w-order-items { margin: 16px 0 0; padding: 12px 0 0; border-top: 1px dashed var(--line); color: #5b5042; font-size: 13px; line-height: 1.9; }
.w-order-actions { display: flex; justify-content: flex-end; margin-top: 14px; }
.w-empty { padding: 40px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 14px; background: rgba(255,255,255,.45); }
.w-footer { margin-top: 36px; text-align: center; color: #a29684; font-size: 12px; line-height: 1.8; }
.w-footer p { margin: 0; }

.w-modal {
  position: fixed; inset: 0; z-index: 50; overflow: auto;
  padding: 26px 18px 36px; background: rgba(42,32,18,.45);
}
.w-modal-bar { position: sticky; top: 0; z-index: 2; display: flex; justify-content: flex-end; gap: 10px; width: min(1200px, 100%); margin: 0 auto 14px; }
.w-cert {
  width: min(241mm, 100%); min-height: 140mm; margin: 0 auto; padding: 6mm 7mm;
  background: #fff; color: #1f1a12; box-shadow: 0 26px 80px rgba(0,0,0,.25);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
  font-synthesis: none;
}
.w-v-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; border-bottom: 1.5px solid #6f6251; padding-bottom: 2mm; }
.w-v-head h1 { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: .6px; white-space: nowrap; }
.w-v-head p { margin: 2px 0 0; font-size: 9px; color: #6f6251; }
.w-v-head img { width: 46px; height: 46px; object-fit: contain; }
.w-v-top-qr { display: flex; flex-direction: column; align-items: center; gap: 1mm; flex: 0 0 auto; color: #6f6251; font-size: 7.5px; line-height: 1.2; text-align: center; }
.w-v-top-qr span { white-space: nowrap; }
.w-v-info { display: flex; flex-wrap: wrap; gap: 2px 18px; padding: 1.6mm 0; font-size: 9.5px; border-bottom: 1px solid #6f6251; }
.w-v-table-wrap { width: 100%; }
.w-cert .w-v-table-wrap table { font-size: 8.5px; }
.w-v-table-wrap th, .w-v-table-wrap td { padding: 1.6mm 1.4mm !important; line-height: 1.3; }
.w-v-table-wrap tbody tr { height: 6mm; }
.w-v-sum { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 3px 18px; padding: 1.4mm 0; font-size: 9.5px; border-bottom: 1px solid #6f6251; }
.w-v-sum b { color: #6f3f18; font-size: 10.5px; }
.w-v-paid b { font-size: 13px; color: #8f2f1f; }
.w-v-terms { column-count: 2; column-gap: 8mm; border: 1px solid #6f6251; padding: 1.5mm 2mm; margin-top: 1.6mm; font-size: 7.1px; line-height: 1.42; }
.w-v-terms p { margin: 0; break-inside: avoid; }
.w-cert-promise { font-weight: 700; }
.w-v-foot { display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: 3px 10px; margin-top: 1.8mm; font-size: 8px; color: #4d4234; }
.w-v-qr { display: flex; flex-direction: column; align-items: center; gap: 1mm; margin-left: auto; color: #8f6b34; text-align: center; }
.w-v-qr img { width: 12mm; height: 12mm; object-fit: contain; }
.w-v-qr em { max-width: 26mm; font-style: normal; font-size: 7.2px; line-height: 1.3; }
.w-cert-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 2px solid #8f6b34; padding-bottom: 10px; }
.w-cert-brand { display: flex; align-items: center; gap: 12px; }
.w-cert-brand img { width: 46px; height: 46px; object-fit: contain; }
.w-cert-brand h2 { margin: 0; font-size: 22px; letter-spacing: 3px; }
.w-cert-brand p { margin: 3px 0 0; color: #6f6251; font-size: 11px; letter-spacing: 2px; }
.w-cert-title { text-align: right; }
.w-cert-title h1 { margin: 0; font-size: 25px; letter-spacing: 4px; }
.w-cert-title p { margin: 4px 0 0; color: #6f6251; font-size: 11px; }
.w-cert-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px; padding: 16px 0 12px; font-size: 12.5px; line-height: 1.7; }
.w-cert-meta span { color: #6f6251; }
.w-cert table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 12px; }
.w-cert th, .w-cert td { border: 1px solid #6f6251; padding: 6px 7px; line-height: 1.35; vertical-align: middle; }
.w-cert th { background: #f3ecdf; font-weight: 700; text-align: center; }
.w-cert td.c { text-align: center; }
.w-cert td.r { text-align: right; }
.w-cert-total { display: flex; justify-content: flex-end; gap: 28px; padding: 10px 2px; font-size: 13px; }
.w-cert-total b { font-size: 16px; color: #8f6b34; }
.w-cert-box { margin-top: 14px; border: 1px solid #6f6251; padding: 12px 14px; font-size: 12px; line-height: 1.9; }
.w-cert-box h3 { margin: 0 0 7px; font-size: 13px; letter-spacing: 2px; }
.w-cert-box p { margin: 2px 0; }
.w-cert-terms { margin-top: 7px; }
.w-cert-terms p { margin: 1px 0; }
.w-cert-promise { font-weight: 700; }
.w-cert-foot { display: flex; justify-content: space-between; margin-top: 24px; font-size: 11px; color: #6f6251; }
.w-cert-qr { display: flex; align-items: center; gap: 8px; }
.w-cert-qr img { width: 58px; height: 58px; object-fit: contain; }

/* 可视化设计器导出的电子凭证模板 */
.w-cert.template-mode {
  width: auto; min-height: 0; padding: 0; background: transparent;
  box-shadow: none;
}
.w-template-page {
  overflow: hidden; margin: 0 auto; background: #fff;
  box-shadow: 0 26px 80px rgba(0,0,0,.25);
}
.w-template-page .v-tpl-page {
  position: relative; overflow: hidden; padding: 0 !important;
  background: #fff; color: #000; box-sizing: border-box;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
  font-synthesis: none;
}
.w-template-page .vd-el { position: absolute; box-sizing: border-box; }
.w-template-page .vd-text { width: 100%; height: 100%; white-space: pre-wrap; overflow: hidden; }
.w-template-page .vd-bordered .vd-text { padding: .45mm 1.5mm; }
.w-template-page .vd-img { width: 100%; height: 100%; object-fit: contain; display: block; }
.w-template-page .vd-qr, .w-template-page .vd-qr img { width: 100%; height: 100%; display: block; }
.w-template-page .vd-barcode, .w-template-page .vd-barcode svg { width: 100%; height: 100%; display: block; }
.w-template-page .vd-fields { width: 100%; height: 100%; border-collapse: collapse; table-layout: fixed; }
.w-template-page .vd-fields td { border: .75pt solid #000; padding: .4mm .6mm; vertical-align: middle; white-space: nowrap; overflow: hidden; font-size: inherit; }
.w-template-page .vd-items { width: 100%; border-collapse: collapse; table-layout: fixed; }
.w-template-page .vd-items th, .w-template-page .vd-items td { border: .75pt solid #000; padding: .4mm .55mm; vertical-align: middle; font-size: inherit; line-height: 1.25; }
.w-template-page .vd-items th { height: 6mm; text-align: center; background: #f2f2f2; font-weight: 700; }
.w-template-page .vd-items .c { text-align: center; }
.w-template-page .vd-items .r { text-align: right; padding-right: 1.2mm; }
.w-template-page .vd-items .fill td { height: 5.8mm; }
.w-template-page .vd-items .vd-adjust td { height: 5mm; font-size: .88em; }
.w-template-page .vd-items .vd-adjust span:first-child { float: left; }
.w-template-page .vd-items .vd-adjust span:last-child { float: right; }
.w-template-page .vd-items .vd-total td { height: 7.4mm; font-size: 1.03em; }
.w-template-page .vd-items .upper { font-weight: 700; letter-spacing: .3pt; }
.w-template-page .vd-terms { width: 100%; height: 100%; padding: .55mm 1.6mm; overflow: hidden; }
.w-template-page .vd-terms p { margin: 0; }
.w-template-page .vd-terms .promise { text-align: center; font-weight: 700; margin-bottom: .3mm; }
.w-template-page .vd-line { width: 100%; border-top: .75pt solid #000; }
.w-template-page .vd-items tbody td.vd-note {
  white-space: pre-wrap; word-break: break-all; overflow-wrap: anywhere;
  vertical-align: top; line-height: 1.25;
}

/* 电子版屏幕配色：打印仍保持黑白商务版式 */
@media screen {
  .w-modal {
    background:
      radial-gradient(ellipse at 20% 0%, rgba(255,255,255,.18), transparent 45%),
      rgba(38,29,18,.56);
    backdrop-filter: blur(3px);
  }
  .w-modal-bar {
    align-items: center;
    padding: 8px 10px;
    border: 1px solid rgba(255,239,208,.2);
    border-radius: 14px;
    background: rgba(42,31,18,.72);
    box-shadow: 0 12px 30px rgba(0,0,0,.18);
    backdrop-filter: blur(8px);
  }
  .w-modal-bar::before {
    content: "电子销售凭证";
    margin-right: auto;
    padding-left: 8px;
    color: #f4e4c5;
    font-size: 14px;
    letter-spacing: 2px;
  }
  .w-modal-bar .w-btn-ghost {
    color: #f4e4c5;
    background: rgba(255,255,255,.06);
    border-color: rgba(244,228,197,.28);
  }
  .w-modal-bar .w-btn-ghost:hover {
    color: #fff;
    border-color: rgba(244,228,197,.5);
  }
  .w-cert.template-mode {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 0 20px;
  }
  .w-template-page {
    border: 1px solid rgba(178,138,78,.28);
    border-radius: 4px;
    box-shadow: 0 30px 80px rgba(0,0,0,.34), 0 2px 8px rgba(0,0,0,.18);
  }
  .w-template-page .v-tpl-page {
    background: linear-gradient(180deg, #fffdf8 0%, #fff 22%, #fffefb 100%);
  }
  .w-template-page .vd-el[data-eid="title"] .vd-text {
    color: #7a5520 !important;
    letter-spacing: 1.2px;
  }
  .w-template-page .vd-items th {
    background: #f3e6ce !important;
    color: #5c421f;
    border-color: #8e6b37 !important;
  }
  .w-template-page .vd-items td {
    border-color: #bda681 !important;
  }
  .w-template-page .vd-items .vd-total td {
    background: #fff7e8;
    font-weight: 700;
  }
  .w-template-page .vd-fields td {
    background: #fffdf8;
    border-color: #bda681 !important;
  }
  .w-template-page .vd-terms {
    border: 1px solid #d9c19a;
    background: #fffaf0;
  }
  .w-template-page .vd-qr, .w-template-page .vd-barcode {
    filter: saturate(.85);
  }
}

@media (max-width: 640px) {
  .w-page { padding: 20px 14px 24px; }
  .w-brand { margin-bottom: 18px; }
  .w-brand h1 { font-size: 23px; }
  .w-login { padding: 22px 18px; margin: 18px auto; }
  .w-login form { flex-direction: column; }
  .w-order { padding: 16px; }
  .w-order-top { flex-direction: column; }
  .w-order-total { text-align: left; }
  .w-result-head { align-items: flex-start; flex-direction: column; }
  .w-modal { padding: 10px 6px 20px; }
  .w-cert { min-height: 0; padding: 4mm; }
  .w-v-head h1 { font-size: 16px; letter-spacing: 1.5px; white-space: normal; }
  .w-v-head img { width: 36px; height: 36px; }
  .w-v-head p { font-size: 8px; }
  .w-v-info { font-size: 8.5px; gap: 1px 10px; }
  .w-v-table-wrap { overflow-x: auto; }
  .w-v-table-wrap table { min-width: 620px; }
  .w-v-terms { column-count: 1; }
  .w-v-foot { flex-wrap: wrap; }
}

@media print {
  @page { size: 241mm 140mm; margin: 0; }
  body { background: #fff; }
  body.printing .w-page, body.printing .w-modal-bar { display: none !important; }
  body.printing .w-modal { position: static; display: block !important; padding: 0; background: #fff; overflow: visible; }
  body.printing .w-cert {
    width: 241mm; height: 140mm; min-height: 0; margin: 0; padding: 5mm 6mm;
    box-shadow: none; overflow: hidden;
  }
  body.printing .w-cert.template-mode { width: 203.2mm; height: 130.4mm; padding: 0; }
  body.printing .w-template-page { width: auto !important; height: auto !important; box-shadow: none; overflow: visible; }
  body.printing .w-template-page .v-tpl-page { transform: none !important; }
  body.printing .w-v-table-wrap { overflow: visible; }
  body.printing .w-v-table-wrap table { min-width: 0; }
}

/* 用户协议 / 隐私政策 */
.w-consent {
  display: flex; flex-wrap: wrap; align-items: center; gap: 3px;
  margin: 2px 0 2px; color: #85796a; font-size: 12.5px; line-height: 1.8;
}
.w-consent-box { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.w-consent-box input[type="checkbox"] { width: 15px; height: 15px; margin: 0; flex: none; accent-color: var(--gold-dark); }
.w-consent-links { display: inline-flex; align-items: center; gap: 2px; }
.w-terms-link {
  padding: 0; border: 0; background: none; color: var(--gold-dark); font-size: 12.5px;
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.w-terms-link:hover { color: #6f5527; }
.w-terms-modal { display: flex; align-items: flex-start; justify-content: center; }
.w-terms-modal[hidden] { display: none; }
.w-terms-card {
  display: flex; flex-direction: column; width: min(720px, 100%); max-height: calc(100vh - 60px);
  background: var(--paper); border-radius: 16px; overflow: hidden;
  box-shadow: 0 26px 80px rgba(0, 0, 0, .25);
}
.w-terms-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.w-terms-head h3 { margin: 0; font-size: 17px; }
.w-terms-body { padding: 18px 22px 10px; overflow: auto; color: #4d4437; font-size: 13.5px; line-height: 1.85; }
.w-terms-body h4 { margin: 18px 0 6px; font-size: 14px; color: var(--ink); }
.w-terms-body h4:first-child { margin-top: 0; }
.w-terms-body p { margin: 0 0 7px; }
.w-terms-foot { display: flex; justify-content: flex-end; padding: 12px 20px 18px; border-top: 1px solid var(--line); }
.w-terms-foot .w-btn { min-width: 170px; }
.w-orders-hint { margin: 0 0 12px; }
.w-order-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.w-btn-del { color: #a4442f; border-color: #e6cfc7; }
.w-btn-del:hover { background: #fbf1ee; }
.w-toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translate(-50%, 8px);
  z-index: 60;
  max-width: calc(100% - 40px);
  padding: 11px 18px;
  border-radius: 999px;
  background: rgba(38, 30, 20, .92);
  color: #f7efe2;
  font-size: 13px;
  opacity: 0;
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none;
}
.w-toast.is-show { opacity: 1; transform: translate(-50%, 0); }
