/* Sky WMS — dark, thumb-first. Target device: Zebra TC22, 5.5" 720x1280
   (~360 CSS px wide). Every layout caps at 412px; nothing below 18px. */

:root {
  --bg:        #0e1116;
  --surface:   #171c24;
  --surface-2: #1e2530;
  --border:    #2a323f;
  --text:      #e8edf5;
  --muted:     #8f9bad;
  --accent:    #2f81f7;
  --accent-in: #0b1626;
  --good:      #2ea043;
  --warn:      #d29922;
  --danger:    #e5534b;
  --radius:    14px;
  --tap:       56px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 18px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: contain;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ───────────────────────────── top bar ───────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) 12px 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-title { font-size: 19px; font-weight: 650; flex: 1; }
.topbar-user  { font-size: 14px; color: var(--muted); max-width: 44%; overflow: hidden;
                text-overflow: ellipsis; white-space: nowrap; }

.icon-btn {
  min-width: 44px; min-height: 44px;
  background: transparent; color: var(--text);
  border: 1px solid transparent; border-radius: 12px;
  font-size: 26px; line-height: 1; cursor: pointer;
}
.icon-btn:active { background: var(--surface-2); }

/* ───────────────────────────── layout ────────────────────────────── */
#main {
  flex: 1;
  width: 100%;
  max-width: 412px;
  margin: 0 auto;
  padding: 16px 12px calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}
.view { display: flex; flex-direction: column; gap: 14px; flex: 1; }
.view[hidden] { display: none; }

/* ───────────────────────────── sign in ───────────────────────────── */
.hero { margin: 12vh 0 8px; text-align: center; }
.hero-mark { font-size: 40px; font-weight: 800; letter-spacing: 2px; }
.hero-mark span { color: var(--accent); margin-left: 6px; }
.hero-sub { color: var(--muted); font-size: 17px; margin: 6px 0 0; }
.note { color: var(--muted); font-size: 15px; text-align: center; margin: 0; }
.note.err { color: var(--danger); }

/* ───────────────────────────── buttons ───────────────────────────── */
.btn {
  min-height: var(--tap);
  padding: 14px 18px;
  font-size: 19px; font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.tag {
  font-size: 12px; font-weight: 700; letter-spacing: .5px;
  text-transform: uppercase;
  background: rgba(255,255,255,.18);
  padding: 3px 7px; border-radius: 999px;
}

/* home tiles */
.tile {
  display: grid;
  grid-template-columns: 56px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 2px 14px;
  text-align: left;
  min-height: 116px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  color: var(--text);
  cursor: pointer;
}
.tile-icon  { grid-row: 1 / 3; font-size: 40px; text-align: center; color: var(--accent); }
.tile-label { font-size: 26px; font-weight: 700; }
.tile-sub   { font-size: 15px; color: var(--muted); }
.tile-primary { border-color: var(--accent); background: linear-gradient(180deg, #1b2634, var(--surface)); }
.tile:disabled { opacity: .5; cursor: not-allowed; }
.tile:disabled .tile-icon { color: var(--muted); }

/* ─────────────────────────── scan test ───────────────────────────── */
.scantest {
  margin-top: auto;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 12px;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px;
}
.scantest-label {
  font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted);
}
.scantest-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 16px; color: var(--good); word-break: break-all; flex: 1 1 100%;
}
.scantest-value.idle { color: var(--muted); }
.scantest-meta { font-size: 12px; color: var(--muted); }

/* ──────────────────────────── picker ─────────────────────────────── */
.searchrow { display: flex; gap: 8px; }
.search {
  flex: 1;
  min-height: var(--tap);
  padding: 12px 14px;
  font-size: 20px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.icon-btn.osk { border-color: var(--border); background: var(--surface);
                font-size: 15px; font-weight: 700; letter-spacing: .5px; min-width: 56px; }
.icon-btn.osk[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

.results { display: flex; flex-direction: column; gap: 8px; }
.result {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.result-main { flex: 1; min-width: 0; }
.result-inv  { font-size: 19px; font-weight: 650; }
.result-sub  { font-size: 14px; color: var(--muted); overflow: hidden;
               text-overflow: ellipsis; white-space: nowrap; }
.result-units { font-size: 15px; color: var(--accent); font-weight: 600; white-space: nowrap; }
.result.added { opacity: .5; }

.add-btn {
  min-width: 52px; min-height: 48px;
  font-size: 26px; font-weight: 700; line-height: 1;
  background: var(--accent); color: #fff;
  border: none; border-radius: 12px; cursor: pointer;
}
.add-btn:disabled { background: var(--surface-2); color: var(--muted); }

.empty { color: var(--muted); font-size: 16px; text-align: center; padding: 22px 8px; }

.selected { border-top: 1px solid var(--border); padding-top: 12px; }
.selected-head { font-size: 15px; color: var(--muted); text-transform: uppercase;
                 letter-spacing: .6px; margin-bottom: 8px;
                 display: flex; align-items: center; gap: 8px; }
.pill { background: var(--accent); color: #fff; border-radius: 999px;
        padding: 2px 9px; font-size: 13px; font-weight: 700; letter-spacing: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 8px 8px 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; font-size: 16px;
}
.chip button {
  min-width: 34px; min-height: 34px;
  background: transparent; border: none; color: var(--muted);
  font-size: 20px; line-height: 1; cursor: pointer; border-radius: 50%;
}
.chip button:active { background: var(--danger); color: #fff; }

/* ──────────────────────────── review ─────────────────────────────── */
.review-summary {
  display: flex; gap: 10px;
  padding: 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
}
.stat { flex: 1; text-align: center; }
.stat-n { display: block; font-size: 28px; font-weight: 750; }
.stat-l { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }

.group { margin-top: 16px; }
.group-head {
  font-size: 16px; font-weight: 650; color: var(--muted);
  text-transform: uppercase; letter-spacing: .6px;
  padding-bottom: 6px; border-bottom: 1px solid var(--border); margin-bottom: 8px;
}
.inv {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 8px; overflow: hidden;
}
.inv-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 14px; }
.inv-main { flex: 1; min-width: 0; }
.inv-no   { font-size: 19px; font-weight: 650; }
.inv-meta { font-size: 14px; color: var(--muted); }
.inv-units { font-size: 17px; font-weight: 700; color: var(--accent); white-space: nowrap; }
.del-btn {
  min-width: 44px; min-height: 44px;
  background: transparent; border: 1px solid var(--border); border-radius: 12px;
  color: var(--danger); font-size: 20px; cursor: pointer;
}
.lines { border-top: 1px solid var(--border); }
.line {
  display: flex; align-items: baseline; gap: 10px;
  padding: 9px 14px; font-size: 15px;
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.line:last-child { border-bottom: none; }
.line-qty { min-width: 42px; font-weight: 700; color: var(--text); }
.line-main { flex: 1; min-width: 0; }
.line-sku  { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text); }
.line-name { color: var(--muted); font-size: 14px;
             overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-bc   { font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
             font-size: 12px; color: var(--muted); }
.line-bc.missing { color: var(--warn); }

/* ─────────────────────────── sticky bar ──────────────────────────── */
.stickybar {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  padding: 12px 0 calc(4px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, var(--bg) 34%);
  display: flex;
}
.stickybar .btn { flex: 1; }

/* ───────────────────────────── toast ─────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%);
  max-width: 380px; width: calc(100% - 32px);
  padding: 12px 16px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 16px; text-align: center; z-index: 50;
}
.toast.err { border-color: var(--danger); color: #ffd7d5; }
