:root {
  --blue: #0078ff;
  --ink: #111;
  --muted: #667085;
  --line: #d7dce2;
  --page: #f4f6f8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

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

button, .button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 9px 13px;
  background: #e8eef5;
  color: #101828;
  cursor: pointer;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

.danger {
  background: #ffe9e7;
  color: #a32115;
}

.primary {
  background: var(--blue);
  color: #fff;
}

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

input[type="checkbox"] {
  width: auto;
  min-height: 0;
}

label {
  display: block;
  margin: 14px 0 7px;
  color: #2d3440;
  font-size: 13px;
  font-weight: 800;
}

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

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

.login-panel {
  width: min(380px, 100%);
}

.error {
  color: #b42318;
  font-weight: 700;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
}

.sidebar {
  background: #050505;
  color: #fff;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.sidebar .panel {
  color: var(--ink);
  border: 0;
}

.brand-row {
  display: grid;
  gap: 4px;
}

.brand-row strong {
  font-size: 24px;
  line-height: 1;
}

.brand-row span {
  color: var(--blue);
}

.brand-row small {
  color: rgba(255,255,255,.65);
}

.login .brand-row small {
  color: var(--muted);
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

#add {
  width: 100%;
  margin-top: 18px;
}

.main {
  padding: 28px;
  display: grid;
  gap: 20px;
  align-content: start;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

h1, h2 {
  margin: 0;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.stats div {
  min-width: 112px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stats small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 3px;
}

.stats strong {
  font-size: 19px;
}

#queueNote {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.code {
  font-family: "Segoe UI Mono", Consolas, monospace;
  font-weight: 900;
}

.badge {
  border-radius: 999px;
  padding: 4px 8px;
  background: #eef5ff;
  color: #0055b7;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.badge.quantity {
  background: #fff4e5;
  color: #8a4b00;
}

.badge.single {
  background: #ecfdf3;
  color: #087443;
}

.label-preview {
  border: 1px solid #e2e6ea;
  background: #fff;
  display: grid;
  place-items: center;
  min-height: 150px;
  overflow: hidden;
}

.label-inner {
  width: 178px;
  height: 100px;
  display: grid;
  grid-template-columns: 96px 1fr;
  align-items: center;
  background: #fff;
  border: 1px solid #cfd6df;
  padding: 2px 5px 2px 2px;
}

.label-inner.marker {
  grid-template-columns: 1fr;
  padding: 10px;
  align-items: center;
  justify-items: start;
}

.label-inner.marker small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.label-inner.marker strong {
  display: block;
  margin-top: 5px;
  font-size: 15px;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.qr-preview {
  width: 96px !important;
  height: 96px !important;
  image-rendering: pixelated;
}

.ur-preview {
  display: grid;
  place-items: center;
  transform: translate(-6px, -4px);
}

.ur-main-preview {
  font-family: Ubuntu, "Arial Black", Arial, sans-serif;
  font-size: 26px;
  font-weight: 900;
  line-height: .72;
}

.ur-main-preview span:last-child { color: var(--blue); }

.brandline-preview {
  margin-top: 4px;
  font-size: 7px;
  font-weight: 800;
}

.brandline-preview span { color: var(--blue); }

.history table {
  width: 100%;
  border-collapse: collapse;
}

.history-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.history-search {
  max-width: 360px;
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.history th, .history td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.row-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.pagination span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.history th {
  color: #344054;
  background: #f9fafb;
  font-size: 12px;
}

.sheet-panel {
  margin: 28px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}

.sheet-panel[hidden] { display: none; }

.sheet-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.sheet-toolbar div {
  display: flex;
  gap: 8px;
}

.sheet {
  position: relative;
  width: 210mm;
  height: 297mm;
  overflow: hidden;
  background: #fff;
  border: 1px solid #d0d5dd;
}

.grid {
  position: absolute;
  left: 2.103mm;
  top: 13.494mm;
  width: 201.489mm;
  height: 270mm;
}

.row {
  display: grid;
  grid-template-columns: 17.798mm 2.822mm 17.586mm 2.822mm 17.586mm 2.822mm 17.586mm 2.822mm 17.604mm 2.822mm 17.586mm 2.822mm 17.586mm 2.822mm 17.586mm 2.822mm 17.586mm 2.822mm 17.586mm;
  width: 201.489mm;
  height: 10mm;
}

.sheet-label {
  width: 100%;
  height: 10mm;
  display: grid;
  grid-template-columns: 9.6mm 1fr;
  align-items: center;
  overflow: hidden;
  background: #fff;
  padding: .2mm .35mm .2mm .2mm;
}

.sheet-label.blank {
  display: block;
}

.sheet-label.marker {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  justify-items: start;
  padding: .8mm .9mm;
  border: .2mm solid #000;
  line-height: 1.05;
}

.sheet-label.marker small {
  display: block;
  color: #666;
  font-size: 1.1mm;
  font-weight: 900;
  margin-bottom: .35mm;
  text-transform: uppercase;
}

.sheet-label.marker strong {
  display: block;
  max-width: 15.8mm;
  color: #111;
  font-size: 1.85mm;
  font-weight: 900;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.sheet-label.marker span {
  display: block;
  margin-top: .35mm;
  color: #444;
  font-size: 1mm;
  font-weight: 800;
}

.gap {
  width: 100%;
  height: 10mm;
}

.qr-canvas {
  width: 9.6mm !important;
  height: 9.6mm !important;
  display: block;
  image-rendering: pixelated;
}

.ur-print {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  transform: translate(-0.6mm, -.45mm);
}

.ur-main-print {
  font-family: Ubuntu, "Arial Black", Arial, sans-serif;
  font-size: 3.7mm;
  font-weight: 900;
  line-height: .72;
}

.ur-main-print span:last-child { color: var(--blue); }

.brandline-print {
  margin-top: .35mm;
  font-size: 1.1mm;
  font-weight: 800;
  line-height: 1;
}

.brandline-print span { color: var(--blue); }

.print-inner {
  display: grid;
  justify-items: center;
  align-items: center;
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .toolbar { align-items: flex-start; flex-direction: column; }
  .stats { justify-content: flex-start; }
}

@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; }
  .app, .sheet-toolbar { display: none; }
  .sheet-panel {
    display: block !important;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    overflow: visible;
  }
  .sheet { border: 0; }
}
