/* labels.css — A4 asset tag sheet (QR + barcode + Atria logo)
   Everything is sized in real millimetres so the browser prints at true scale. */

:root {
  --ink: #0f172a;
  --mut: #64748b;
  --line: #e2e8f0;
  --accent: #1d4ed8;
  --bg: #eef2f7;
  --card: #ffffff;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 "Inter", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ───────────────────────── top bar ───────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { height: 30px; width: auto; object-fit: contain; }
.brand-title { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.brand-sub { font-size: 11.5px; color: var(--mut); }
.topbar-actions { display: flex; gap: 8px; }

/* ───────────────────────── layout ───────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 380px 320px;
  gap: 16px;
  padding: 18px 22px 8px;
  align-items: start;
}
@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.panel-h {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mut);
}
.panel-h.mt { margin-top: 20px; }

.field { margin-bottom: 12px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 5px;
}
.field input, .field select {
  width: 100%;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: #f8fafc;
  border: 1px solid #d7dee8;
  border-radius: 8px;
  outline: none;
}
.field input:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
  background: #fff;
}

.fixed-size {
  padding: 8px 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
  background: #f1f5f9;
  border: 1px solid #d7dee8;
  border-radius: 8px;
}

.checks { display: grid; gap: 7px; margin-top: 4px; }
.chk {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: #334155;
  cursor: pointer;
}
.chk input { accent-color: var(--accent); width: 15px; height: 15px; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.btn {
  appearance: none;
  border: 1px solid #d7dee8;
  background: #fff;
  color: #1e293b;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 9px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: 0.15s;
}
.btn:hover { background: #f1f5f9; border-color: #c3ccd9; }
.btn.sm { font-size: 12px; padding: 6px 10px; border-radius: 8px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1740b8; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.hint, .stats { font-size: 11.5px; color: var(--mut); margin: 8px 0 0; }
.stats { font-weight: 600; color: #334155; }

/* ───────────────────────── picker ───────────────────────── */
.pick-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 10px;
  flex-wrap: wrap;
}
.count { font-size: 11.5px; font-weight: 700; color: var(--accent); margin-left: auto; }

.picker {
  border: 1px solid var(--line);
  border-radius: 10px;
  max-height: 330px;
  overflow-y: auto;
  background: #fff;
}
.pick-row {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 7px 10px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
}
.pick-row:last-child { border-bottom: 0; }
.pick-row:hover { background: #f8fafc; }
.pick-row.on { background: #eff6ff; }
.pick-row input { margin-top: 2px; accent-color: var(--accent); width: 15px; height: 15px; flex: 0 0 auto; }
.pick-txt { min-width: 0; }
.pick-name {
  font-size: 12.5px;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pick-code {
  font: 11px/1.3 ui-monospace, Consolas, "Courier New", monospace;
  color: var(--mut);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}
.pager .muted { font-size: 11.5px; color: var(--mut); }

/* ───────────────────────── preview ───────────────────────── */
.preview-area {
  padding: 10px 22px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.preview-empty {
  padding: 40px 20px;
  color: var(--mut);
  font-size: 13px;
  text-align: center;
  background: #fff;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius);
  width: min(640px, 100%);
}

/* ───────────────────── the ticket (2 × 4 in) ─────────────────────
   The page itself is one ticket: 50.8 × 101.6 mm, one ticket per page, fed
   top-to-bottom. Every size below is a real millimetre constant and the jsPDF
   export uses the same numbers, so screen, print and download agree. */
.sheet {
  width: 50.8mm;
  height: 101.6mm;
  padding: 0;
  background: #fff;
  box-shadow: 0 6px 26px rgba(15, 23, 42, 0.18);
  position: relative;
  overflow: hidden;
  zoom: 1.5;
  break-after: page;
  page-break-after: always;
  break-inside: avoid;
}

.ticket {
  position: absolute;
  left: 2mm;
  top: 2mm;
  width: 46.8mm;
  height: 97.6mm;
  padding: 2.4mm;
  background: #fff;
  color: #0b1220;
  border: 0.3mm solid #94a3b8;
  border-radius: 1.5mm;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ticket.no-border { border-color: #fff; }

/* logo + warning strip */
.tk-head {
  height: 5mm;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2mm;
}
.tk-logo {
  height: 5mm;
  width: auto;
  max-width: 21mm;
  object-fit: contain;
  display: block;
}
.tk-warn {
  font-size: 6.2pt;
  font-weight: 700;
  color: #b91c1c;
  white-space: nowrap;
}
/* the vertical ticket is only 41.4 mm wide — the logo and the warning have to
   share that, so both step down slightly to keep "Do not remove sticker" whole */
.ticket:not(.h) .tk-logo { height: 4.5mm; }
.ticket:not(.h) .tk-warn { font-size: 5.5pt; }

/* asset title — always two lines tall so the layout never shifts */
.tk-title {
  height: 7.8mm;
  margin-top: 2mm;
  flex: 0 0 auto;
  font-size: 9.4pt;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.tk-code {
  height: 3.2mm;
  margin-top: 1mm;
  flex: 0 0 auto;
  font-family: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
  font-size: 8.8pt;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
}

.tk-qr {
  height: var(--tk-qr);
  margin-top: 2.6mm;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tk-qr img {
  width: var(--tk-qr);
  height: var(--tk-qr);
  display: block;
  image-rendering: pixelated;
}

.tk-bc {
  height: 7mm;
  margin-top: 2.6mm;
  flex: 0 0 auto;
}
.tk-bc svg { width: 100%; height: 100%; display: block; }

/* S/N · model · PO · purchase date · vendor */
.tk-details {
  height: 20mm;
  margin-top: 2.8mm;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
}
.tk-details .dt {
  height: 4mm;
  display: flex;
  align-items: center;
  gap: 1.6mm;
  min-width: 0;
}
.tk-details .k {
  width: 13mm;
  flex: 0 0 auto;
  font-size: 6pt;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #64748b;
}
.tk-details .v {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 6.6pt;
  font-weight: 700;
  color: #0b1220;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ───────────────── horizontal ticket (4 × 2 in) ─────────────────
   Same 2 × 4 in page, rotated: QR on the left, title / code / details in a
   column beside it, barcode across the bottom. One ticket per page. */
.sheet.h { width: 101.6mm; height: 50.8mm; }
.ticket.h { width: 97.6mm; height: 46.8mm; }
.ticket.h .tk-body {
  height: var(--tk-qr);
  margin-top: 1.4mm;
  flex: 0 0 auto;
  display: flex;
  gap: 2.6mm;
  min-width: 0;
}
.ticket.h .tk-qr {
  width: var(--tk-qr);
  height: var(--tk-qr);
  margin-top: 0;
  flex: 0 0 auto;
}
.ticket.h .tk-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.ticket.h .tk-title {
  height: 7mm;
  margin-top: 0;
  font-size: 8.6pt;
}
.ticket.h .tk-code {
  height: 2.9mm;
  margin-top: 0.6mm;
  font-size: 8.2pt;
}
.ticket.h .tk-details {
  height: 15mm;
  margin-top: 1mm;
}
.ticket.h .tk-details .dt { height: 3mm; }
.ticket.h .tk-details .k { width: 13mm; }
.ticket.h .tk-bc {
  height: 6.2mm;
  margin-top: 1.4mm;
}

/* ───────────────────────── print ───────────────────────── */
@media print {
  html, body {
    width: 50.8mm;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
  }
  .ui, .no-print { display: none !important; }

  .preview-area {
    padding: 0 !important;
    gap: 0 !important;
    display: block !important;
  }
  .sheet {
    width: 50.8mm;
    height: 101.6mm;
    margin: 0 !important;
    padding: 0 !important;
    zoom: 1 !important;
    box-shadow: none !important;
    overflow: hidden;
    break-after: page;
    page-break-after: always;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .sheet.h { width: 101.6mm; height: 50.8mm; }
  .sheet:last-child { break-after: auto; page-break-after: auto; }

  .ticket {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
