:root {
  --bg: #edf4ff;
  --panel: rgba(255, 255, 255, 0.94);
  --ink: #1d257d;
  --muted: #5e669f;
  --accent: #ff7a18;
  --accent-strong: #dc5d00;
  --blue-deep: #252a8f;
  --blue-soft: #dce7ff;
  --line: rgba(37, 42, 143, 0.14);
  --paper: #ffffff;
  --shadow: 0 24px 60px rgba(28, 45, 125, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 122, 24, 0.22), transparent 26%),
    radial-gradient(circle at bottom right, rgba(37, 42, 143, 0.2), transparent 30%),
    linear-gradient(135deg, #f6f9ff 0%, #e6efff 55%, #fff4e8 100%);
}

.shell {
  display: grid;
  grid-template-columns: minmax(320px, 400px) 1fr;
  gap: 24px;
  padding: 24px;
}

.panel,
.workspace {
  border: 1px solid var(--line);
  border-radius: 0;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

.panel {
  padding: 28px;
  background: var(--panel);
}

.workspace {
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(244, 248, 255, 0.92)),
    var(--paper);
}

.eyebrow {
  margin-bottom: 10px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1;
}

.intro {
  margin-top: 14px;
  color: var(--muted);
  line-height: 1.6;
}

.form-grid {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

label {
  display: grid;
  gap: 8px;
}

label span {
  font-size: 0.92rem;
  font-weight: 500;
}

.field-title {
  font-size: 0.92rem;
  font-weight: 500;
}

.required-star {
  color: #d61f1f;
  font-weight: 700;
}

.optional-text {
  color: var(--muted);
  font-weight: 400;
}

.names-section {
  display: grid;
  gap: 10px;
}

.names-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.name-fields {
  display: grid;
  gap: 10px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 4px;
}

.name-fields.is-hidden {
  display: none;
}

.name-field {
  display: grid;
  gap: 6px;
}

.name-field span {
  font-size: 0.82rem;
  color: var(--muted);
}

.toggle-field {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.toggle-field input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-slider {
  position: relative;
  width: 42px;
  height: 24px;
  border: 1px solid rgba(37, 42, 143, 0.2);
  background: #d8e3fb;
  transition: background 120ms ease;
}

.toggle-slider::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  transition: transform 120ms ease;
}

.toggle-field input:checked + .toggle-slider {
  background: linear-gradient(135deg, #ff8d32 0%, var(--accent-strong) 100%);
}

.toggle-field input:checked + .toggle-slider::after {
  transform: translateX(18px);
}

input {
  width: 100%;
  border: 1px solid rgba(37, 42, 143, 0.18);
  border-radius: 0;
  padding: 14px 16px;
  color: var(--ink);
  font: inherit;
  background: rgba(255, 255, 255, 0.98);
}

input:focus {
  outline: 2px solid rgba(255, 122, 24, 0.22);
  border-color: var(--accent);
}

.currency-input {
  display: grid;
  grid-template-columns: 50px 1fr;
  align-items: center;
  border: 1px solid rgba(37, 42, 143, 0.18);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.98);
}

.currency-input span {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--blue-deep);
  font-weight: 700;
  border-right: 1px solid rgba(37, 42, 143, 0.12);
}

.currency-input input {
  border: 0;
  background: transparent;
}

.actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 8px;
}

button {
  border: 0;
  border-radius: 0;
  padding: 14px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease, background 120ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button.primary {
  color: #fff;
  background: linear-gradient(135deg, #ff8d32 0%, var(--accent-strong) 100%);
}

button.secondary {
  color: var(--blue-deep);
  background: linear-gradient(180deg, #ffffff 0%, #edf3ff 100%);
  border: 1px solid rgba(37, 42, 143, 0.18);
}

.summary-section {
  margin-top: 24px;
}

.summary-title {
  margin-bottom: 12px;
  color: var(--blue-deep);
  font-size: 1rem;
  letter-spacing: 0.08em;
}

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

.summary div {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(235, 243, 255, 0.88));
  border-top: 4px solid var(--accent);
}

.summary span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.86rem;
}

.summary strong {
  display: block;
  font-size: 1.15rem;
  color: var(--blue-deep);
  line-height: 1.3;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.workspace-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 20px;
}

#status-text {
  max-width: 360px;
  color: var(--muted);
  text-align: right;
}

.pages {
  display: grid;
  gap: 24px;
}

.print-page {
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  padding: 10mm;
  border-radius: 0;
  background: var(--paper);
  box-shadow: 0 20px 40px rgba(28, 45, 125, 0.1);
}

.page-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8mm;
}

.voucher-card {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 48mm;
  padding: 14px;
  border: 1.5px solid #000;
  border-radius: 0;
  background: #fff;
  overflow: hidden;
  position: relative;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.card-bottom {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: stretch;
  gap: 12px;
}

.card-brand-block {
  display: grid;
  gap: 8px;
}

.card-side-meta {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.card-logo {
  display: block;
  width: 74px;
  max-height: 48px;
  object-fit: contain;
  filter: grayscale(1) contrast(1.2);
}

.brand,
.label,
.card-note {
  color: #000;
}

.brand {
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.amount {
  margin-top: 8px;
  font-size: 1.65rem;
}

.key-number,
.voucher-code {
  font-family: "Consolas", "Courier New", monospace;
}

.key-number {
  padding: 6px 10px;
  border: 1px solid #000;
  border-radius: 0;
  background: #fff;
  font-size: 0.85rem;
  white-space: nowrap;
}

.card-body {
  display: grid;
  align-content: center;
  gap: 8px;
}

.label {
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.voucher-code {
  font-size: 1.3rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  word-break: break-word;
  color: #000;
}

.card-note {
  font-size: 0.8rem;
  line-height: 1.5;
}

.card-contact {
  padding-top: 8px;
  border-top: 1px solid #000;
  text-align: center;
}

.contact-line {
  color: #000;
  font-size: 0.68rem;
  line-height: 1.35;
}

@media (max-width: 1200px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .workspace-head {
    align-items: start;
    flex-direction: column;
  }

  #status-text {
    text-align: left;
  }
}

@media (max-width: 720px) {
  .shell {
    padding: 14px;
  }

  .panel,
  .workspace {
    padding: 18px;
    border-radius: 0;
  }

  .actions,
  .summary,
  .page-grid {
    grid-template-columns: 1fr;
  }

  .print-page {
    width: 100%;
    min-height: auto;
    padding: 14px;
  }
}

@page {
  size: A4;
  margin: 10mm;
}

@media print {
  body {
    background: #fff;
  }

  .controls,
  .workspace-head {
    display: none;
  }

  .shell,
  .workspace,
  .pages {
    display: block;
    padding: 0;
    margin: 0;
    background: #fff;
    box-shadow: none;
    border: 0;
  }

  .print-page {
    width: auto;
    min-height: 277mm;
    padding: 0;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    break-after: page;
  }

  .print-page:last-child {
    break-after: auto;
  }

  .page-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 4mm;
    min-height: 277mm;
  }

  .voucher-card {
    min-height: 0;
    height: 100%;
    padding: 8px 10px;
    break-inside: avoid;
    color-adjust: exact;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .card-top {
    gap: 8px;
  }

  .card-bottom {
    gap: 6px;
  }

  .card-logo {
    width: 52px;
    max-height: 34px;
    filter: grayscale(1) contrast(1.5);
  }

  .brand {
    font-size: 0.68rem;
  }

  .amount {
    margin-top: 0;
    font-size: 0.95rem;
  }

  .key-number {
    padding: 3px 6px;
    font-size: 0.66rem;
  }

  .card-note {
    font-size: 0.64rem;
    line-height: 1.2;
  }

  .card-contact {
    padding-top: 4px;
  }

  .contact-line {
    font-size: 0.5rem;
    line-height: 1.2;
  }

  @page {
    size: A4;
    margin: 10mm;
  }
}
