:root {
  --app-bg: #edf2f8;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #d0d8e6;
  --blue: #0a2a66;
  --paper: #fffdfa;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--app-bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  min-height: 100vh;
}

.controls {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 18px;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.controls h1 {
  margin: 0 0 8px;
  font-size: 21px;
  line-height: 1.25;
}

.intro,
.hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.intro {
  margin-bottom: 18px;
}

.hint {
  padding: 12px;
  border: 1px dashed #bdc8da;
  border-radius: 8px;
  background: #f7f9fc;
}

.field {
  margin-bottom: 13px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid #c4cfde;
  border-radius: 8px;
  outline: none;
  background: #ffffff;
  color: #111827;
  font-size: 14px;
}

input:focus,
select:focus {
  border-color: #1b63c9;
  box-shadow: 0 0 0 3px rgba(27, 99, 201, 0.14);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 18px 0 14px;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

.button.primary {
  color: #ffffff;
  background: #092d72;
}

.button.secondary {
  color: #092d72;
  background: #e8f0ff;
}

.button.download {
  grid-column: 1 / -1;
  color: #ffffff;
  background: #174f9a;
}

.preview {
  overflow: auto;
  padding: 22px;
}

.preview-toolbar {
  display: flex;
  max-width: 210mm;
  justify-content: space-between;
  gap: 16px;
  margin: 0 auto 14px;
  color: var(--muted);
  font-size: 13px;
}

.pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.page {
  --page-pad: 7mm;
  --page-gap: 3mm;
  --page-inner-width: calc(210mm - (var(--page-pad) * 2));
  --page-inner-height: calc(297mm - (var(--page-pad) * 2));
  --voucher-cell-width: calc((var(--page-inner-width) - var(--page-gap)) / 2);
  --voucher-cell-height: calc((var(--page-inner-height) - (var(--page-gap) * 4)) / 5);
  position: relative;
  display: grid;
  width: 210mm;
  height: 297mm;
  padding: var(--page-pad);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(5, minmax(0, 1fr));
  gap: var(--page-gap);
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
  page-break-after: always;
  break-after: page;
}

.page::before {
  content: "";
  position: absolute;
  inset: 5mm;
  z-index: 4;
  border: 0.25mm dashed rgba(9, 45, 114, 0.35);
  pointer-events: none;
}

.cut-line {
  position: absolute;
  z-index: 5;
  pointer-events: none;
}

.cut-line.vertical {
  top: var(--page-pad);
  bottom: var(--page-pad);
  left: calc(var(--page-pad) + var(--voucher-cell-width) + (var(--page-gap) / 2));
  border-left: 0.26mm dashed currentColor;
  opacity: 0.58;
}

.cut-line.horizontal {
  right: var(--page-pad);
  left: var(--page-pad);
  border-top: 0.26mm dashed currentColor;
  opacity: 0.58;
}

.cut-line.h1 { top: calc(var(--page-pad) + (var(--voucher-cell-height) * 1) + (var(--page-gap) * 0.5)); }
.cut-line.h2 { top: calc(var(--page-pad) + (var(--voucher-cell-height) * 2) + (var(--page-gap) * 1.5)); }
.cut-line.h3 { top: calc(var(--page-pad) + (var(--voucher-cell-height) * 3) + (var(--page-gap) * 2.5)); }
.cut-line.h4 { top: calc(var(--page-pad) + (var(--voucher-cell-height) * 4) + (var(--page-gap) * 3.5)); }

.page-svg-border {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  color: var(--voucher-main, #0b3b82);
  pointer-events: none;
}

.voucher {
  position: relative;
  z-index: 2;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* Original styles, restored */
.legacy-voucher {
  display: flex;
  flex-direction: column;
  border-radius: 3mm;
  padding: 4.8mm 6mm 4.2mm;
  isolation: isolate;
}

.legacy-voucher .brand {
  overflow: hidden;
  font-size: 3.6mm;
  font-weight: 900;
  letter-spacing: 0.22mm;
  line-height: 1.2;
  white-space: nowrap;
  text-align: center;
  text-overflow: ellipsis;
}

.legacy-voucher .subbrand {
  overflow: hidden;
  margin-top: 0.6mm;
  font-size: 1.7mm;
  font-weight: 700;
  line-height: 1.2;
  opacity: 0.62;
  letter-spacing: 0.12mm;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.legacy-voucher .main {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 1.2mm;
  margin-top: 1.8mm;
  line-height: 1;
  white-space: nowrap;
}

.legacy-voucher .amount {
  font-family: Arial, "Microsoft YaHei", sans-serif;
  font-size: 13.8mm;
  font-weight: 950;
  letter-spacing: -0.3mm;
}

.legacy-voucher .unit {
  font-size: 5mm;
  font-weight: 950;
}

.legacy-voucher .info {
  display: grid;
  gap: 0.45mm;
  margin-top: 1.4mm;
  font-size: 2.35mm;
  font-weight: 650;
  line-height: 1.25;
}

.legacy-voucher .info-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.9mm;
  min-width: 0;
  white-space: nowrap;
}

.legacy-voucher .info-line span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

.legacy-voucher .icon {
  width: 2.6mm;
  height: 2.6mm;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  font-size: 1.8mm;
  font-weight: 900;
  flex: 0 0 auto;
}

.legacy-voucher .serial {
  position: absolute;
  right: 6mm;
  bottom: 8.8mm;
  z-index: 2;
  display: flex;
  align-items: baseline;
  gap: 0.8mm;
  text-align: center;
}

.legacy-voucher .serial-label {
  font-size: 2.6mm;
  font-weight: 900;
}

.legacy-voucher .serial-no {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 4.7mm;
  font-weight: 800;
  letter-spacing: 0.1mm;
}

.legacy-voucher .note {
  position: absolute;
  right: 6mm;
  bottom: 3mm;
  left: 6mm;
  z-index: 2;
  overflow: hidden;
  font-size: 1.65mm;
  line-height: 1.15;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legacy-voucher .cut {
  position: absolute;
  inset: 2.3mm;
  z-index: 3;
  border: 0.25mm dashed rgba(0, 0, 0, 0.18);
  border-radius: 2mm;
  pointer-events: none;
}

.style-corporate {
  color: #0a2a66;
  border: 0.45mm solid #0a2a66;
  background:
    linear-gradient(135deg, #06215c 0 12mm, transparent 12.2mm),
    linear-gradient(315deg, #0b63d8 0 17mm, transparent 17.2mm),
    linear-gradient(140deg, rgba(12, 99, 216, 0.12), transparent 45%),
    #ffffff;
}

.style-corporate::before {
  content: "";
  position: absolute;
  right: -18mm;
  top: 4mm;
  z-index: -1;
  width: 58mm;
  height: 58mm;
  border-radius: 50%;
  background: radial-gradient(circle at center, rgba(11, 99, 216, 0.10), rgba(11, 99, 216, 0.03) 50%, transparent 62%);
}

.style-corporate .amount,
.style-corporate .unit,
.style-corporate .brand,
.style-corporate .serial-label {
  color: #063b96;
}

.style-corporate .icon {
  color: white;
  background: #0b63d8;
}

.style-finance {
  color: #17345e;
  border: 0.35mm solid #8db3de;
  background:
    repeating-linear-gradient(135deg, rgba(51, 108, 176, 0.045) 0 1mm, transparent 1mm 3mm),
    linear-gradient(90deg, #f8fbff, #ffffff 44%, #eef5ff);
}

.style-finance::before {
  content: "";
  position: absolute;
  inset: 5mm;
  z-index: -1;
  border: 0.35mm solid rgba(43, 102, 178, 0.28);
  border-radius: 2mm;
}

.style-finance .amount,
.style-finance .unit {
  color: #0b55ad;
}

.style-finance .serial {
  right: 8mm;
  bottom: 8.5mm;
  padding: 1.1mm 3.2mm;
  color: white;
  background: linear-gradient(135deg, #0b55ad, #063b7a);
  border-radius: 999px;
  box-shadow: 0 1mm 3mm rgba(6, 59, 122, 0.18);
}

.style-finance .serial-label,
.style-finance .serial-no {
  display: inline;
  color: white;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 3.4mm;
  letter-spacing: 0.1mm;
}

.style-finance .icon {
  color: #0b55ad;
  background: #e7f0ff;
}

.style-minimal {
  color: #111827;
  border: 0.35mm solid #0f172a;
  border-radius: 2mm;
  background: white;
}

.style-minimal::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: -1;
  width: 4mm;
  background: #0b63d8;
}

.style-minimal .subbrand,
.style-minimal .cut {
  display: none;
}

.style-minimal .main,
.style-minimal .info {
  margin-left: 5mm;
}

.style-minimal .amount {
  color: #0b63d8;
}

.style-minimal .unit {
  color: #111827;
}

.style-minimal .icon {
  color: #0b63d8;
  background: transparent;
  border: 0.25mm solid #0b63d8;
}

.style-minimal .serial {
  border-top: 0.3mm solid #111827;
  padding-top: 1.5mm;
}

.style-minimal .note {
  left: 14mm;
}

.style-tech {
  color: #0a2540;
  border: 0.35mm solid rgba(37, 99, 235, 0.38);
  background:
    radial-gradient(circle at 12% 12%, rgba(33, 150, 243, 0.16), transparent 22%),
    radial-gradient(circle at 100% 0%, rgba(124, 58, 237, 0.13), transparent 34%),
    linear-gradient(135deg, #ffffff 0%, #f7fbff 58%, #eef5ff 100%);
}

.style-tech::before {
  content: "";
  position: absolute;
  right: -10mm;
  top: -18mm;
  z-index: -1;
  width: 55mm;
  height: 70mm;
  background: linear-gradient(135deg, rgba(0, 91, 255, 0.18), rgba(124, 58, 237, 0.10));
  clip-path: polygon(24% 0, 100% 0, 76% 100%, 0 100%);
  transform: rotate(22deg);
}

.style-tech .amount {
  color: transparent;
  background: linear-gradient(135deg, #0066ff, #6d28d9);
  -webkit-background-clip: text;
  background-clip: text;
}

.style-tech .unit,
.style-tech .brand,
.style-tech .serial-label {
  color: #0b63d8;
}

.style-tech .icon {
  color: white;
  background: linear-gradient(135deg, #0b63d8, #6d28d9);
}

/* User reference style */
.reference-voucher {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3mm 4.5mm;
  text-align: center;
  color: #2c3e50;
  border: 0.55mm solid #b22234;
  border-radius: 2.7mm;
  background: #fffef7;
  box-shadow: 0 0.4mm 1.4mm rgba(0, 0, 0, 0.06);
}

.reference-company {
  width: 100%;
  overflow: hidden;
  padding-bottom: 1mm;
  margin-bottom: 1.3mm;
  color: #1a3c6e;
  border-bottom: 0.25mm solid #d0d7e2;
  font-size: 3.7mm;
  font-weight: 800;
  letter-spacing: 0.45mm;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-amount {
  color: #b22234;
  font-size: 8mm;
  font-weight: 950;
  line-height: 1.08;
  white-space: nowrap;
}

.reference-amount small {
  margin-left: 1mm;
  color: #444444;
  font-size: 4.2mm;
  font-weight: 500;
}

.reference-number {
  min-width: 31mm;
  padding: 0.55mm 3.8mm;
  margin: 1.2mm 0;
  color: #2c3e50;
  background: #edf2f7;
  border-radius: 999px;
  font-family: "Courier New", monospace;
  font-size: 5.1mm;
  font-weight: 700;
  letter-spacing: 0.2mm;
  line-height: 1.16;
}

.reference-valid {
  width: 100%;
  padding-top: 1mm;
  color: #555555;
  border-top: 0.25mm solid #dddddd;
  font-size: 2.9mm;
  font-weight: 600;
  line-height: 1.35;
}

.reference-valid span {
  display: inline-block;
  padding: 0 1.6mm;
  color: #8a6d3b;
  background: #fef3d7;
  border-radius: 1mm;
  font-weight: 800;
}

/* New Figma SVG styles */
.is-figma-page {
  color: var(--voucher-main, #0b3b82);
  background:
    radial-gradient(circle at center, rgba(9, 45, 114, 0.035), transparent 34%),
    var(--paper);
}

.svg-voucher {
  color: var(--voucher-main);
}

.voucher-svg {
  display: block;
  width: 100%;
  height: 100%;
  color: var(--voucher-main);
}

.voucher-svg text {
  text-anchor: middle;
  dominant-baseline: middle;
  fill: var(--voucher-dark);
}

.svg-guilloche ellipse {
  fill: none;
  stroke: var(--voucher-main);
  stroke-width: 0.9;
}

.svg-ornament {
  color: var(--voucher-main);
  stroke: currentColor;
  stroke-width: 1.5;
}

.svg-ornament circle {
  stroke: currentColor;
}

.svg-brand {
  font-family: "SimSun", "Songti SC", "Noto Serif SC", serif;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0;
}

.svg-title {
  font-family: "SimSun", "Songti SC", "Noto Serif SC", serif;
  font-weight: 900;
}

.svg-amount {
  font-size: 49px;
}

.svg-name {
  font-size: 30px;
}

.compact .svg-amount,
.bold-frame .svg-amount,
.band-title .svg-amount,
.diagonal-title .svg-amount,
.ribbon-title .svg-amount {
  font-size: 48px;
}

.compact .svg-name,
.bold-frame .svg-name,
.band-title .svg-name,
.diagonal-title .svg-name,
.ribbon-title .svg-name {
  font-size: 29px;
}

.side .svg-amount {
  font-size: 45px;
}

.side .svg-name {
  font-size: 27px;
}

.medal-title .svg-amount {
  font-size: 43px;
}

.medal-title .svg-name {
  font-size: 26px;
}

.mono-title .svg-amount {
  font-size: 50px;
}

.mono-title .svg-name {
  font-size: 28px;
}

.svg-detail {
  font-family: "SimSun", "Songti SC", "Noto Serif SC", serif;
  font-size: 10.6px;
  font-weight: 700;
  letter-spacing: 0;
}

.svg-serial-plate {
  fill: var(--voucher-main);
  stroke: var(--voucher-dark);
  stroke-width: 1.5;
}

.svg-serial {
  fill: #ffffff !important;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

.svg-serial.small {
  font-size: 10px;
}

.svg-note {
  font-family: "SimSun", "Songti SC", "Noto Serif SC", serif;
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0;
}

.svg-side-word {
  fill: #ffffff !important;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.8px;
}

.svg-rosette circle,
.svg-rosette path {
  fill: none;
  stroke: var(--voucher-main);
  stroke-width: 2.2;
}

.scheme-side .svg-rosette circle,
.scheme-side .svg-rosette path {
  stroke: #ffffff;
}

.svg-info-band {
  fill: var(--voucher-pale);
  opacity: 0.82;
}

.ribbon-brand {
  fill: #ffffff !important;
  font-size: 14px;
}

.medal-brand {
  font-size: 16px;
}

.side-note {
  font-size: 6.8px;
}

.mono-brand {
  font-family: "Microsoft YaHei", "Noto Sans SC", Arial, sans-serif;
  font-size: 16px;
  letter-spacing: 0;
}

.mono-label {
  fill: var(--voucher-dark);
  font-family: Arial, sans-serif;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.8px;
}

@media screen and (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .controls {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .preview {
    padding: 12px;
  }

  .page {
    transform: scale(0.55);
    transform-origin: top center;
    margin-bottom: -130mm;
  }
}

@media print {
  body {
    background: #ffffff;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .app-shell {
    display: block;
  }

  .controls,
  .preview-toolbar {
    display: none !important;
  }

  .preview {
    padding: 0;
    overflow: visible;
  }

  .pages {
    display: block;
  }

  .page {
    margin: 0;
    box-shadow: none;
  }

  .reference-voucher {
    box-shadow: none;
  }

  @page {
    size: A4 portrait;
    margin: 0;
  }
}
