/* ─── Design tokens ─── */
:root {
  --bg: #eef0f4;
  --surface: #ffffff;
  --ink: #111827;
  --ink-2: #374151;
  --muted: #9ca3af;
  --line: #d1d5db;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-bg: #dbeafe;
  --blue-border: #93c5fd;
  --green: #16a34a;
  --green-dark: #15803d;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --red-border: #fca5a5;
}

/* ─── Reset ─── */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

/* ─── Login ─── */

.pda-login-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 18px;
  background: var(--bg);
}

.pda-login-card {
  display: grid;
  gap: 14px;
  width: 100%;
  max-width: 420px;
  padding: 28px 24px 24px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 4px 28px rgba(0, 0, 0, 0.09);
}

/* Brand mark above the login form title */
.pda-login-brand {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  gap: 10px;
  margin-bottom: 2px;
}

.pda-login-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--blue);
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 900;
  color: #ffffff;
  letter-spacing: -1px;
  -webkit-flex-shrink: 0;
  flex-shrink: 0;
}

.pda-login-brand-text {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.pda-login-card h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.pda-login-card p {
  margin: -4px 0 4px;
  color: var(--muted);
  font-size: 14px;
}

.pda-login-card label {
  display: grid;
  gap: 7px;
  color: var(--ink-2);
  font-weight: 700;
}

.pda-login-card input {
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 18px;
}

.login-error {
  min-height: 22px;
  color: var(--red);
  font-weight: 700;
}

/* ─── App Shell ─── */
/* Header is full-bleed; screens carry their own padding */
.pda-app {
  min-height: 100vh;
}

/* ─── Header ─── */
.pda-top {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 20;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  gap: 10px;
  background: var(--blue-dark);
  padding: 12px 14px;
  min-height: 68px;
}

/* Title block fills whatever space the two buttons don't need */
.pda-top > div {
  -webkit-flex: 1 1 0;
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
}

/* Shared pill style for refresh + account buttons */
.pda-refresh,
.pda-account {
  min-width: 0;
  min-height: 0;
  padding: 0 13px;
  height: 34px;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  -webkit-flex-shrink: 0;
  flex-shrink: 0;
}

/* Status line inside the header title block */
.pda-status {
  display: block;
  margin-top: 3px;
  font-size: 10px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.50);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.2px;
}

.pda-top p {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pda-top h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.15;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.back-button {
  min-width: 64px;
  min-height: 50px;
  padding: 0 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-size: 16px;
  font-weight: 700;
}

/* ─── Screen visibility ─── */
.screen {
  display: none;
}

.screen.active {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 14px;
}

/* ─── Home Screen ─── */
.home-action {
  width: 100%;
  min-height: 148px;
  border: 0;
  border-radius: 14px;
  color: #ffffff;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  padding: 20px;
}

.home-action-title {
  display: block;
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1;
}

.home-action-sub {
  display: block;
  margin-top: 8px;
  font-size: 15px;
  font-weight: 500;
  opacity: 0.75;
  letter-spacing: 0;
}

.home-action.outbound {
  background: var(--blue);
}

.home-action.inbound {
  background: var(--green);
}

.home-action.stock {
  background: #0f766e;
}

.home-action:disabled {
  opacity: 0.4;
}

/* ─── Stock lookup ─── */
.stock-filter-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.stock-filter-panel label {
  display: grid;
  gap: 6px;
}

.stock-filter-panel label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.stock-filter-panel select,
.stock-filter-panel input {
  width: 100%;
  min-height: 48px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  background: #f8fafc;
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
}

.stock-summary {
  padding: 12px 14px;
  border: 1px solid #99f6e4;
  border-radius: 10px;
  background: #ccfbf1;
  color: #0f766e;
  font-size: 15px;
  font-weight: 800;
}

.stock-row {
  align-items: start !important;
}

.stock-type-line {
  font-size: 12px !important;
  color: var(--muted) !important;
}

.stock-warehouse-chips {
  display: -webkit-flex !important;
  display: flex !important;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px !important;
}

.stock-warehouse-chips span {
  display: -webkit-inline-flex !important;
  display: inline-flex !important;
  margin: 0 !important;
  padding: 4px 7px;
  border-radius: 7px;
  background: #f1f5f9;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 700;
}

.empty-chips {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

/* ─── Generic list ─── */
.list {
  display: grid;
  gap: 10px;
}

.list-button {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 82px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 14px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.list-button strong,
.list-button span {
  display: block;
}

.list-button strong {
  font-size: 20px;
  font-weight: 700;
}

.sku-inventory-row strong {
  font-size: 19px;
  line-height: 1.25;
}

.list-button span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.sku-color-name {
  color: var(--ink-2) !important;
  font-size: 16px !important;
  font-weight: 800;
}

.sku-code-line {
  font-size: 12px !important;
  color: var(--muted) !important;
  overflow-wrap: anywhere;
}

/* Qty badge (warehouse totals / SKU counts) */
.qty {
  min-width: 60px;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--blue-bg);
  color: var(--blue);
  text-align: center;
  font-size: 22px;
  font-weight: 800;
}

/* ─── Selected warehouse banner ─── */
.selected-warehouse {
  padding: 13px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 10px;
  color: var(--ink-2);
  font-size: 15px;
  font-weight: 600;
}

/* ─── Start outbound button ─── */
.start-outbound-button {
  width: 100%;
  min-height: 54px;
  border: 0;
  border-radius: 10px;
  background: var(--blue);
  color: #ffffff;
  font-size: 18px;
  font-weight: 700;
}

/* ─── Brand filter bar ─── */
.brand-filter-bar {
  display: -webkit-flex;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
  /* hide scrollbar but keep scroll */
  scrollbar-width: none;
}

.brand-filter-bar::-webkit-scrollbar {
  display: none;
}

.brand-pill {
  display: -webkit-inline-flex;
  display: inline-flex;
  -webkit-align-items: center;
  align-items: center;
  gap: 5px;
  -webkit-flex-shrink: 0;
  flex-shrink: 0;
  height: 36px;
  padding: 0 14px;
  border: 1.5px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
}

.brand-pill.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #ffffff;
}

.pill-count {
  display: inline-block;
  min-width: 20px;
  height: 20px;
  line-height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.10);
  color: inherit;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.brand-pill.active .pill-count {
  background: rgba(255, 255, 255, 0.22);
}

/* ─── Inventory section label ─── */
.inventory-head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
}

/* ─── SKU Summary card (top of scan screen) ─── */
.sku-summary {
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.sku-summary strong {
  display: block;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.sku-summary span {
  display: block;
  color: var(--muted);
  font-size: 14px;
}

/* ─── Scan input box ─── */
.scan-box {
  display: grid;
  gap: 8px;
}

.scan-box > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
}

.scan-box input {
  width: 100%;
  height: 58px;
  border: 2px solid var(--blue);
  border-radius: 10px;
  padding: 0 14px;
  background: #f8fafc;
  color: var(--ink);
  font-size: 20px;
  font-weight: 700;
}

.scan-box input[readonly] {
  background: #f8fafc;
}

/* ─── Scanner buffer (debug / "last scanned" status) ─── */
.scanner-buffer {
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px dashed var(--line);
  border-radius: 7px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Scan result status ─── */
.scan-status {
  padding: 13px 14px;
  background: var(--blue-bg);
  border: 1px solid var(--blue-border);
  border-radius: 10px;
  color: var(--blue);
  font-size: 16px;
  font-weight: 700;
  min-height: 52px;
}

.scan-status.error {
  background: var(--red-bg);
  border-color: var(--red-border);
  color: var(--red);
}

.inbound-panel {
  display: grid;
  gap: 12px;
}

.inbound-product {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.inbound-product strong,
.inbound-product span {
  display: block;
}

.inbound-product strong {
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
}

.inbound-product span {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.inbound-stock-line {
  display: grid !important;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding-top: 6px;
  color: var(--ink-2) !important;
  font-size: 15px !important;
  font-weight: 700;
}

.inbound-stock-line b {
  color: var(--green);
  font-size: 26px;
}

.qty-picker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.qty-button {
  min-height: 58px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 22px;
  font-weight: 800;
}

.qty-button.active {
  border-color: var(--green);
  background: #dcfce7;
  color: var(--green-dark);
}

.inbound-submit {
  background: var(--green);
}

/* ─── Scan counter (big focal number) ─── */
.scan-counter {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.scan-counter span {
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
}

.scan-counter strong {
  font-size: 60px;
  font-weight: 800;
  color: var(--blue);
  line-height: 1;
}

/* ─── Scan log panel ─── */
.scan-log-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
}

.scan-log-head {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
}

.scan-log {
  display: grid;
  max-height: 220px;
  overflow: auto;
}

.scan-log-row {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}

.scan-log-row:last-child {
  border-bottom: 0;
}

.scan-log-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.scan-log-row strong {
  overflow-wrap: anywhere;
  font-size: 15px;
}

.scan-log-product {
  display: block;
  line-height: 1.28;
}

.scan-log-product small {
  display: block;
  margin-top: 3px;
}

.scan-log-color {
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 800;
}

.scan-log-code {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.empty-log {
  padding: 18px 14px;
  color: var(--muted);
  font-size: 14px;
}

/* ─── Confirm list ─── */
.confirm-list {
  display: grid;
}

.confirm-row {
  display: grid;
  grid-template-columns: 1fr 72px;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  min-height: 68px;
}

.confirm-row:last-child {
  border-bottom: 0;
}

.confirm-row strong,
.confirm-row span {
  display: block;
}

.confirm-row strong {
  font-size: 18px;
  font-weight: 700;
}

.confirm-row span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.confirm-qty {
  height: 58px;
  border-radius: 10px;
  background: var(--blue-bg);
  color: var(--blue);
  text-align: center;
  font-size: 26px;
  font-weight: 800;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
}

/* Login card — confirm-button is a plain block, not sticky */
.pda-login-card .confirm-button {
  position: static;
}

/* ─── Primary action button (confirm / finish scan) ─── */
.confirm-button {
  width: 100%;
  min-height: 68px;
  border: 0;
  border-radius: 12px;
  background: var(--blue);
  color: #ffffff;
  font-size: 22px;
  font-weight: 800;
  /* Stick to bottom so it's always reachable when list is long */
  position: -webkit-sticky;
  position: sticky;
  bottom: 12px;
}

.confirm-button:disabled {
  background: var(--line);
  color: var(--muted);
}

/* ─── Empty state ─── */
.empty {
  min-height: 140px;
  display: grid;
  place-items: center;
  border: 2px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
  padding: 20px;
  font-size: 15px;
}

/* runtime-status element moved into header; footer removed */

/* ─── Brand tag (chip above product name) ─── */
.sku-brand-tag {
  display: inline-block;
  padding: 2px 7px;
  margin-bottom: 4px;
  border-radius: 5px;
  background: var(--blue-bg);
  color: var(--blue);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  line-height: 1.4;
}

.scan-log-brand {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--blue);
  letter-spacing: 0.4px;
  margin-bottom: 1px;
  font-style: normal;
}

/* ─── SKU inventory rows: tighter, 3-line hierarchy ─── */

/* 4 lines (brand + name + color + code): 88px is comfortable */
.sku-inventory-row {
  min-height: 88px;
}

/* Product name: 2-line max, natural wrap */
.sku-inventory-row strong {
  display: block;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
  white-space: normal;
  overflow: hidden;
  max-height: 2.6em;
}

/* Override generic .list-button span for color and model */
.list-button .sku-color-name,
.confirm-row .sku-color-name {
  display: block;
  margin-top: 3px;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
}

.list-button .sku-code-line,
.confirm-row .sku-code-line {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

/* ─── Scan log: product / color / model hierarchy ─── */

/* Make the strong a block so nested smalls stack vertically */
.scan-log-product {
  display: block;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.scan-log-color {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  margin-top: 2px;
  font-style: normal;
}

.scan-log-code {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  margin-top: 1px;
  font-style: normal;
}

/* Give scan-log rows a bit more height to breathe */
.scan-log-row {
  min-height: 60px;
  padding-top: 8px;
  padding-bottom: 8px;
  -webkit-align-items: flex-start;
  align-items: flex-start;
}

.scan-log-row > span {
  padding-top: 2px;
}
