:root {
  --pink: #E5157A;
  --pink-press: #C40F66;
  --cyan: #0FA8DF;
  --ink: #1C1E21;
  --ink-2: #5A6068;
  --bed: #EDEFF1;
  --sheet: #FFFFFF;
  --line: #D9DDE1;
  --ok: #17804A;
  --bad: #B3261E;
  --warn-bg: #FFF4D6;
  --r-sm: 8px;
  --r-lg: 14px;
  --tabs-h: 62px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 16px/1.45 var(--font);
  color: var(--ink);
  background: var(--bed);
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
}
body.no-tabs { padding-bottom: 0; }
main { max-width: 720px; margin: 0 auto; padding: 14px 14px 24px; outline: none; }
h1 { font-size: 1.45rem; line-height: 1.2; margin: 6px 0 14px; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; margin: 22px 0 8px; }
p { margin: 0 0 10px; }
.muted { color: var(--ink-2); font-size: .92rem; }
.num { font-variant-numeric: tabular-nums; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: var(--r-sm);
  border: 1.5px solid var(--line); background: var(--sheet); color: var(--ink);
  font: 600 1rem var(--font); cursor: pointer; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--pink); border-color: var(--pink); color: #fff; }
.btn-primary:active { background: var(--pink-press); }
.btn-scan { background: var(--cyan); border-color: var(--cyan); color: #fff; }
.btn-danger { color: var(--bad); }
.btn-wide { width: 100%; }
.btn-sm { min-height: 38px; padding: 0 12px; font-size: .92rem; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
input, select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; font: 1rem var(--font); color: var(--ink);
  border: 1.5px solid var(--line); border-radius: var(--r-sm); background: var(--sheet);
}
input:focus, select:focus, textarea:focus { border-color: var(--cyan); outline: none; }
label.field { display: block; }
label.field > span { display: block; font-size: .88rem; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.check { display: flex; gap: 10px; align-items: center; min-height: 44px; }
.check input { width: 22px; min-height: 22px; }

/* ---------- surfaces ---------- */
.panel { background: var(--sheet); border-radius: var(--r-lg); padding: 14px; }
.list { background: var(--sheet); border-radius: var(--r-lg); overflow: hidden; }
.list > * { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--bed); text-decoration: none; color: inherit; background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; font: inherit; }
.list > *:last-child { border-bottom: 0; }
.list .thumb { width: 44px; height: 44px; border-radius: 6px; object-fit: contain; background: var(--bed); flex: none; }
.list .t { font-weight: 600; line-height: 1.25; }
.list .s { font-size: .86rem; color: var(--ink-2); }
.badge { display: inline-block; font-size: .78rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--bed); color: var(--ink-2); }
.badge.ok { background: #E3F4EA; color: var(--ok); }
.badge.bad { background: #FBE6E5; color: var(--bad); }
.badge.warn { background: var(--warn-bg); color: #7A5600; }
.notice { background: var(--warn-bg); border-radius: var(--r-sm); padding: 10px 12px; font-size: .94rem; margin-bottom: 12px; }
.notice.bad { background: #FBE6E5; color: #7F1A14; }
.empty { text-align: center; padding: 28px 14px; color: var(--ink-2); }

/* Printer's crop marks: the scanner frame and the total panel wear them. */
.crop { position: absolute; inset: 0; pointer-events: none; }
.crop i { position: absolute; width: 22px; height: 22px; border: 0 solid currentColor; }
.crop i:nth-child(1) { top: -9px; left: -9px; border-top-width: 2px; border-left-width: 2px; }
.crop i:nth-child(2) { top: -9px; right: -9px; border-top-width: 2px; border-right-width: 2px; }
.crop i:nth-child(3) { bottom: -9px; left: -9px; border-bottom-width: 2px; border-left-width: 2px; }
.crop i:nth-child(4) { bottom: -9px; right: -9px; border-bottom-width: 2px; border-right-width: 2px; }

/* ---------- tabs ---------- */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--sheet); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabs a { flex: 1; height: var(--tabs-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: .74rem; font-weight: 600; color: var(--ink-2); text-decoration: none; }
#tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#tabs a.on { color: var(--pink); }

/* ---------- login ---------- */
.login { max-width: 360px; margin: 6vh auto 0; text-align: center; }
.login h1 { margin-bottom: 4px; }
.who { display: grid; gap: 8px; margin: 18px 0; }
.dots { display: flex; justify-content: center; gap: 12px; margin: 18px 0; }
.dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); }
.dots i.on { background: var(--ink); }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pad button { min-height: 62px; font: 600 1.4rem var(--font); border-radius: var(--r-lg); border: 0; background: var(--sheet); color: var(--ink); }
.pad button:active { background: var(--line); }

/* ---------- register ---------- */
.find { position: sticky; top: 0; z-index: 5; background: var(--bed); padding: 4px 0 10px; }
.results { position: absolute; left: 0; right: 0; top: 100%; z-index: 6; max-height: 55vh; overflow: auto; box-shadow: 0 10px 30px rgba(28, 30, 33, .18); }
.cart .line { align-items: flex-start; }
.qty { display: flex; align-items: center; border: 1.5px solid var(--line); border-radius: var(--r-sm); flex: none; }
.qty button { width: 40px; height: 40px; border: 0; background: none; font: 600 1.25rem var(--font); color: var(--ink); }
.qty span { min-width: 28px; text-align: center; font-weight: 700; }
.price { text-align: right; font-weight: 700; white-space: nowrap; }
.price s { display: block; font-weight: 400; color: var(--ink-2); font-size: .82rem; }
.totals { position: relative; margin: 26px 9px 12px; padding: 16px; background: var(--sheet); color: var(--ink); }
.totals .crop { color: var(--pink); }
.totals .r { display: flex; justify-content: space-between; padding: 2px 0; }
.totals .grand { font-size: 1.6rem; font-weight: 800; margin-top: 6px; letter-spacing: -0.01em; }
.charge-bar { position: sticky; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 8px); z-index: 4; }
.charge-bar .btn { min-height: 60px; font-size: 1.2rem; box-shadow: 0 6px 18px rgba(229, 21, 122, .35); }

/* ---------- sheets (bottom dialogs) ---------- */
dialog.sheet { width: 100%; max-width: 560px; margin: auto auto 0; border: 0; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 92vh; overflow: auto; }
dialog.sheet::backdrop, #scanner::backdrop { background: rgba(28, 30, 33, .55); }
.sheet h2 { margin-top: 0; }
.pay-opts { display: grid; gap: 10px; }
.pay-opts .btn { justify-content: space-between; min-height: 58px; }
.cash-quick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.cash-quick .btn { padding: 0 4px; min-width: 0; }

/* ---------- scanner ---------- */
#scanner { width: 100%; max-width: 560px; border: 0; padding: 18px; background: #000; color: #fff; border-radius: var(--r-lg); }
.scan-frame { position: relative; margin: 12px; color: var(--cyan); }
#scan-video { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; background: #222; }
.scan-frame .crop i { width: 30px; height: 30px; }
.scan-frame .crop i { border-width: 0; }
.scan-frame .crop i:nth-child(1) { border-top-width: 3px; border-left-width: 3px; }
.scan-frame .crop i:nth-child(2) { border-top-width: 3px; border-right-width: 3px; }
.scan-frame .crop i:nth-child(3) { border-bottom-width: 3px; border-left-width: 3px; }
.scan-frame .crop i:nth-child(4) { border-bottom-width: 3px; border-right-width: 3px; }
#scan-hint { text-align: center; margin: 14px 0; }
.scan-actions { display: flex; gap: 10px; justify-content: center; }

/* ---------- receipt ---------- */
.receipt { background: var(--sheet); border-radius: var(--r-lg); padding: 18px; }
.receipt table { width: 100%; border-collapse: collapse; }
.receipt td { padding: 4px 0; vertical-align: top; }
.receipt td:last-child { text-align: right; white-space: nowrap; }
.receipt .sum td { border-top: 1px solid var(--line); }
.receipt .big td { font-size: 1.25rem; font-weight: 800; }
.paid-stamp { color: var(--ok); font-weight: 800; font-size: 1.1rem; }

/* ---------- item ---------- */
.stock-big { font-size: 2.6rem; font-weight: 800; line-height: 1; }
.barcode-img { display: block; background: #fff; padding: 8px; border-radius: var(--r-sm); max-width: 100%; height: 90px; }
.hist .s { font-size: .82rem; }

/* ---------- toast ---------- */
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 84px); z-index: 50; background: var(--ink); color: #fff; padding: 12px 16px; border-radius: var(--r-sm); max-width: calc(100vw - 32px); font-size: .95rem; }
#toast.bad { background: var(--bad); }

/* ---------- labels (print) ---------- */
.labels-page { background: #fff; }
.label { display: inline-flex; flex-direction: column; justify-content: center; align-items: center; overflow: hidden; text-align: center; page-break-inside: avoid; break-inside: avoid; }
.label .ln { font: 700 8pt/1.1 var(--font); max-height: 2.2em; overflow: hidden; }
.label .lp { font: 800 10pt/1 var(--font); }
.label img { width: 100%; height: auto; }
.fmt-roll .label { width: 2.25in; height: 1.25in; padding: .06in .1in; page-break-after: always; break-after: page; }
.fmt-roll .label img { max-height: .62in; }
.fmt-5160 { width: 8.5in; padding: .5in .1875in 0; display: grid; grid-template-columns: repeat(3, 2.625in); column-gap: .125in; }
.fmt-5160 .label { width: 2.625in; height: 1in; padding: .05in .12in; }
.fmt-5160 .label img { max-height: .5in; }
@media print {
  body { background: #fff; padding: 0; }
  #tabs, .no-print, #toast { display: none !important; }
  main { max-width: none; padding: 0; margin: 0; }
  .receipt { border-radius: 0; padding: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
