:root {
  color-scheme: light;
  --ink: #18202a;
  --muted: #65717d;
  --line: #cfd7df;
  --panel: #ffffff;
  --green: #1f6f5b;
  --green-dark: #155241;
  --coral: #b94f3f;
  --focus: #2b68a8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(135deg, #f7f8f5 0%, #edf2ef 48%, #eef1f7 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[hidden] {
  display: none !important;
}

button,
input {
  font: inherit;
}

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

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(100%, 360px);
  display: grid;
  gap: 16px;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(24, 32, 42, 0.08);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 410px) 1fr;
  gap: 24px;
  align-items: stretch;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(24, 32, 42, 0.08);
}

.editor-panel {
  padding: 22px;
}

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

h1 {
  margin: 0 0 4px;
  font-size: 1.55rem;
  line-height: 1.1;
}

p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.form-grid {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: #344151;
  font-size: 0.9rem;
  font-weight: 650;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
  color: var(--ink);
  background: #fbfcfd;
}

input:focus {
  border-color: var(--focus);
  outline: 3px solid rgba(43, 104, 168, 0.17);
}

.actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  margin-top: 18px;
}

button {
  min-height: 46px;
  border: 1px solid #aeb9c3;
  border-radius: 6px;
  color: var(--ink);
  background: #f7f9fb;
  cursor: pointer;
  font-weight: 750;
}

button:hover {
  border-color: #7d8b99;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

button.primary {
  color: #fff;
  border-color: var(--green);
  background: var(--green);
}

button.primary:hover {
  background: var(--green-dark);
}

output {
  display: block;
  min-height: 22px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

output.error {
  color: var(--coral);
}

output.success {
  color: var(--green-dark);
}

.payload-preview {
  max-height: 260px;
  overflow: auto;
  margin: 14px 0 0;
  padding: 12px;
  color: #24303d;
  background: #f6f8fa;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.preview-wrap {
  display: grid;
  min-height: 520px;
  padding: 28px;
  background:
    linear-gradient(rgba(24, 32, 42, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(24, 32, 42, 0.05) 1px, transparent 1px),
    #e5ebe7;
  background-size: 22px 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.label-stack {
  width: 100%;
  min-height: 100%;
  display: grid;
  align-content: start;
}

.empty-state {
  align-self: center;
  justify-self: center;
  color: var(--muted);
  font-weight: 650;
}

.barcode-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
}

.barcode-card {
  width: min(100%, 210px);
  aspect-ratio: 38 / 62;
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  align-content: start;
  gap: 5px;
  padding: 14px 13px;
  color: #111;
  background: #fff;
  border: 1px dashed #87919b;
  border-radius: 6px;
  box-shadow: 0 16px 42px rgba(24, 32, 42, 0.13);
}

.barcode-art {
  align-self: end;
  min-height: 66px;
  margin-top: 8px;
}

.barcode-art svg {
  width: 100%;
  height: 66px;
  display: block;
}

.label-line {
  overflow-wrap: anywhere;
  font-size: 0.78rem;
  line-height: 1.16;
}

.label-line.strong {
  font-weight: 800;
}

.barcode-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.92rem;
  letter-spacing: 0;
}

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

  .preview-wrap {
    min-height: 340px;
  }
}

@media (max-width: 520px) {
  .app-shell {
    width: min(100% - 20px, 1080px);
    padding: 18px 0;
  }

  .preview-wrap {
    padding: 18px;
  }
}
