:root {
  --bg: #f6f6f4;
  --panel: #fff;
  --ink: #16171a;
  --muted: #6b6f76;
  --line: #e2e2df;
  --accent: #1a1a1a;
  --ok: #17693f;
  --warn: #9a5b00;
  --warn-bg: #fff6e6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121316;
    --panel: #1b1d21;
    --ink: #ececee;
    --muted: #9aa0a8;
    --line: #2c2f35;
    --accent: #ececee;
    --ok: #5fd39b;
    --warn: #ffc46b;
    --warn-bg: #2e2413;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 ui-sans-serif, -apple-system, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 660px;
  margin: 0 auto;
  padding: 40px 20px 64px;
}

header { margin-bottom: 28px; }

h1 {
  margin: 0 0 6px;
  font-size: 26px;
  letter-spacing: -0.02em;
}

.sub { margin: 0; color: var(--muted); font-size: 14px; }

nav { margin-top: 14px; display: flex; gap: 8px; }

nav a {
  font-size: 13px;
  text-decoration: none;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  background: var(--panel);
}
nav a[aria-current="page"] { color: var(--ink); border-color: var(--ink); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
}

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px; }

input[type="text"], textarea {
  width: 100%;
  font: 500 24px/1.3 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.06em;
  padding: 14px 16px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
}
textarea {
  font-size: 15px;
  letter-spacing: 0.04em;
  min-height: 150px;
  resize: vertical;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* The status line is load-bearing: it names the symbology so a barcode is never
   silently something other than what the user thinks it is. */
.status {
  margin-top: 12px;
  min-height: 22px;
  font-size: 13.5px;
  color: var(--muted);
}
.status.ok { color: var(--ok); }
.status.warn {
  color: var(--warn);
  background: var(--warn-bg);
  border-radius: 8px;
  padding: 8px 10px;
}

.preview {
  margin-top: 22px;
  padding: 24px 16px;
  background: #fff;           /* barcodes need a white quiet zone even in dark mode */
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview svg { max-width: 100%; height: auto; }
.preview .empty { color: #9aa0a8; font-size: 14px; }

.actions { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; }

button {
  font: 500 14px/1 inherit;
  padding: 11px 16px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: var(--accent); color: var(--panel); border-color: var(--accent); }

/* --- label sheet --- */
.sheet {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.cell {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 8px;
  text-align: center;
  break-inside: avoid;        /* never split a barcode across a page break */
  page-break-inside: avoid;
}
.cell svg { max-width: 100%; height: auto; }
.cell .bad { color: #b3261e; font-size: 12px; font-family: ui-monospace, monospace; }

@media print {
  @page { margin: 12mm; }
  body { background: #fff; }
  .wrap { max-width: none; padding: 0; }
  header, nav, .panel, .noprint { display: none !important; }
  .sheet {
    margin: 0;
    grid-template-columns: repeat(3, 1fr);
    gap: 6mm;
  }
  .cell { border: none; padding: 0; }
}
