:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --panel: #ffffff;
  --ink: #202720;
  --muted: #66706a;
  --line: #dbe2dc;
  --accent: #17695a;
  --accent-strong: #0f4e43;
  --warn: #8a3e17;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1360px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 0 22px;
}

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

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: clamp(1.7rem, 3vw, 2.6rem);
}

h2 {
  font-size: 1.15rem;
}

.toolbar-actions,
.grid,
.series-grid {
  display: flex;
  gap: 10px;
}

.workspace {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.panel,
.preview-area {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel {
  display: grid;
  gap: 16px;
  padding: 18px;
  position: sticky;
  top: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-weight: 700;
}

label span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 400;
  line-height: 1.35;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  background: #fbfcfb;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(23, 105, 90, 0.2);
  border-color: var(--accent);
}

.grid {
  display: grid;
  grid-template-columns: 1fr 130px;
}

details {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

summary {
  cursor: pointer;
  font-weight: 700;
}

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

button {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
}

.primary,
button:not(.secondary) {
  background: var(--accent);
  color: #fff;
}

.primary:hover,
button:not(.secondary):hover {
  background: var(--accent-strong);
}

.secondary {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.secondary:hover {
  border-color: var(--accent);
}

.preview-area {
  min-height: 520px;
  padding: 18px;
}

.preview-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.preview-header p {
  margin: 4px 0 0;
  color: var(--muted);
}

.labels {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 12px;
}

.label-card {
  overflow: hidden;
  min-height: 214px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.label-content {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.label-title {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.label-body {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.label-meta {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.label-code {
  overflow-wrap: anywhere;
  font-size: 1.05rem;
  font-weight: 700;
}

.qr-code {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  background: #fff;
}

.encoded-url {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.3;
}

.error {
  color: var(--warn);
  font-weight: 700;
}

@media (max-width: 860px) {
  .toolbar,
  .toolbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .label-body {
    grid-template-columns: 1fr;
  }

  .panel {
    position: static;
  }
}

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

  .toolbar,
  .panel,
  .preview-header {
    display: none;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .workspace {
    display: block;
  }

  .preview-area {
    border: 0;
    padding: 0;
  }

  .labels {
    grid-template-columns: repeat(2, 1fr);
    gap: 6mm;
  }

  .label-card {
    break-inside: avoid;
    border-color: #222;
    border-radius: 0;
  }

  .label-body {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .qr-code {
    width: 34mm;
  }
}
