:root {
  --bg: #f4f5f7; --panel: #ffffff; --text: #16181d; --muted: #646b78; --line: #e1e4ea;
  --accent: #6d28d9; --accent-text: #fff; --accent-soft: #efe7fd;
  --good: #15803d; --good-soft: #e3f5e9; --warn: #b45309; --warn-soft: #fdf1df; --bad: #b91c1c; --bad-soft: #fde6e6;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318; --panel: #1b1e25; --text: #eceef2; --muted: #9aa1ae; --line: #2c313b;
    --accent: #8b5cf6; --accent-soft: #2a2142;
    --good: #4ade80; --good-soft: #15291d; --warn: #fbbf24; --warn-soft: #2e2512; --bad: #f87171; --bad-soft: #321a1a;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 14px; }
.error { color: var(--bad); min-height: 1.4em; margin: 8px 0 0; }

button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 10px 14px; min-height: 44px; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.ghost { background: transparent; }
button.danger { color: var(--bad); }
button.wide { width: 100%; }
button:disabled { opacity: .5; cursor: default; }
input, select { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
label { display: block; font-size: 14px; color: var(--muted); margin: 12px 0 0; }
label input { margin-top: 4px; color: var(--text); }

/* Login */
#login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border-radius: 16px; padding: 24px; box-shadow: var(--shadow); text-align: center; }
.login-card label, .login-card .error { text-align: left; }
.login-logo { width: 100%; max-width: 260px; height: auto; display: block; margin: 0 auto; }
.login-card h1 { margin: 8px 0 4px; font-size: 22px; }
.name-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.name-list button { font-weight: 600; }
.name-list button.active { border-color: var(--accent); background: var(--accent-soft); }
.pin-for { margin: 16px 0 8px; }
.pin-dots { display: flex; justify-content: center; gap: 10px; height: 18px; margin-bottom: 12px; }
.pin-dots span { width: 14px; height: 14px; border-radius: 50%; background: var(--text); }
.pin-hidden { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad button { font-size: 22px; min-height: 56px; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; white-space: nowrap; }
.brand img { height: 36px; width: auto; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tabs a { padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 600; white-space: nowrap; }
.tabs a.active { color: var(--accent); background: var(--accent-soft); }
.tut-btn { min-height: 36px; padding: 6px 12px; border-radius: 999px; font-weight: 700; white-space: nowrap; background: #0b0b12; color: #ffe14a; border-color: #0b0b12; }
.reg-link { min-height: 36px; padding: 8px 12px; border-radius: 999px; font-weight: 700; white-space: nowrap; background: var(--accent); color: var(--accent-text); text-decoration: none; }
.tutorial-layer { position: fixed; inset: 0; z-index: 40; background: #0b0b12; }
.tutorial-layer iframe { width: 100%; height: 100%; border: 0; display: block; }
.user-chip { min-height: 36px; padding: 6px 12px; border-radius: 999px; font-weight: 600; white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; min-width: 0; }
main { max-width: 960px; margin: 0 auto; padding: 16px 16px 96px; }
body:not(.owner) .owner-only { display: none !important; }

@media (max-width: 720px) {
  .brand span { display: none; }
  .tabs { position: fixed; bottom: 0; left: 0; right: 0; background: var(--panel); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; z-index: 6; }
  .tabs a { flex: 1; text-align: center; padding: 10px 4px; font-size: 14px; }
  .topbar { justify-content: space-between; gap: 8px; padding: 8px 12px; }
  .tut-btn, .reg-link, .user-chip { padding: 6px 10px; font-size: 14px; }
  .user-chip { max-width: 30vw; }
}

/* Scan */
.scanbar { display: flex; gap: 8px; }
.scanbar input { font-size: 20px; min-height: 56px; font-weight: 600; letter-spacing: .02em; }
.cam-btn { min-width: 56px; min-height: 56px; display: grid; place-items: center; }
#camera-wrap { margin-top: 12px; }
#camera { border-radius: var(--radius); overflow: hidden; background: #000; }
#camera video { width: 100% !important; }
.hint { color: var(--muted); font-size: 14px; margin: 12px 0; }
.dest { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--accent); color: var(--accent-text); border-radius: var(--radius); padding: 10px 10px 10px 16px; margin-bottom: 12px; font-size: 18px; }
.dest b { font-size: 24px; }
.dest-label { opacity: .85; font-size: 15px; }
.dest .ghost { color: var(--accent-text); border-color: rgba(255,255,255,.5); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 6px; font-size: 17px; }
.result { display: flex; gap: 14px; align-items: flex-start; }
.result.flash-good { border-color: var(--good); background: var(--good-soft); }
.result.flash-warn { border-color: var(--warn); background: var(--warn-soft); }
.result.flash-bad { border-color: var(--bad); background: var(--bad-soft); }
.thumb { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; background: var(--line); flex: none; }
.result-body { flex: 1; min-width: 0; }
.result-title { font-weight: 700; font-size: 18px; margin: 0; }
.where { display: inline-flex; align-items: center; gap: 6px; margin: 8px 0; font-size: 15px; }
.loc-badge { display: inline-block; font-weight: 800; font-size: 20px; padding: 4px 12px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); }
.loc-badge.none { background: var(--warn-soft); color: var(--warn); font-size: 15px; }
.loc-badge.sold { background: var(--bad-soft); color: var(--bad); font-size: 15px; }
.meta { color: var(--muted); font-size: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.section-title { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 24px 0 8px; }

.log { list-style: none; margin: 0; padding: 0; }
.log li { display: flex; gap: 10px; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.log li .when { color: var(--muted); font-size: 13px; white-space: nowrap; margin-left: auto; }
.log li .kind { font-size: 12px; font-weight: 700; text-transform: uppercase; padding: 2px 6px; border-radius: 4px; background: var(--line); white-space: nowrap; }
.log li .kind.sold { background: var(--bad-soft); color: var(--bad); }
.log li .kind.move { background: var(--accent-soft); color: var(--accent); }
.log li .kind.added, .log li .kind.restocked { background: var(--good-soft); color: var(--good); }
.log a, .items a { color: inherit; }
.linkish { background: none; border: 0; padding: 0; min-height: 0; color: var(--accent); text-decoration: underline; cursor: pointer; }

.pull-banner { display: block; background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 12px; font-weight: 700; text-decoration: none; }
.eb-line { font-size: 14px; margin-top: 6px; }
.eb-line.bad { color: var(--bad); }
.eb-line.wait { color: var(--warn); }
.tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 6px; border-radius: 4px; background: var(--line); }
.tag.live { background: var(--good-soft); color: var(--good); }
.tag.hidden { background: var(--warn-soft); color: var(--warn); }
.tag.ended { background: var(--bad-soft); color: var(--bad); }
#view-ebay .filters { grid-template-columns: 1fr 160px 200px auto; }
@media (max-width: 720px) { #view-ebay .filters { grid-template-columns: 1fr 1fr; } }

/* Find */
.filters { display: grid; grid-template-columns: 1fr 180px 140px; gap: 8px; }
@media (max-width: 720px) { .filters { grid-template-columns: 1fr 1fr; } .filters input { grid-column: 1 / -1; } }
.bulkbar { position: sticky; top: 60px; z-index: 4; display: flex; gap: 8px; align-items: center; margin-top: 10px; background: var(--accent-soft); border-radius: var(--radius); padding: 8px; }
.bulkbar select { flex: 1; }
.bulkbar span { font-weight: 700; white-space: nowrap; padding: 0 6px; }
.items { list-style: none; margin: 0; padding: 0; }
.items li { display: flex; align-items: center; gap: 12px; padding: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; cursor: pointer; }
.items li .thumb { width: 44px; height: 44px; }
.items li .grow { flex: 1; min-width: 0; }
.items li .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.items li input[type=checkbox] { width: 22px; height: 22px; min-height: 0; flex: none; }
.items li .loc-badge { font-size: 15px; }

/* Locations */
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.row-gap { display: flex; gap: 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-top: 12px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; cursor: pointer; text-align: left; min-height: 0; min-width: 0; }
.tile .code { font-size: 22px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .nm { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .n { margin-top: 6px; font-weight: 600; }
.tile.floor { border-left: 4px solid var(--good); }
.tile.special { border-left: 4px solid var(--warn); }
.tile.unplaced { border-left: 4px solid var(--bad); }
.tile.inactive { opacity: .5; }

/* Settings */
.toggles, .people { list-style: none; margin: 8px 0; padding: 0; }
.toggles li, .people li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.toggles input { width: 22px; height: 22px; min-height: 0; }
.people li .who { flex: 1; } .people li .role { color: var(--muted); font-size: 13px; }
.add-person { display: grid; grid-template-columns: 1fr 1fr 130px auto; gap: 8px; margin-top: 12px; }
@media (max-width: 720px) { .add-person { grid-template-columns: 1fr 1fr; } }
.status-line { margin: 6px 0 12px; font-size: 14px; }
.status-line.bad { color: var(--bad); }

/* Modal + toast */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--panel); border-radius: 16px; width: 100%; max-width: 520px; max-height: 88vh; overflow: auto; padding: 20px; }
.modal h2 { margin: 0 0 8px; font-size: 20px; }
.modal .close-row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; margin-top: 10px; }
.picker button { font-weight: 700; padding: 10px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
@media (max-width: 400px) { .picker { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); } .picker button { font-size: 15px; } }
.picker button.current { border-color: var(--accent); color: var(--accent); }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 10px; z-index: 30; max-width: calc(100% - 32px); font-weight: 600; box-shadow: 0 4px 16px rgba(0,0,0,.2); }

/* Locator tools: offline bar, bin check, suggested links, Whatnot wrap-up, pick list */
.offline-bar { background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--warn); padding: 8px 16px; font-size: 14px; text-align: center; }
.offline-bar .linkish { color: var(--warn); font-weight: 700; }
.check-card { border-color: var(--accent); }
.check-code { font-size: 32px; font-weight: 800; color: var(--accent); line-height: 1.1; }
.check-count { font-size: 16px; text-align: right; }
.check-count b { font-size: 22px; }
.loc-badge.check-ok { background: var(--good-soft); color: var(--good); font-size: 15px; }
.items li .sg-to { color: var(--muted); font-weight: 600; margin-top: 4px; }
.sg-list li { align-items: flex-start; cursor: default; }
.sg-list li input[type=checkbox] { margin-top: 2px; }
.seg { display: flex; flex: none; }
.seg button { min-height: 40px; padding: 6px 10px; font-weight: 700; white-space: nowrap; border-radius: 0; }
.seg button:first-child { border-radius: 10px 0 0 10px; }
.seg button:last-child { border-radius: 0 10px 10px 0; border-left: 0; }
.seg button.on[data-v="sold"] { background: var(--good); border-color: var(--good); color: #fff; }
.seg button.on[data-v="back"] { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (max-width: 520px) { .wn-list li { flex-wrap: wrap; } .wn-list .seg { width: 100%; } .wn-list .seg button { flex: 1; } }
#pull-list li button { flex: none; }
.pick-sheet { color: #000; font: 14px/1.4 system-ui, sans-serif; }
.pick-sheet h1 { font-size: 20px; margin: 0 0 4px; }
.pick-sheet table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.pick-sheet th, .pick-sheet td { text-align: left; padding: 8px 6px; border-bottom: 1px solid #999; vertical-align: top; }
.pick-sheet .bin { font-weight: 900; font-size: 18px; white-space: nowrap; }
.pick-sheet .box { font-size: 20px; width: 24px; }

/* Label printing (same styles drive the on-screen preview) */
#print-area { display: none; }
.label { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: #000; background: #fff; overflow: hidden; box-sizing: border-box; }
.label svg { display: block; }
.label.l2x1 { width: 2in; height: 1in; padding: .04in .08in; }
.label.l2x1 .lc { font: 900 30px/1 system-ui, sans-serif; letter-spacing: .02em; }
.label.l2x1 .ln { display: none; }
.label.l2x1 svg { width: 1.8in; height: .46in; margin-top: .04in; }
.label.l4x6 { width: 4in; height: 6in; }
.label.l4x6 .lc { font: 900 120px/1 system-ui, sans-serif; }
.label.l4x6 .ln { font: 600 22px system-ui, sans-serif; margin: 6px 0 18px; }
.label.l4x6 svg { width: 3.5in; height: 1.6in; }
.sheet { display: grid; grid-template-columns: 1fr 1fr; gap: .25in; }
.label.small { height: 1.9in; border: 1px dashed #999; }
.label.small .lc { font: 900 48px/1 system-ui, sans-serif; }
.label.small .ln { font: 600 12px system-ui, sans-serif; margin: 2px 0 6px; }
.label.small svg { width: 3in; height: .7in; }
.label-preview { display: flex; justify-content: center; padding: 16px; background: var(--line); border-radius: 10px; margin-top: 12px; }
.label-preview .label { box-shadow: 0 1px 4px rgba(0,0,0,.25); border-radius: 4px; }
.label-preview .label.l4x6 { transform: scale(.35); transform-origin: top center; margin-bottom: calc(-6in * .65); }
.label-preview .sheet { transform: scale(.4); transform-origin: top center; width: 7.5in; margin-bottom: -60%; background: #fff; padding: .1in; }
@media print {
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block; }
  #print-area .label.l2x1, #print-area .label.l4x6 { break-after: page; }
  #print-area .sheet { break-after: page; }
}
