/* Beauty Bazaar - Sticker Barcode Printer
   Print layout uses millimetres only. */
:root {
  --navy: #14213d; --gold: #b8923a; --gold-l: #f4e3a8; --cream: #f1edd4;
  --ink: #1e2230; --muted: #6b7185; --line: #e4dfc8; --bg: #f6f3e6;
  --good: #1a7f4b; --warn: #a66300; --bad: #c0262d;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; }

/* ============ DASHBOARD ============ */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--navy); color: var(--gold-l);
  padding: 10px 22px; position: sticky; top: 0; z-index: 20; border-bottom: 3px solid var(--gold); }
.brand { display: flex; align-items: center; gap: 12px; }
.logo { height: 46px; width: auto; border-radius: 6px; background: var(--cream); padding: 2px; }
.topbar h1 { margin: 0; font: 700 20px Georgia, serif; letter-spacing: .18em; }
.topbar p { margin: 2px 0 0; font-size: 12px; opacity: .8; color: #fff; }
.logout { color: var(--gold-l); font-size: 13px; }

.layout { display: grid; grid-template-columns: minmax(400px, 1fr) minmax(380px, 1fr); gap: 18px; padding: 18px 22px 40px; max-width: 1560px; margin: 0 auto; }
@media (max-width: 980px) { .layout { grid-template-columns: 1fr; } }

.card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(20,33,61,.05); }
.card h2 { margin: 0 0 12px; font: 700 16px Georgia, serif; color: var(--navy); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.num { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: var(--gold); color: #fff; font: 700 13px "Segoe UI", Arial, sans-serif; }
.sticky { position: sticky; top: 84px; }
.pill { font: 600 12px "Segoe UI", Arial, sans-serif; background: #f3efdb; color: var(--navy); padding: 3px 10px; border-radius: 99px; }
.pill:empty { display: none; }

.grid-form { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 12px; }
.grid-form.four { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 700px) { .grid-form, .grid-form.four { grid-template-columns: 1fr 1fr; } }
.span2 { grid-column: span 2; } .span3 { grid-column: span 3; } .span4 { grid-column: 1 / -1; }
@media (max-width: 700px) { .span3, .span4 { grid-column: 1 / -1; } }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); font-size: 13px; }
label.check.inline { display: inline-flex; margin: 0 4px; }
input[type=text], input[type=number], input[type=search], select {
  font: inherit; font-size: 14px; color: var(--ink); padding: 9px 10px; border: 1px solid #d3cdb0; border-radius: 7px; background: #fff; width: 100%; }
input:focus, select:focus { outline: 2px solid #e6d28f; border-color: var(--gold); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--navy); }
.form-buttons, .row-buttons { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-buttons { margin-top: 12px; }

.btn { font: inherit; font-weight: 600; font-size: 14px; padding: 9px 16px; border-radius: 8px; border: 1px solid #cfc8a8; background: #fff; color: var(--navy); cursor: pointer; }
.btn:hover { background: #f8f5e6; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: var(--gold-l); }
.btn.primary:hover { background: #0d1830; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.print { width: 100%; padding: 16px; font-size: 18px; letter-spacing: .06em; background: var(--gold); border-color: var(--gold); color: #fff; }
.btn.print:hover { background: #a07f2f; }
.print-note { margin: 10px 0 0; font-size: 13px; color: var(--ink); background: #fff8dc; border: 1px dashed var(--gold); padding: 8px 10px; border-radius: 7px; }

.hint { font-size: 12px; color: var(--muted); font-weight: 400; margin: 0; }
.hint.good { color: var(--good); } .hint.warn { color: var(--warn); } .hint.bad { color: var(--bad); }
.msg { display: none; margin-top: 10px; padding: 9px 12px; border-radius: 7px; font-size: 13px; }
.msg.show { display: block; }
.msg.err { background: #fde8e9; color: var(--bad); } .msg.warn { background: #fff3dc; color: var(--warn); } .msg.ok { background: #e3f6ec; color: var(--good); }

.table-wrap { overflow-x: auto; }
.table-wrap.lib { max-height: 280px; overflow-y: auto; margin-top: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); padding: 6px 8px; border-bottom: 2px solid var(--line); position: sticky; top: 0; background: #fff; }
td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.mono { font-family: Consolas, Menlo, monospace; font-size: 12px; }
.tag { font: 700 10px "Segoe UI", Arial, sans-serif; padding: 1px 6px; border-radius: 4px; }
.tag.good { background: #e3f6ec; color: var(--good); } .tag.warn { background: #fff3dc; color: var(--warn); } .tag.bad { background: #fde8e9; color: var(--bad); }
input.qty { width: 62px; padding: 6px; }
.actions { white-space: nowrap; }
.link { background: none; border: 0; color: #2b4aa8; cursor: pointer; font: inherit; font-size: 12.5px; padding: 2px 5px; }
.link.danger { color: var(--bad); }
.empty { color: var(--muted); text-align: center; padding: 14px 0; margin: 0; }
#libSearch { margin-bottom: 4px; }

.settings-info { margin: 12px 0 0; padding: 9px 12px; background: #f8f5e6; border-radius: 7px; font-size: 12.5px; line-height: 1.5; }
.settings-info.bad { background: #fde8e9; color: var(--bad); }

.preview-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.preview-head h2 { margin: 0; }
.zoom { flex-direction: row; align-items: center; gap: 6px; }
.zoom select { width: auto; padding: 5px 8px; }
.preview-scroll { max-height: calc(100vh - 175px); overflow: auto; background: #7d8296; border-radius: 8px; padding: 14px; text-align: center; }
#previewHost { display: inline-block; text-align: left; }
#previewHost .page { margin: 0 auto 18px; box-shadow: 0 3px 14px rgba(0,0,0,.4); }
.pageno { position: absolute; right: 4mm; bottom: 1mm; font: 9pt Arial, sans-serif; color: #999; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: #222; color: #fff; padding: 10px 18px; border-radius: 8px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 50; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%); }

#measure { position: absolute; left: -10000px; top: 0; visibility: hidden; pointer-events: none; }
#measure .label { width: 100%; height: 100%; }

/* ============ A4 PAGE + STICKER (millimetres) ============ */
.page {
  position: relative; width: 210mm; height: 296mm;      /* 1 mm less than A4 so Chrome never adds a blank page */
  background: #fff; overflow: hidden;
  page-break-inside: avoid; break-inside: avoid;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.sheet { position: absolute; display: grid; }

.label {
  position: relative; width: 100%; height: 100%; overflow: hidden; background: #fff; color: var(--navy);
  display: grid; break-inside: avoid; page-break-inside: avoid;
  font-family: Georgia, "Times New Roman", serif;
}
.label.bordered { border: 0.3mm solid var(--gold); border-radius: 1.4mm; }
.l-brand { background: var(--cream); overflow: hidden; border-right: 0.25mm solid var(--gold); }
.l-brand img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center top; }

.l-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; text-align: center;
  padding: calc(1.5mm * var(--s)) 1.2mm calc(1.1mm * var(--s)) 1.4mm; }
.l-shop { font-size: calc(7pt * var(--s)); font-weight: 700; letter-spacing: .16em; line-height: 1.1; white-space: nowrap; }
.l-rule { height: 0.25mm; margin: calc(.6mm * var(--s)) 3mm calc(.5mm * var(--s));
  background: linear-gradient(90deg, transparent, var(--gold), transparent); position: relative; }
.l-rule::after { content: ""; position: absolute; left: 50%; top: 50%; width: 1.1mm; height: 1.1mm; background: var(--gold);
  transform: translate(-50%, -50%) rotate(45deg); }
.l-namebox { height: calc(7.4mm * var(--s)); display: flex; align-items: center; justify-content: center; overflow: hidden; flex: 0 0 auto; }
.l-name { display: block; width: 100%; font-size: calc(9.5pt * var(--s)); font-weight: 700; line-height: 1.1; color: #111;
  overflow-wrap: anywhere; word-break: break-word; }
.l-sku { font: 600 calc(6.8pt * var(--s)) Arial, sans-serif; color: #333; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: .3mm; }
.l-bars { flex: 1 1 auto; min-height: 8mm; margin-top: calc(.7mm * var(--s)); background: #fff; }
.l-bars svg { display: block; width: 100%; height: 100%; }
.l-code { font: 700 calc(7pt * var(--s)) "Courier New", monospace; letter-spacing: .1em; color: #000; line-height: 1.2; white-space: nowrap; }
.l-mrp { font: 800 calc(8.6pt * var(--s)) Arial, sans-serif; color: #111; margin-top: calc(.5mm * var(--s)); line-height: 1.2; }
.l-price { font: 800 calc(9.5pt * var(--s)) Arial, sans-serif; background: var(--navy); color: var(--gold-l); border-radius: 1mm;
  padding: calc(.45mm * var(--s)) 0; margin-top: calc(.4mm * var(--s)); line-height: 1.2; letter-spacing: .03em;
  -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.l-foot { font: 600 calc(5.4pt * var(--s)) Arial, sans-serif; color: #7a6320; margin-top: calc(.5mm * var(--s)); white-space: nowrap; line-height: 1.1; }

.label.test { border: 0.25mm dashed #000; display: flex; align-items: center; justify-content: center; font: 8pt Arial, sans-serif; color: #000; text-align: center; border-radius: 0; }

/* ============ PRINT ============ */
#printArea { display: none; }
@page { size: A4 portrait; margin: 0; }

@media print {
  html, body { background: #fff !important; margin: 0 !important; padding: 0 !important; height: auto !important; overflow: visible !important; }
  .admin, .toast, #measure { display: none !important; }
  #printArea { display: block !important; }
  #printArea .page { margin: 0 !important; box-shadow: none !important; page-break-after: always; break-after: page; }
  #printArea .page:last-child { page-break-after: auto; break-after: auto; }
  .pageno { display: none !important; }
}
