:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #15181e;
  --muted: #6e7480;
  --line: #e3e6eb;
  --line-strong: #cfd4dc;
  --accent: #405cf5;
  --accent-soft: #eef0ff;
  --danger: #cf3b46;
  --shadow: 0 14px 42px rgba(20, 27, 45, 0.07);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 0, rgba(255, 255, 255, 0.96), transparent 36rem),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

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

.page-shell {
  width: min(100% - 40px, 1000px);
  margin: 0 auto;
  padding: 64px 0 80px;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 32px;
}

.page-header h1 {
  margin: 0 0 6px;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.08;
  letter-spacing: -0.04em;
}

.page-header p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

.section-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  width: min(100%, 500px);
  margin: 0 0 26px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 7px 22px rgba(20, 27, 45, 0.05);
}

.section-tab {
  min-height: 42px;
  padding: 8px 16px;
  color: var(--muted);
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-size: 14px;
  font-weight: 750;
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.section-tab:hover {
  color: var(--text);
}

.section-tab.is-active {
  color: #fff;
  background: var(--text);
  box-shadow: 0 5px 14px rgba(21, 24, 30, 0.18);
}

.section-tab:focus-visible {
  outline: 3px solid rgba(64, 92, 245, 0.22);
  outline-offset: 2px;
}

.app-section[hidden] {
  display: none;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 10px);
  grid-template-rows: repeat(2, 10px);
  gap: 4px;
  flex: 0 0 auto;
  padding: 13px;
  border-radius: 14px;
  color: #fff;
  background: var(--text);
  box-shadow: 0 8px 22px rgba(21, 24, 30, 0.18);
}

.brand-mark span {
  border: 2px solid currentColor;
  border-radius: 2px;
}

.brand-mark span:nth-child(2),
.brand-mark span:nth-child(3) {
  border-width: 0;
  background: currentColor;
}

.panel {
  padding: 30px;
  border: 1px solid rgba(222, 225, 231, 0.9);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.section-heading,
.labels-toolbar,
.card-meta,
.field-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-heading {
  gap: 16px;
  margin-bottom: 26px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.section-heading h2,
.labels-heading h2 {
  margin: 0;
  font-size: 21px;
  letter-spacing: -0.02em;
}

.size-badge,
.count-badge,
.code-type-badge,
.shipping-point-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.size-badge {
  padding: 8px 11px;
  color: #5e6470;
  border: 1px solid var(--line);
  background: #fafbfc;
}

.field-group label,
.type-fieldset legend {
  display: block;
  margin-bottom: 9px;
  font-size: 14px;
  font-weight: 700;
}

.field-group + .field-group {
  margin-top: 14px;
}

.field-group input,
.field-group select,
.field-group textarea {
  width: 100%;
  padding: 0 16px;
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  outline: none;
  background: #fff;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.field-group input,
.field-group select {
  height: 52px;
}

.field-group textarea {
  min-height: 92px;
  padding-top: 14px;
  padding-bottom: 14px;
  line-height: 1.4;
  resize: vertical;
}

.field-group input::placeholder,
.field-group textarea::placeholder {
  color: #a2a7b0;
}

.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(64, 92, 245, 0.12);
}

.field-group input[aria-invalid="true"],
.field-group select[aria-invalid="true"],
.field-group textarea[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(207, 59, 70, 0.1);
}

.post-fields {
  margin-top: 14px;
}

.post-fields[hidden] {
  display: none;
}

.select-wrap {
  position: relative;
}

.select-wrap::after {
  position: absolute;
  top: 50%;
  right: 17px;
  width: 8px;
  height: 8px;
  border-right: 2px solid #737985;
  border-bottom: 2px solid #737985;
  content: "";
  pointer-events: none;
  transform: translateY(-70%) rotate(45deg);
}

.field-group select {
  padding: 0 44px 0 16px;
  appearance: none;
  cursor: pointer;
}

.field-group select:invalid {
  color: #a2a7b0;
}

.field-group select option {
  color: var(--text);
}

.product-fields-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 0.42fr);
  gap: 14px;
  margin-top: 14px;
}

.product-fields-row .field-group + .field-group {
  margin-top: 0;
}

.field-meta {
  min-height: 22px;
  padding-top: 7px;
  color: #9297a1;
  font-size: 12px;
}

.field-error {
  color: var(--danger);
  font-weight: 650;
}

.type-fieldset {
  min-width: 0;
  margin: 18px 0 24px;
  padding: 0;
  border: 0;
}

.type-switch {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.type-option {
  position: relative;
  cursor: pointer;
}

.type-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.type-option-content {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 12px;
  min-height: 74px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.type-option input:checked + .type-option-content {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.type-option input:focus-visible + .type-option-content {
  outline: 3px solid rgba(64, 92, 245, 0.2);
  outline-offset: 2px;
}

.type-option strong,
.type-option small {
  display: block;
}

.type-option strong {
  margin-bottom: 4px;
  font-size: 14px;
}

.type-option small {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.check-dot {
  width: 18px;
  height: 18px;
  border: 1.5px solid #bcc1ca;
  border-radius: 50%;
  box-shadow: inset 0 0 0 4px #fff;
  background: #fff;
}

.type-option input:checked + .type-option-content .check-dot {
  border-color: var(--accent);
  background: var(--accent);
}

.barcode-icon,
.qr-icon {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  background-color: #fff;
}

.barcode-icon {
  border: 9px solid #fff;
  background-image: repeating-linear-gradient(90deg, #181b21 0 2px, transparent 2px 4px, #181b21 4px 5px, transparent 5px 7px);
  box-shadow: 0 0 0 1px var(--line);
}

.qr-icon {
  border: 7px solid #fff;
  background:
    linear-gradient(90deg, #181b21 25%, transparent 25% 50%, #181b21 50% 75%, transparent 75%),
    linear-gradient(#181b21 25%, transparent 25% 50%, #181b21 50% 75%, transparent 75%);
  background-size: 12px 12px;
  box-shadow: 0 0 0 1px var(--line);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 17px;
  border: 0;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, opacity 150ms ease;
}

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

.button:active:not(:disabled) {
  transform: translateY(0);
}

.button:focus-visible,
.delete-button:focus-visible {
  outline: 3px solid rgba(64, 92, 245, 0.22);
  outline-offset: 2px;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.button-primary {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 8px 20px rgba(64, 92, 245, 0.24);
}

.generate-button {
  width: 100%;
  height: 50px;
}

.button-dark {
  color: #fff;
  background: var(--text);
}

.button-ghost {
  color: #5f6570;
  border: 1px solid var(--line);
  background: #fff;
}

.download-icon {
  font-size: 19px;
  line-height: 1;
}

.labels-section {
  margin-top: 38px;
}

.labels-toolbar {
  gap: 20px;
  margin-bottom: 18px;
}

.labels-heading {
  display: flex;
  align-items: center;
  gap: 10px;
}

.count-badge {
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  color: var(--accent);
  background: var(--accent-soft);
}

.toolbar-actions {
  display: flex;
  gap: 9px;
}

.empty-state {
  padding: 54px 20px;
  text-align: center;
  border: 1px dashed #d5d9e0;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.54);
}

.empty-state[hidden] {
  display: none;
}

.empty-icon {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  width: 54px;
  height: 42px;
  margin: 0 auto 16px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(23, 28, 40, 0.06);
}

.empty-icon span {
  width: 4px;
  height: 23px;
  background: #c8cdd5;
}

.empty-icon span:nth-child(2) {
  width: 7px;
  height: 18px;
}

.empty-icon span:nth-child(3) {
  height: 25px;
}

.empty-state h3 {
  margin: 0 0 7px;
  font-size: 16px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

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

.product-items-list {
  display: grid;
  gap: 10px;
}

.product-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 70px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 7px 22px rgba(20, 27, 45, 0.04);
}

.product-item-copy {
  min-width: 0;
}

.product-item-name {
  display: block;
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-item-copy p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.product-empty-icon {
  align-items: center;
  justify-content: center;
}

.product-empty-icon span {
  width: auto;
  height: auto;
  color: #a4aab4;
  background: transparent;
  font-size: 23px;
  font-weight: 850;
  line-height: 1;
}

.label-card {
  align-self: start;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: #fff;
  box-shadow: 0 9px 28px rgba(20, 27, 45, 0.05);
}

.card-meta {
  gap: 12px;
  min-height: 55px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
}

.card-meta > div {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.code-type-badge {
  flex: 0 0 auto;
  min-width: 30px;
  height: 24px;
  padding: 0 8px;
  color: var(--accent);
  background: var(--accent-soft);
}

.shipping-point-badge {
  flex: 0 1 auto;
  min-width: 0;
  height: 24px;
  padding: 0 8px;
  overflow: hidden;
  color: #626874;
  background: #f0f2f5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-number {
  overflow: hidden;
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.delete-button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
  padding: 6px;
  color: #8b9099;
  border: 0;
  border-radius: 7px;
  background: transparent;
  font-size: 12px;
  cursor: pointer;
}

.delete-button:hover {
  color: var(--danger);
  background: #fff0f1;
}

.delete-button span {
  font-size: 18px;
  line-height: 0.8;
}

.label-preview-wrap {
  padding: 20px;
  background: #f7f8fa;
}

.label-preview {
  position: relative;
  display: flex;
  flex-direction: column;
  aspect-ratio: 58 / 40;
  width: 100%;
  overflow: hidden;
  padding: 5.2% 5.2% 4.2%;
  color: #000;
  border: 1px solid #e4e5e7;
  background: #fff;
  box-shadow: 0 5px 16px rgba(22, 27, 38, 0.08);
}

.standard-label-preview[hidden],
.post-label-preview[hidden] {
  display: none;
}

.post-label-preview {
  position: relative;
  display: flex;
  flex-direction: column;
  aspect-ratio: 120 / 70;
  width: 100%;
  overflow: hidden;
  padding: 3.2% 3.6% 2.2%;
  color: #101318;
  border: 1px solid #e4e5e7;
  background: #fff;
  box-shadow: 0 5px 16px rgba(22, 27, 38, 0.08);
}

.post-preview-brand {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 2%;
  border-bottom: 1px solid #d8dbe1;
  font-size: clamp(10px, 1.45vw, 16px);
  letter-spacing: 0.015em;
}

.post-preview-details {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-height: 0;
  padding: 2.1% 0 1.5%;
}

.post-preview-column {
  min-width: 0;
  padding-right: 7%;
}

.post-preview-column + .post-preview-column {
  padding-right: 0;
  padding-left: 7%;
  border-left: 1px solid #d8dbe1;
}

.post-preview-column p {
  margin: 0 0 3.4%;
}

.post-preview-column span,
.post-preview-column strong {
  display: block;
}

.post-preview-column span {
  margin-bottom: 1%;
  color: #626874;
  font-size: clamp(6px, 0.72vw, 8px);
  font-weight: 750;
  letter-spacing: 0.035em;
  line-height: 1.1;
  text-transform: uppercase;
}

.post-preview-column strong {
  display: -webkit-box;
  overflow: hidden;
  font-size: clamp(7px, 0.9vw, 10px);
  line-height: 1.12;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.post-preview-recipient strong {
  font-size: clamp(8px, 1.05vw, 12px);
}

.post-preview-code {
  display: flex;
  flex: 0 0 28%;
  flex-direction: column;
  align-items: center;
  min-height: 0;
}

.post-preview-code .code-preview {
  width: 92%;
  margin: 0;
}

.post-preview-code .code-preview svg {
  width: 100%;
  height: 100%;
}

.post-preview-number {
  flex: 0 0 auto;
  margin-top: 0.5%;
  font-size: clamp(8px, 1.05vw, 12px);
  letter-spacing: 0.04em;
  line-height: 1;
}

.label-header {
  flex: 0 0 auto;
  min-width: 0;
}

.label-title {
  overflow: hidden;
  margin: 0;
  font-size: var(--label-font-size, 16px);
  line-height: 1.15;
  text-overflow: ellipsis;
  transform: scaleX(var(--preview-title-scale, 1));
  transform-origin: left center;
  white-space: nowrap;
  width: var(--preview-title-width, 100%);
}

.label-title + .label-title {
  margin-top: 0.7%;
}

.label-title strong {
  font-weight: 700;
}

.label-title span {
  font-weight: 500;
}

.code-preview {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  min-height: 0;
  margin-top: 2.2%;
}

.code-preview svg {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.label-card[data-type="barcode"] .code-preview svg {
  width: 100%;
  height: 82%;
}

.label-card[data-type="qr"] .code-preview svg {
  width: auto;
  height: 100%;
  aspect-ratio: 1;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 44px));
  padding: 12px 15px;
  color: #fff;
  border-radius: 10px;
  background: #232832;
  box-shadow: 0 12px 34px rgba(13, 17, 26, 0.24);
  font-size: 13px;
  font-weight: 650;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.is-error {
  background: #a92e38;
}

@media (max-width: 700px) {
  .page-shell {
    width: min(100% - 28px, 580px);
    padding: 34px 0 56px;
  }

  .page-header {
    align-items: flex-start;
    margin-bottom: 24px;
  }

  .page-header p {
    font-size: 14px;
  }

  .panel {
    padding: 22px;
    border-radius: 17px;
  }

  .type-switch,
  .labels-grid,
  .product-fields-row {
    grid-template-columns: 1fr;
  }

  .product-fields-row .field-group + .field-group {
    margin-top: 0;
  }

  .labels-toolbar {
    align-items: flex-end;
  }

  .toolbar-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}

@media (max-width: 470px) {
  .page-header {
    gap: 13px;
  }

  .section-tabs {
    width: 100%;
  }

  .section-tab {
    min-height: 44px;
    padding: 8px 10px;
    font-size: 13px;
  }

  .brand-mark {
    grid-template-columns: repeat(2, 8px);
    grid-template-rows: repeat(2, 8px);
    padding: 11px;
    border-radius: 12px;
  }

  .section-heading {
    align-items: flex-start;
  }

  .field-meta > span:first-child {
    display: none;
  }

  .field-error {
    margin-left: auto;
  }

  .labels-toolbar {
    display: block;
  }

  .toolbar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 13px;
  }

  .toolbar-actions .button {
    padding: 0 11px;
  }

  .label-preview-wrap {
    padding: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
