/* LUXIAOJUN Warehouse - brand: red #C20000, ink #171717, body #5C5C5C, cream #FAF2E6 */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --red: #C20000;
  --ink: #171717;
  --body: #5C5C5C;
  --cream: #FAF2E6;
  --line: #E5E1DA;
  --bg: #FFFFFF;
  --ok-bg: #EAF4EC;
  --warn-bg: #FFF4D6;
  --crit-bg: #FDE8E8;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}
html, body { height: 100%; }
body {
  font-family: 'Nunito Sans', -apple-system, sans-serif;
  background: var(--bg); color: var(--body);
  font-size: 16px; overscroll-behavior: none;
}
h1, h2, h3, h4 { font-family: 'Inter', -apple-system, sans-serif; color: var(--ink); font-weight: 700; }
h2 { font-size: 22px; } h3 { font-size: 16px; margin-bottom: 10px; } h4 { font-size: 14px; margin: 14px 0 6px; }
a { color: var(--red); text-decoration: none; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, textarea, select {
  font-family: inherit; font-size: 16px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  width: 100%; background: #fff;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--red); outline-offset: -1px; border-color: var(--red); }
label { display: block; font-size: 13px; color: var(--ink); font-weight: 600; margin: 10px 0 4px; }

#app { display: flex; flex-direction: column; height: 100dvh; }
#main {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: calc(14px + var(--safe-top)) 18px 24px;
  max-width: 1100px; width: 100%; margin: 0 auto;
}

/* splash */
#splash { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 70dvh; gap: 14px; }
#splash .logo { font-family: 'Inter', sans-serif; font-weight: 800; font-size: 26px; color: var(--ink); letter-spacing: 2px; }
#splash .logo b { color: var(--red); }
.logo-img { height: 34px; max-width: 86vw; object-fit: contain; display: block; }
#splash .logo-img { height: 40px; }
.page-head .logo-img { height: 26px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--red); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* page head */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.head-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.crumb { color: var(--body); font-weight: 400; }

/* segmented control */
.seg-group { display: inline-flex; background: #F2EFE9; border-radius: 10px; padding: 3px; }
.seg { border: 0; background: transparent; padding: 8px 16px; border-radius: 8px; color: var(--body); font-weight: 600; }
.seg.active { background: var(--ink); color: #fff; }

/* buttons */
.btn {
  border: 0; border-radius: 10px; padding: 11px 18px; font-weight: 700;
  letter-spacing: 0.3px; min-height: 44px;
}
.btn-primary { background: var(--red); color: #fff; text-transform: uppercase; font-size: 14px; }
.btn-primary:active { background: #9B0000; }
.btn-primary:disabled { background: #D9A0A0; }
.btn-ghost { background: #fff; color: var(--ink); border: 1.5px solid var(--line); }
.btn-danger-ghost { background: #fff; color: var(--red); border: 1.5px solid #EBC4C4; }
.btn-icon {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  width: 36px; height: 36px; font-size: 15px; color: var(--body); flex: none;
}
.row-gap { display: flex; gap: 10px; align-items: center; }
.row-gap.wrap { flex-wrap: wrap; }

/* stats + cards */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--cream); border-radius: 14px; padding: 16px; }
.stat-n { font-family: 'Inter', sans-serif; font-size: 30px; font-weight: 800; color: var(--ink); }
.stat-l { font-size: 13px; margin-top: 2px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 14px; }

/* The store theme's CSS collapses elements inside <details>; undo that for the
   app's own dropdowns (screen only, so label printing still hides the app). */
@media screen {
  #app details, #app details * { visibility: visible !important; }
}

/* collapsible card (e.g. Low stock dropdown) */
details.collapse > summary {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  cursor: pointer; list-style: none; min-height: 32px;
}
details.collapse > summary::-webkit-details-marker { display: none; }
details.collapse > summary h3 { margin-bottom: 0; }
.collapse-arrow { color: var(--body); font-size: 18px; transition: transform 0.2s; flex: none; }
details.collapse[open] .collapse-arrow { transform: rotate(180deg); }
details.collapse[open] > summary { margin-bottom: 10px; }
.two-col { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 860px) { .two-col { grid-template-columns: 1fr 1fr; align-items: start; } }
.center-col { display: flex; flex-direction: column; align-items: center; }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--body); padding: 6px 8px; border-bottom: 2px solid var(--line); }
td { padding: 9px 8px; border-bottom: 1px solid #F0EDE7; color: var(--ink); vertical-align: middle; }
.num { text-align: right; }
th.num { text-align: right; }
tr.warn td { background: var(--warn-bg); }
tr.crit td { background: var(--crit-bg); }
.table-scroll { overflow-x: auto; }

/* card grids (pallets, racks) */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.pallet-card, .rack-card {
  border: 1.5px solid var(--line); border-radius: 14px; padding: 16px; background: #fff;
  cursor: pointer; min-height: 92px;
}
.pallet-card { background: var(--cream); border-color: #E8DFCE; }
.pallet-card:active, .rack-card:active { border-color: var(--red); }
.pc-code { font-family: 'Inter', sans-serif; font-weight: 800; font-size: 18px; color: var(--ink); }
.pc-name { color: var(--ink); margin-top: 2px; }
.pc-meta { font-size: 13px; margin-top: 6px; }

/* chips */
.chip { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; padding: 3px 9px; border-radius: 999px; }
.chip-on_pallet { background: var(--cream); color: #7A5B14; }
.chip-unpacked { background: var(--ok-bg); color: #1D6B32; }
.chip-shipped { background: #EAEAEA; color: var(--body); }

/* pallet detail */
.pd-top { display: flex; gap: 18px; align-items: flex-start; }
.qr-slot svg { display: block; }
.qr-med svg { width: 110px; height: 110px; }
.qr-big svg { width: 190px; height: 190px; }
.box-row { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; cursor: pointer; }
.box-row:active { border-color: var(--red); }
.box-items { font-size: 13.5px; margin-top: 6px; color: var(--body); }
.box-photo { max-width: 100%; border-radius: 12px; border: 1px solid var(--line); }
.label-text { background: #FAF9F6; border: 1px solid var(--line); border-radius: 10px; padding: 10px; white-space: pre-wrap; font-size: 14px; color: var(--ink); }

/* box form */
.bf-photo { margin-bottom: 6px; }
.photo-btn { display: inline-flex; align-items: center; gap: 6px; }
#bf-preview img { max-width: 100%; max-height: 220px; border-radius: 10px; margin-top: 8px; }
.bf-item { display: flex; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid #F0EDE7; }
.bf-item-name { flex: 1; color: var(--ink); font-size: 14.5px; }
.bf-qty { width: 74px; text-align: center; }

/* variant picker */
.vpick { position: relative; margin: 8px 0; }
.vpick-list {
  position: absolute; z-index: 30; left: 0; right: 0; top: 100%;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  max-height: 260px; overflow-y: auto; box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.vpick-item { padding: 11px 12px; border-bottom: 1px solid #F0EDE7; color: var(--ink); font-size: 14.5px; cursor: pointer; }
.vpick-item:active { background: var(--cream); }
.hidden { display: none !important; }

/* stepper */
.stepper { display: inline-flex; align-items: center; gap: 10px; }
.step-btn { width: 40px; height: 40px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; font-size: 20px; color: var(--ink); }
.step-val { min-width: 30px; text-align: center; font-weight: 700; color: var(--ink); }

/* count mode */
.count-status { background: var(--cream); border-radius: 14px; padding: 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.count-status.armed { background: var(--ok-bg); }
.cs-rack { font-size: 17px; color: var(--ink); }
.count-help { margin: 10px 0 16px 22px; line-height: 1.9; color: var(--ink); }

/* layout */
.ly-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 10px; flex-wrap: wrap; }
.ly-zoom { display: inline-flex; gap: 8px; align-items: center; }
.ly-scroll { overflow: auto; border: 1px solid var(--line); border-radius: 14px; background: #FBFAF7; }
.ly-canvas {
  position: relative; width: 1200px; height: 800px; transform-origin: 0 0;
  background-image: linear-gradient(#EFECE5 1px, transparent 1px), linear-gradient(90deg, #EFECE5 1px, transparent 1px);
  background-size: 50px 50px;
}
.ly-item {
  position: absolute; border-radius: 8px; padding: 6px 8px; overflow: hidden;
  touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer;
}
.ly-pallet { background: var(--cream); border: 2px solid #D9C89F; }
.ly-rack { background: #fff; border: 2px solid var(--ink); }
.ly-rack.warn { background: var(--warn-bg); border-color: #C9A227; }
.ly-rack.crit { background: var(--crit-bg); border-color: var(--red); }
.ly-code { font-family: 'Inter', sans-serif; font-weight: 800; font-size: 13px; color: var(--ink); }
.ly-meta { font-size: 11px; color: var(--body); }
.ly-resize { position: absolute; right: 2px; bottom: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--ink); opacity: 0; }
.ly-tray { margin-top: 10px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tray-item { border: 1.5px dashed var(--body); background: #fff; border-radius: 10px; padding: 8px 12px; font-weight: 700; color: var(--ink); }
.ly-legend { display: flex; gap: 18px; margin-top: 10px; font-size: 13px; flex-wrap: wrap; }
.lg { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 4px; }
.lg-pallet { background: var(--cream); border: 1.5px solid #D9C89F; }
.lg-rack { background: #fff; border: 1.5px solid var(--ink); }
.lg-warn { background: var(--warn-bg); border: 1.5px solid #C9A227; }
.lg-crit { background: var(--crit-bg); border: 1.5px solid var(--red); }
.ly-canvas.editing .ly-resize { opacity: 0.85; }

/* products - category tiles */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.cat-tile {
  border: 1.5px solid var(--line); background: var(--cream); border-radius: 16px;
  padding: 18px 14px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  min-height: 170px; justify-content: center;
}
.cat-tile:active { border-color: var(--red); }
.cat-tile img { width: 84px; height: 84px; object-fit: cover; border-radius: 12px; background: #fff; }
.cat-name { font-family: 'Inter', sans-serif; font-weight: 800; font-size: 18px; color: var(--ink); }
.cat-count { font-size: 13px; color: var(--body); }

/* products */
.prod-tools { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.search { max-width: 420px; }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 14.5px; color: var(--ink); font-weight: 400; margin: 4px 0; }
.check input { width: 20px; height: 20px; accent-color: var(--red); }
details.prod { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; background: #fff; }
details.prod summary {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; cursor: pointer; list-style: none;
}
details.prod summary::-webkit-details-marker { display: none; }
.prod-img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; background: var(--cream); flex: none; }
.prod-img-empty { display: inline-block; }
.prod-title { flex: 1; color: var(--ink); font-weight: 600; font-size: 14.5px; }
.prod-nums { font-size: 12.5px; color: var(--body); text-align: right; flex: none; }
details.prod > .table-scroll { padding: 0 14px 12px; }

/* labels view */
.label-checks { max-height: 300px; overflow-y: auto; margin-bottom: 12px; display: flex; flex-direction: column; }

/* activity */
.act-row { display: flex; gap: 10px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid #F0EDE7; font-size: 14px; flex-wrap: wrap; }
.act-kind { font-weight: 700; color: var(--ink); flex: none; }
.act-what { flex: 1; min-width: 140px; }
.act-when { color: #9B958B; font-size: 12.5px; flex: none; }

/* tabs */
#tabs {
  display: flex; border-top: 1px solid var(--line); background: #fff;
  padding-bottom: var(--safe-bot); flex: none;
}
.tab {
  flex: 1; border: 0; background: none; padding: 9px 2px 7px;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  color: var(--body); font-size: 11.5px; font-weight: 600; min-height: 54px;
}
.tab-ic { font-size: 21px; line-height: 1.1; }
.tab.active { color: var(--red); }

/* modal */
/* Modals, toasts, and the scan button sit above the app overlay even when the
   app is embedded in the store theme at a very high z-index. */
.wh-modal-backdrop {
  position: fixed; inset: 0; background: rgba(23, 23, 23, 0.45); z-index: 2147483200;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.wh-modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 560px;
  max-height: 88dvh; display: flex; flex-direction: column;
}
.wh-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 8px; }
.wh-modal-body { padding: 4px 18px 16px; overflow-y: auto; }
.wh-modal-foot { padding: 12px 18px 16px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--line); }
.wh-camera-modal { max-width: 480px; }
#cam-reader { border-radius: 12px; overflow: hidden; }

/* toasts */
#toasts { position: fixed; top: calc(12px + var(--safe-top)); left: 50%; transform: translateX(-50%); z-index: 2147483300; display: flex; flex-direction: column; gap: 8px; width: min(520px, 92vw); }
.toast {
  padding: 13px 16px; border-radius: 12px; color: #fff; font-weight: 600; font-size: 14.5px;
  opacity: 0; transform: translateY(-8px); transition: all 0.25s; box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}
.toast.show { opacity: 1; transform: none; }
.toast.ok { background: var(--ink); }
.toast.err { background: var(--red); }

/* narrow screens (iPhone, iPad split view): keep everything centered and readable */
@media (max-width: 640px) {
  .page-head { flex-direction: column; align-items: center; text-align: center; }
  .head-right { justify-content: center; }
  .stat { text-align: center; }
  .stat-n { font-size: 26px; }
  .prod-tools { justify-content: center; }
  .count-status { flex-direction: column; text-align: center; }
  .ly-toolbar { justify-content: center; }
  .ly-legend { justify-content: center; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .pallet-card, .rack-card { text-align: center; }
}

/* global camera scan button - works on every screen: pallet QR, rack barcode, shoe barcode */
#global-scan {
  position: fixed; right: 16px; bottom: calc(70px + var(--safe-bot)); z-index: 2147483100;
  border: 0; border-radius: 999px; padding: 14px 22px;
  background: var(--red); color: #fff; font-size: 15px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  box-shadow: 0 6px 18px rgba(194, 0, 0, 0.4);
}
#global-scan:active { background: #9B0000; }

.hint { color: #9B958B; font-size: 13px; font-weight: 400; }
.center { text-align: center; margin-top: 14px; }
.error-text { color: var(--red); font-weight: 600; }

/* print */
#print-area { display: none; }
@media print {
  @page { size: letter; margin: 0; }
  html, body { margin: 0 !important; padding: 0 !important; background: #fff; }
  /* Only the label sheet prints, even when the app is embedded in the store theme. */
  body * { visibility: hidden !important; }
  #print-area, #print-area * { visibility: visible !important; }
  #app, #toasts, .wh-modal-backdrop, #global-scan { display: none !important; }
  #print-area { display: grid !important; position: absolute; left: 0; top: 0; width: 8.5in; grid-template-columns: 1fr 1fr; gap: 24px; padding: 10mm; }
  .plabel { border: 1px dashed #999; border-radius: 8px; padding: 10mm 6mm; text-align: center; break-inside: avoid; }
  .plabel .qr-slot svg { width: 42mm; height: 42mm; }
  .plabel-code { font-family: 'Inter', sans-serif; font-weight: 800; font-size: 22pt; margin-top: 4mm; color: #000; }
  .plabel-sub { font-size: 11pt; color: #333; margin-top: 1mm; }

  /* FBA-style sticker sheet: Avery 5160, 3 columns x 10 rows on US Letter */
  #print-area.fba { display: block !important; padding: 0; }
  .fba-sheet {
    width: 8.5in; height: 11in; box-sizing: border-box;
    padding: 0.5in 0.1875in; page-break-after: always;
    display: grid; grid-template-columns: repeat(3, 2.625in); grid-auto-rows: 1in;
    column-gap: 0.125in; row-gap: 0;
  }
  .fba-cell {
    width: 2.625in; height: 1in; box-sizing: border-box;
    border: 0.75pt solid #aaa; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
  }
  .fba-cell svg { max-width: 2.35in; max-height: 0.85in; }
}
