:root {
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;

  color: #132038;
  background: #f8fafc;
  font-synthesis: none;

  --page-bg: #f8fafc;
  --surface: #ffffff;
  --surface-soft: #fbfcfe;
  --text: #132038;
  --muted: #75829a;
  --muted-strong: #536079;
  --line: #dbe3ee;
  --line-soft: #e8edf4;

  --teal: #0797a0;
  --teal-deep: #087d86;
  --teal-soft: #effafb;
  --teal-line: #cceef0;

  --coral: #ff5a47;
  --coral-deep: #ed4939;
  --coral-soft: #fff4f2;
  --coral-line: #ffd7d0;

  --navy: #071a3d;
  --shadow: 0 12px 32px rgba(30, 52, 82, 0.06);

  /* Keep the exact existing printable-label measurements. */
  --label-width: 121mm;
  --label-height: 75mm;
  --label-radius: 4mm;
  --label-border-width: 0.35mm;
  --divider-width: 0.2mm;
  --label-font-size: 11pt;
}

/* =========================================================
   Dark mode variables
   ========================================================= */

body:has(#themeToggle:checked) {
  --page-bg: #0d1420;
  --surface: #131c2a;
  --surface-soft: #182231;
  --text: #eef4fb;
  --muted: #9faabd;
  --muted-strong: #bdc7d6;
  --line: #2a3749;
  --line-soft: #222e3f;
  --teal-soft: #102d31;
  --teal-line: #1c4d52;
  --coral-soft: #34201f;
  --coral-line: #58302b;
  --navy: #f4f7fb;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.26);
}

* {
  box-sizing: border-box;
}

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

body {
  position: relative;
  isolation: isolate;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 2% 8%, rgba(7, 151, 160, 0.08), transparent 16rem),
    radial-gradient(circle at 98% 13%, rgba(255, 90, 71, 0.06), transparent 15rem),
    var(--page-bg);
  color: var(--text);
  transition: background-color 0.2s ease, color 0.2s ease;
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

/* =========================================================
   Main page
   ========================================================= */

.page-shell {
  position: relative;
  z-index: 2;
  width: min(1240px, calc(100% - 32px));
  margin: 28px auto 46px;
}

/* =========================================================
   Header / intro
   ========================================================= */

.page-header {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 24px;
  margin-bottom: 24px;
  min-height: 122px;
}

.header-copy {
  width: min(860px, 100%);
  text-align: center;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--teal-deep);
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.eyebrow span {
  color: var(--coral);
  margin: 0 8px;
}

.page-header h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(2rem, 4vw, 3.15rem);
  line-height: 1.08;
  letter-spacing: -0.045em;
  font-weight: 800;
}

.header-subtitle {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.theme-toggle {
  position: absolute;
  top: 0;
  right: 0;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 93%, transparent);
  color: var(--text);
  box-shadow: 0 5px 18px rgba(31, 50, 78, 0.05);
  cursor: pointer;
  user-select: none;
  font-size: 0.8rem;
  font-weight: 650;
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.switch-track {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: #aab4c4;
  transition: background 0.2s ease;
}

.switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.22);
  transition: transform 0.2s ease;
}

#themeToggle:checked ~ .page-shell .switch-track {
  background: var(--teal);
}

#themeToggle:checked ~ .page-shell .switch-knob {
  transform: translateX(14px);
}

/* =========================================================
   Forms
   ========================================================= */

.forms-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.address-card,
.preview-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 17px;
  box-shadow: var(--shadow);
}

.address-card {
  overflow: hidden;
}

.receiver-card {
  border-color: var(--teal-line);
}

.sender-card {
  border-color: var(--coral-line);
}

.card-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.receiver-card .card-heading {
  background: linear-gradient(90deg, var(--teal-soft), color-mix(in srgb, var(--surface) 72%, var(--teal-soft)));
}

.sender-card .card-heading {
  background: linear-gradient(90deg, var(--coral-soft), color-mix(in srgb, var(--surface) 72%, var(--coral-soft)));
}

.card-avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  flex: 0 0 auto;
}

.receiver-card .card-avatar {
  background: linear-gradient(145deg, #08a9b1, #087983);
}

.sender-card .card-avatar {
  background: linear-gradient(145deg, #ff6b57, #f14535);
}

.card-avatar svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.card-heading h2 {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.2;
  font-weight: 800;
}

.receiver-card .card-heading h2 {
  color: var(--teal-deep);
}

.sender-card .card-heading h2 {
  color: var(--coral-deep);
}

.form-body {
  padding: 14px 18px 16px;
}

.field-row {
  display: flex;
  gap: 14px;
}

.field-row > .field-group {
  flex: 1;
}

.top-row .field-group {
  min-width: 0;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  margin-bottom: 12px;
}

.field-group label {
  color: var(--text);
  font-size: 0.78rem;
  line-height: 1.25;
  font-weight: 720;
}

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

.field-group input,
.field-group select {
  width: 100%;
  height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 0.84rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.field-group input::placeholder {
  color: #9ca6b5;
}

.field-group input:focus,
.field-group select:focus {
  border-color: color-mix(in srgb, var(--teal) 68%, #7f8ca0);
  box-shadow: 0 0 0 3px rgba(7, 151, 160, 0.11);
}

.field-group input[readonly],
.field-group select:disabled {
  background: color-mix(in srgb, var(--surface-soft) 82%, var(--line-soft));
  color: var(--muted-strong);
}

.field-group select:disabled {
  cursor: not-allowed;
}

.input-shell {
  position: relative;
}

.input-shell input {
  padding-left: 36px;
}

.field-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  z-index: 2;
  transform: translateY(-50%);
  color: #69768a;
  font-size: 0.92rem;
  pointer-events: none;
}

svg.field-icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sender-card .mobile-icon {
  color: var(--coral);
}

.receiver-card .field-group:focus-within .field-icon {
  color: var(--teal);
}

.sender-card .field-group:focus-within .field-icon {
  color: var(--coral);
}

.field-group small {
  min-height: 14px;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.2;
}

.field-group small.error,
.pin-status.error {
  color: #c9382c;
  font-weight: 650;
}

.compact {
  flex: 1 !important;
  max-width: none;
}

.wide {
  flex: 1.08 !important;
}

/* =========================================================
   Preview section
   ========================================================= */

.preview-section {
  margin-top: 18px;
  overflow-x: auto;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  min-height: 58px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(90deg, rgba(7, 151, 160, 0.055), transparent 56%);
}

.preview-heading {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.preview-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: linear-gradient(145deg, #08a9b1, #087983);
  color: #ffffff;
}

.preview-icon svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}

.section-title h2 {
  margin: 0;
  color: var(--teal-deep);
  font-size: 1.04rem;
  white-space: nowrap;
}

.print-hint {
  margin: 0 0 0 8px;
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 9px 15px;
  background: linear-gradient(135deg, #099e9f, #087984);
  color: #ffffff;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 750;
  box-shadow: 0 8px 18px rgba(7, 121, 132, 0.18);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.primary-button:hover {
  filter: brightness(1.04);
}

.primary-button:active {
  transform: translateY(1px);
}

.print-icon {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.print-icon-dot {
  fill: currentColor;
  stroke: none;
}

.label-stage {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 330px;
  padding: 22px 18px 24px;
}



/* =========================================================
   Decorative page background
   ========================================================= */

/*
 * These shapes deliberately use z-index 0/1 rather than negative values.
 * Negative z-index placed them behind the body background and made them invisible.
 */

body::before {
  content: "";
  position: absolute;
  top: 34px;
  left: -92px;
  width: 285px;
  height: 255px;
  border-radius: 43% 57% 65% 35% / 48% 38% 62% 52%;
  background: rgba(73, 201, 209, 0.15);
  z-index: 0;
  pointer-events: none;
}

body::after {
  content: "";
  position: absolute;
  top: 72px;
  right: -88px;
  width: 275px;
  height: 225px;
  border-radius: 56% 44% 36% 64% / 42% 58% 42% 58%;
  background: rgba(73, 201, 209, 0.12);
  z-index: 0;
  pointer-events: none;
}

.page-decoration {
  position: absolute;
  z-index: 1;
  pointer-events: none;
}

/* Teal dotted pattern at the upper-left. */
.decoration-dots {
  top: 58px;
  left: 22px;
  width: 92px;
  height: 92px;
  opacity: 0.52;
  background-image: radial-gradient(circle, #43bcc5 2px, transparent 2.2px);
  background-size: 15px 15px;
}

/* Coral dashed accent at the upper-right. */
.decoration-arrow {
  top: 112px;
  right: 22px;
  width: 240px;
  height: 110px;
}

.decoration-arrow svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  color: #ff7468;
}

.decoration-arrow .arrow-curve {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-dasharray: 4 5;
}

.decoration-arrow .arrow-head {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Tone decorations down in dark mode. */
body:has(#themeToggle:checked)::before,
body:has(#themeToggle:checked)::after,
body:has(#themeToggle:checked) .page-decoration {
  opacity: 0.28;
}

/* =========================================================
   Fixed-size printable label
   Black and white by design
   ========================================================= */

.shipping-label {
  width: var(--label-width);
  height: var(--label-height);
  min-width: var(--label-width);
  min-height: var(--label-height);
  max-width: var(--label-width);
  max-height: var(--label-height);
  margin: 0;
  border: var(--label-border-width) solid #111111;
  border-radius: var(--label-radius);
  background: #ffffff;
  color: #111111;
  display: block;
  overflow: hidden;
  box-shadow: 0 8px 18px rgba(18, 31, 49, 0.08);
}

.label-main {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  height: 100%;
  min-width: 0;
}

.label-address {
  min-width: 0;
  height: 100%;
  padding: 7mm 6mm;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  overflow: hidden;
  background: #ffffff;
  color: #111111;
}

.receiver-label {
  border-right: var(--divider-width) dashed #c4c7cb;
}

.label-caption {
  align-self: flex-start;
  margin: 0 0 2.2mm;
  padding: 0.8mm 2mm;
  border: 0;
  border-radius: 1.2mm;
  background: #101010;
  color: #ffffff;
  font-size: 9.5pt;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.label-address h3 {
  margin: 0 0 1.7mm;
  font-size: 11pt;
  line-height: 1.25;
  font-weight: 800;
  color: #111111;
  overflow-wrap: anywhere;
  word-break: break-word;
}

#previewReceiverAddress,
#previewSenderAddress {
  margin: 0;
  font-size: var(--label-font-size);
  line-height: 1.35;
  font-weight: 500;
  color: #111111;
  white-space: pre-line;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.preview-mobile {
  display: flex;
  align-items: baseline;
  gap: 1.4mm;
  margin: auto 0 0;
  padding-top: 1.5mm;
  font-size: var(--label-font-size);
  line-height: 1.2;
  font-weight: 500;
  color: #111111;
  white-space: nowrap;
}

.phone-glyph {
  width: 12pt;
  height: 12pt;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* =========================================================
   Privacy note
   ========================================================= */

.privacy-note {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 9px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.privacy-icon {
  width: 28px;
  height: 28px;
  box-sizing: border-box;
  flex: 0 0 auto;
  padding: 5px;
  border-radius: 50%;
  background: var(--teal);
  color: #ffffff;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* =========================================================
   Tablet / mobile
   ========================================================= */

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

  .page-header {
    justify-content: flex-start;
    padding-right: 130px;
  }

  .header-copy {
    text-align: left;
  }
}

@media (max-width: 620px) {
  .page-shell {
    width: calc(100% - 16px);
    margin-top: 16px;
  }

  .page-header {
    min-height: auto;
    padding-right: 0;
    padding-top: 50px;
  }

  .theme-toggle {
    left: 0;
    right: auto;
  }

  .page-header h1 {
    font-size: 2rem;
  }

  .forms-grid {
    gap: 14px;
  }

  .field-row {
    flex-direction: column;
    gap: 0;
  }

  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .preview-heading {
    width: 100%;
    flex-wrap: wrap;
  }

  .print-hint {
    width: 100%;
    margin-left: 48px;
    white-space: normal;
  }

  .preview-actions,
  .primary-button {
    width: 100%;
  }

  .primary-button {
    justify-content: center;
  }

  .label-stage {
    justify-content: flex-start;
    overflow-x: auto;
  }
}

/* =========================================================
   Printing - one fixed label only
   ========================================================= */

@page {
  size: auto;
  margin: 0;
}

@media print {
  body::before,
  body::after,
  .page-decoration {
    display: none !important;
  }

  html,
  body {
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    background: #ffffff !important;
  }

  body * {
    visibility: hidden !important;
  }

  #printArea,
  #printArea * {
    visibility: visible !important;
  }

  .page-shell {
    width: 0 !important;
    height: 0 !important;
    min-width: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  .page-header,
  .forms-grid,
  .section-title,
  .privacy-note {
    display: none !important;
  }

  .preview-section,
  .label-stage {
    width: 0 !important;
    height: 0 !important;
    min-width: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    overflow: visible !important;
  }

  #printArea {
    position: fixed !important;
    top: 10% !important;
    left: 10% !important;
    width: var(--label-width) !important;
    height: var(--label-height) !important;
    min-width: var(--label-width) !important;
    min-height: var(--label-height) !important;
    max-width: var(--label-width) !important;
    max-height: var(--label-height) !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: scale(0.9) !important;
    transform-origin: top left !important;
    border: var(--label-border-width) solid #111111 !important;
    border-radius: var(--label-radius) !important;
    background: #ffffff !important;
    color: #111111 !important;
    box-shadow: none !important;
    overflow: hidden !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  #printArea .label-main {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    width: 100% !important;
    height: 100% !important;
  }

  #printArea .label-address {
    height: 100% !important;
    min-height: 0 !important;
    padding: 7mm 6mm !important;
    overflow: hidden !important;
    background: #ffffff !important;
    color: #111111 !important;
  }

  #printArea .receiver-label {
    border-right: var(--divider-width) dashed #c4c7cb !important;
  }

  #printArea .label-caption {
    margin: 0 0 2.2mm !important;
    padding: 0.8mm 2mm !important;
    border-radius: 1.2mm !important;
    background: #101010 !important;
    color: #ffffff !important;
    font-size: 9.5pt !important;
    line-height: 1 !important;
    font-weight: 800 !important;
  }

  #printArea .label-address h3 {
    margin: 0 0 1.7mm !important;
    font-size: 11pt !important;
    line-height: 1.25 !important;
    font-weight: 800 !important;
    color: #111111 !important;
  }

  #printArea #previewReceiverAddress,
  #printArea #previewSenderAddress {
    margin: 0 !important;
    font-size: var(--label-font-size) !important;
    line-height: 1.35 !important;
    font-weight: 500 !important;
    color: #111111 !important;
    white-space: pre-line !important;
  }

  #printArea .preview-mobile {
    display: flex !important;
    align-items: baseline !important;
    gap: 1.4mm !important;
    margin: auto 0 0 !important;
    padding-top: 1.5mm !important;
    font-size: var(--label-font-size) !important;
    line-height: 1.2 !important;
    color: #111111 !important;
    white-space: nowrap !important;
  }

  .qr-panel,
  .qr-section,
  #qrImage,
  .qr-image {
    display: none !important;
  }
}
